From 740252164ed830502ff966628bc07be07e10159b Mon Sep 17 00:00:00 2001 From: Andrea Faulds Date: Wed, 15 Jan 2025 17:05:11 +0100 Subject: [PATCH 1/2] [mlir-cpu-runner] Pass --exclude-libs to linker when building runner (#122920) This fixes a conflict between the version of LLVM linked against by the runner and the unrelated version of LLVM that may be dynamically loaded by a graphics driver. (Relevant to #73457: fixes loading certain Vulkan drivers.) Recommit of f879da799b4e112d79243dde6d299259d8359eeb, which had been reverted by d8d30a96031bfdad3e2c424e14a4247c14980cb5 due to it causing UBSan/ASan/HWASan/MSan build failures. --- mlir/tools/mlir-cpu-runner/CMakeLists.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mlir/tools/mlir-cpu-runner/CMakeLists.txt b/mlir/tools/mlir-cpu-runner/CMakeLists.txt index 811583b97bc71..cb937ace1de31 100644 --- a/mlir/tools/mlir-cpu-runner/CMakeLists.txt +++ b/mlir/tools/mlir-cpu-runner/CMakeLists.txt @@ -26,3 +26,14 @@ target_link_libraries(mlir-cpu-runner PRIVATE MLIRExecutionEngine MLIRJitRunner ) + +# Preventing re-export of symbols causes link errors with ASan and UBSan libs. +if (NOT LLVM_USE_SANITIZER) + target_link_options(mlir-cpu-runner + PRIVATE + # On Linux, disable re-export of any static linked libraries that came + # through. This prevents our LLVM build from interfering with the version + # of LLVM included in certain graphics drivers. + $<$:LINKER:--exclude-libs,ALL> + ) +endif() From 528b28425d8ab791d553509ce42807f46a53e3b0 Mon Sep 17 00:00:00 2001 From: Jonas Rickert Date: Thu, 20 Mar 2025 01:22:43 -0600 Subject: [PATCH 2/2] Do not link mlir-cpu-runner with '--exclude-libs' as this causes errors in the pass registration --- mlir/tools/mlir-cpu-runner/CMakeLists.txt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/mlir/tools/mlir-cpu-runner/CMakeLists.txt b/mlir/tools/mlir-cpu-runner/CMakeLists.txt index cb937ace1de31..580bb16849726 100644 --- a/mlir/tools/mlir-cpu-runner/CMakeLists.txt +++ b/mlir/tools/mlir-cpu-runner/CMakeLists.txt @@ -28,12 +28,13 @@ target_link_libraries(mlir-cpu-runner PRIVATE ) # Preventing re-export of symbols causes link errors with ASan and UBSan libs. -if (NOT LLVM_USE_SANITIZER) - target_link_options(mlir-cpu-runner - PRIVATE - # On Linux, disable re-export of any static linked libraries that came - # through. This prevents our LLVM build from interfering with the version - # of LLVM included in certain graphics drivers. - $<$:LINKER:--exclude-libs,ALL> - ) -endif() +# AMD: Disabled as it causes passed to not be registered +#if (NOT LLVM_USE_SANITIZER) +# target_link_options(mlir-cpu-runner +# PRIVATE +# # On Linux, disable re-export of any static linked libraries that came +# # through. This prevents our LLVM build from interfering with the version +# # of LLVM included in certain graphics drivers. +# $<$:LINKER:--exclude-libs,ALL> +# ) +#endif()