Skip to content

cc targets fail to build when path mapping is enabled for Cpp actions #335

@jjudd

Description

@jjudd

When trying out this toolchain in our main monorepo I noticed that enabling path mapping with --experimental_output_paths=strip and opting into path mapping for the CppCompile action with --modify_execution_info=CppCompile=+supports-path-mapping causes cc targets to fail to build.

Based on The State of Path Mapping discussion on GitHub, I'd expect Cpp actions to work with path mapping. I haven't run into this issue with other cc toolchains, so I believe it is specific to this one.

I created a minimal repro case here: https://github.com/lucidsoftware/toolchains_llvm_bootstrapped_path_mapping_cppcompile_repro

Summary of the issue
When path mapping is enabled with --experimental_output_paths=strip and path mapping for Cpp actions is enabled as follows:

--incompatible_modify_execution_info_additive
--modify_execution_info=CppModuleMap=+supports-path-mapping
--modify_execution_info=CppArchive=+supports-path-mapping
--modify_execution_info=CppCompile=+supports-path-mapping

Then building cc targets fails with errors like the following:

ERROR: /home/redacted/toolchains_llvm_bootstrapped_path_mapping_cppcompile_repro/hello/BUILD.bazel:3:10: Compiling hello/main.cc failed: (Exit 1): clang++ failed: error executing CppCompile command (from cc_binary rule target //hello:hello) external/llvm++http_archive+llvm-toolchain-minimal-21.1.8-linux-amd64/bin/clang++ -target x86_64-linux-gnu -no-canonical-prefixes -Wno-builtin-macro-redefined '-D__DATE__="redacted"' ... (remaining 48 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
hello/main.cc:1:10: fatal error: 'iostream' file not found
    1 | #include <iostream>
      |          ^~~~~~~~~~
1 error generated.

I believe this is an issue specifically with CppCompile because if I do not enable path mapping for that action, then the build succeeds. To clarify if I don't use this option, then build succeeds: --modify_execution_info=CppCompile=+supports-path-mapping.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions