Skip to content

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

Merged
UebelAndre merged 1 commit into
bazelbuild:mainfrom
tamasvajk:stdlib-isystem
May 7, 2026
Merged

UebelAndre merged 1 commit into
bazelbuild:mainfrom
tamasvajk:stdlib-isystem

Conversation

@tamasvajk

@tamasvajk tamasvajk commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

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
@tamasvajk

Copy link
Copy Markdown
Contributor Author

@UebelAndre Is there anything needed from my side to get this merged?

@UebelAndre UebelAndre left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the ping, looks good to me!

@UebelAndre
UebelAndre added this pull request to the merge queue May 7, 2026
Merged via the queue into bazelbuild:main with commit 72c67cd May 7, 2026
3 checks passed
@tamasvajk

Copy link
Copy Markdown
Contributor Author

Thank you for the ping, looks good to me!

@UebelAndre Thank you for having a look and merging it. I opened a couple of other PRs, which are ready for review and have green CI checks. Are you the best person to review them?

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.

2 participants