diff --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake index bbc5c2a42358..2b12530bda98 100644 --- a/mlir/cmake/modules/AddMLIR.cmake +++ b/mlir/cmake/modules/AddMLIR.cmake @@ -495,7 +495,9 @@ function(add_mlir_aggregate name) # many other platforms are more strict. We want these libraries to be # self contained, and we want any undefined symbols to be reported at # 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 "LINKER:-z,defs" )