Skip to content

Commit 7a565a8

Browse files
authored
use /usr/bin/basename for rules_cc (#186)
Another random compatibility issue, after updating the rust tool chain it can't find `basename` when linking with our custom toolchain - copied this from rules_cc https://github.com/bazelbuild/rules_cc/blob/0fee42b524315fd16c197877f24d5b8ba0a9a1ee/cc/private/toolchain/osx_cc_wrapper.sh.tpl#L42 I checked and we aren't using any of the other tools they impl that pattern for
1 parent 0ee1c4d commit 7a565a8

File tree

18 files changed

+84
-35
lines changed

18 files changed

+84
-35
lines changed

MODULE.bazel.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cc/toolchains/gcc_arm_embedded/wrappers/wrapper

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ if [ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]; then
3333
set -x
3434
fi
3535

36-
tool_name=$(basename "$0")
36+
BASENAME=/usr/bin/basename
37+
[ -x "$BASENAME" ] || BASENAME="basename"
38+
39+
tool_name=$($BASENAME "$0")
3740
# In case the tool label is changed, a change in here is very likely needed
3841
# This establishes backwards compatibility with the old WORKSPACE file
3942
toolchain_bindir=external/x86_64_linux_gcc_arm_embedded_toolchain/bin
@@ -57,7 +60,7 @@ elif case "$0" in /*) true;; *) false;; esac; then
5760
#
5861
# If the wrapper is relocated then this line needs to be adjusted.
5962

60-
execroot_path="${0%/*/*/*/*/*/*/*/*}"
63+
execroot_path="${0%/*/*/*/*/*/*/*/*}"
6164

6265
# Legacy path for non-bazelmod
6366
tool="${execroot_path}/${toolchain_bindir}/${tool_name}"

cc/toolchains/gcc_arm_gnu_8_3/wrappers/wrapper

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ if [ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]; then
3333
set -x
3434
fi
3535

36-
tool_name=$(basename "$0")
36+
BASENAME=/usr/bin/basename
37+
[ -x "$BASENAME" ] || BASENAME="basename"
38+
39+
tool_name=$($BASENAME "$0")
3740
# In case the tool label is changed, a change in here is very likely needed
3841
# This establishes backwards compatibility with the old WORKSPACE file
3942
toolchain_bindir=external/gcc_arm_gnu_8_3_toolchain/bin
@@ -57,7 +60,7 @@ elif case "$0" in /*) true;; *) false;; esac; then
5760
#
5861
# If the wrapper is relocated then this line needs to be adjusted.
5962

60-
execroot_path="${0%/*/*/*/*/*/*/*/*}"
63+
execroot_path="${0%/*/*/*/*/*/*/*/*}"
6164

6265
# Legacy path for non-bazelmod
6366
tool="${execroot_path}/${toolchain_bindir}/${tool_name}"

cc/toolchains/llvm/aarch64-darwin/wrappers/wrapper

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ if [ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]; then
3333
set -x
3434
fi
3535

36-
tool_name=$(basename "$0")
36+
BASENAME=/usr/bin/basename
37+
[ -x "$BASENAME" ] || BASENAME="basename"
38+
39+
tool_name=$($BASENAME "$0")
3740
# In case the tool label is changed, a change in here is very likely needed
3841
# This establishes backwards compatibility with the old WORKSPACE file
3942
toolchain_bindir=external/aarch64-darwin-llvm/bin
@@ -57,7 +60,7 @@ elif case "$0" in /*) true;; *) false;; esac; then
5760
#
5861
# If the wrapper is relocated then this line needs to be adjusted.
5962

60-
execroot_path="${0%/*/*/*/*/*/*/*/*}"
63+
execroot_path="${0%/*/*/*/*/*/*/*/*}"
6164

6265
# Legacy path for non-bazelmod
6366
tool="${execroot_path}/${toolchain_bindir}/${tool_name}"

cc/toolchains/llvm/aarch64-linux/wrappers/wrapper

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ if [ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]; then
3333
set -x
3434
fi
3535

36-
tool_name=$(basename "$0")
36+
BASENAME=/usr/bin/basename
37+
[ -x "$BASENAME" ] || BASENAME="basename"
38+
39+
tool_name=$($BASENAME "$0")
3740
toolchain_bindir=external/aarch64-linux-llvm/bin
3841
toolchain_bindir_as_bzlmod="external/rules_swiftnav++swift_cc_toolchain_extension+aarch64-linux-llvm/bin"
3942

@@ -55,7 +58,7 @@ elif case "$0" in /*) true;; *) false;; esac; then
5558
#
5659
# If the wrapper is relocated then this line needs to be adjusted.
5760

58-
execroot_path="${0%/*/*/*/*/*/*/*/*}"
61+
execroot_path="${0%/*/*/*/*/*/*/*/*}"
5962

6063
# Legacy path for non-bazelmod
6164
tool="${execroot_path}/${toolchain_bindir}/${tool_name}"

cc/toolchains/llvm/cc_toolchain_config.bzl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ def cc_toolchain_config(
103103
])
104104
else:
105105
link_flags.extend([
106+
"-B/usr/bin", # Tell clang where to find system linker
106107
"-headerpad_max_install_names",
107108
"-Wl,-no_warn_duplicate_libraries",
108109
])

cc/toolchains/llvm/x86_64-aarch64-linux/wrappers/wrapper

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ if [ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]; then
3333
set -x
3434
fi
3535

36-
tool_name=$(basename "$0")
36+
BASENAME=/usr/bin/basename
37+
[ -x "$BASENAME" ] || BASENAME="basename"
38+
39+
tool_name=$($BASENAME "$0")
3740
toolchain_bindir=external/x86_64-linux-llvm/bin
3841
toolchain_bindir_as_bzlmod="external/rules_swiftnav++swift_cc_toolchain_extension+x86_64-linux-llvm/bin"
3942

@@ -55,7 +58,7 @@ elif case "$0" in /*) true;; *) false;; esac; then
5558
#
5659
# If the wrapper is relocated then this line needs to be adjusted.
5760

58-
execroot_path="${0%/*/*/*/*/*/*/*/*}"
61+
execroot_path="${0%/*/*/*/*/*/*/*/*}"
5962

6063
# Legacy path for non-bazelmod
6164
tool="${execroot_path}/${toolchain_bindir}/${tool_name}"

cc/toolchains/llvm/x86_64-darwin/wrappers/wrapper

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ if [ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]; then
3333
set -x
3434
fi
3535

36-
tool_name=$(basename "$0")
36+
BASENAME=/usr/bin/basename
37+
[ -x "$BASENAME" ] || BASENAME="basename"
38+
39+
tool_name=$($BASENAME "$0")
3740
toolchain_bindir=external/x86_64-darwin-llvm/bin
3841
toolchain_bindir_as_bzlmod="external/rules_swiftnav++swift_cc_toolchain_extension+x86_64-darwin-llvm/bin"
3942

cc/toolchains/llvm/x86_64-linux/wrappers/wrapper

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ if [ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]; then
3333
set -x
3434
fi
3535

36-
tool_name=$(basename "$0")
36+
BASENAME=/usr/bin/basename
37+
[ -x "$BASENAME" ] || BASENAME="basename"
38+
39+
tool_name=$($BASENAME "$0")
3740
# In case the tool label is changed, a change in here is very likely needed
3841
# This establishes backwards compatibility with the old WORKSPACE file
3942
toolchain_bindir=external/x86_64-linux-llvm/bin
@@ -57,7 +60,7 @@ elif case "$0" in /*) true;; *) false;; esac; then
5760
#
5861
# If the wrapper is relocated then this line needs to be adjusted.
5962

60-
execroot_path="${0%/*/*/*/*/*/*/*/*}"
63+
execroot_path="${0%/*/*/*/*/*/*/*/*}"
6164

6265
# Legacy path for non-bazelmod
6366
tool="${execroot_path}/${toolchain_bindir}/${tool_name}"

cc/toolchains/llvm20/aarch64-darwin/wrappers/wrapper

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ if [ -n "$SWIFTNAV_VERBOSE_TOOLCHAIN" ]; then
3333
set -x
3434
fi
3535

36-
tool_name=$(basename "$0")
36+
BASENAME=/usr/bin/basename
37+
[ -x "$BASENAME" ] || BASENAME="basename"
38+
39+
tool_name=$($BASENAME "$0")
3740
# In case the tool label is changed, a change in here is very likely needed
3841
# This establishes backwards compatibility with the old WORKSPACE file
3942
toolchain_bindir=external/aarch64-darwin-llvm20/bin
@@ -57,7 +60,7 @@ elif case "$0" in /*) true;; *) false;; esac; then
5760
#
5861
# If the wrapper is relocated then this line needs to be adjusted.
5962

60-
execroot_path="${0%/*/*/*/*/*/*/*/*}"
63+
execroot_path="${0%/*/*/*/*/*/*/*/*}"
6164

6265
# Legacy path for non-bazelmod
6366
tool="${execroot_path}/${toolchain_bindir}/${tool_name}"

0 commit comments

Comments
 (0)