From 016c0adda7cb1a1ab7850abdd9229037d9097bda Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Tue, 10 Aug 2021 21:08:44 +0200 Subject: Use lld on Linux Since we require building with a relatively modern clang, we might as well use its linker (and in the future, its C++ standard library). --- driver/BUILD.bazel | 15 ++++++++++++--- examples/src/main/native/BUILD.bazel | 8 ++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/driver/BUILD.bazel b/driver/BUILD.bazel index 8a0762ea..8e095559 100644 --- a/driver/BUILD.bazel +++ b/driver/BUILD.bazel @@ -79,7 +79,10 @@ cc_binary( ], linkopts = [ "-rdynamic", - ], + ] + select({ + "@platforms//os:linux": ["-fuse-ld=lld"], + "//conditions:default": [], + }), visibility = ["//visibility:public"], deps = [":driver_lib"], ) @@ -103,7 +106,10 @@ cc_binary( "-fsanitize=address", "-static-libsan", "-rdynamic", - ], + ] + select({ + "@platforms//os:linux": ["-fuse-ld=lld"], + "//conditions:default": [], + }), visibility = ["//visibility:public"], deps = [":driver_lib"] + select({ # There is no static ASan runtime on macOS, so link to the dynamic @@ -123,7 +129,10 @@ cc_binary( # Link UBSan statically, even on macOS. "-static-libsan", "-rdynamic", - ], + ] + select({ + "@platforms//os:linux": ["-fuse-ld=lld"], + "//conditions:default": [], + }), visibility = ["//visibility:public"], deps = [":driver_lib"], ) diff --git a/examples/src/main/native/BUILD.bazel b/examples/src/main/native/BUILD.bazel index f2587cbe..12bbc120 100644 --- a/examples/src/main/native/BUILD.bazel +++ b/examples/src/main/native/BUILD.bazel @@ -9,6 +9,10 @@ cc_shared_library( copts = [ "-fsanitize=fuzzer-no-link,address", ], + linkopts = select({ + "@platforms//os:linux": ["-fuse-ld=lld"], + "//conditions:default": [], + }), visibility = ["//examples:__pkg__"], deps = [ "@bazel_tools//tools/jdk:jni", @@ -27,6 +31,10 @@ cc_shared_library( # Workaround for https://github.com/bazelbuild/bazel/issues/11122. "-fno-sanitize=vptr,function", ], + linkopts = select({ + "@platforms//os:linux": ["-fuse-ld=lld"], + "//conditions:default": [], + }), visibility = ["//examples:__pkg__"], deps = [ "@bazel_tools//tools/jdk:jni", -- cgit v1.2.3