Open
Conversation
Owner
Author
|
Also PR fails because windows mingw headers need also be passed |
dzbarsky
approved these changes
Mar 31, 2026
keith
approved these changes
Mar 31, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change needs careful review due to its impact on correctness, long-term maintenance, and downstream users of the toolchain (e.g. rules_go, rules_foreign_cc).
Background
Until now, we passed C++ include paths via
-isystem. This worked because Clang implicitly appends its builtin headers at the end of the search path (and we also pass them explicitly via-internal-isystem).In CUDA mode (
-x cuda), the driver injects an additional builtin include path (cuda_wrappers) before the standard C++ includes. This ordering is required because these wrappers override parts of the C++ standard library specifically for CUDA.With
-isystem, we lose control over this ordering, which breaks CUDA compilation.The problem
We need to preserve Clang’s intended include ordering in CUDA mode:
Options considered
1. Manually inject
cuda_wrappersThis would restore the correct ordering, but requires reliably detecting CUDA mode.
That is non-trivial:
cuda_compileaction is being introduced, but.ccfiles with-x cuda, which bypasses extension-based detectionThis is a good option but it means we can never be compliant with such codebases unless they rename their files to
.cuor.cu.cc.2. Rely on the Clang driver (
-stdlib++-isystem) (chosen)-stdlib++-isystemlets the driver handle ordering of standard library includes correctly, including CUDA-specific adjustments.However, this introduces a constraint:
-stdlib++-isystemis ignored in C modeWhat this PR does
In C++ (
cpp_compile):stdlib++,libc,kernel) via-stdlib++-isystemcuda_wrappersIn C (
c_compile):-isystemforlibcandkernel-stdlib++-isystemis ignoredTradeoff
We are left with two imperfect options:
Detect CUDA and manually inject
cuda_wrappersDelegate ordering to the driver via
-stdlib++-isystemThis PR adopts option (2) as the only robust approach given current constraints.