fix: Use get_tool_for_action and absolutize sysroot path#1111
Open
tsudol-plaid wants to merge 2 commits into
Open
fix: Use get_tool_for_action and absolutize sysroot path#1111tsudol-plaid wants to merge 2 commits into
tsudol-plaid wants to merge 2 commits into
Conversation
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.
The compiler executable path provided by
cc_toolchain.compiler_executabledoes not necessarily point to the actual compiler path. For example, on MacOS it isexternal/llvm+/toolchain/gcc, which does not actually exist.Instead, the real compiler needs to be discovered via
cc_common.get_tool_for_action. This gives the real compiler pathexternal/llvm++_repo_rules+llvm-toolchain-minimal-22.1.3-darwin-arm64/bin/clang.Additionally, the
--sysrootflag needs to be passed in to the compiler so that it can find system headers. Like theCCandCXXenv vars, the given sysroot path is relative to the Bazel workspace root, so it needs to be absolutized before it can be added toCFLAGS.This should be perfectly safe, because the sysroot directory is included in the toolchain's
all_fileslist, so it will be present in the Bazel workspace.This is a follow-on from #1108.
Test plan
I am unsure how to test this, because it seems to require MacOS and its weird C++ setup.