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.
This commit is contained in:
parent
8f4a0b2c40
commit
6bca3e279a
|
@ -42,6 +42,7 @@ set -x
|
|||
test_args=(
|
||||
"--extra_toolchains=${toolchain_name}"
|
||||
"--copt=-v"
|
||||
"--linkopt=-Wl,-v"
|
||||
"--linkopt=-Wl,-t"
|
||||
)
|
||||
|
||||
|
|
|
@ -34,9 +34,7 @@ filegroup(
|
|||
|
||||
filegroup(
|
||||
name = "ld",
|
||||
srcs = [
|
||||
"bin/ld.lld",
|
||||
],
|
||||
srcs = glob(["bin/ld.lld", "bin/ld64.lld"]),
|
||||
)
|
||||
|
||||
filegroup(
|
||||
|
|
|
@ -56,12 +56,14 @@ function parse_option() {
|
|||
|
||||
if [[ -f %{toolchain_path_prefix}bin/clang ]]; then
|
||||
execroot_path=""
|
||||
execroot_abs_path="${PWD}/"
|
||||
elif [[ ${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.
|
||||
# This script is at _execroot_/external/_repo_name_/bin/cc_wrapper.sh
|
||||
execroot_path="${BASH_SOURCE[0]%/*/*/*/*}/"
|
||||
execroot_abs_path="$(cd "${execroot_path}" && pwd -P)/"
|
||||
else
|
||||
echo >&2 "ERROR: could not find clang; PWD=\"${PWD}\"; PATH=\"${PATH}\"."
|
||||
exit 5
|
||||
|
@ -71,6 +73,8 @@ function sanitize_option() {
|
|||
local -r opt=$1
|
||||
if [[ ${opt} == */cc_wrapper.sh ]]; then
|
||||
printf "%s" "${execroot_path}%{toolchain_path_prefix}bin/clang"
|
||||
elif [[ ${opt} == "-fuse-ld=ld64.lld" ]]; then
|
||||
echo "-fuse-ld=${execroot_abs_path}%{toolchain_path_prefix}bin/ld64.lld"
|
||||
elif [[ ${opt} =~ ^-fsanitize-(ignore|black)list=[^/] ]]; then
|
||||
# shellcheck disable=SC2206
|
||||
parts=(${opt/=/ }) # Split flag name and value into array.
|
||||
|
|
Loading…
Reference in New Issue