Skip to content

Commit

Permalink
llvm_toolchain: fixes for using/running the toolchain from other loca…
Browse files Browse the repository at this point in the history
…tions in the execroot

As the message within explains, `rules_foreign_cc` will use a different
PWD than the execroot root for cmake targets which breaks the wrapper
script. This commit has the wrapper script search alongside itself for
`clang` when it isn't in the usual places.
  • Loading branch information
rrbutani committed Aug 15, 2021
1 parent b71147e commit 2da3afb
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion toolchain/cc_wrapper.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,19 @@ done
if [[ "${PATH}:" == *"%{toolchain_path_prefix}bin:"* ]]; then
# GoCompile sets the PATH to the directory containing the linker, and changes CWD.
clang "$@"
else
elif [[ -f %{toolchain_path_prefix}bin/clang ]]; then
%{toolchain_path_prefix}bin/clang "$@"
else
# Some consumers of `CcToolchainConfigInfo`s will use a PWD that *isn't*
# the execroot (i.e. `cmake` from `rules_foreign_cc`). For cases like this,
# we'll try to find `clang` by assuming it's next to this script.
potential_clang_path="$(dirname "${0}")/clang"
if [[ -f ${potential_clang_path} ]]; then
"${potential_clang_path}" "${@}"
else
echo "ERROR: could not find clang; PWD is: $(pwd)."
exit 5
fi
fi

function get_library_path() {
Expand Down

0 comments on commit 2da3afb

Please sign in to comment.