summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/Passes/TestPlugin.cpp
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2018-05-19 03:05:30 +0000
committerNico Weber <nicolasweber@gmx.de>2018-05-19 03:05:30 +0000
commit5533357c38c9d6508b16c80446f5e60611fca66b (patch)
treef22bd3a531493ad4846d0cda0298e95d552677a7 /llvm/unittests/Passes/TestPlugin.cpp
parentea988f1fd998d59f96a14bfb47db5470747f00d0 (diff)
downloadbcm5719-llvm-5533357c38c9d6508b16c80446f5e60611fca66b.tar.gz
bcm5719-llvm-5533357c38c9d6508b16c80446f5e60611fca66b.zip
Fix build warning compiling TestPlugin on Windows and disable Passes plugin stuff on Windows since it fundamentally can't work
Aaron Ballman reported that TestPlugin warned about it using exception handling without /EHsc flag, and that llvmGetPassInfo() had conflicting export attributes (dllimport in the header, dllexport in the source file). /EHsc is because TestPlugin didn't use the llvm_ cmake functions, so llvm_update_compile_flags didn't get called for the target (llvm_update_compile_flags explicitly passes /Ehs-c-, which fixes the warning). Use add_llvm_loadable_module instead of add_library(... MODULE) to fix this. This also has the side effect of not building the plugin on Windows. That's not a big problem, since before the plugin was built on Windows, but the test didn't attempt to load it, due to -DLLVM_ENABLE_PLUGIN not being passed to PluginsTests.cpp during compilation on Windows. This makes the plugin behavior consistent with e.g. lib/Transforms/Hello/CMakeLists.txt. (This also automatically sets LTDL_SHLIB_EXT correctly.) The dllimport/dllexport warning is more serious: Since LLVM doesn't generally use export annotations for its code, the only way the plugin could link was by linking in some LLVM libraries both into the test and the dll, so the plugin would call the llvm code in the dll instead of the copy in the main executable. This means globals weren't shared, and things generally can't work. (I think there's a build config where you can build a LLVM.dll which might work, but that wasn't how the test was configured. If that config is used, the dll should still be built, but I haven't checked). Now that add_llvm_loadable_module is used, LLVM_LINK_COMPONENTS got linked into both executable and plugin on posix too, so unset it after the executable so that the plugin doesn't end up with a 2nd copy of things on posix. https://reviews.llvm.org/D47082 llvm-svn: 332796
Diffstat (limited to 'llvm/unittests/Passes/TestPlugin.cpp')
-rw-r--r--llvm/unittests/Passes/TestPlugin.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/unittests/Passes/TestPlugin.cpp b/llvm/unittests/Passes/TestPlugin.cpp
index 2ba6f9baf22..3dc5cdc8476 100644
--- a/llvm/unittests/Passes/TestPlugin.cpp
+++ b/llvm/unittests/Passes/TestPlugin.cpp
@@ -32,7 +32,7 @@ void registerCallbacks(PassBuilder &PB) {
});
}
-extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK LLVM_PLUGIN_EXPORT
+extern "C" ::llvm::PassPluginLibraryInfo LLVM_ATTRIBUTE_WEAK
llvmGetPassPluginInfo() {
return {LLVM_PLUGIN_API_VERSION, TEST_PLUGIN_NAME, TEST_PLUGIN_VERSION,
registerCallbacks};
OpenPOWER on IntegriCloud