Skip to content

Commit dffd255

Browse files
committed
fix(plugin): use linker pragma to export llvmGetPassPluginInfo on MSVC
1 parent 5862269 commit dffd255

8 files changed

Lines changed: 1188 additions & 6 deletions

File tree

3.38 KB
Binary file not shown.
Binary file not shown.

cargo-obfuscate/target/debug/incremental/cargo_obfuscate-2ig7taw79wpsa/s-hhjk68y1dw-0n6o4ud.lock

Whitespace-only changes.

log.log

Lines changed: 1182 additions & 0 deletions
Large diffs are not rendered by default.

passes/src/PassPlugin.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ llvm::PassPluginLibraryInfo getObfuscatorPluginInfo() {
113113
};
114114
}
115115

116-
// On MSVC, LLVM_ATTRIBUTE_WEAK is empty, so the entry point is not exported from the DLL and
117-
// opt/clang cannot resolve llvmGetPassPluginInfo (legacy-plugin error).
116+
// On MSVC, LLVM_ATTRIBUTE_WEAK is empty and LLVM's header already declares
117+
// llvmGetPassPluginInfo without __declspec(dllexport). Adding dllexport to
118+
// the definition causes C2375 (redefinition; different linkage). Use a
119+
// linker pragma to export the symbol instead — same effect, no conflict.
118120
#if defined(_MSC_VER)
119-
#define LLVM_OBFUSCATOR_PLUGIN_ABI __declspec(dllexport)
120-
#else
121-
#define LLVM_OBFUSCATOR_PLUGIN_ABI LLVM_ATTRIBUTE_WEAK
121+
#pragma comment(linker, "/export:llvmGetPassPluginInfo")
122122
#endif
123123

124-
extern "C" LLVM_OBFUSCATOR_PLUGIN_ABI ::llvm::PassPluginLibraryInfo llvmGetPassPluginInfo() {
124+
extern "C" LLVM_ATTRIBUTE_WEAK ::llvm::PassPluginLibraryInfo llvmGetPassPluginInfo() {
125125
return getObfuscatorPluginInfo();
126126
}

0 commit comments

Comments
 (0)