diff --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake --- a/mlir/cmake/modules/AddMLIR.cmake +++ b/mlir/cmake/modules/AddMLIR.cmake @@ -495,7 +495,9 @@ # 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" )