Skip to content

Commit 69ea174

Browse files
authored
llvm-shlib: Fix mingw dll exports (#148772)
In c87d198, the `__jit_debug_*` symbols gained explicit dllexport annotations. Unfortunately, mingw's linkers have a quirk where the presence of any dllexport symbols at all will switch off the `-export-all-symbols` flag, so without a full conversion to dllexport annotations (#109483), the mingw LLVM dll build is broken in LLVM 20+ when building with GCC (when building with clang, LLVM_ALWAYS_EXPORT expands to the default visibility attribute, see extended discussion in #148772). Fix this by adding the flag explicitly as was done for clang-shlib earlier in https://reviews.llvm.org/D151620.
1 parent 2943673 commit 69ea174

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

llvm/tools/llvm-shlib/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ if(LLVM_BUILD_LLVM_DYLIB)
4141
llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} $<TARGET_FILE_NAME:LLVM> SHARED FULL_DEST COMPONENT LLVM)
4242
endif()
4343

44+
if (MINGW OR CYGWIN)
45+
# The LLVM DLL is supposed to export all symbols (except for ones
46+
# that are explicitly hidden). Normally, this is what happens anyway, but
47+
# if there are symbols that are marked explicitly as dllexport, we'd only
48+
# export them and nothing else. Therefore, add --export-all-symbols to
49+
# make sure we export all symbols despite potential dllexports.
50+
target_link_options(LLVM PRIVATE LINKER:--export-all-symbols)
51+
endif()
52+
4453
list(REMOVE_DUPLICATES LIB_NAMES)
4554
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
4655
set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})

0 commit comments

Comments
 (0)