[Mlir-commits] [mlir] 3283a6f - [mlir-cpu-runner] Add `export_executable_symbols` in CMake

Andrzej Warzynski llvmlistbot at llvm.org
Fri Apr 7 07:41:13 PDT 2023


Author: Andrzej Warzynski
Date: 2023-04-07T14:40:57Z
New Revision: 3283a6fb0df3717ed4888fd492a4bdac5b0cbbbc

URL: https://github.com/llvm/llvm-project/commit/3283a6fb0df3717ed4888fd492a4bdac5b0cbbbc
DIFF: https://github.com/llvm/llvm-project/commit/3283a6fb0df3717ed4888fd492a4bdac5b0cbbbc.diff

LOG: [mlir-cpu-runner] Add `export_executable_symbols` in CMake

This patch is primarily about the change in
"mlir/tools/mlir-cpu-runner/CMakeLists.txt". LLJIT needs access to
symbols (e.g. llvm_orc_registerEHFrameSectionWrapper) that will be
defined in the executable when LLVM is linked statically. This change is
consistent with how other tools within LLVM use LLJIT. It is required to
make sure that:
```
 $ mlir-cpu-runner --host-supports-jit
```
correctly returns `true` on platforms that do support JITting (in my
case that's AArch64 Linux).

The change in "mlir/lib/ExecutionEngine/CMakeLists.txt" is required to
avoid ODR violations when symbols from `mlir-cpu-runner` are exported
and when loading `libmlir_async_runtime.so` in `mlir-cpu-runner`.
Specifically, to avoid `EnableABIBreakingChecks` being defined twice.
For more context:
  * https://github.com/llvm/llvm-project/issues/61712
  * https://github.com/llvm/llvm-project/issues/61856
  * https://reviews.llvm.org/D146935 (this PR)

This change relands ccdcfad0815296d8952438632d9abe6bc0a5258a

Fixes #61856

Differential Revision: https://reviews.llvm.org/D146935

Added: 
    

Modified: 
    mlir/lib/ExecutionEngine/CMakeLists.txt
    mlir/tools/mlir-cpu-runner/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/mlir/lib/ExecutionEngine/CMakeLists.txt b/mlir/lib/ExecutionEngine/CMakeLists.txt
index 5ed7af625aacc..14d8ed2095e05 100644
--- a/mlir/lib/ExecutionEngine/CMakeLists.txt
+++ b/mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -168,6 +168,12 @@ if(LLVM_ENABLE_PIC)
   )
   set_property(TARGET mlir_async_runtime PROPERTY CXX_VISIBILITY_PRESET hidden)
   target_compile_definitions(mlir_async_runtime PRIVATE mlir_async_runtime_EXPORTS)
+  if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+    # Don't export symbols from link-time dependencies, these are internal
+    # implementation details.
+    # FIXME: Add a similar fix for Windows.
+    target_link_options(mlir_async_runtime PRIVATE "-Wl,-exclude-libs,ALL")
+  endif()
 
   if(MLIR_ENABLE_CUDA_RUNNER)
     # Configure CUDA support. Using check_language first allows us to give a

diff  --git a/mlir/tools/mlir-cpu-runner/CMakeLists.txt b/mlir/tools/mlir-cpu-runner/CMakeLists.txt
index c2ab62ee93a5e..1766b28aa0b11 100644
--- a/mlir/tools/mlir-cpu-runner/CMakeLists.txt
+++ b/mlir/tools/mlir-cpu-runner/CMakeLists.txt
@@ -22,3 +22,5 @@ target_link_libraries(mlir-cpu-runner PRIVATE
   MLIRTargetLLVMIRExport
   MLIRSupport
   )
+
+export_executable_symbols(mlir-cpu-runner)


        


More information about the Mlir-commits mailing list