Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass absolute path to gold when using Clang
Prior to this change Bazel's C++ toolchain autoconfiguration generated toolchain that passed `-fuse-ld=gold` when gold linker was detected. After this change this will be `-fuse-ld=/usr/bin/ld.gold` or similar depending on what clang reported. Gcc will still use -fuse-ld=gold (as it doesn't accept absolute path argument to `-fuse-ld`). This is to make the Clang autogenerated toolchain not depend on PATH if we can help it. Gcc is still leaking the PATH. The leak: 1) CC is installed in a non-standard location, or is checked-in into the workspace. 2) CC is passed to Bazel's cc_configure, Bazel autoconfigures the toolchain using CC. 3) Remote worker has CC installed in the same non-standard location, or gets CC in action inputs. 4) If Host system has gold on its PATH (potentially to the surprise of the user, user might assume that since they provide CC explicitly only that installation is used), Bazel will autoconfigure the toolchain to use gold linker. 5) Remote system doesn't have gold installed, build fails. Alternative solutions: * Pass -B$(dirname $(which gcc)) to CC and pass empty PATH to all Bazel's C++ autoconfiguration commands * Do not detect gold automatically at all, require environment variable to be explicitly set to enable gold Both are backwards incompatible changes. Solution in this PR is backwards compatible. It's also not fixing the issue for Gcc. Closes #8580. PiperOrigin-RevId: 256623542
- Loading branch information