Make llvmc work again.

Chris recently broke llvmc with his Makefile changes (r75379). That patch made
the global change .o -> .a, which caused built-in llvmc plugins to stop working
since plugin initialization in llvmc is based on static variables not referenced
from the main executable. This patch implements auto-generated forced references
to the plugin libraries.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74000 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mikhail Glushenkov
2009-06-23 20:46:48 +00:00
parent 06509db630
commit d80d8690af
6 changed files with 159 additions and 6 deletions
+8 -1
View File
@@ -1984,6 +1984,7 @@ void EmitRegisterPlugin(int Priority, std::ostream& O) {
/// additional declarations.
void EmitIncludes(std::ostream& O) {
O << "#include \"llvm/CompilerDriver/CompilationGraph.h\"\n"
<< "#include \"llvm/CompilerDriver/ForceLinkageMacros.h\"\n"
<< "#include \"llvm/CompilerDriver/Plugin.h\"\n"
<< "#include \"llvm/CompilerDriver/Tool.h\"\n\n"
@@ -2106,7 +2107,13 @@ void EmitPluginCode(const PluginData& Data, std::ostream& O) {
// Emit code for plugin registration.
EmitRegisterPlugin(Data.Priority, O);
O << "} // End anonymous namespace.\n";
O << "} // End anonymous namespace.\n\n";
// Force linkage magic.
O << "namespace llvmc {\n";
O << "LLVMC_FORCE_LINKAGE_DECL(LLVMC_PLUGIN_NAME) {}\n";
O << "}\n";
// EOF
}