[llvm] [llvm-jitlink] Explicit exports for builtin runtime functions in MinGW executables (PR #107375)

Stefan Gränitz via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 5 02:42:19 PDT 2024


https://github.com/weliveindetail created https://github.com/llvm/llvm-project/pull/107375

Use explicit exports to fix the symbol resolution part of https://github.com/llvm/llvm-project/issues/98714 in MinGW

>From 0abf9ec89799d913f534c4e8986d85bbe918a113 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Stefan=20Gr=C3=A4nitz?= <stefan.graenitz at gmail.com>
Date: Wed, 4 Sep 2024 15:14:03 +0200
Subject: [PATCH] [llvm-jitlink] Export builtin runtime functions from MinGW
 executables

---
 llvm/tools/llvm-jitlink/CMakeLists.txt | 27 ++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/llvm/tools/llvm-jitlink/CMakeLists.txt b/llvm/tools/llvm-jitlink/CMakeLists.txt
index e337fe5f998656..c2790616e01927 100644
--- a/llvm/tools/llvm-jitlink/CMakeLists.txt
+++ b/llvm/tools/llvm-jitlink/CMakeLists.txt
@@ -37,3 +37,30 @@ endif()
 if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
   target_link_libraries(llvm-jitlink PRIVATE socket)
 endif()
+
+if(MINGW)
+  set(builtin_runtime_functions
+    llvm_orc_registerEHFrameSectionWrapper
+    llvm_orc_deregisterEHFrameSectionWrapper
+    llvm_orc_registerJITLoaderGDBWrapper
+    llvm_orc_registerJITLoaderGDBAllocAction
+    llvm_orc_registerJITLoaderPerfStart
+    llvm_orc_registerJITLoaderPerfEnd
+    llvm_orc_registerJITLoaderPerfImpl
+    llvm_orc_registerVTuneImpl
+    llvm_orc_unregisterVTuneImpl
+    llvm_orc_test_registerVTuneImpl
+    )
+
+  foreach(entry IN LISTS builtin_runtime_functions)
+    string(APPEND exports_multiline "${entry}\n")
+  endforeach()
+
+  set(file_stem ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/llvm-jitlink)
+  file(WRITE ${file_stem}.symbols ${exports_multiline})
+  file(WRITE ${file_stem}.def "EXPORTS\n${exports_multiline}")
+
+  add_llvm_symbol_exports(llvm-jitlink ${file_stem}.symbols)
+else()
+  export_executable_symbols(llvm-jitlink)
+endif(MINGW)



More information about the llvm-commits mailing list