[llvm] 69ea174 - llvm-shlib: Fix mingw dll exports (#148772)

via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 15 01:54:32 PDT 2025


Author: Keno Fischer
Date: 2025-07-15T04:54:28-04:00
New Revision: 69ea174bf07533b7f63139f78b0ec3d3766aedc4

URL: https://github.com/llvm/llvm-project/commit/69ea174bf07533b7f63139f78b0ec3d3766aedc4
DIFF: https://github.com/llvm/llvm-project/commit/69ea174bf07533b7f63139f78b0ec3d3766aedc4.diff

LOG: llvm-shlib: Fix mingw dll exports (#148772)

In c87d198cd964f37343083848f8fdd58bb0b00156, 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.

Added: 
    

Modified: 
    llvm/tools/llvm-shlib/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt
index 9a2015f61f2bf..53003d90160fe 100644
--- a/llvm/tools/llvm-shlib/CMakeLists.txt
+++ b/llvm/tools/llvm-shlib/CMakeLists.txt
@@ -41,6 +41,15 @@ if(LLVM_BUILD_LLVM_DYLIB)
     llvm_install_library_symlink(LLVM-${LLVM_VERSION_MAJOR}${LLVM_VERSION_SUFFIX} $<TARGET_FILE_NAME:LLVM> SHARED FULL_DEST COMPONENT LLVM)
   endif()
 
+  if (MINGW OR CYGWIN)
+    # The LLVM DLL is supposed to export all symbols (except for ones
+    # that are explicitly hidden). Normally, this is what happens anyway, but
+    # if there are symbols that are marked explicitly as dllexport, we'd only
+    # export them and nothing else. Therefore, add --export-all-symbols to
+    # make sure we export all symbols despite potential dllexports.
+    target_link_options(LLVM PRIVATE LINKER:--export-all-symbols)
+  endif()
+
   list(REMOVE_DUPLICATES LIB_NAMES)
   if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
     set(LIB_NAMES -Wl,-all_load ${LIB_NAMES})


        


More information about the llvm-commits mailing list