Adds extern "C" ints to the .cpp files that use RegisterTarget, as
authorOscar Fuentes <ofv@wanadoo.es>
Sat, 15 Nov 2008 21:36:30 +0000 (21:36 +0000)
committerOscar Fuentes <ofv@wanadoo.es>
Sat, 15 Nov 2008 21:36:30 +0000 (21:36 +0000)
well as 2 files that use "Registrator"s. These are to be used by the
MSVC builds, as the Win32 linker does not include libs that are
otherwise unreferenced, even if global constructors in the lib have
side-effects.

Patch by Scott Graham!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@59378 91177308-0d34-0410-b5e6-96231b3b80d8

13 files changed:
lib/Target/ARM/ARMTargetMachine.cpp
lib/Target/Alpha/AlphaTargetMachine.cpp
lib/Target/CBackend/CBackend.cpp
lib/Target/CellSPU/SPUTargetMachine.cpp
lib/Target/CppBackend/CPPBackend.cpp
lib/Target/MSIL/MSILWriter.cpp
lib/Target/Mips/MipsTargetMachine.cpp
lib/Target/PIC16/PIC16TargetMachine.cpp
lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp
lib/Target/PowerPC/PPCTargetMachine.cpp
lib/Target/Sparc/SparcTargetMachine.cpp
lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp
lib/Target/XCore/XCoreTargetMachine.cpp

index b9c9c4860056e6c16df4eee1bb4203fe637a7f5d..a5d3659d3c74f4ca666ec7eb7530ecbe6484a1bb 100644 (file)
@@ -28,6 +28,13 @@ static cl::opt<bool> DisableLdStOpti("disable-arm-loadstore-opti", cl::Hidden,
 static cl::opt<bool> DisableIfConversion("disable-arm-if-conversion",cl::Hidden,
                               cl::desc("Disable if-conversion pass"));
 
+/// ARMTargetMachineModule - Note that this is used on hosts that cannot link
+/// in a library unless there are references into the library.  In particular,
+/// it seems that it is not possible to get things to work on Win32 without
+/// this.  Though it is unused, do not remove it.
+extern "C" int ARMTargetMachineModule;
+int ARMTargetMachineModule = 0;
+
 // Register the target.
 static RegisterTarget<ARMTargetMachine>   X("arm",   "ARM");
 static RegisterTarget<ThumbTargetMachine> Y("thumb", "Thumb");
index cb4dd3ea1fa7df680b8434d6461ae256be96f33a..c65485b061ca8bdd384a714f53cfd07806e3c8ac 100644 (file)
 
 using namespace llvm;
 
+/// AlphaTargetMachineModule - Note that this is used on hosts that cannot link
+/// in a library unless there are references into the library.  In particular,
+/// it seems that it is not possible to get things to work on Win32 without
+/// this.  Though it is unused, do not remove it.
+extern "C" int AlphaTargetMachineModule;
+int AlphaTargetMachineModule = 0;
+
 // Register the targets
 static RegisterTarget<AlphaTargetMachine> X("alpha", "Alpha [experimental]");
 
index 6e69b9e24954abd18ee29af8faead3f766f95cb8..e8804dcad2768de77d3f2ffda877027cc4b47ee6 100644 (file)
 #include <sstream>
 using namespace llvm;
 
+/// CBackendTargetMachineModule - Note that this is used on hosts that
+/// cannot link in a library unless there are references into the
+/// library.  In particular, it seems that it is not possible to get
+/// things to work on Win32 without this.  Though it is unused, do not
+/// remove it.
+extern "C" int CBackendTargetMachineModule;
+int CBackendTargetMachineModule = 0;
+
 // Register the target.
 static RegisterTarget<CTargetMachine> X("c", "C backend");
 
index 5e225844dbb1a7e82c2b9d58bf3cf35ac0e7ef5a..48b85832e5824d4ff4c7bb1bf2e4ad8664681430 100644 (file)
 
 using namespace llvm;
 
+/// CellSPUTargetMachineModule - Note that this is used on hosts that
+/// cannot link in a library unless there are references into the
+/// library.  In particular, it seems that it is not possible to get
+/// things to work on Win32 without this.  Though it is unused, do not
+/// remove it.
+extern "C" int CellSPUTargetMachineModule;
+int CellSPUTargetMachineModule = 0;
+
 namespace {
   // Register the targets
   RegisterTarget<SPUTargetMachine>
index b51621d882a7496a03cee2e19d92053043e8cb4b..5b646bac3ee85efa57635bafd68f23c51b2e86de 100644 (file)
@@ -71,6 +71,14 @@ static cl::opt<std::string> NameToGenerate("cppfor", cl::Optional,
   cl::desc("Specify the name of the thing to generate"),
   cl::init("!bad!"));
 
+/// CppBackendTargetMachineModule - Note that this is used on hosts
+/// that cannot link in a library unless there are references into the
+/// library.  In particular, it seems that it is not possible to get
+/// things to work on Win32 without this.  Though it is unused, do not
+/// remove it.
+extern "C" int CppBackendTargetMachineModule;
+int CppBackendTargetMachineModule = 0;
+
 // Register the target.
 static RegisterTarget<CPPTargetMachine> X("cpp", "C++ backend");
 
index a27c0cc688a247548a3e8a42d88c811579f98784..0cbd01117e554ce4cc770fb16f166782a14d83c8 100644 (file)
@@ -44,6 +44,13 @@ namespace {
   };
 }
 
+/// MSILTargetMachineModule - Note that this is used on hosts that
+/// cannot link in a library unless there are references into the
+/// library.  In particular, it seems that it is not possible to get
+/// things to work on Win32 without this.  Though it is unused, do not
+/// remove it.
+extern "C" int MSILTargetMachineModule;
+int MSILTargetMachineModule = 0;
 
 static RegisterTarget<MSILTarget> X("msil", "MSIL backend");
 
index 25a0eaa857c57819dad7445d0b76b0d85e9e71bc..ff2e5b81589c9950090723f25fcdb24956418764 100644 (file)
 #include "llvm/Target/TargetMachineRegistry.h"
 using namespace llvm;
 
+/// MipsTargetMachineModule - Note that this is used on hosts that
+/// cannot link in a library unless there are references into the
+/// library.  In particular, it seems that it is not possible to get
+/// things to work on Win32 without this.  Though it is unused, do not
+/// remove it.
+extern "C" int MipsTargetMachineModule;
+int MipsTargetMachineModule = 0;
+
 // Register the target.
 static RegisterTarget<MipsTargetMachine>    X("mips", "Mips");
 static RegisterTarget<MipselTargetMachine>  Y("mipsel", "Mipsel");
index 4a0a3b01c8153e157d51978e752a0972d9a1a17d..f2ddad14bf254fff99d9886531af4132c7f4a90f 100644 (file)
 
 using namespace llvm;
 
+/// PIC16TargetMachineModule - Note that this is used on hosts that
+/// cannot link in a library unless there are references into the
+/// library.  In particular, it seems that it is not possible to get
+/// things to work on Win32 without this.  Though it is unused, do not
+/// remove it.
+extern "C" int PIC16TargetMachineModule;
+int PIC16TargetMachineModule = 0;
+
 namespace {
   // Register the targets
   RegisterTarget<PIC16TargetMachine> X("pic16", "PIC16 14-bit [experimental]");
index 6c17dbece07e673ea419c8e0209c3c01486dbcb9..3043b0098b4112c83fec081c092ca74daafb59a9 100644 (file)
@@ -1112,3 +1112,6 @@ namespace {
     }
   } Registrator;
 }
+
+extern "C" int PowerPCAsmPrinterForceLink;
+int PowerPCAsmPrinterForceLink = 0;
index 22b459cb748f6e867e5582c739bcff94caa44541..0ff65d2a0d325892efabd065a2a4707a0b5c5382 100644 (file)
 #include "llvm/Support/raw_ostream.h"
 using namespace llvm;
 
+/// PowerPCTargetMachineModule - Note that this is used on hosts that
+/// cannot link in a library unless there are references into the
+/// library.  In particular, it seems that it is not possible to get
+/// things to work on Win32 without this.  Though it is unused, do not
+/// remove it.
+extern "C" int PowerPCTargetMachineModule;
+int PowerPCTargetMachineModule = 0;
+
 // Register the targets
 static RegisterTarget<PPC32TargetMachine>
 X("ppc32", "PowerPC 32");
index 80af77e6808fd0a9e286f56157c215cbcdda23e6..21c4205b37d96a054f7511e2a362a5999959c1b5 100644 (file)
 #include "llvm/Target/TargetMachineRegistry.h"
 using namespace llvm;
 
+/// SparcTargetMachineModule - Note that this is used on hosts that
+/// cannot link in a library unless there are references into the
+/// library.  In particular, it seems that it is not possible to get
+/// things to work on Win32 without this.  Though it is unused, do not
+/// remove it.
+extern "C" int SparcTargetMachineModule;
+int SparcTargetMachineModule = 0;
+
 // Register the target.
 static RegisterTarget<SparcTargetMachine> X("sparc", "SPARC");
 
index d616accbc3f04a2439442debf39f9cfbed81db8e..48ee11f5a9d4afba60695cfa832d8a02a74c9099 100644 (file)
@@ -41,3 +41,6 @@ namespace {
     }
   } Registrator;
 }
+
+extern "C" int X86AsmPrinterForceLink;
+int X86AsmPrinterForceLink = 0;
index bc93880217c791ba6f1b283e36e7e58cdc0165bf..b3853044bb9c72aad6dec95bf1e3884d68396511 100644 (file)
 #include "llvm/Target/TargetMachineRegistry.h"
 using namespace llvm;
 
+/// XCoreTargetMachineModule - Note that this is used on hosts that
+/// cannot link in a library unless there are references into the
+/// library.  In particular, it seems that it is not possible to get
+/// things to work on Win32 without this.  Though it is unused, do not
+/// remove it.
+extern "C" int XCoreTargetMachineModule;
+int XCoreTargetMachineModule = 0;
+
 namespace {
   // Register the target.
   RegisterTarget<XCoreTargetMachine> X("xcore", "XCore");