From 7611bb2e2084e9c08685ddacf463c1adc8cdb136 Mon Sep 17 00:00:00 2001 From: Thomas Fransham Date: Thu, 7 Nov 2024 15:11:40 +0000 Subject: [PATCH] [ORC] Switch to new visibility macros for JIT debug symbols (#113848) Use LLVM_ALWAYS_EXPORT for __jit_debug_descriptor and __jit_debug_register_code so there exported even if LLVM is not built as a shared library. This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on windows #109483. --- llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.cpp | 5 +++-- llvm/tools/lli/lli.cpp | 3 ++- .../llvm-jitlink-executor/llvm-jitlink-executor.cpp | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.cpp b/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.cpp index 7529d9cef67ed5..6347032f010bef 100644 --- a/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.cpp +++ b/llvm/lib/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.cpp @@ -10,6 +10,7 @@ #include "llvm/ExecutionEngine/JITSymbol.h" #include "llvm/Support/BinaryStreamReader.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/FormatVariadic.h" #include @@ -26,13 +27,13 @@ extern "C" { // We put information about the JITed function in this global, which the // debugger reads. Make sure to specify the version statically, because the // debugger checks the version before we can set it during runtime. -LLVM_ATTRIBUTE_VISIBILITY_DEFAULT +LLVM_ALWAYS_EXPORT struct jit_descriptor __jit_debug_descriptor = {JitDescriptorVersion, 0, nullptr, nullptr}; // Debuggers that implement the GDB JIT interface put a special breakpoint in // this function. -LLVM_ATTRIBUTE_VISIBILITY_DEFAULT +LLVM_ALWAYS_EXPORT LLVM_ATTRIBUTE_NOINLINE void __jit_debug_register_code() { // The noinline and the asm prevent calls to this function from being // optimized out. diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp index 4c023bcdd61658..540c43889da758 100644 --- a/llvm/tools/lli/lli.cpp +++ b/llvm/tools/lli/lli.cpp @@ -50,6 +50,7 @@ #include "llvm/Object/Archive.h" #include "llvm/Object/ObjectFile.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/Format.h" @@ -751,7 +752,7 @@ int main(int argc, char **argv, char * const *envp) { // JITLink debug support plugins put information about JITed code in this GDB // JIT Interface global from OrcTargetProcess. -extern "C" struct jit_descriptor __jit_debug_descriptor; +extern "C" LLVM_ABI struct jit_descriptor __jit_debug_descriptor; static struct jit_code_entry * findNextDebugDescriptorEntry(struct jit_code_entry *Latest) { diff --git a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp b/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp index 73a50deb152d84..86b89a38c17601 100644 --- a/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp +++ b/llvm/tools/llvm-jitlink/llvm-jitlink-executor/llvm-jitlink-executor.cpp @@ -17,6 +17,7 @@ #include "llvm/ExecutionEngine/Orc/TargetProcess/RegisterEHFrames.h" #include "llvm/ExecutionEngine/Orc/TargetProcess/SimpleExecutorMemoryManager.h" #include "llvm/ExecutionEngine/Orc/TargetProcess/SimpleRemoteEPCServer.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/DynamicLibrary.h" #include "llvm/Support/Error.h" @@ -117,7 +118,7 @@ int openListener(std::string Host, std::string PortStr) { // JITLink debug support plugins put information about JITed code in this GDB // JIT Interface global from OrcTargetProcess. -extern "C" struct jit_descriptor __jit_debug_descriptor; +extern "C" LLVM_ABI struct jit_descriptor __jit_debug_descriptor; static void *findLastDebugDescriptorEntryPtr() { struct jit_code_entry *Last = __jit_debug_descriptor.first_entry;