[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
This commit is contained in:
Arthur Eubanks 2021-09-20 10:42:07 -07:00
parent dd0226561e
commit b64fdaa86b
3 changed files with 10 additions and 2 deletions

View File

@ -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") {

View File

@ -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

View File

@ -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"