From 92adc19be95347225f713db8cc1b5e22ac08bb5e Mon Sep 17 00:00:00 2001 From: Oscar Fuentes Date: Sat, 15 Nov 2008 21:36:30 +0000 Subject: [PATCH] Adds extern "C" ints to the .cpp files that use RegisterTarget, as 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 --- lib/Target/ARM/ARMTargetMachine.cpp | 7 +++++++ lib/Target/Alpha/AlphaTargetMachine.cpp | 7 +++++++ lib/Target/CBackend/CBackend.cpp | 8 ++++++++ lib/Target/CellSPU/SPUTargetMachine.cpp | 8 ++++++++ lib/Target/CppBackend/CPPBackend.cpp | 8 ++++++++ lib/Target/MSIL/MSILWriter.cpp | 7 +++++++ lib/Target/Mips/MipsTargetMachine.cpp | 8 ++++++++ lib/Target/PIC16/PIC16TargetMachine.cpp | 8 ++++++++ lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp | 3 +++ lib/Target/PowerPC/PPCTargetMachine.cpp | 8 ++++++++ lib/Target/Sparc/SparcTargetMachine.cpp | 8 ++++++++ lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp | 3 +++ lib/Target/XCore/XCoreTargetMachine.cpp | 8 ++++++++ 13 files changed, 91 insertions(+) diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp index b9c9c486005..a5d3659d3c7 100644 --- a/lib/Target/ARM/ARMTargetMachine.cpp +++ b/lib/Target/ARM/ARMTargetMachine.cpp @@ -28,6 +28,13 @@ static cl::opt DisableLdStOpti("disable-arm-loadstore-opti", cl::Hidden, static cl::opt 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 X("arm", "ARM"); static RegisterTarget Y("thumb", "Thumb"); diff --git a/lib/Target/Alpha/AlphaTargetMachine.cpp b/lib/Target/Alpha/AlphaTargetMachine.cpp index cb4dd3ea1fa..c65485b061c 100644 --- a/lib/Target/Alpha/AlphaTargetMachine.cpp +++ b/lib/Target/Alpha/AlphaTargetMachine.cpp @@ -21,6 +21,13 @@ 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 X("alpha", "Alpha [experimental]"); diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 6e69b9e2495..e8804dcad27 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -48,6 +48,14 @@ #include 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 X("c", "C backend"); diff --git a/lib/Target/CellSPU/SPUTargetMachine.cpp b/lib/Target/CellSPU/SPUTargetMachine.cpp index 5e225844dbb..48b85832e58 100644 --- a/lib/Target/CellSPU/SPUTargetMachine.cpp +++ b/lib/Target/CellSPU/SPUTargetMachine.cpp @@ -21,6 +21,14 @@ 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 diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index b51621d882a..5b646bac3ee 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -71,6 +71,14 @@ static cl::opt 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 X("cpp", "C++ backend"); diff --git a/lib/Target/MSIL/MSILWriter.cpp b/lib/Target/MSIL/MSILWriter.cpp index a27c0cc688a..0cbd01117e5 100644 --- a/lib/Target/MSIL/MSILWriter.cpp +++ b/lib/Target/MSIL/MSILWriter.cpp @@ -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 X("msil", "MSIL backend"); diff --git a/lib/Target/Mips/MipsTargetMachine.cpp b/lib/Target/Mips/MipsTargetMachine.cpp index 25a0eaa857c..ff2e5b81589 100644 --- a/lib/Target/Mips/MipsTargetMachine.cpp +++ b/lib/Target/Mips/MipsTargetMachine.cpp @@ -19,6 +19,14 @@ #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 X("mips", "Mips"); static RegisterTarget Y("mipsel", "Mipsel"); diff --git a/lib/Target/PIC16/PIC16TargetMachine.cpp b/lib/Target/PIC16/PIC16TargetMachine.cpp index 4a0a3b01c81..f2ddad14bf2 100644 --- a/lib/Target/PIC16/PIC16TargetMachine.cpp +++ b/lib/Target/PIC16/PIC16TargetMachine.cpp @@ -21,6 +21,14 @@ 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 X("pic16", "PIC16 14-bit [experimental]"); diff --git a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp index 6c17dbece07..3043b0098b4 100644 --- a/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/AsmPrinter/PPCAsmPrinter.cpp @@ -1112,3 +1112,6 @@ namespace { } } Registrator; } + +extern "C" int PowerPCAsmPrinterForceLink; +int PowerPCAsmPrinterForceLink = 0; diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp index 22b459cb748..0ff65d2a0d3 100644 --- a/lib/Target/PowerPC/PPCTargetMachine.cpp +++ b/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -21,6 +21,14 @@ #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 X("ppc32", "PowerPC 32"); diff --git a/lib/Target/Sparc/SparcTargetMachine.cpp b/lib/Target/Sparc/SparcTargetMachine.cpp index 80af77e6808..21c4205b37d 100644 --- a/lib/Target/Sparc/SparcTargetMachine.cpp +++ b/lib/Target/Sparc/SparcTargetMachine.cpp @@ -18,6 +18,14 @@ #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 X("sparc", "SPARC"); diff --git a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp index d616accbc3f..48ee11f5a9d 100644 --- a/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86AsmPrinter.cpp @@ -41,3 +41,6 @@ namespace { } } Registrator; } + +extern "C" int X86AsmPrinterForceLink; +int X86AsmPrinterForceLink = 0; diff --git a/lib/Target/XCore/XCoreTargetMachine.cpp b/lib/Target/XCore/XCoreTargetMachine.cpp index bc93880217c..b3853044bb9 100644 --- a/lib/Target/XCore/XCoreTargetMachine.cpp +++ b/lib/Target/XCore/XCoreTargetMachine.cpp @@ -18,6 +18,14 @@ #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 X("xcore", "XCore"); -- 2.34.1