Skip to content

fix: Use get_tool_for_action and absolutize sysroot path#1111

Open
tsudol-plaid wants to merge 2 commits into
aspect-build:1.xfrom
tsudol-plaid:complex-cc
Open

fix: Use get_tool_for_action and absolutize sysroot path#1111
tsudol-plaid wants to merge 2 commits into
aspect-build:1.xfrom
tsudol-plaid:complex-cc

Conversation

@tsudol-plaid

@tsudol-plaid tsudol-plaid commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

The compiler executable path provided by cc_toolchain.compiler_executable does not necessarily point to the actual compiler path. For example, on MacOS it is external/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 path external/llvm++_repo_rules+llvm-toolchain-minimal-22.1.3-darwin-arm64/bin/clang.

Additionally, the --sysroot flag needs to be passed in to the compiler so that it can find system headers. Like the CC and CXX env vars, the given sysroot path is relative to the Bazel workspace root, so it needs to be absolutized before it can be added to CFLAGS.
This should be perfectly safe, because the sysroot directory is included in the toolchain's all_files list, so it will be present in the Bazel workspace.

This is a follow-on from #1108.

Test plan

  • Manual testing; please provide instructions so we can reproduce:

I am unsure how to test this, because it seems to require MacOS and its weird C++ setup.

@tsudol-plaid tsudol-plaid changed the title Use get_tool_for_action and absolutize sysroot path fix: Use get_tool_for_action and absolutize sysroot path Jun 15, 2026
@tsudol-plaid tsudol-plaid marked this pull request as ready for review June 15, 2026 21:51
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