Skip to content

Commit 6bca3e2

Browse files
authored
Support LLD linker for Darwin (#286)
Users can use with `--linkopt=-fuse-ld=ld64.lld` flag. Eventually, we should make this the default. But only after we hear from some users that it works for their projects. This PR will make it easy for them to test.
1 parent 8f4a0b2 commit 6bca3e2

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

tests/scripts/run_tests.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ set -x
4242
test_args=(
4343
"--extra_toolchains=${toolchain_name}"
4444
"--copt=-v"
45+
"--linkopt=-Wl,-v"
4546
"--linkopt=-Wl,-t"
4647
)
4748

toolchain/BUILD.llvm_repo

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@ filegroup(
3434

3535
filegroup(
3636
name = "ld",
37-
srcs = [
38-
"bin/ld.lld",
39-
],
37+
srcs = glob(["bin/ld.lld", "bin/ld64.lld"]),
4038
)
4139

4240
filegroup(

toolchain/osx_cc_wrapper.sh.tpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,14 @@ function parse_option() {
5656

5757
if [[ -f %{toolchain_path_prefix}bin/clang ]]; then
5858
execroot_path=""
59+
execroot_abs_path="${PWD}/"
5960
elif [[ ${BASH_SOURCE[0]} == "/"* ]]; then
6061
# Some consumers of `CcToolchainConfigInfo` (e.g. `cmake` from rules_foreign_cc)
6162
# change CWD and call $CC (this script) with its absolute path.
6263
# For cases like this, we'll try to find `clang` through an absolute path.
6364
# This script is at _execroot_/external/_repo_name_/bin/cc_wrapper.sh
6465
execroot_path="${BASH_SOURCE[0]%/*/*/*/*}/"
66+
execroot_abs_path="$(cd "${execroot_path}" && pwd -P)/"
6567
else
6668
echo >&2 "ERROR: could not find clang; PWD=\"${PWD}\"; PATH=\"${PATH}\"."
6769
exit 5
@@ -71,6 +73,8 @@ function sanitize_option() {
7173
local -r opt=$1
7274
if [[ ${opt} == */cc_wrapper.sh ]]; then
7375
printf "%s" "${execroot_path}%{toolchain_path_prefix}bin/clang"
76+
elif [[ ${opt} == "-fuse-ld=ld64.lld" ]]; then
77+
echo "-fuse-ld=${execroot_abs_path}%{toolchain_path_prefix}bin/ld64.lld"
7478
elif [[ ${opt} =~ ^-fsanitize-(ignore|black)list=[^/] ]]; then
7579
# shellcheck disable=SC2206
7680
parts=(${opt/=/ }) # Split flag name and value into array.

0 commit comments

Comments
 (0)