fix: standard library selection in toolchain #96
Merged
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.
I noticed that in #92 we inadvertently made it so that the standard library that is selected will always be
libstdc++Here we detect if a builtin sysroot exists to decide whether to choose
libstdc++orlibc++:rules_swiftnav/cc/toolchains/llvm/cc_toolchain_config.bzl
Line 38 in 0775da8
The problem with this is that we pass a
selecttype at the call-site:rules_swiftnav/cc/toolchains/llvm/x86_64-linux/BUILD.bazel
Line 118 in 0775da8
select statements are not expanded in macros, so
builtin_sysroot != Noneis always true.Design Notes
To fix I refactored the toolchain config so that the standard library compiler and linker options are set via select statements.
I also made it so that regardless of the config setting - if we're cross compiling, then
libstdc++will be selected.I also added an extra config setting
_use_libstdc++so that libstdc++ can be used independently of a sysroot.Testing