From a805e117c98f717990436a507f8f99e64f6906d6 Mon Sep 17 00:00:00 2001 From: jhchouuu Date: Thu, 21 May 2026 04:30:11 +0000 Subject: [PATCH] fix: use compiled spdlog with hidden visibility to prevent symbol collision MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both MORI and rocroller (loaded via hipblaslt/TransformerEngine) statically link spdlog. When TransformerEngine loads libtransformer_engine.so with RTLD_GLOBAL, rocroller's spdlog symbols enter the global namespace and interpose MORI's spdlog calls (e.g. registry::initialize_logger dispatches into rocroller's set_formatter), causing heap corruption (free(): invalid size / SIGABRT). Switch from spdlog::spdlog_header_only to the compiled spdlog::spdlog target and set CXX_VISIBILITY_PRESET=hidden + VISIBILITY_INLINES_HIDDEN=ON. This compiles spdlog into a static archive with hidden visibility; when linked into MORI's .so files, the spdlog symbols are not exported to the dynamic symbol table and cannot be interposed. The previous header-only mode (introduced in aceb70c for an XLA build fix) made target_compile_options on the spdlog target ineffective because MORI never linked the compiled spdlog library — the visibility flags were applied to an unused target. The XLA build concern no longer applies after the header decoupling work in commits 53a8513f and 40c08208. Tested: TE (all 3 init orders PASS), JAX/XLA (BUILD_XLA_FFI_OPS=ON PASS). --- CMakeLists.txt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 12ea7c3b..7b509fa8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -152,13 +152,18 @@ set(SPDLOG_BUILD_BENCH CACHE BOOL "" FORCE) set(CMAKE_POSITION_INDEPENDENT_CODE ON) add_subdirectory(3rdparty/spdlog) -# Hide spdlog symbols from other libraries to avoid symbol conflicts -target_compile_options(spdlog PRIVATE -fvisibility=hidden - -fvisibility-inlines-hidden) +# Hide spdlog symbols to avoid cross-library symbol collisions. Both rocroller +# (via hipblaslt/TE) and MORI statically link spdlog; if both export spdlog +# symbols, MORI's spdlog calls can be interposed by rocroller's copy, causing +# heap corruption (free(): invalid size). Using the compiled spdlog library (not +# header-only) with hidden visibility ensures spdlog symbols stay internal to +# MORI's .so files. +set_target_properties(spdlog PROPERTIES CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON) add_library(mori_logging INTERFACE) target_include_directories(mori_logging INTERFACE include) -target_link_libraries(mori_logging INTERFACE spdlog::spdlog_header_only) +target_link_libraries(mori_logging INTERFACE spdlog::spdlog) if(ENABLE_PROFILER) find_package(