[llvm] Export LLVM plugin entrypoint for windows shared library builds (PR #115431)
Thomas Fransham via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 11 14:47:25 PST 2024
https://github.com/fsfod updated https://github.com/llvm/llvm-project/pull/115431
>From fe7200c66b9f865638c4eb8b6eb5af4c4e210f4f Mon Sep 17 00:00:00 2001
From: Thomas Fransham <tfransham at gmail.com>
Date: Thu, 7 Nov 2024 19:48:34 +0000
Subject: [PATCH 1/2] Export LLVM plugin entrypoint for windows shared library
builds
Add Symbol visibility macro to llvmGetPassPluginInfo so plugins export it for
windows shared library builds with explicit symbol visibility macros enabled.
This avoids the need for existing plugins having to manually add visibility
macros to there llvmGetPassPluginInfo function to work on windows.
This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on window.
---
llvm/include/llvm/Passes/PassPlugin.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/include/llvm/Passes/PassPlugin.h b/llvm/include/llvm/Passes/PassPlugin.h
index 013b7a827c47dd..43310d0b9f14af 100644
--- a/llvm/include/llvm/Passes/PassPlugin.h
+++ b/llvm/include/llvm/Passes/PassPlugin.h
@@ -107,7 +107,7 @@ class PassPlugin {
/// };
/// }
/// ```
-extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK
+extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK LLVM_ABI_EXPORT
llvmGetPassPluginInfo();
#endif /* LLVM_PASSES_PASSPLUGIN_H */
>From b13e6485a1549036fcc3ec602d2aac55585b6268 Mon Sep 17 00:00:00 2001
From: Thomas Fransham <tfransham at gmail.com>
Date: Mon, 11 Nov 2024 22:47:01 +0000
Subject: [PATCH 2/2] Switch to just using dllexport for llvmGetPassPluginInfo
declaration
---
llvm/include/llvm/Passes/PassPlugin.h | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/llvm/include/llvm/Passes/PassPlugin.h b/llvm/include/llvm/Passes/PassPlugin.h
index 43310d0b9f14af..967de9f29ba795 100644
--- a/llvm/include/llvm/Passes/PassPlugin.h
+++ b/llvm/include/llvm/Passes/PassPlugin.h
@@ -107,7 +107,13 @@ class PassPlugin {
/// };
/// }
/// ```
-extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK LLVM_ABI_EXPORT
+
+#if defined(_WIN32) && defined(LLVM_BUILD_LLVM_DYLIB)
+extern "C" ::llvm::PassPluginLibraryInfo __declspec(dllexport)
+llvmGetPassPluginInfo();
+#else
+extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK
llvmGetPassPluginInfo();
+#endif
#endif /* LLVM_PASSES_PASSPLUGIN_H */
More information about the llvm-commits
mailing list