You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When absolute_paths = True, the toolchain_path_prefix variable is an absolute path, so attempting to prefix it with execroot_abs_path means that the execroot absolute path is duplicated, leading clang to fail to invoke the linker.
❯ bazel build //parser/parser:generate_diagnostics
WARNING: Build option --linkopt has changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed).
INFO: Analyzed target //parser/parser:generate_diagnostics (68 packages loaded, 368 targets configured).
ERROR: /Users/jez/sandbox/bazel_example/parser/parser/BUILD:1:10: Linking parser/parser/generate_diagnostics failed: (Exit 1): cc_wrapper.sh failed: error executing CppLink command (from target //parser/parser:generate_diagnostics) external/llvm_toolchain_15_0_7/bin/cc_wrapper.sh @bazel-out/darwin_arm64-fastbuild/bin/parser/parser/generate_diagnostics-2.params
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
clang: error: invalid linker name in argument '-fuse-ld=/private/var/tmp/_bazel/2e52735c4d41272832995da68cda80bb/sandbox/darwin-sandbox/8/execroot/_main//private/var/tmp/_bazel/2e52735c4d41272832995da68cda80bb/external/llvm_toolchain_15_0_7_llvm/bin/ld64.lld'
Target //parser/parser:generate_diagnostics failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 1.063s, Critical Path: 0.69s
INFO: 6 processes: 5 internal, 1 darwin-sandbox.
ERROR: Build did NOT complete successfully
I didn't see an easy way to access absolute_paths from inside the cc_wrapper.sh file, so I just applied a patch like this to make progress:
if [[ -f "%{toolchain_path_prefix}bin/ld64.lld" ]]; then
echo "-fuse-ld=%{toolchain_path_prefix}bin/ld64.lld"
else
echo "-fuse-ld=${execroot_abs_path}%{toolchain_path_prefix}bin/ld64.lld"
fi
which is bad for its own reasons (if that file happens to exist, it might be the wrong one?) but I'm not sure if that matters. At the very least, it's not explicit to the user what's going on and deserves a comment that this condition needs to be here in support of absolute_paths.
Feel free to use this code or another solution at your leisure.
toolchains_llvm/toolchain/osx_cc_wrapper.sh.tpl
Lines 76 to 77 in f0a43a5
When
absolute_paths = True
, thetoolchain_path_prefix
variable is an absolute path, so attempting to prefix it withexecroot_abs_path
means that the execroot absolute path is duplicated, leading clang to fail to invoke the linker.In the error message, this:
needs to be this:
or else the file does not exist.
This appeared in #286, which was a fix for #212.
The text was updated successfully, but these errors were encountered: