Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add target_toolchain_roots and make sysroot more hermetic #441

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AustinSchuh
Copy link
Contributor

It is useful when cross compiling to have 1 LLVM build used as the compiler, and multiple others used for their libc++/target libraries.

This concept forces us to be much more robust about what comes from the target toolchain, and what comes from the compiler. Leave toolchain_roots for the compiler roots, but add a new flag, target_toolchain_roots with the same semantics for target toolchains. This necesitates being much more clear internally about what comes from what.

This isn't fully enough to make everything hermetic, clang still has some autodetection logic left over when using sysroots. We want to very explicity specify the resource directory it should use, as well as where the standard C/C++ libraries come from so it finds only what we want it to find.

When pulling from a sysroot, we need to know the version of stdc++ to find includes. Use the stdlib variable for that by supporting "stdc++-12" for example, and parsing the number out.

It is useful when cross compiling to have 1 LLVM build used as the
compiler, and multiple others used for their libc++/target libraries.

This concept forces us to be much more robust about what comes from the
target toolchain, and what comes from the compiler.  Leave
toolchain_roots for the compiler roots, but add a new flag,
target_toolchain_roots with the same semantics for target toolchains.
This necesitates being much more clear internally about what comes from
what.

This isn't fully enough to make everything hermetic, clang still has
some autodetection logic left over when using sysroots.  We want to very
explicity specify the resource directory it should use, as well as where
the standard C/C++ libraries come from so it finds only what we want it
to find.

When pulling from a sysroot, we need to know the version of stdc++ to
find includes.  Use the stdlib variable for that by supporting
"stdc++-12" for example, and parsing the number out.
@AustinSchuh AustinSchuh force-pushed the target_toolchain_roots branch from 170ca55 to 4291cb6 Compare January 14, 2025 06:42
@AustinSchuh
Copy link
Contributor Author

bazelbuild/rules_cc#304 needs to land and be available before this can merge. But I would appreciate feedback on this before then as that could take a bit.

We used features before for asan/msan/cuda/etc, but I think we can use flags + select instead and avoid needing to change rules_cc again. Feedback welcome on the best way to do all that.

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