Skip to content

Handle all -isystem variant flags in cargo build script path rewriting#3996

Open
tamasvajk wants to merge 1 commit intobazelbuild:mainfrom
tamasvajk:stdlib-isystem
Open

Handle all -isystem variant flags in cargo build script path rewriting#3996
tamasvajk wants to merge 1 commit intobazelbuild:mainfrom
tamasvajk:stdlib-isystem

Conversation

@tamasvajk
Copy link
Copy Markdown
Contributor

@tamasvajk tamasvajk commented Apr 28, 2026

Summary

Handle all -isystem variant flags in cargo build script path rewriting.

Problem

When Bazel passes CC toolchain flags to cargo build scripts, paths following -isystem are prefixed with ${pwd} so they resolve correctly inside the sandbox. However, several other Clang flags that take system include paths were not handled:

  • -stdlib++-isystem — C++ standard library headers
  • -isystem-after — appended to SYSTEM include search path
  • -cxx-isystem — C++ SYSTEM include search path

See the Clang command line reference for the full set.

This caused cargo build scripts to fail when the CC toolchain used any of these flags, because paths weren't rewritten for the sandbox.

Fix

Add -stdlib++-isystem, -isystem-after, and -cxx-isystem to the flag list in _pwd_flags_isystem.


Note: This PR was largely AI-generated using Claude Code, with human review and guidance throughout.

@tamasvajk tamasvajk changed the title Handle -stdlib++-isystem in cargo build script path rewriting Handle all -isystem variant flags in cargo build script path rewriting Apr 28, 2026
Add -stdlib++-isystem, -isystem-after, and -cxx-isystem to the set
of flags whose following path argument gets prefixed with ${pwd}.
These are standard Clang flags for specifying system include paths
that were not handled, causing cargo build scripts to fail in the
sandbox when the CC toolchain uses them.

See the Clang documentation for the full set of isystem-like flags:
https://clang.llvm.org/docs/ClangCommandLineReference.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant