diff --git a/toolchain/cc_wrapper.sh.tpl b/toolchain/cc_wrapper.sh.tpl index e972d57e6..fbba9d74c 100644 --- a/toolchain/cc_wrapper.sh.tpl +++ b/toolchain/cc_wrapper.sh.tpl @@ -34,7 +34,7 @@ set -euo pipefail if [[ -f %{toolchain_path_prefix}bin/clang ]]; then execroot_path="" -elif [[ ${BASH_SOURCE[0]} == "/"* ]]; then +elif [[ ${BASH_SOURCE[0]} == "/"* ]] || [[ ${BASH_SOURCE[0]} == "../"* ]]; then # Some consumers of `CcToolchainConfigInfo` (e.g. `cmake` from rules_foreign_cc) # change CWD and call $CC (this script) with its absolute path. # For cases like this, we'll try to find `clang` through an absolute path. diff --git a/toolchain/osx_cc_wrapper.sh.tpl b/toolchain/osx_cc_wrapper.sh.tpl index 31122784b..6b48be56e 100755 --- a/toolchain/osx_cc_wrapper.sh.tpl +++ b/toolchain/osx_cc_wrapper.sh.tpl @@ -57,7 +57,7 @@ function parse_option() { if [[ -f %{toolchain_path_prefix}bin/clang ]]; then execroot_path="" execroot_abs_path="${PWD}/" -elif [[ ${BASH_SOURCE[0]} == "/"* ]]; then +elif [[ ${BASH_SOURCE[0]} == "/"* ]] || [[ ${BASH_SOURCE[0]} == "../"* ]]; then # Some consumers of `CcToolchainConfigInfo` (e.g. `cmake` from rules_foreign_cc) # change CWD and call $CC (this script) with its absolute path. # For cases like this, we'll try to find `clang` through an absolute path.