[Mlir-commits] [mlir] 87296fd - [mlir] Don't use -z, defs on sanitizer builds

Rahul Kayaith llvmlistbot at llvm.org
Mon Mar 13 11:04:36 PDT 2023


Author: Rahul Kayaith
Date: 2023-03-13T14:04:31-04:00
New Revision: 87296fd3c1c5f8d20be017b3b1295ffbf7bf8e0d

URL: https://github.com/llvm/llvm-project/commit/87296fd3c1c5f8d20be017b3b1295ffbf7bf8e0d
DIFF: https://github.com/llvm/llvm-project/commit/87296fd3c1c5f8d20be017b3b1295ffbf7bf8e0d.diff

LOG: [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

Added: 
    

Modified: 
    mlir/cmake/modules/AddMLIR.cmake

Removed: 
    


################################################################################
diff  --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake
index bbc5c2a42358f..2b12530bda985 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"
     )


        


More information about the Mlir-commits mailing list