[mlir] Don't use -z,defs on sanitizer builds

This works around link errors when building the python bindings with
ASAN, since the ASAN run-time doesn't get linked into shared libraries.
The ASAN docs specficially call out -z,defs as a potential issue:
https://clang.llvm.org/docs/AddressSanitizer.html#usage

closes https://github.com/llvm/llvm-project/issues/60565

Reviewed By: stellaraccident, mehdi_amini

Differential Revision: https://reviews.llvm.org/D145956
This commit is contained in:
Rahul Kayaith 2023-03-13 12:42:25 -04:00
parent 4e901cda72
commit 87296fd3c1

View File

@ -495,7 +495,9 @@ function(add_mlir_aggregate name)
# many other platforms are more strict. We want these libraries to be # many other platforms are more strict. We want these libraries to be
# self contained, and we want any undefined symbols to be reported at # self contained, and we want any undefined symbols to be reported at
# library construction time, not at library use, so make Linux strict too. # library construction time, not at library use, so make Linux strict too.
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") # We make an exception for sanitizer builds, since the AddressSanitizer
# run-time doesn't get linked into shared libraries.
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (NOT LLVM_USE_SANITIZER))
target_link_options(${name} PRIVATE target_link_options(${name} PRIVATE
"LINKER:-z,defs" "LINKER:-z,defs"
) )