From 5311f9a49ed73d81f2de0ba467925070f740958b Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 10 Jun 2019 22:12:56 +0000 Subject: [PATCH] CMake: Make most target symbols hidden by default Summary: For builds with LLVM_BUILD_LLVM_DYLIB=ON and BUILD_SHARED_LIBS=OFF this change makes all symbols in the target specific libraries hidden by default. A new macro called LLVM_EXTERNAL_VISIBILITY has been added to mark symbols in these libraries public, which is mainly needed for the definitions of the LLVMInitialize* functions. This patch reduces the number of public symbols in libLLVM.so by about 25%. This should improve load times for the dynamic library and also make abi checker tools, like abidiff require less memory when analyzing libLLVM.so One side-effect of this change is that for builds with LLVM_BUILD_LLVM_DYLIB=ON and LLVM_LINK_LLVM_DYLIB=ON some unittests that access symbols that are no longer public will need to be statically linked. Before and after public symbol counts (using gcc 8.2.1, ld.bfd 2.31.1): nm before/libLLVM-9svn.so | grep ' [A-Zuvw] ' | wc -l 36221 nm after/libLLVM-9svn.so | grep ' [A-Zuvw] ' | wc -l 26278 Reviewers: chandlerc, beanz, mgorny, rnk, hans Reviewed By: rnk, hans Subscribers: Jim, hiraditya, michaelplatings, chapuni, jholewinski, arsenm, dschuff, jyknight, dylanmckay, sdardis, nemanjai, jvesely, nhaehnle, javed.absar, sbc100, jgravelle-google, aheejin, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, zzheng, edward-jones, mgrang, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, kristina, jsji, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D54439 llvm-svn: 362990 --- include/llvm/Support/Compiler.h | 6 ++++++ lib/Target/AArch64/AArch64AsmPrinter.cpp | 2 +- lib/Target/AArch64/AArch64TargetMachine.cpp | 2 +- .../AArch64/AsmParser/AArch64AsmParser.cpp | 2 +- .../Disassembler/AArch64Disassembler.cpp | 2 +- .../MCTargetDesc/AArch64MCTargetDesc.cpp | 2 +- .../AArch64/TargetInfo/AArch64TargetInfo.cpp | 2 +- lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp | 2 +- lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 2 +- .../AMDGPU/AsmParser/AMDGPUAsmParser.cpp | 2 +- .../Disassembler/AMDGPUDisassembler.cpp | 2 +- .../MCTargetDesc/AMDGPUMCTargetDesc.cpp | 2 +- .../AMDGPU/TargetInfo/AMDGPUTargetInfo.cpp | 2 +- lib/Target/ARC/ARCAsmPrinter.cpp | 2 +- lib/Target/ARC/ARCTargetMachine.cpp | 2 +- .../ARC/Disassembler/ARCDisassembler.cpp | 2 +- .../ARC/MCTargetDesc/ARCMCTargetDesc.cpp | 2 +- lib/Target/ARC/TargetInfo/ARCTargetInfo.cpp | 2 +- lib/Target/ARM/ARMAsmPrinter.cpp | 2 +- lib/Target/ARM/ARMTargetMachine.cpp | 2 +- lib/Target/ARM/AsmParser/ARMAsmParser.cpp | 2 +- .../ARM/Disassembler/ARMDisassembler.cpp | 2 +- .../ARM/MCTargetDesc/ARMMCTargetDesc.cpp | 2 +- lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp | 2 +- lib/Target/AVR/AVRAsmPrinter.cpp | 2 +- lib/Target/AVR/AVRTargetMachine.cpp | 2 +- lib/Target/AVR/AsmParser/AVRAsmParser.cpp | 2 +- .../AVR/Disassembler/AVRDisassembler.cpp | 2 +- .../AVR/MCTargetDesc/AVRMCTargetDesc.cpp | 2 +- lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp | 2 +- lib/Target/BPF/AsmParser/BPFAsmParser.cpp | 2 +- lib/Target/BPF/BPFAsmPrinter.cpp | 2 +- lib/Target/BPF/BPFTargetMachine.cpp | 2 +- .../BPF/Disassembler/BPFDisassembler.cpp | 2 +- .../BPF/MCTargetDesc/BPFMCTargetDesc.cpp | 2 +- lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp | 2 +- lib/Target/CMakeLists.txt | 8 ++++++++ .../Hexagon/AsmParser/HexagonAsmParser.cpp | 4 ++-- .../Disassembler/HexagonDisassembler.cpp | 2 +- lib/Target/Hexagon/HexagonAsmPrinter.cpp | 2 +- lib/Target/Hexagon/HexagonTargetMachine.cpp | 2 +- .../MCTargetDesc/HexagonMCTargetDesc.cpp | 2 +- .../Hexagon/TargetInfo/HexagonTargetInfo.cpp | 2 +- lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp | 2 +- .../Lanai/Disassembler/LanaiDisassembler.cpp | 2 +- lib/Target/Lanai/LanaiAsmPrinter.cpp | 2 +- lib/Target/Lanai/LanaiTargetMachine.cpp | 2 +- .../Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp | 2 +- .../Lanai/TargetInfo/LanaiTargetInfo.cpp | 2 +- .../MSP430/AsmParser/MSP430AsmParser.cpp | 2 +- .../Disassembler/MSP430Disassembler.cpp | 2 +- .../MCTargetDesc/MSP430MCTargetDesc.cpp | 2 +- lib/Target/MSP430/MSP430AsmPrinter.cpp | 2 +- lib/Target/MSP430/MSP430TargetMachine.cpp | 2 +- .../MSP430/TargetInfo/MSP430TargetInfo.cpp | 2 +- lib/Target/Mips/AsmParser/MipsAsmParser.cpp | 2 +- .../Mips/Disassembler/MipsDisassembler.cpp | 2 +- .../Mips/MCTargetDesc/MipsMCTargetDesc.cpp | 2 +- lib/Target/Mips/MipsAsmPrinter.cpp | 2 +- lib/Target/Mips/MipsTargetMachine.cpp | 2 +- lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp | 2 +- .../NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp | 2 +- lib/Target/NVPTX/NVPTXAsmPrinter.cpp | 2 +- lib/Target/NVPTX/NVPTXTargetMachine.cpp | 2 +- .../NVPTX/TargetInfo/NVPTXTargetInfo.cpp | 2 +- lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp | 2 +- .../PowerPC/Disassembler/PPCDisassembler.cpp | 2 +- .../PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp | 2 +- lib/Target/PowerPC/PPCAsmPrinter.cpp | 2 +- lib/Target/PowerPC/PPCTargetMachine.cpp | 2 +- .../PowerPC/TargetInfo/PowerPCTargetInfo.cpp | 2 +- lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp | 2 +- .../RISCV/Disassembler/RISCVDisassembler.cpp | 2 +- .../RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp | 2 +- lib/Target/RISCV/RISCVAsmPrinter.cpp | 2 +- lib/Target/RISCV/RISCVTargetMachine.cpp | 2 +- .../RISCV/TargetInfo/RISCVTargetInfo.cpp | 2 +- lib/Target/Sparc/AsmParser/SparcAsmParser.cpp | 2 +- .../Sparc/Disassembler/SparcDisassembler.cpp | 2 +- .../Sparc/MCTargetDesc/SparcMCTargetDesc.cpp | 2 +- lib/Target/Sparc/SparcAsmPrinter.cpp | 2 +- lib/Target/Sparc/SparcTargetMachine.cpp | 2 +- .../Sparc/TargetInfo/SparcTargetInfo.cpp | 2 +- .../SystemZ/AsmParser/SystemZAsmParser.cpp | 2 +- .../Disassembler/SystemZDisassembler.cpp | 2 +- .../MCTargetDesc/SystemZMCTargetDesc.cpp | 2 +- lib/Target/SystemZ/SystemZAsmPrinter.cpp | 2 +- lib/Target/SystemZ/SystemZTargetMachine.cpp | 2 +- .../SystemZ/TargetInfo/SystemZTargetInfo.cpp | 2 +- .../AsmParser/WebAssemblyAsmParser.cpp | 2 +- .../Disassembler/WebAssemblyDisassembler.cpp | 2 +- .../MCTargetDesc/WebAssemblyMCTargetDesc.cpp | 2 +- .../TargetInfo/WebAssemblyTargetInfo.cpp | 2 +- .../WebAssembly/WebAssemblyAsmPrinter.cpp | 2 +- .../WebAssembly/WebAssemblyTargetMachine.cpp | 2 +- lib/Target/X86/AsmParser/X86AsmParser.cpp | 2 +- .../X86/Disassembler/X86Disassembler.cpp | 2 +- .../X86/MCTargetDesc/X86MCTargetDesc.cpp | 2 +- lib/Target/X86/TargetInfo/X86TargetInfo.cpp | 2 +- lib/Target/X86/X86AsmPrinter.cpp | 2 +- lib/Target/X86/X86TargetMachine.cpp | 2 +- .../XCore/Disassembler/XCoreDisassembler.cpp | 2 +- .../XCore/MCTargetDesc/XCoreMCTargetDesc.cpp | 2 +- .../XCore/TargetInfo/XCoreTargetInfo.cpp | 2 +- lib/Target/XCore/XCoreAsmPrinter.cpp | 2 +- lib/Target/XCore/XCoreTargetMachine.cpp | 2 +- unittests/CMakeLists.txt | 6 ++++++ unittests/Target/AArch64/CMakeLists.txt | 2 +- unittests/Target/WebAssembly/CMakeLists.txt | 2 +- .../llvm-exegesis/AArch64/CMakeLists.txt | 2 +- .../tools/llvm-exegesis/ARM/CMakeLists.txt | 2 +- .../llvm-exegesis/PowerPC/CMakeLists.txt | 2 +- .../tools/llvm-exegesis/X86/CMakeLists.txt | 2 +- utils/unittest/CMakeLists.txt | 20 +++++++++++++++++++ 114 files changed, 151 insertions(+), 111 deletions(-) diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index 3f4f465f396..ddcb3d2b860 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -100,11 +100,17 @@ /// not accessible from outside it. Can also be used to mark variables and /// functions, making them private to any shared library they are linked into. /// On PE/COFF targets, library visibility is the default, so this isn't needed. +/// +/// LLVM_EXTERNAL_VISIBILITY - classes, functions, and variables marked with this +/// attribute will be made public and visible outside of any shared library they +/// are linked in to. #if (__has_attribute(visibility) || LLVM_GNUC_PREREQ(4, 0, 0)) && \ !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_WIN32) #define LLVM_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden"))) +#define LLVM_EXTERNAL_VISIBILITY __attribute__ ((visibility("default"))) #else #define LLVM_LIBRARY_VISIBILITY +#define LLVM_EXTERNAL_VISIBLITY #endif #if defined(__GNUC__) diff --git a/lib/Target/AArch64/AArch64AsmPrinter.cpp b/lib/Target/AArch64/AArch64AsmPrinter.cpp index 0b527265dd3..15fb7c2f650 100644 --- a/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ b/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -1129,7 +1129,7 @@ void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) { } // Force static initialization. -extern "C" void LLVMInitializeAArch64AsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAArch64AsmPrinter() { RegisterAsmPrinter X(getTheAArch64leTarget()); RegisterAsmPrinter Y(getTheAArch64beTarget()); RegisterAsmPrinter Z(getTheARM64Target()); diff --git a/lib/Target/AArch64/AArch64TargetMachine.cpp b/lib/Target/AArch64/AArch64TargetMachine.cpp index a9f7233413d..16501576ea6 100644 --- a/lib/Target/AArch64/AArch64TargetMachine.cpp +++ b/lib/Target/AArch64/AArch64TargetMachine.cpp @@ -152,7 +152,7 @@ static cl::opt cl::desc("Enable the AAcrh64 branch target pass"), cl::init(true)); -extern "C" void LLVMInitializeAArch64Target() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAArch64Target() { // Register the target. RegisterTargetMachine X(getTheAArch64leTarget()); RegisterTargetMachine Y(getTheAArch64beTarget()); diff --git a/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp index 0973d2bd960..fc9047bb3c2 100644 --- a/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -5514,7 +5514,7 @@ AArch64AsmParser::classifySymbolRef(const MCExpr *Expr, } /// Force static initialization. -extern "C" void LLVMInitializeAArch64AsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAArch64AsmParser() { RegisterMCAsmParser X(getTheAArch64leTarget()); RegisterMCAsmParser Y(getTheAArch64beTarget()); RegisterMCAsmParser Z(getTheARM64Target()); diff --git a/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp b/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp index 145ffef6f6f..ef4fd29871e 100644 --- a/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp +++ b/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp @@ -278,7 +278,7 @@ createAArch64ExternalSymbolizer(const Triple &TT, LLVMOpInfoCallback GetOpInfo, SymbolLookUp, DisInfo); } -extern "C" void LLVMInitializeAArch64Disassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAArch64Disassembler() { TargetRegistry::RegisterMCDisassembler(getTheAArch64leTarget(), createAArch64Disassembler); TargetRegistry::RegisterMCDisassembler(getTheAArch64beTarget(), diff --git a/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp b/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp index df12274d947..cdd76ee5405 100644 --- a/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp +++ b/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp @@ -365,7 +365,7 @@ static MCInstrAnalysis *createAArch64InstrAnalysis(const MCInstrInfo *Info) { } // Force static initialization. -extern "C" void LLVMInitializeAArch64TargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAArch64TargetMC() { for (Target *T : {&getTheAArch64leTarget(), &getTheAArch64beTarget(), &getTheAArch64_32Target(), &getTheARM64Target(), &getTheARM64_32Target()}) { diff --git a/lib/Target/AArch64/TargetInfo/AArch64TargetInfo.cpp b/lib/Target/AArch64/TargetInfo/AArch64TargetInfo.cpp index 7f02da6a951..a6796742117 100644 --- a/lib/Target/AArch64/TargetInfo/AArch64TargetInfo.cpp +++ b/lib/Target/AArch64/TargetInfo/AArch64TargetInfo.cpp @@ -31,7 +31,7 @@ Target &llvm::getTheARM64_32Target() { return TheARM64_32Target; } -extern "C" void LLVMInitializeAArch64TargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAArch64TargetInfo() { // Now register the "arm64" name for use with "-march". We don't want it to // take possession of the Triple::aarch64 tags though. TargetRegistry::RegisterTarget(getTheARM64Target(), "arm64", diff --git a/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp b/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp index 3b1faacab36..28780158fbe 100644 --- a/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp +++ b/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp @@ -91,7 +91,7 @@ createAMDGPUAsmPrinterPass(TargetMachine &tm, return new AMDGPUAsmPrinter(tm, std::move(Streamer)); } -extern "C" void LLVMInitializeAMDGPUAsmPrinter() { +extern "C" void LLVM_EXTERNAL_VISIBILITY LLVMInitializeAMDGPUAsmPrinter() { TargetRegistry::RegisterAsmPrinter(getTheAMDGPUTarget(), llvm::createR600AsmPrinterPass); TargetRegistry::RegisterAsmPrinter(getTheGCNTarget(), diff --git a/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp index 41876eb7125..8c7f85c6ea4 100644 --- a/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -182,7 +182,7 @@ static cl::opt EnableScalarIRPasses( cl::init(true), cl::Hidden); -extern "C" void LLVMInitializeAMDGPUTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUTarget() { // Register the target RegisterTargetMachine X(getTheAMDGPUTarget()); RegisterTargetMachine Y(getTheGCNTarget()); diff --git a/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp index 37879520ec0..cbdf1f4ffaa 100644 --- a/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ b/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -6404,7 +6404,7 @@ void AMDGPUAsmParser::cvtSDWA(MCInst &Inst, const OperandVector &Operands, } /// Force static initialization. -extern "C" void LLVMInitializeAMDGPUAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUAsmParser() { RegisterMCAsmParser A(getTheAMDGPUTarget()); RegisterMCAsmParser B(getTheGCNTarget()); } diff --git a/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp b/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp index 307f0cb7cde..ae5c9abe790 100644 --- a/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp +++ b/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp @@ -1091,7 +1091,7 @@ static MCDisassembler *createAMDGPUDisassembler(const Target &T, return new AMDGPUDisassembler(STI, Ctx, T.createMCInstrInfo()); } -extern "C" void LLVMInitializeAMDGPUDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUDisassembler() { TargetRegistry::RegisterMCDisassembler(getTheGCNTarget(), createAMDGPUDisassembler); TargetRegistry::RegisterMCSymbolizer(getTheGCNTarget(), diff --git a/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp b/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp index 88df64d18cc..9507836c64c 100644 --- a/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp +++ b/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp @@ -134,7 +134,7 @@ static MCInstrAnalysis *createAMDGPUMCInstrAnalysis(const MCInstrInfo *Info) { return new AMDGPUMCInstrAnalysis(Info); } -extern "C" void LLVMInitializeAMDGPUTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUTargetMC() { TargetRegistry::RegisterMCInstrInfo(getTheGCNTarget(), createAMDGPUMCInstrInfo); TargetRegistry::RegisterMCInstrInfo(getTheAMDGPUTarget(), createR600MCInstrInfo); diff --git a/lib/Target/AMDGPU/TargetInfo/AMDGPUTargetInfo.cpp b/lib/Target/AMDGPU/TargetInfo/AMDGPUTargetInfo.cpp index 30cf12337c6..9ec437760c0 100644 --- a/lib/Target/AMDGPU/TargetInfo/AMDGPUTargetInfo.cpp +++ b/lib/Target/AMDGPU/TargetInfo/AMDGPUTargetInfo.cpp @@ -28,7 +28,7 @@ Target &llvm::getTheGCNTarget() { } /// Extern function to initialize the targets for the AMDGPU backend -extern "C" void LLVMInitializeAMDGPUTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUTargetInfo() { RegisterTarget R600(getTheAMDGPUTarget(), "r600", "AMD GPUs HD2XXX-HD6XXX", "AMDGPU"); RegisterTarget GCN(getTheGCNTarget(), "amdgcn", diff --git a/lib/Target/ARC/ARCAsmPrinter.cpp b/lib/Target/ARC/ARCAsmPrinter.cpp index 5c3e2c9e773..7915ca00331 100644 --- a/lib/Target/ARC/ARCAsmPrinter.cpp +++ b/lib/Target/ARC/ARCAsmPrinter.cpp @@ -62,6 +62,6 @@ void ARCAsmPrinter::EmitInstruction(const MachineInstr *MI) { } // Force static initialization. -extern "C" void LLVMInitializeARCAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARCAsmPrinter() { RegisterAsmPrinter X(getTheARCTarget()); } diff --git a/lib/Target/ARC/ARCTargetMachine.cpp b/lib/Target/ARC/ARCTargetMachine.cpp index 9fb45d686c2..2e53994ce5b 100644 --- a/lib/Target/ARC/ARCTargetMachine.cpp +++ b/lib/Target/ARC/ARCTargetMachine.cpp @@ -81,7 +81,7 @@ void ARCPassConfig::addPreRegAlloc() { } // Force static initialization. -extern "C" void LLVMInitializeARCTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARCTarget() { RegisterTargetMachine X(getTheARCTarget()); } diff --git a/lib/Target/ARC/Disassembler/ARCDisassembler.cpp b/lib/Target/ARC/Disassembler/ARCDisassembler.cpp index 82da18617b9..5f861d57ed0 100644 --- a/lib/Target/ARC/Disassembler/ARCDisassembler.cpp +++ b/lib/Target/ARC/Disassembler/ARCDisassembler.cpp @@ -365,7 +365,7 @@ static MCDisassembler *createARCDisassembler(const Target &T, return new ARCDisassembler(STI, Ctx, T.createMCInstrInfo()); } -extern "C" void LLVMInitializeARCDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARCDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheARCTarget(), createARCDisassembler); diff --git a/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp b/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp index aa4818cd57a..c5d95f1b58a 100644 --- a/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp +++ b/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp @@ -81,7 +81,7 @@ static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S, } // Force static initialization. -extern "C" void LLVMInitializeARCTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARCTargetMC() { // Register the MC asm info. Target &TheARCTarget = getTheARCTarget(); RegisterMCAsmInfoFn X(TheARCTarget, createARCMCAsmInfo); diff --git a/lib/Target/ARC/TargetInfo/ARCTargetInfo.cpp b/lib/Target/ARC/TargetInfo/ARCTargetInfo.cpp index 59b9f806d59..d4a74e1c417 100644 --- a/lib/Target/ARC/TargetInfo/ARCTargetInfo.cpp +++ b/lib/Target/ARC/TargetInfo/ARCTargetInfo.cpp @@ -16,6 +16,6 @@ Target &llvm::getTheARCTarget() { return TheARCTarget; } -extern "C" void LLVMInitializeARCTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARCTargetInfo() { RegisterTarget X(getTheARCTarget(), "arc", "ARC", "ARC"); } diff --git a/lib/Target/ARM/ARMAsmPrinter.cpp b/lib/Target/ARM/ARMAsmPrinter.cpp index 6bede80adaa..8d1d3af624e 100644 --- a/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/ARMAsmPrinter.cpp @@ -2066,7 +2066,7 @@ void ARMAsmPrinter::EmitInstruction(const MachineInstr *MI) { //===----------------------------------------------------------------------===// // Force static initialization. -extern "C" void LLVMInitializeARMAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARMAsmPrinter() { RegisterAsmPrinter X(getTheARMLETarget()); RegisterAsmPrinter Y(getTheARMBETarget()); RegisterAsmPrinter A(getTheThumbLETarget()); diff --git a/lib/Target/ARM/ARMTargetMachine.cpp b/lib/Target/ARM/ARMTargetMachine.cpp index ae541208aef..0c6f1a6659e 100644 --- a/lib/Target/ARM/ARMTargetMachine.cpp +++ b/lib/Target/ARM/ARMTargetMachine.cpp @@ -78,7 +78,7 @@ namespace llvm { void initializeARMExecutionDomainFixPass(PassRegistry&); } -extern "C" void LLVMInitializeARMTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARMTarget() { // Register the target. RegisterTargetMachine X(getTheARMLETarget()); RegisterTargetMachine A(getTheThumbLETarget()); diff --git a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp index f8a00f713e4..0222c7cc821 100644 --- a/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -10390,7 +10390,7 @@ bool ARMAsmParser::parseDirectiveThumbSet(SMLoc L) { } /// Force static initialization. -extern "C" void LLVMInitializeARMAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARMAsmParser() { RegisterMCAsmParser X(getTheARMLETarget()); RegisterMCAsmParser Y(getTheARMBETarget()); RegisterMCAsmParser A(getTheThumbLETarget()); diff --git a/lib/Target/ARM/Disassembler/ARMDisassembler.cpp b/lib/Target/ARM/Disassembler/ARMDisassembler.cpp index 6948f7af469..d1ea76a1465 100644 --- a/lib/Target/ARM/Disassembler/ARMDisassembler.cpp +++ b/lib/Target/ARM/Disassembler/ARMDisassembler.cpp @@ -874,7 +874,7 @@ DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size, return MCDisassembler::Fail; } -extern "C" void LLVMInitializeARMDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARMDisassembler() { TargetRegistry::RegisterMCDisassembler(getTheARMLETarget(), createARMDisassembler); TargetRegistry::RegisterMCDisassembler(getTheARMBETarget(), diff --git a/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp b/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp index 24491b35fa5..f1e5d11966f 100644 --- a/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp +++ b/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp @@ -300,7 +300,7 @@ static MCInstrAnalysis *createThumbMCInstrAnalysis(const MCInstrInfo *Info) { } // Force static initialization. -extern "C" void LLVMInitializeARMTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARMTargetMC() { for (Target *T : {&getTheARMLETarget(), &getTheARMBETarget(), &getTheThumbLETarget(), &getTheThumbBETarget()}) { // Register the MC asm info. diff --git a/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp b/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp index 86cb907abfa..a7f7d75e356 100644 --- a/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp +++ b/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp @@ -27,7 +27,7 @@ Target &llvm::getTheThumbBETarget() { return TheThumbBETarget; } -extern "C" void LLVMInitializeARMTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARMTargetInfo() { RegisterTarget X(getTheARMLETarget(), "arm", "ARM", "ARM"); RegisterTarget Y(getTheARMBETarget(), "armeb", diff --git a/lib/Target/AVR/AVRAsmPrinter.cpp b/lib/Target/AVR/AVRAsmPrinter.cpp index 7586bd7b78f..80b802e8201 100644 --- a/lib/Target/AVR/AVRAsmPrinter.cpp +++ b/lib/Target/AVR/AVRAsmPrinter.cpp @@ -178,7 +178,7 @@ void AVRAsmPrinter::EmitInstruction(const MachineInstr *MI) { } // end of namespace llvm -extern "C" void LLVMInitializeAVRAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAVRAsmPrinter() { llvm::RegisterAsmPrinter X(llvm::getTheAVRTarget()); } diff --git a/lib/Target/AVR/AVRTargetMachine.cpp b/lib/Target/AVR/AVRTargetMachine.cpp index a36c8b0f964..98de6d320b0 100644 --- a/lib/Target/AVR/AVRTargetMachine.cpp +++ b/lib/Target/AVR/AVRTargetMachine.cpp @@ -76,7 +76,7 @@ TargetPassConfig *AVRTargetMachine::createPassConfig(PassManagerBase &PM) { return new AVRPassConfig(*this, PM); } -extern "C" void LLVMInitializeAVRTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAVRTarget() { // Register the target. RegisterTargetMachine X(getTheAVRTarget()); diff --git a/lib/Target/AVR/AsmParser/AVRAsmParser.cpp b/lib/Target/AVR/AsmParser/AVRAsmParser.cpp index aac5644711e..4db17459f53 100644 --- a/lib/Target/AVR/AsmParser/AVRAsmParser.cpp +++ b/lib/Target/AVR/AsmParser/AVRAsmParser.cpp @@ -682,7 +682,7 @@ bool AVRAsmParser::parseLiteralValues(unsigned SizeInBytes, SMLoc L) { return (parseMany(parseOne)); } -extern "C" void LLVMInitializeAVRAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAVRAsmParser() { RegisterMCAsmParser X(getTheAVRTarget()); } diff --git a/lib/Target/AVR/Disassembler/AVRDisassembler.cpp b/lib/Target/AVR/Disassembler/AVRDisassembler.cpp index e203a5069c8..9d88cd33600 100644 --- a/lib/Target/AVR/Disassembler/AVRDisassembler.cpp +++ b/lib/Target/AVR/Disassembler/AVRDisassembler.cpp @@ -52,7 +52,7 @@ static MCDisassembler *createAVRDisassembler(const Target &T, } -extern "C" void LLVMInitializeAVRDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAVRDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheAVRTarget(), createAVRDisassembler); diff --git a/lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp b/lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp index f6607b26a06..bfc274d9cdc 100644 --- a/lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp +++ b/lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp @@ -89,7 +89,7 @@ static MCTargetStreamer *createMCAsmTargetStreamer(MCStreamer &S, return new AVRTargetAsmStreamer(S); } -extern "C" void LLVMInitializeAVRTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAVRTargetMC() { // Register the MC asm info. RegisterMCAsmInfo X(getTheAVRTarget()); diff --git a/lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp b/lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp index c62d5cb85bc..69b509b33e8 100644 --- a/lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp +++ b/lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp @@ -15,7 +15,7 @@ Target &getTheAVRTarget() { } } -extern "C" void LLVMInitializeAVRTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAVRTargetInfo() { llvm::RegisterTarget X(llvm::getTheAVRTarget(), "avr", "Atmel AVR Microcontroller", "AVR"); } diff --git a/lib/Target/BPF/AsmParser/BPFAsmParser.cpp b/lib/Target/BPF/AsmParser/BPFAsmParser.cpp index 75885fd058a..a22746b7c7a 100644 --- a/lib/Target/BPF/AsmParser/BPFAsmParser.cpp +++ b/lib/Target/BPF/AsmParser/BPFAsmParser.cpp @@ -493,7 +493,7 @@ bool BPFAsmParser::ParseInstruction(ParseInstructionInfo &Info, StringRef Name, bool BPFAsmParser::ParseDirective(AsmToken DirectiveID) { return true; } -extern "C" void LLVMInitializeBPFAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeBPFAsmParser() { RegisterMCAsmParser X(getTheBPFTarget()); RegisterMCAsmParser Y(getTheBPFleTarget()); RegisterMCAsmParser Z(getTheBPFbeTarget()); diff --git a/lib/Target/BPF/BPFAsmPrinter.cpp b/lib/Target/BPF/BPFAsmPrinter.cpp index 129a8c0704d..65cab35a6f5 100644 --- a/lib/Target/BPF/BPFAsmPrinter.cpp +++ b/lib/Target/BPF/BPFAsmPrinter.cpp @@ -142,7 +142,7 @@ void BPFAsmPrinter::EmitInstruction(const MachineInstr *MI) { } // Force static initialization. -extern "C" void LLVMInitializeBPFAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeBPFAsmPrinter() { RegisterAsmPrinter X(getTheBPFleTarget()); RegisterAsmPrinter Y(getTheBPFbeTarget()); RegisterAsmPrinter Z(getTheBPFTarget()); diff --git a/lib/Target/BPF/BPFTargetMachine.cpp b/lib/Target/BPF/BPFTargetMachine.cpp index e5d2e72e451..9e834ddf7d6 100644 --- a/lib/Target/BPF/BPFTargetMachine.cpp +++ b/lib/Target/BPF/BPFTargetMachine.cpp @@ -27,7 +27,7 @@ static cl:: opt DisableMIPeephole("disable-bpf-peephole", cl::Hidden, cl::desc("Disable machine peepholes for BPF")); -extern "C" void LLVMInitializeBPFTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeBPFTarget() { // Register the target. RegisterTargetMachine X(getTheBPFleTarget()); RegisterTargetMachine Y(getTheBPFbeTarget()); diff --git a/lib/Target/BPF/Disassembler/BPFDisassembler.cpp b/lib/Target/BPF/Disassembler/BPFDisassembler.cpp index c845524ad65..bcbdd6f0296 100644 --- a/lib/Target/BPF/Disassembler/BPFDisassembler.cpp +++ b/lib/Target/BPF/Disassembler/BPFDisassembler.cpp @@ -84,7 +84,7 @@ static MCDisassembler *createBPFDisassembler(const Target &T, } -extern "C" void LLVMInitializeBPFDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeBPFDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheBPFTarget(), createBPFDisassembler); diff --git a/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp b/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp index fa27b335f3a..58da0830d00 100644 --- a/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp +++ b/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp @@ -97,7 +97,7 @@ static MCInstrAnalysis *createBPFInstrAnalysis(const MCInstrInfo *Info) { return new BPFMCInstrAnalysis(Info); } -extern "C" void LLVMInitializeBPFTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeBPFTargetMC() { for (Target *T : {&getTheBPFleTarget(), &getTheBPFbeTarget(), &getTheBPFTarget()}) { // Register the MC asm info. diff --git a/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp b/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp index 5dfa915034b..49eb9ad62c5 100644 --- a/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp +++ b/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp @@ -24,7 +24,7 @@ Target &llvm::getTheBPFTarget() { return TheBPFTarget; } -extern "C" void LLVMInitializeBPFTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeBPFTargetInfo() { TargetRegistry::RegisterTarget(getTheBPFTarget(), "bpf", "BPF (host endian)", "BPF", [](Triple::ArchType) { return false; }, true); diff --git a/lib/Target/CMakeLists.txt b/lib/Target/CMakeLists.txt index 1e6abfacb79..5256b913144 100644 --- a/lib/Target/CMakeLists.txt +++ b/lib/Target/CMakeLists.txt @@ -13,6 +13,14 @@ add_llvm_library(LLVMTarget ${LLVM_MAIN_INCLUDE_DIR}/llvm/Target ) +# When building shared objects for each target there are some internal APIs +# that are used across shared objects which we can't hide. +if (NOT BUILD_SHARED_LIBS) + # Set default visibility to hidden, so we don't export all the Target classes + # in libLLVM.so. + set(CMAKE_CXX_VISIBILITY_PRESET hidden) +endif() + foreach(t ${LLVM_TARGETS_TO_BUILD}) message(STATUS "Targeting ${t}") add_subdirectory(${t}) diff --git a/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp b/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp index 0881bf841f9..8711d67c56f 100644 --- a/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp +++ b/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp @@ -813,10 +813,10 @@ bool HexagonAsmParser::RegisterMatchesArch(unsigned MatchNum) const { return true; } -// extern "C" void LLVMInitializeHexagonAsmLexer(); +// extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonAsmLexer(); /// Force static initialization. -extern "C" void LLVMInitializeHexagonAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonAsmParser() { RegisterMCAsmParser X(getTheHexagonTarget()); } diff --git a/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp b/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp index 99e3ee87157..2519857fdcc 100644 --- a/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp +++ b/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp @@ -158,7 +158,7 @@ static MCDisassembler *createHexagonDisassembler(const Target &T, return new HexagonDisassembler(STI, Ctx, T.createMCInstrInfo()); } -extern "C" void LLVMInitializeHexagonDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonDisassembler() { TargetRegistry::RegisterMCDisassembler(getTheHexagonTarget(), createHexagonDisassembler); } diff --git a/lib/Target/Hexagon/HexagonAsmPrinter.cpp b/lib/Target/Hexagon/HexagonAsmPrinter.cpp index b07d15609ed..3f8d5eaf08b 100644 --- a/lib/Target/Hexagon/HexagonAsmPrinter.cpp +++ b/lib/Target/Hexagon/HexagonAsmPrinter.cpp @@ -771,6 +771,6 @@ void HexagonAsmPrinter::EmitInstruction(const MachineInstr *MI) { OutStreamer->EmitInstruction(MCB, getSubtargetInfo()); } -extern "C" void LLVMInitializeHexagonAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonAsmPrinter() { RegisterAsmPrinter X(getTheHexagonTarget()); } diff --git a/lib/Target/Hexagon/HexagonTargetMachine.cpp b/lib/Target/Hexagon/HexagonTargetMachine.cpp index 80b8480448f..8656f97ac90 100644 --- a/lib/Target/Hexagon/HexagonTargetMachine.cpp +++ b/lib/Target/Hexagon/HexagonTargetMachine.cpp @@ -180,7 +180,7 @@ static Reloc::Model getEffectiveRelocModel(Optional RM) { return *RM; } -extern "C" void LLVMInitializeHexagonTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonTarget() { // Register the target. RegisterTargetMachine X(getTheHexagonTarget()); diff --git a/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp b/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp index 9c50b25156c..59a6299fa1e 100644 --- a/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp +++ b/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp @@ -456,7 +456,7 @@ static MCInstrAnalysis *createHexagonMCInstrAnalysis(const MCInstrInfo *Info) { } // Force static initialization. -extern "C" void LLVMInitializeHexagonTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonTargetMC() { // Register the MC asm info. RegisterMCAsmInfoFn X(getTheHexagonTarget(), createHexagonMCAsmInfo); diff --git a/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp b/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp index d77b235d007..48770be3e30 100644 --- a/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp +++ b/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp @@ -15,7 +15,7 @@ Target &llvm::getTheHexagonTarget() { return TheHexagonTarget; } -extern "C" void LLVMInitializeHexagonTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonTargetInfo() { RegisterTarget X( getTheHexagonTarget(), "hexagon", "Hexagon", "Hexagon"); } diff --git a/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp b/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp index 9af8a0b35b2..7c26249b0d0 100644 --- a/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp +++ b/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp @@ -1223,6 +1223,6 @@ bool LanaiAsmParser::ParseInstruction(ParseInstructionInfo & /*Info*/, #define GET_MATCHER_IMPLEMENTATION #include "LanaiGenAsmMatcher.inc" -extern "C" void LLVMInitializeLanaiAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeLanaiAsmParser() { RegisterMCAsmParser x(getTheLanaiTarget()); } diff --git a/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp b/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp index 25ae7c52170..cbb00bb472d 100644 --- a/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp +++ b/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp @@ -36,7 +36,7 @@ static MCDisassembler *createLanaiDisassembler(const Target & /*T*/, return new LanaiDisassembler(STI, Ctx); } -extern "C" void LLVMInitializeLanaiDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeLanaiDisassembler() { // Register the disassembler TargetRegistry::RegisterMCDisassembler(getTheLanaiTarget(), createLanaiDisassembler); diff --git a/lib/Target/Lanai/LanaiAsmPrinter.cpp b/lib/Target/Lanai/LanaiAsmPrinter.cpp index 64d963475e1..8dbd0a443c3 100644 --- a/lib/Target/Lanai/LanaiAsmPrinter.cpp +++ b/lib/Target/Lanai/LanaiAsmPrinter.cpp @@ -237,6 +237,6 @@ bool LanaiAsmPrinter::isBlockOnlyReachableByFallthrough( } // Force static initialization. -extern "C" void LLVMInitializeLanaiAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeLanaiAsmPrinter() { RegisterAsmPrinter X(getTheLanaiTarget()); } diff --git a/lib/Target/Lanai/LanaiTargetMachine.cpp b/lib/Target/Lanai/LanaiTargetMachine.cpp index 8ae0225629a..69387119f1f 100644 --- a/lib/Target/Lanai/LanaiTargetMachine.cpp +++ b/lib/Target/Lanai/LanaiTargetMachine.cpp @@ -30,7 +30,7 @@ namespace llvm { void initializeLanaiMemAluCombinerPass(PassRegistry &); } // namespace llvm -extern "C" void LLVMInitializeLanaiTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeLanaiTarget() { // Register the target. RegisterTargetMachine registered_target( getTheLanaiTarget()); diff --git a/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp b/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp index a9de0416fca..9de15bf61c8 100644 --- a/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp +++ b/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp @@ -123,7 +123,7 @@ static MCInstrAnalysis *createLanaiInstrAnalysis(const MCInstrInfo *Info) { return new LanaiMCInstrAnalysis(Info); } -extern "C" void LLVMInitializeLanaiTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeLanaiTargetMC() { // Register the MC asm info. RegisterMCAsmInfo X(getTheLanaiTarget()); diff --git a/lib/Target/Lanai/TargetInfo/LanaiTargetInfo.cpp b/lib/Target/Lanai/TargetInfo/LanaiTargetInfo.cpp index 93deb891dec..2bb9f6ed1e9 100644 --- a/lib/Target/Lanai/TargetInfo/LanaiTargetInfo.cpp +++ b/lib/Target/Lanai/TargetInfo/LanaiTargetInfo.cpp @@ -16,7 +16,7 @@ Target &llvm::getTheLanaiTarget() { return TheLanaiTarget; } -extern "C" void LLVMInitializeLanaiTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeLanaiTargetInfo() { RegisterTarget X(getTheLanaiTarget(), "lanai", "Lanai", "Lanai"); } diff --git a/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp b/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp index a0ec14ae238..788543c4b1a 100644 --- a/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp +++ b/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp @@ -529,7 +529,7 @@ bool MSP430AsmParser::ParseLiteralValues(unsigned Size, SMLoc L) { return (parseMany(parseOne)); } -extern "C" void LLVMInitializeMSP430AsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430AsmParser() { RegisterMCAsmParser X(getTheMSP430Target()); } diff --git a/lib/Target/MSP430/Disassembler/MSP430Disassembler.cpp b/lib/Target/MSP430/Disassembler/MSP430Disassembler.cpp index 59c12e24e8b..c76baac23ad 100644 --- a/lib/Target/MSP430/Disassembler/MSP430Disassembler.cpp +++ b/lib/Target/MSP430/Disassembler/MSP430Disassembler.cpp @@ -62,7 +62,7 @@ static MCDisassembler *createMSP430Disassembler(const Target &T, return new MSP430Disassembler(STI, Ctx); } -extern "C" void LLVMInitializeMSP430Disassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430Disassembler() { TargetRegistry::RegisterMCDisassembler(getTheMSP430Target(), createMSP430Disassembler); } diff --git a/lib/Target/MSP430/MCTargetDesc/MSP430MCTargetDesc.cpp b/lib/Target/MSP430/MCTargetDesc/MSP430MCTargetDesc.cpp index da928733015..f207d24ce04 100644 --- a/lib/Target/MSP430/MCTargetDesc/MSP430MCTargetDesc.cpp +++ b/lib/Target/MSP430/MCTargetDesc/MSP430MCTargetDesc.cpp @@ -57,7 +57,7 @@ static MCInstPrinter *createMSP430MCInstPrinter(const Triple &T, return nullptr; } -extern "C" void LLVMInitializeMSP430TargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430TargetMC() { Target &T = getTheMSP430Target(); RegisterMCAsmInfo X(T); diff --git a/lib/Target/MSP430/MSP430AsmPrinter.cpp b/lib/Target/MSP430/MSP430AsmPrinter.cpp index 3a71a084d1a..f9d1422d8f8 100644 --- a/lib/Target/MSP430/MSP430AsmPrinter.cpp +++ b/lib/Target/MSP430/MSP430AsmPrinter.cpp @@ -183,6 +183,6 @@ bool MSP430AsmPrinter::runOnMachineFunction(MachineFunction &MF) { } // Force static initialization. -extern "C" void LLVMInitializeMSP430AsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430AsmPrinter() { RegisterAsmPrinter X(getTheMSP430Target()); } diff --git a/lib/Target/MSP430/MSP430TargetMachine.cpp b/lib/Target/MSP430/MSP430TargetMachine.cpp index 8c4ca982c96..8e7e34cd495 100644 --- a/lib/Target/MSP430/MSP430TargetMachine.cpp +++ b/lib/Target/MSP430/MSP430TargetMachine.cpp @@ -21,7 +21,7 @@ #include "llvm/Support/TargetRegistry.h" using namespace llvm; -extern "C" void LLVMInitializeMSP430Target() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430Target() { // Register the target. RegisterTargetMachine X(getTheMSP430Target()); } diff --git a/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp b/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp index 5da7d588079..9d4a8f141cc 100644 --- a/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp +++ b/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp @@ -15,7 +15,7 @@ Target &llvm::getTheMSP430Target() { return TheMSP430Target; } -extern "C" void LLVMInitializeMSP430TargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430TargetInfo() { RegisterTarget X(getTheMSP430Target(), "msp430", "MSP430 [experimental]", "MSP430"); } diff --git a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp index e45592274e3..cf0be46cefc 100644 --- a/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -8190,7 +8190,7 @@ bool MipsAsmParser::parseInternalDirectiveReallowModule() { return false; } -extern "C" void LLVMInitializeMipsAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsAsmParser() { RegisterMCAsmParser X(getTheMipsTarget()); RegisterMCAsmParser Y(getTheMipselTarget()); RegisterMCAsmParser A(getTheMips64Target()); diff --git a/lib/Target/Mips/Disassembler/MipsDisassembler.cpp b/lib/Target/Mips/Disassembler/MipsDisassembler.cpp index ef13507fe63..39923f002d7 100644 --- a/lib/Target/Mips/Disassembler/MipsDisassembler.cpp +++ b/lib/Target/Mips/Disassembler/MipsDisassembler.cpp @@ -555,7 +555,7 @@ static MCDisassembler *createMipselDisassembler( return new MipsDisassembler(STI, Ctx, false); } -extern "C" void LLVMInitializeMipsDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheMipsTarget(), createMipsDisassembler); diff --git a/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp b/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp index ddeec03ba78..03f7ddd4e51 100644 --- a/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp +++ b/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp @@ -162,7 +162,7 @@ static MCInstrAnalysis *createMipsMCInstrAnalysis(const MCInstrInfo *Info) { return new MipsMCInstrAnalysis(Info); } -extern "C" void LLVMInitializeMipsTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsTargetMC() { for (Target *T : {&getTheMipsTarget(), &getTheMipselTarget(), &getTheMips64Target(), &getTheMips64elTarget()}) { // Register the MC asm info. diff --git a/lib/Target/Mips/MipsAsmPrinter.cpp b/lib/Target/Mips/MipsAsmPrinter.cpp index db83fe49cec..40fe7a82917 100644 --- a/lib/Target/Mips/MipsAsmPrinter.cpp +++ b/lib/Target/Mips/MipsAsmPrinter.cpp @@ -1296,7 +1296,7 @@ bool MipsAsmPrinter::isLongBranchPseudo(int Opcode) const { } // Force static initialization. -extern "C" void LLVMInitializeMipsAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsAsmPrinter() { RegisterAsmPrinter X(getTheMipsTarget()); RegisterAsmPrinter Y(getTheMipselTarget()); RegisterAsmPrinter A(getTheMips64Target()); diff --git a/lib/Target/Mips/MipsTargetMachine.cpp b/lib/Target/Mips/MipsTargetMachine.cpp index c878abb042e..046e0d7b524 100644 --- a/lib/Target/Mips/MipsTargetMachine.cpp +++ b/lib/Target/Mips/MipsTargetMachine.cpp @@ -44,7 +44,7 @@ using namespace llvm; #define DEBUG_TYPE "mips" -extern "C" void LLVMInitializeMipsTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsTarget() { // Register the target. RegisterTargetMachine X(getTheMipsTarget()); RegisterTargetMachine Y(getTheMipselTarget()); diff --git a/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp b/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp index 0082ca34cdb..44041987ec7 100644 --- a/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp +++ b/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp @@ -27,7 +27,7 @@ Target &llvm::getTheMips64elTarget() { return TheMips64elTarget; } -extern "C" void LLVMInitializeMipsTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsTargetInfo() { RegisterTarget X(getTheMipsTarget(), "mips", "MIPS (32-bit big endian)", "Mips"); diff --git a/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp b/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp index c8b85b2718a..d758c2c8695 100644 --- a/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp +++ b/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp @@ -66,7 +66,7 @@ static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S, } // Force static initialization. -extern "C" void LLVMInitializeNVPTXTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeNVPTXTargetMC() { for (Target *T : {&getTheNVPTXTarget32(), &getTheNVPTXTarget64()}) { // Register the MC asm info. RegisterMCAsmInfo X(*T); diff --git a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp index 5f38b4a3c4c..e99d41ca14a 100644 --- a/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -2260,7 +2260,7 @@ void NVPTXAsmPrinter::printMemOperand(const MachineInstr *MI, int opNum, } // Force static initialization. -extern "C" void LLVMInitializeNVPTXAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeNVPTXAsmPrinter() { RegisterAsmPrinter X(getTheNVPTXTarget32()); RegisterAsmPrinter Y(getTheNVPTXTarget64()); } diff --git a/lib/Target/NVPTX/NVPTXTargetMachine.cpp b/lib/Target/NVPTX/NVPTXTargetMachine.cpp index 11b3fe2fa3d..2e2db7ab8e6 100644 --- a/lib/Target/NVPTX/NVPTXTargetMachine.cpp +++ b/lib/Target/NVPTX/NVPTXTargetMachine.cpp @@ -72,7 +72,7 @@ void initializeNVPTXProxyRegErasurePass(PassRegistry &); } // end namespace llvm -extern "C" void LLVMInitializeNVPTXTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeNVPTXTarget() { // Register the target. RegisterTargetMachine X(getTheNVPTXTarget32()); RegisterTargetMachine Y(getTheNVPTXTarget64()); diff --git a/lib/Target/NVPTX/TargetInfo/NVPTXTargetInfo.cpp b/lib/Target/NVPTX/TargetInfo/NVPTXTargetInfo.cpp index 2c71ec58ec4..235be9c0dbb 100644 --- a/lib/Target/NVPTX/TargetInfo/NVPTXTargetInfo.cpp +++ b/lib/Target/NVPTX/TargetInfo/NVPTXTargetInfo.cpp @@ -19,7 +19,7 @@ Target &llvm::getTheNVPTXTarget64() { return TheNVPTXTarget64; } -extern "C" void LLVMInitializeNVPTXTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeNVPTXTargetInfo() { RegisterTarget X(getTheNVPTXTarget32(), "nvptx", "NVIDIA PTX 32-bit", "NVPTX"); RegisterTarget Y(getTheNVPTXTarget64(), "nvptx64", diff --git a/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp b/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp index c9524da93ac..094ee5af336 100644 --- a/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp +++ b/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp @@ -1786,7 +1786,7 @@ bool PPCAsmParser::ParseDirectiveLocalEntry(SMLoc L) { /// Force static initialization. -extern "C" void LLVMInitializePowerPCAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCAsmParser() { RegisterMCAsmParser A(getThePPC32Target()); RegisterMCAsmParser B(getThePPC64Target()); RegisterMCAsmParser C(getThePPC64LETarget()); diff --git a/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp b/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp index 4814529c330..d848b02ee06 100644 --- a/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp +++ b/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp @@ -51,7 +51,7 @@ static MCDisassembler *createPPCLEDisassembler(const Target &T, return new PPCDisassembler(STI, Ctx, /*IsLittleEndian=*/true); } -extern "C" void LLVMInitializePowerPCDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCDisassembler() { // Register the disassembler for each target. TargetRegistry::RegisterMCDisassembler(getThePPC32Target(), createPPCDisassembler); diff --git a/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp b/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp index 395b4236fa8..9f4cd6ed641 100644 --- a/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp +++ b/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp @@ -260,7 +260,7 @@ static MCInstPrinter *createPPCMCInstPrinter(const Triple &T, return new PPCInstPrinter(MAI, MII, MRI, T); } -extern "C" void LLVMInitializePowerPCTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCTargetMC() { for (Target *T : {&getThePPC32Target(), &getThePPC64Target(), &getThePPC64LETarget()}) { // Register the MC asm info. diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp index 8ba21d7c68f..f8a892dbe9b 100644 --- a/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -1651,7 +1651,7 @@ createPPCAsmPrinterPass(TargetMachine &tm, } // Force static initialization. -extern "C" void LLVMInitializePowerPCAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCAsmPrinter() { TargetRegistry::RegisterAsmPrinter(getThePPC32Target(), createPPCAsmPrinterPass); TargetRegistry::RegisterAsmPrinter(getThePPC64Target(), diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp index da1121bac9c..bc6c3b7f35c 100644 --- a/lib/Target/PowerPC/PPCTargetMachine.cpp +++ b/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -94,7 +94,7 @@ static cl::opt ReduceCRLogical("ppc-reduce-cr-logicals", cl::desc("Expand eligible cr-logical binary ops to branches"), cl::init(false), cl::Hidden); -extern "C" void LLVMInitializePowerPCTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCTarget() { // Register the targets RegisterTargetMachine A(getThePPC32Target()); RegisterTargetMachine B(getThePPC64Target()); diff --git a/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp b/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp index 99b5dec7466..649bd648a6c 100644 --- a/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp +++ b/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp @@ -23,7 +23,7 @@ Target &llvm::getThePPC64LETarget() { return ThePPC64LETarget; } -extern "C" void LLVMInitializePowerPCTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCTargetInfo() { RegisterTarget X(getThePPC32Target(), "ppc32", "PowerPC 32", "PPC"); diff --git a/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp index bac43187ca7..a0c6e8c9b35 100644 --- a/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -1754,7 +1754,7 @@ bool RISCVAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc, return false; } -extern "C" void LLVMInitializeRISCVAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVAsmParser() { RegisterMCAsmParser X(getTheRISCV32Target()); RegisterMCAsmParser Y(getTheRISCV64Target()); } diff --git a/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp b/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp index 36200c03f70..3a770fe9dd9 100644 --- a/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp +++ b/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp @@ -48,7 +48,7 @@ static MCDisassembler *createRISCVDisassembler(const Target &T, return new RISCVDisassembler(STI, Ctx); } -extern "C" void LLVMInitializeRISCVDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVDisassembler() { // Register the disassembler for each target. TargetRegistry::RegisterMCDisassembler(getTheRISCV32Target(), createRISCVDisassembler); diff --git a/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp b/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp index d920fd203d8..57422a2cb62 100644 --- a/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp +++ b/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp @@ -84,7 +84,7 @@ static MCTargetStreamer *createRISCVAsmTargetStreamer(MCStreamer &S, return new RISCVTargetAsmStreamer(S, OS); } -extern "C" void LLVMInitializeRISCVTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVTargetMC() { for (Target *T : {&getTheRISCV32Target(), &getTheRISCV64Target()}) { TargetRegistry::RegisterMCAsmInfo(*T, createRISCVMCAsmInfo); TargetRegistry::RegisterMCInstrInfo(*T, createRISCVMCInstrInfo); diff --git a/lib/Target/RISCV/RISCVAsmPrinter.cpp b/lib/Target/RISCV/RISCVAsmPrinter.cpp index 2afa1fb0e4c..4e274f59d5c 100644 --- a/lib/Target/RISCV/RISCVAsmPrinter.cpp +++ b/lib/Target/RISCV/RISCVAsmPrinter.cpp @@ -123,7 +123,7 @@ bool RISCVAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, } // Force static initialization. -extern "C" void LLVMInitializeRISCVAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVAsmPrinter() { RegisterAsmPrinter X(getTheRISCV32Target()); RegisterAsmPrinter Y(getTheRISCV64Target()); } diff --git a/lib/Target/RISCV/RISCVTargetMachine.cpp b/lib/Target/RISCV/RISCVTargetMachine.cpp index d539dbeef23..85201877ec0 100644 --- a/lib/Target/RISCV/RISCVTargetMachine.cpp +++ b/lib/Target/RISCV/RISCVTargetMachine.cpp @@ -24,7 +24,7 @@ #include "llvm/Target/TargetOptions.h" using namespace llvm; -extern "C" void LLVMInitializeRISCVTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVTarget() { RegisterTargetMachine X(getTheRISCV32Target()); RegisterTargetMachine Y(getTheRISCV64Target()); auto PR = PassRegistry::getPassRegistry(); diff --git a/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp b/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp index e44984a3fcc..4f265d55638 100644 --- a/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp +++ b/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp @@ -20,7 +20,7 @@ Target &llvm::getTheRISCV64Target() { return TheRISCV64Target; } -extern "C" void LLVMInitializeRISCVTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVTargetInfo() { RegisterTarget X(getTheRISCV32Target(), "riscv32", "32-bit RISC-V", "RISCV"); RegisterTarget Y(getTheRISCV64Target(), "riscv64", diff --git a/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp b/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp index 15453ae59a4..774bd8f7a37 100644 --- a/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp +++ b/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp @@ -1308,7 +1308,7 @@ bool SparcAsmParser::matchSparcAsmModifiers(const MCExpr *&EVal, return true; } -extern "C" void LLVMInitializeSparcAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSparcAsmParser() { RegisterMCAsmParser A(getTheSparcTarget()); RegisterMCAsmParser B(getTheSparcV9Target()); RegisterMCAsmParser C(getTheSparcelTarget()); diff --git a/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp b/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp index bee331874e9..f28025f7f2e 100644 --- a/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp +++ b/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp @@ -48,7 +48,7 @@ static MCDisassembler *createSparcDisassembler(const Target &T, } -extern "C" void LLVMInitializeSparcDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSparcDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheSparcTarget(), createSparcDisassembler); diff --git a/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp b/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp index ce593bb6677..c32a81ae583 100644 --- a/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp +++ b/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp @@ -89,7 +89,7 @@ static MCInstPrinter *createSparcMCInstPrinter(const Triple &T, return new SparcInstPrinter(MAI, MII, MRI); } -extern "C" void LLVMInitializeSparcTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSparcTargetMC() { // Register the MC asm info. RegisterMCAsmInfoFn X(getTheSparcTarget(), createSparcMCAsmInfo); RegisterMCAsmInfoFn Y(getTheSparcV9Target(), createSparcV9MCAsmInfo); diff --git a/lib/Target/Sparc/SparcAsmPrinter.cpp b/lib/Target/Sparc/SparcAsmPrinter.cpp index 4d5cbfbadc9..f0caf3bc284 100644 --- a/lib/Target/Sparc/SparcAsmPrinter.cpp +++ b/lib/Target/Sparc/SparcAsmPrinter.cpp @@ -439,7 +439,7 @@ bool SparcAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, } // Force static initialization. -extern "C" void LLVMInitializeSparcAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSparcAsmPrinter() { RegisterAsmPrinter X(getTheSparcTarget()); RegisterAsmPrinter Y(getTheSparcV9Target()); RegisterAsmPrinter Z(getTheSparcelTarget()); diff --git a/lib/Target/Sparc/SparcTargetMachine.cpp b/lib/Target/Sparc/SparcTargetMachine.cpp index 195cff79de0..80f09c0ff66 100644 --- a/lib/Target/Sparc/SparcTargetMachine.cpp +++ b/lib/Target/Sparc/SparcTargetMachine.cpp @@ -20,7 +20,7 @@ #include "llvm/Support/TargetRegistry.h" using namespace llvm; -extern "C" void LLVMInitializeSparcTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSparcTarget() { // Register the target. RegisterTargetMachine X(getTheSparcTarget()); RegisterTargetMachine Y(getTheSparcV9Target()); diff --git a/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp b/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp index eafa2b4b2f1..3bf5907012d 100644 --- a/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp +++ b/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp @@ -23,7 +23,7 @@ Target &llvm::getTheSparcelTarget() { return TheSparcelTarget; } -extern "C" void LLVMInitializeSparcTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSparcTargetInfo() { RegisterTarget X(getTheSparcTarget(), "sparc", "Sparc", "Sparc"); RegisterTarget Y( diff --git a/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp b/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp index a259ba3433d..98756421efb 100644 --- a/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp +++ b/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp @@ -1371,6 +1371,6 @@ SystemZAsmParser::parsePCRel(OperandVector &Operands, int64_t MinVal, } // Force static initialization. -extern "C" void LLVMInitializeSystemZAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZAsmParser() { RegisterMCAsmParser X(getTheSystemZTarget()); } diff --git a/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp b/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp index 70c26db33ce..a9a8a46a8ca 100644 --- a/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp +++ b/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp @@ -46,7 +46,7 @@ static MCDisassembler *createSystemZDisassembler(const Target &T, return new SystemZDisassembler(STI, Ctx); } -extern "C" void LLVMInitializeSystemZDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheSystemZTarget(), createSystemZDisassembler); diff --git a/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp b/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp index 3c0300cfd8f..ab4d6f9aeac 100644 --- a/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp +++ b/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp @@ -182,7 +182,7 @@ static MCInstPrinter *createSystemZMCInstPrinter(const Triple &T, return new SystemZInstPrinter(MAI, MII, MRI); } -extern "C" void LLVMInitializeSystemZTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZTargetMC() { // Register the MCAsmInfo. TargetRegistry::RegisterMCAsmInfo(getTheSystemZTarget(), createSystemZMCAsmInfo); diff --git a/lib/Target/SystemZ/SystemZAsmPrinter.cpp b/lib/Target/SystemZ/SystemZAsmPrinter.cpp index f3d7d3e1fd1..b3d430c58a6 100644 --- a/lib/Target/SystemZ/SystemZAsmPrinter.cpp +++ b/lib/Target/SystemZ/SystemZAsmPrinter.cpp @@ -644,6 +644,6 @@ void SystemZAsmPrinter::EmitEndOfAsmFile(Module &M) { } // Force static initialization. -extern "C" void LLVMInitializeSystemZAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZAsmPrinter() { RegisterAsmPrinter X(getTheSystemZTarget()); } diff --git a/lib/Target/SystemZ/SystemZTargetMachine.cpp b/lib/Target/SystemZ/SystemZTargetMachine.cpp index 5c49e6eff0b..8bb6b625c37 100644 --- a/lib/Target/SystemZ/SystemZTargetMachine.cpp +++ b/lib/Target/SystemZ/SystemZTargetMachine.cpp @@ -29,7 +29,7 @@ using namespace llvm; -extern "C" void LLVMInitializeSystemZTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZTarget() { // Register the target. RegisterTargetMachine X(getTheSystemZTarget()); } diff --git a/lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp b/lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp index 713a55ee840..36291e07988 100644 --- a/lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp +++ b/lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp @@ -16,7 +16,7 @@ Target &llvm::getTheSystemZTarget() { return TheSystemZTarget; } -extern "C" void LLVMInitializeSystemZTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZTargetInfo() { RegisterTarget X( getTheSystemZTarget(), "systemz", "SystemZ", "SystemZ"); } diff --git a/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp b/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp index 44136b69efe..a8d88154cfa 100644 --- a/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp +++ b/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp @@ -764,7 +764,7 @@ public: } // end anonymous namespace // Force static initialization. -extern "C" void LLVMInitializeWebAssemblyAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyAsmParser() { RegisterMCAsmParser X(getTheWebAssemblyTarget32()); RegisterMCAsmParser Y(getTheWebAssemblyTarget64()); } diff --git a/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp b/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp index f9bf3f85d30..60e55499baf 100644 --- a/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp +++ b/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp @@ -65,7 +65,7 @@ static MCDisassembler *createWebAssemblyDisassembler(const Target &T, return new WebAssemblyDisassembler(STI, Ctx, std::move(MCII)); } -extern "C" void LLVMInitializeWebAssemblyDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyDisassembler() { // Register the disassembler for each target. TargetRegistry::RegisterMCDisassembler(getTheWebAssemblyTarget32(), createWebAssemblyDisassembler); diff --git a/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp b/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp index 21545c39164..82e8e91afdd 100644 --- a/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp +++ b/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp @@ -95,7 +95,7 @@ static MCTargetStreamer *createNullTargetStreamer(MCStreamer &S) { } // Force static initialization. -extern "C" void LLVMInitializeWebAssemblyTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTargetMC() { for (Target *T : {&getTheWebAssemblyTarget32(), &getTheWebAssemblyTarget64()}) { // Register the MC asm info. diff --git a/lib/Target/WebAssembly/TargetInfo/WebAssemblyTargetInfo.cpp b/lib/Target/WebAssembly/TargetInfo/WebAssemblyTargetInfo.cpp index e4afe2bb283..87317f8a7f1 100644 --- a/lib/Target/WebAssembly/TargetInfo/WebAssemblyTargetInfo.cpp +++ b/lib/Target/WebAssembly/TargetInfo/WebAssemblyTargetInfo.cpp @@ -26,7 +26,7 @@ Target &llvm::getTheWebAssemblyTarget64() { return TheWebAssemblyTarget64; } -extern "C" void LLVMInitializeWebAssemblyTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTargetInfo() { RegisterTarget X(getTheWebAssemblyTarget32(), "wasm32", "WebAssembly 32-bit", "WebAssembly"); RegisterTarget Y(getTheWebAssemblyTarget64(), "wasm64", diff --git a/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp index 7f9d41da397..97f14a2d698 100644 --- a/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp +++ b/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp @@ -443,7 +443,7 @@ bool WebAssemblyAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, } // Force static initialization. -extern "C" void LLVMInitializeWebAssemblyAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyAsmPrinter() { RegisterAsmPrinter X(getTheWebAssemblyTarget32()); RegisterAsmPrinter Y(getTheWebAssemblyTarget64()); } diff --git a/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp index 937d272d213..9f45a0dca27 100644 --- a/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -45,7 +45,7 @@ static cl::opt EnableEmSjLj( cl::desc("WebAssembly Emscripten-style setjmp/longjmp handling"), cl::init(false)); -extern "C" void LLVMInitializeWebAssemblyTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTarget() { // Register the target. RegisterTargetMachine X( getTheWebAssemblyTarget32()); diff --git a/lib/Target/X86/AsmParser/X86AsmParser.cpp b/lib/Target/X86/AsmParser/X86AsmParser.cpp index 8387b9549c1..882cc375f22 100644 --- a/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -3709,7 +3709,7 @@ bool X86AsmParser::parseDirectiveFPOEndProc(SMLoc L) { } // Force static initialization. -extern "C" void LLVMInitializeX86AsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeX86AsmParser() { RegisterMCAsmParser X(getTheX86_32Target()); RegisterMCAsmParser Y(getTheX86_64Target()); } diff --git a/lib/Target/X86/Disassembler/X86Disassembler.cpp b/lib/Target/X86/Disassembler/X86Disassembler.cpp index 9a635bbe5f8..e233422ddea 100644 --- a/lib/Target/X86/Disassembler/X86Disassembler.cpp +++ b/lib/Target/X86/Disassembler/X86Disassembler.cpp @@ -844,7 +844,7 @@ static MCDisassembler *createX86Disassembler(const Target &T, return new X86GenericDisassembler(STI, Ctx, std::move(MII)); } -extern "C" void LLVMInitializeX86Disassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeX86Disassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheX86_32Target(), createX86Disassembler); diff --git a/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp index ce05ad97450..a62a1843663 100644 --- a/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp +++ b/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp @@ -523,7 +523,7 @@ static MCInstrAnalysis *createX86MCInstrAnalysis(const MCInstrInfo *Info) { } // Force static initialization. -extern "C" void LLVMInitializeX86TargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeX86TargetMC() { for (Target *T : {&getTheX86_32Target(), &getTheX86_64Target()}) { // Register the MC asm info. RegisterMCAsmInfoFn X(*T, createX86MCAsmInfo); diff --git a/lib/Target/X86/TargetInfo/X86TargetInfo.cpp b/lib/Target/X86/TargetInfo/X86TargetInfo.cpp index 47c41626a66..18cda8f591c 100644 --- a/lib/Target/X86/TargetInfo/X86TargetInfo.cpp +++ b/lib/Target/X86/TargetInfo/X86TargetInfo.cpp @@ -19,7 +19,7 @@ Target &llvm::getTheX86_64Target() { return TheX86_64Target; } -extern "C" void LLVMInitializeX86TargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeX86TargetInfo() { RegisterTarget X( getTheX86_32Target(), "x86", "32-bit X86: Pentium-Pro and above", "X86"); diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index 80120722e0e..0201398377c 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -727,7 +727,7 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) { //===----------------------------------------------------------------------===// // Force static initialization. -extern "C" void LLVMInitializeX86AsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeX86AsmPrinter() { RegisterAsmPrinter X(getTheX86_32Target()); RegisterAsmPrinter Y(getTheX86_64Target()); } diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp index a005e7fcf4b..d95ac756572 100644 --- a/lib/Target/X86/X86TargetMachine.cpp +++ b/lib/Target/X86/X86TargetMachine.cpp @@ -60,7 +60,7 @@ static cl::opt EnableCondBrFoldingPass("x86-condbr-folding", "folding pass"), cl::init(false), cl::Hidden); -extern "C" void LLVMInitializeX86Target() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeX86Target() { // Register the target. RegisterTargetMachine X(getTheX86_32Target()); RegisterTargetMachine Y(getTheX86_64Target()); diff --git a/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp b/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp index ff3d41fd527..230726a0283 100644 --- a/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp +++ b/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp @@ -774,7 +774,7 @@ static MCDisassembler *createXCoreDisassembler(const Target &T, return new XCoreDisassembler(STI, Ctx); } -extern "C" void LLVMInitializeXCoreDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXCoreDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheXCoreTarget(), createXCoreDisassembler); diff --git a/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp b/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp index 877f38e22f9..715ea9d5e54 100644 --- a/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp +++ b/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp @@ -121,7 +121,7 @@ static MCTargetStreamer *createTargetAsmStreamer(MCStreamer &S, } // Force static initialization. -extern "C" void LLVMInitializeXCoreTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXCoreTargetMC() { // Register the MC asm info. RegisterMCAsmInfoFn X(getTheXCoreTarget(), createXCoreMCAsmInfo); diff --git a/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp b/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp index 5604f29db3e..d5f66c2bd82 100644 --- a/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp +++ b/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp @@ -15,7 +15,7 @@ Target &llvm::getTheXCoreTarget() { return TheXCoreTarget; } -extern "C" void LLVMInitializeXCoreTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXCoreTargetInfo() { RegisterTarget X(getTheXCoreTarget(), "xcore", "XCore", "XCore"); } diff --git a/lib/Target/XCore/XCoreAsmPrinter.cpp b/lib/Target/XCore/XCoreAsmPrinter.cpp index 9f615b9e774..a0823cf81dc 100644 --- a/lib/Target/XCore/XCoreAsmPrinter.cpp +++ b/lib/Target/XCore/XCoreAsmPrinter.cpp @@ -292,6 +292,6 @@ void XCoreAsmPrinter::EmitInstruction(const MachineInstr *MI) { } // Force static initialization. -extern "C" void LLVMInitializeXCoreAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXCoreAsmPrinter() { RegisterAsmPrinter X(getTheXCoreTarget()); } diff --git a/lib/Target/XCore/XCoreTargetMachine.cpp b/lib/Target/XCore/XCoreTargetMachine.cpp index 2a8cd6b657b..75d6f239248 100644 --- a/lib/Target/XCore/XCoreTargetMachine.cpp +++ b/lib/Target/XCore/XCoreTargetMachine.cpp @@ -105,7 +105,7 @@ void XCorePassConfig::addPreEmitPass() { } // Force static initialization. -extern "C" void LLVMInitializeXCoreTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXCoreTarget() { RegisterTargetMachine X(getTheXCoreTarget()); } diff --git a/unittests/CMakeLists.txt b/unittests/CMakeLists.txt index 68fa8533baf..816c61eceaf 100644 --- a/unittests/CMakeLists.txt +++ b/unittests/CMakeLists.txt @@ -8,6 +8,12 @@ function(add_llvm_unittest_with_input_files test_dirname) add_unittest_with_input_files(UnitTests ${test_dirname} ${ARGN}) endfunction() +# The target unittests may test APIs that aren't exported in libLLVM.so, so +# we need to always link against the static libraries. +function(add_llvm_target_unittest test_dir_name) + add_llvm_unittest(${test_dir_name} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN}) +endfunction() + add_subdirectory(ADT) add_subdirectory(Analysis) add_subdirectory(AsmParser) diff --git a/unittests/Target/AArch64/CMakeLists.txt b/unittests/Target/AArch64/CMakeLists.txt index 76f6c8226a8..d23e68096b3 100644 --- a/unittests/Target/AArch64/CMakeLists.txt +++ b/unittests/Target/AArch64/CMakeLists.txt @@ -17,6 +17,6 @@ set(LLVM_LINK_COMPONENTS Target ) -add_llvm_unittest(AArch64Tests +add_llvm_target_unittest(AArch64Tests InstSizes.cpp ) diff --git a/unittests/Target/WebAssembly/CMakeLists.txt b/unittests/Target/WebAssembly/CMakeLists.txt index 5ec82240b03..2e467e46c93 100644 --- a/unittests/Target/WebAssembly/CMakeLists.txt +++ b/unittests/Target/WebAssembly/CMakeLists.txt @@ -13,6 +13,6 @@ set(LLVM_LINK_COMPONENTS WebAssemblyInfo ) -add_llvm_unittest(WebAssemblyTests +add_llvm_target_unittest(WebAssemblyTests WebAssemblyExceptionInfoTest.cpp ) diff --git a/unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt b/unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt index 392efce26c0..907de111945 100644 --- a/unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt +++ b/unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt @@ -13,7 +13,7 @@ set(LLVM_LINK_COMPONENTS AArch64 ) -add_llvm_unittest(LLVMExegesisAArch64Tests +add_llvm_target_unittest(LLVMExegesisAArch64Tests TargetTest.cpp ) target_link_libraries(LLVMExegesisAArch64Tests PRIVATE diff --git a/unittests/tools/llvm-exegesis/ARM/CMakeLists.txt b/unittests/tools/llvm-exegesis/ARM/CMakeLists.txt index b000974938f..27ecff5f4ae 100644 --- a/unittests/tools/llvm-exegesis/ARM/CMakeLists.txt +++ b/unittests/tools/llvm-exegesis/ARM/CMakeLists.txt @@ -13,7 +13,7 @@ set(LLVM_LINK_COMPONENTS ARM ) -add_llvm_unittest(LLVMExegesisARMTests +add_llvm_target_unittest(LLVMExegesisARMTests AssemblerTest.cpp ) target_link_libraries(LLVMExegesisARMTests PRIVATE LLVMExegesis) diff --git a/unittests/tools/llvm-exegesis/PowerPC/CMakeLists.txt b/unittests/tools/llvm-exegesis/PowerPC/CMakeLists.txt index e8a53e3692a..6324ae652de 100644 --- a/unittests/tools/llvm-exegesis/PowerPC/CMakeLists.txt +++ b/unittests/tools/llvm-exegesis/PowerPC/CMakeLists.txt @@ -13,7 +13,7 @@ set(LLVM_LINK_COMPONENTS PowerPC ) -add_llvm_unittest(LLVMExegesisPowerPCTests +add_llvm_target_unittest(LLVMExegesisPowerPCTests AnalysisTest.cpp TargetTest.cpp ) diff --git a/unittests/tools/llvm-exegesis/X86/CMakeLists.txt b/unittests/tools/llvm-exegesis/X86/CMakeLists.txt index 88c38d0d7e8..a63d7f3ba56 100644 --- a/unittests/tools/llvm-exegesis/X86/CMakeLists.txt +++ b/unittests/tools/llvm-exegesis/X86/CMakeLists.txt @@ -13,7 +13,7 @@ set(LLVM_LINK_COMPONENTS X86 ) -add_llvm_unittest(LLVMExegesisX86Tests +add_llvm_target_unittest(LLVMExegesisX86Tests AssemblerTest.cpp BenchmarkResultTest.cpp RegisterAliasingTest.cpp diff --git a/utils/unittest/CMakeLists.txt b/utils/unittest/CMakeLists.txt index 0850d49e3a3..5aad048f2c3 100644 --- a/utils/unittest/CMakeLists.txt +++ b/utils/unittest/CMakeLists.txt @@ -71,3 +71,23 @@ add_llvm_library(gtest ) add_subdirectory(UnitTestMain) + +# When LLVM_LINK_LLVM_DYLIB is enabled, libLLVM.so is added to the interface +# link libraries for gtest and gtest_main. This means that any target, like +# unittests for example, that links against gtest will be forced to link +# against libLLVM.so. In some cases we may want to statically unittests if they +# need access to symbols that are marked private in libLLVM.so. The only +# way we can make this work is to remove libLLVM.so from the list of interface +# link libraries for gtest and then make gtest users responsible for explicitly +# adding libLLVM.so to their targets link libraries if they need it. + +function (gtest_remove_dylib_from_link_interface target) + get_target_property(interface_libs ${target} INTERFACE_LINK_LIBRARIES) + if (interface_libs) + list(REMOVE_ITEM interface_libs LLVM) + set_target_properties(${target} PROPERTIES INTERFACE_LINK_LIBRARIES "${interface_libs}") + endif() +endfunction() + +gtest_remove_dylib_from_link_interface(gtest) +gtest_remove_dylib_from_link_interface(gtest_main)