OSDN Git Service

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 b9c9c48..a5d3659 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 cb4dd3e..c65485b 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 6e69b9e..e8804dc 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 5e22584..48b8583 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 b51621d..5b646ba 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 a27c0cc..0cbd011 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 25a0eaa..ff2e5b8 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 4a0a3b0..f2ddad1 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 6c17dbe..3043b00 100644 (file)
@@ -1112,3 +1112,6 @@ namespace {
     }
   } Registrator;
 }
+
+extern "C" int PowerPCAsmPrinterForceLink;
+int PowerPCAsmPrinterForceLink = 0;
index 22b459c..0ff65d2 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 80af77e..21c4205 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 d616acc..48ee11f 100644 (file)
@@ -41,3 +41,6 @@ namespace {
     }
   } Registrator;
 }
+
+extern "C" int X86AsmPrinterForceLink;
+int X86AsmPrinterForceLink = 0;
index bc93880..b385304 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");