[llvm] b64fdaa - [gn build] Don't pass -Wl, -z, defs for sanitizer builds
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 20 11:39:52 PDT 2021
Author: Arthur Eubanks
Date: 2021-09-20T11:39:39-07:00
New Revision: b64fdaa86b5b35fa982dd1f41d32b37a9d5208b6
URL: https://github.com/llvm/llvm-project/commit/b64fdaa86b5b35fa982dd1f41d32b37a9d5208b6
DIFF: https://github.com/llvm/llvm-project/commit/b64fdaa86b5b35fa982dd1f41d32b37a9d5208b6.diff
LOG: [gn build] Don't pass -Wl,-z,defs for sanitizer builds
-Wl,-z,defs doesn't work with sanitizers.
See https://clang.llvm.org/docs/AddressSanitizer.html
Reviewed By: thakis
Differential Revision: https://reviews.llvm.org/D110086
Added:
Modified:
llvm/utils/gn/build/BUILD.gn
llvm/utils/gn/build/BUILDCONFIG.gn
llvm/utils/gn/build/toolchain/BUILD.gn
Removed:
################################################################################
diff --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn
index bbd7a16b2a68a..03f6d8e74fe34 100644
--- a/llvm/utils/gn/build/BUILD.gn
+++ b/llvm/utils/gn/build/BUILD.gn
@@ -370,6 +370,14 @@ config("no_rtti") {
cflags_objcc = cflags_cc
}
+config("zdefs") {
+ # -Wl,-z,defs doesn't work with sanitizers.
+ # https://clang.llvm.org/docs/AddressSanitizer.html
+ if (current_os != "ios" && current_os != "mac" && current_os != "win" && !(use_asan || use_tsan || use_ubsan)) {
+ ldflags = [ "-Wl,-z,defs" ]
+ }
+}
+
# To make an archive that can be distributed, you need to remove this config and
# set complete_static_lib.
config("thin_archive") {
diff --git a/llvm/utils/gn/build/BUILDCONFIG.gn b/llvm/utils/gn/build/BUILDCONFIG.gn
index 1d876be9e3a81..858b811c13b15 100644
--- a/llvm/utils/gn/build/BUILDCONFIG.gn
+++ b/llvm/utils/gn/build/BUILDCONFIG.gn
@@ -22,7 +22,7 @@ set_defaults("static_library") {
configs = shared_binary_target_configs
}
set_defaults("shared_library") {
- configs = shared_binary_target_configs
+ configs = shared_binary_target_configs + [ "//llvm/utils/gn/build:zdefs" ]
}
set_defaults("source_set") {
configs = shared_binary_target_configs
diff --git a/llvm/utils/gn/build/toolchain/BUILD.gn b/llvm/utils/gn/build/toolchain/BUILD.gn
index 0f33ee76cb6d3..9819acd6a2ba5 100644
--- a/llvm/utils/gn/build/toolchain/BUILD.gn
+++ b/llvm/utils/gn/build/toolchain/BUILD.gn
@@ -109,7 +109,7 @@ template("unix_toolchain") {
command = "$ld -shared {{ldflags}} -o $outfile {{inputs}} {{libs}} {{frameworks}}"
default_output_extension = ".dylib"
} else {
- command = "$ld -shared {{ldflags}} -Wl,-z,defs -Wl,-soname,{{target_output_name}}{{output_extension}} -o $outfile {{inputs}} {{libs}}"
+ command = "$ld -shared {{ldflags}} -Wl,-soname,{{target_output_name}}{{output_extension}} -o $outfile {{inputs}} {{libs}}"
default_output_extension = ".so"
}
description = "SOLINK $outfile"
More information about the llvm-commits
mailing list