[Mlir-commits] [mlir] f55a6fd - [mlir] Make sure that aggregate shared libraries define all of their symbols.
Stella Laurenzo
llvmlistbot at llvm.org
Mon Aug 15 12:02:37 PDT 2022
Author: Stella Laurenzo
Date: 2022-08-15T12:02:24-07:00
New Revision: f55a6fde1d479144f3448f04438b12178cb59e5f
URL: https://github.com/llvm/llvm-project/commit/f55a6fde1d479144f3448f04438b12178cb59e5f
DIFF: https://github.com/llvm/llvm-project/commit/f55a6fde1d479144f3448f04438b12178cb59e5f.diff
LOG: [mlir] Make sure that aggregate shared libraries define all of their symbols.
We were hitting issues on Linux where this was only being caught at runtime, and different linkers (BFD vs LLD) are differently strict in such situations. Such libraries will also fail to build properly on Windows (but test coverage of that is limited, so it is better to enforce globally).
Differential Revision: https://reviews.llvm.org/D131911
Added:
Modified:
mlir/cmake/modules/AddMLIR.cmake
Removed:
################################################################################
diff --git a/mlir/cmake/modules/AddMLIR.cmake b/mlir/cmake/modules/AddMLIR.cmake
index eba0243727ddc..15079eea3009c 100644
--- a/mlir/cmake/modules/AddMLIR.cmake
+++ b/mlir/cmake/modules/AddMLIR.cmake
@@ -159,7 +159,7 @@ function(add_mlir_pdll_library target inputFile ofn)
" filepath: \"${LLVM_TARGET_DEFINITIONS_ABSOLUTE}\"\n"
" includes: \"${CMAKE_CURRENT_SOURCE_DIR};${tblgen_includes}\"\n"
)
-
+
add_public_tablegen_target(${target})
endfunction()
@@ -490,6 +490,17 @@ function(add_mlir_aggregate name)
${ARG_PUBLIC_LIBS}
)
target_sources(${name} PRIVATE ${_objects})
+
+ # Linux defaults to allowing undefined symbols in shared libraries whereas
+ # 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")
+ target_link_options(${name} PRIVATE
+ "LINKER:-z,defs"
+ )
+ endif()
+
# TODO: Should be transitive.
set_target_properties(${name} PROPERTIES
MLIR_AGGREGATE_EXCLUDE_LIBS "${_embed_libs}")
More information about the Mlir-commits
mailing list