Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion toolchain/cc_wrapper.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also get a path like this if you include the wrapper in runfiles and invoke it via $(rootpath ... ) or File.short_path. That's probably less likely than your use case, so I'm not against this change at all, but maybe we can find a way to distinguish these two cases.

Could you add a test for this? It would only take an sh_test that adds the toolchain files to data and launches it via $(rootpath ...).

# 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.
Expand Down
2 changes: 1 addition & 1 deletion toolchain/osx_cc_wrapper.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down