diff --git a/llvm/include/llvm/Support/Compiler.h b/llvm/include/llvm/Support/Compiler.h --- a/llvm/include/llvm/Support/Compiler.h +++ b/llvm/include/llvm/Support/Compiler.h @@ -117,11 +117,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_VISIBILITY #endif #if defined(__GNUC__) diff --git a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp --- a/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ b/llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -1279,7 +1279,7 @@ } // 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/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp --- a/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp +++ b/llvm/lib/Target/AArch64/AArch64TargetMachine.cpp @@ -154,7 +154,7 @@ 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/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp --- a/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ b/llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -5509,7 +5509,7 @@ } /// 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/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp b/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp --- a/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp +++ b/llvm/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp @@ -278,7 +278,7 @@ SymbolLookUp, DisInfo); } -extern "C" void LLVMInitializeAArch64Disassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAArch64Disassembler() { TargetRegistry::RegisterMCDisassembler(getTheAArch64leTarget(), createAArch64Disassembler); TargetRegistry::RegisterMCDisassembler(getTheAArch64beTarget(), diff --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp --- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp +++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp @@ -366,7 +366,7 @@ } // 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/llvm/lib/Target/AArch64/TargetInfo/AArch64TargetInfo.cpp b/llvm/lib/Target/AArch64/TargetInfo/AArch64TargetInfo.cpp --- a/llvm/lib/Target/AArch64/TargetInfo/AArch64TargetInfo.cpp +++ b/llvm/lib/Target/AArch64/TargetInfo/AArch64TargetInfo.cpp @@ -31,7 +31,7 @@ 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/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp @@ -90,7 +90,7 @@ 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/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp --- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -183,7 +183,7 @@ 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/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp --- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -6980,7 +6980,7 @@ } /// Force static initialization. -extern "C" void LLVMInitializeAMDGPUAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUAsmParser() { RegisterMCAsmParser A(getTheAMDGPUTarget()); RegisterMCAsmParser B(getTheGCNTarget()); } diff --git a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp --- a/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp +++ b/llvm/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp @@ -1253,7 +1253,7 @@ 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/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp --- a/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp +++ b/llvm/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp @@ -134,7 +134,7 @@ 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/llvm/lib/Target/AMDGPU/TargetInfo/AMDGPUTargetInfo.cpp b/llvm/lib/Target/AMDGPU/TargetInfo/AMDGPUTargetInfo.cpp --- a/llvm/lib/Target/AMDGPU/TargetInfo/AMDGPUTargetInfo.cpp +++ b/llvm/lib/Target/AMDGPU/TargetInfo/AMDGPUTargetInfo.cpp @@ -28,7 +28,7 @@ } /// 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/llvm/lib/Target/ARC/ARCAsmPrinter.cpp b/llvm/lib/Target/ARC/ARCAsmPrinter.cpp --- a/llvm/lib/Target/ARC/ARCAsmPrinter.cpp +++ b/llvm/lib/Target/ARC/ARCAsmPrinter.cpp @@ -62,6 +62,6 @@ } // Force static initialization. -extern "C" void LLVMInitializeARCAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARCAsmPrinter() { RegisterAsmPrinter X(getTheARCTarget()); } diff --git a/llvm/lib/Target/ARC/ARCTargetMachine.cpp b/llvm/lib/Target/ARC/ARCTargetMachine.cpp --- a/llvm/lib/Target/ARC/ARCTargetMachine.cpp +++ b/llvm/lib/Target/ARC/ARCTargetMachine.cpp @@ -81,7 +81,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeARCTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARCTarget() { RegisterTargetMachine X(getTheARCTarget()); } diff --git a/llvm/lib/Target/ARC/Disassembler/ARCDisassembler.cpp b/llvm/lib/Target/ARC/Disassembler/ARCDisassembler.cpp --- a/llvm/lib/Target/ARC/Disassembler/ARCDisassembler.cpp +++ b/llvm/lib/Target/ARC/Disassembler/ARCDisassembler.cpp @@ -365,7 +365,7 @@ 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/llvm/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp b/llvm/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp --- a/llvm/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp +++ b/llvm/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp @@ -82,7 +82,7 @@ } // 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/llvm/lib/Target/ARC/TargetInfo/ARCTargetInfo.cpp b/llvm/lib/Target/ARC/TargetInfo/ARCTargetInfo.cpp --- a/llvm/lib/Target/ARC/TargetInfo/ARCTargetInfo.cpp +++ b/llvm/lib/Target/ARC/TargetInfo/ARCTargetInfo.cpp @@ -16,6 +16,6 @@ return TheARCTarget; } -extern "C" void LLVMInitializeARCTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARCTargetInfo() { RegisterTarget X(getTheARCTarget(), "arc", "ARC", "ARC"); } diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp --- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp @@ -2142,7 +2142,7 @@ //===----------------------------------------------------------------------===// // 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/llvm/lib/Target/ARM/ARMTargetMachine.cpp b/llvm/lib/Target/ARM/ARMTargetMachine.cpp --- a/llvm/lib/Target/ARM/ARMTargetMachine.cpp +++ b/llvm/lib/Target/ARM/ARMTargetMachine.cpp @@ -79,7 +79,7 @@ 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/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp --- a/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ b/llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -11495,7 +11495,7 @@ } /// 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/llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp b/llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp --- a/llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp +++ b/llvm/lib/Target/ARM/Disassembler/ARMDisassembler.cpp @@ -1099,7 +1099,7 @@ return MCDisassembler::Fail; } -extern "C" void LLVMInitializeARMDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARMDisassembler() { TargetRegistry::RegisterMCDisassembler(getTheARMLETarget(), createARMDisassembler); TargetRegistry::RegisterMCDisassembler(getTheARMBETarget(), diff --git a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp --- a/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp +++ b/llvm/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp @@ -317,7 +317,7 @@ } // 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/llvm/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp b/llvm/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp --- a/llvm/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp +++ b/llvm/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp @@ -27,7 +27,7 @@ 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/llvm/lib/Target/AVR/AVRAsmPrinter.cpp b/llvm/lib/Target/AVR/AVRAsmPrinter.cpp --- a/llvm/lib/Target/AVR/AVRAsmPrinter.cpp +++ b/llvm/lib/Target/AVR/AVRAsmPrinter.cpp @@ -178,7 +178,7 @@ } // end of namespace llvm -extern "C" void LLVMInitializeAVRAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAVRAsmPrinter() { llvm::RegisterAsmPrinter X(llvm::getTheAVRTarget()); } diff --git a/llvm/lib/Target/AVR/AVRTargetMachine.cpp b/llvm/lib/Target/AVR/AVRTargetMachine.cpp --- a/llvm/lib/Target/AVR/AVRTargetMachine.cpp +++ b/llvm/lib/Target/AVR/AVRTargetMachine.cpp @@ -76,7 +76,7 @@ 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/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp --- a/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp +++ b/llvm/lib/Target/AVR/AsmParser/AVRAsmParser.cpp @@ -682,7 +682,7 @@ return (parseMany(parseOne)); } -extern "C" void LLVMInitializeAVRAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAVRAsmParser() { RegisterMCAsmParser X(getTheAVRTarget()); } diff --git a/llvm/lib/Target/AVR/Disassembler/AVRDisassembler.cpp b/llvm/lib/Target/AVR/Disassembler/AVRDisassembler.cpp --- a/llvm/lib/Target/AVR/Disassembler/AVRDisassembler.cpp +++ b/llvm/lib/Target/AVR/Disassembler/AVRDisassembler.cpp @@ -52,7 +52,7 @@ } -extern "C" void LLVMInitializeAVRDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAVRDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheAVRTarget(), createAVRDisassembler); diff --git a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp --- a/llvm/lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp +++ b/llvm/lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp @@ -89,7 +89,7 @@ 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/llvm/lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp b/llvm/lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp --- a/llvm/lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp +++ b/llvm/lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp @@ -15,7 +15,7 @@ } } -extern "C" void LLVMInitializeAVRTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAVRTargetInfo() { llvm::RegisterTarget X(llvm::getTheAVRTarget(), "avr", "Atmel AVR Microcontroller", "AVR"); } diff --git a/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp b/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp --- a/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp +++ b/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp @@ -493,7 +493,7 @@ 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/llvm/lib/Target/BPF/BPFAsmPrinter.cpp b/llvm/lib/Target/BPF/BPFAsmPrinter.cpp --- a/llvm/lib/Target/BPF/BPFAsmPrinter.cpp +++ b/llvm/lib/Target/BPF/BPFAsmPrinter.cpp @@ -148,7 +148,7 @@ } // 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/llvm/lib/Target/BPF/BPFTargetMachine.cpp b/llvm/lib/Target/BPF/BPFTargetMachine.cpp --- a/llvm/lib/Target/BPF/BPFTargetMachine.cpp +++ b/llvm/lib/Target/BPF/BPFTargetMachine.cpp @@ -27,7 +27,7 @@ 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/llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp b/llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp --- a/llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp +++ b/llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp @@ -84,7 +84,7 @@ } -extern "C" void LLVMInitializeBPFDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeBPFDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheBPFTarget(), createBPFDisassembler); diff --git a/llvm/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp b/llvm/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp --- a/llvm/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp +++ b/llvm/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp @@ -97,7 +97,7 @@ 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/llvm/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp b/llvm/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp --- a/llvm/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp +++ b/llvm/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp @@ -24,7 +24,7 @@ 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/llvm/lib/Target/CMakeLists.txt b/llvm/lib/Target/CMakeLists.txt --- a/llvm/lib/Target/CMakeLists.txt +++ b/llvm/lib/Target/CMakeLists.txt @@ -13,6 +13,14 @@ ${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 AND NOT APPLE) + # 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/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp b/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp --- a/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp +++ b/llvm/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp @@ -813,10 +813,10 @@ 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/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp b/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp --- a/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp +++ b/llvm/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp @@ -158,7 +158,7 @@ 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/llvm/lib/Target/Hexagon/HexagonAsmPrinter.cpp b/llvm/lib/Target/Hexagon/HexagonAsmPrinter.cpp --- a/llvm/lib/Target/Hexagon/HexagonAsmPrinter.cpp +++ b/llvm/lib/Target/Hexagon/HexagonAsmPrinter.cpp @@ -771,6 +771,6 @@ OutStreamer->EmitInstruction(MCB, getSubtargetInfo()); } -extern "C" void LLVMInitializeHexagonAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonAsmPrinter() { RegisterAsmPrinter X(getTheHexagonTarget()); } diff --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp --- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp +++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp @@ -180,7 +180,7 @@ return *RM; } -extern "C" void LLVMInitializeHexagonTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonTarget() { // Register the target. RegisterTargetMachine X(getTheHexagonTarget()); diff --git a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp --- a/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp +++ b/llvm/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp @@ -455,7 +455,7 @@ } // 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/llvm/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp b/llvm/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp --- a/llvm/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp +++ b/llvm/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp @@ -15,7 +15,7 @@ return TheHexagonTarget; } -extern "C" void LLVMInitializeHexagonTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonTargetInfo() { RegisterTarget X( getTheHexagonTarget(), "hexagon", "Hexagon", "Hexagon"); } diff --git a/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp b/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp --- a/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp +++ b/llvm/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp @@ -1224,6 +1224,6 @@ #define GET_MATCHER_IMPLEMENTATION #include "LanaiGenAsmMatcher.inc" -extern "C" void LLVMInitializeLanaiAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeLanaiAsmParser() { RegisterMCAsmParser x(getTheLanaiTarget()); } diff --git a/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp b/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp --- a/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp +++ b/llvm/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp @@ -36,7 +36,7 @@ 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/llvm/lib/Target/Lanai/LanaiAsmPrinter.cpp b/llvm/lib/Target/Lanai/LanaiAsmPrinter.cpp --- a/llvm/lib/Target/Lanai/LanaiAsmPrinter.cpp +++ b/llvm/lib/Target/Lanai/LanaiAsmPrinter.cpp @@ -237,6 +237,6 @@ } // Force static initialization. -extern "C" void LLVMInitializeLanaiAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeLanaiAsmPrinter() { RegisterAsmPrinter X(getTheLanaiTarget()); } diff --git a/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp b/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp --- a/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp +++ b/llvm/lib/Target/Lanai/LanaiTargetMachine.cpp @@ -30,7 +30,7 @@ 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/llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp b/llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp --- a/llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp +++ b/llvm/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp @@ -123,7 +123,7 @@ 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/llvm/lib/Target/Lanai/TargetInfo/LanaiTargetInfo.cpp b/llvm/lib/Target/Lanai/TargetInfo/LanaiTargetInfo.cpp --- a/llvm/lib/Target/Lanai/TargetInfo/LanaiTargetInfo.cpp +++ b/llvm/lib/Target/Lanai/TargetInfo/LanaiTargetInfo.cpp @@ -16,7 +16,7 @@ return TheLanaiTarget; } -extern "C" void LLVMInitializeLanaiTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeLanaiTargetInfo() { RegisterTarget X(getTheLanaiTarget(), "lanai", "Lanai", "Lanai"); } diff --git a/llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp b/llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp --- a/llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp +++ b/llvm/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp @@ -529,7 +529,7 @@ return (parseMany(parseOne)); } -extern "C" void LLVMInitializeMSP430AsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430AsmParser() { RegisterMCAsmParser X(getTheMSP430Target()); } diff --git a/llvm/lib/Target/MSP430/Disassembler/MSP430Disassembler.cpp b/llvm/lib/Target/MSP430/Disassembler/MSP430Disassembler.cpp --- a/llvm/lib/Target/MSP430/Disassembler/MSP430Disassembler.cpp +++ b/llvm/lib/Target/MSP430/Disassembler/MSP430Disassembler.cpp @@ -62,7 +62,7 @@ return new MSP430Disassembler(STI, Ctx); } -extern "C" void LLVMInitializeMSP430Disassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430Disassembler() { TargetRegistry::RegisterMCDisassembler(getTheMSP430Target(), createMSP430Disassembler); } diff --git a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCTargetDesc.cpp b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCTargetDesc.cpp --- a/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCTargetDesc.cpp +++ b/llvm/lib/Target/MSP430/MCTargetDesc/MSP430MCTargetDesc.cpp @@ -57,7 +57,7 @@ return nullptr; } -extern "C" void LLVMInitializeMSP430TargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430TargetMC() { Target &T = getTheMSP430Target(); RegisterMCAsmInfo X(T); diff --git a/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp b/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp --- a/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp +++ b/llvm/lib/Target/MSP430/MSP430AsmPrinter.cpp @@ -185,6 +185,6 @@ } // Force static initialization. -extern "C" void LLVMInitializeMSP430AsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430AsmPrinter() { RegisterAsmPrinter X(getTheMSP430Target()); } diff --git a/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp b/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp --- a/llvm/lib/Target/MSP430/MSP430TargetMachine.cpp +++ b/llvm/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/llvm/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp b/llvm/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp --- a/llvm/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp +++ b/llvm/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp @@ -15,7 +15,7 @@ return TheMSP430Target; } -extern "C" void LLVMInitializeMSP430TargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430TargetInfo() { RegisterTarget X(getTheMSP430Target(), "msp430", "MSP430 [experimental]", "MSP430"); } diff --git a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp --- a/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ b/llvm/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -8643,7 +8643,7 @@ 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/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp b/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp --- a/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp +++ b/llvm/lib/Target/Mips/Disassembler/MipsDisassembler.cpp @@ -564,7 +564,7 @@ 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/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp --- a/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp +++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp @@ -166,7 +166,7 @@ 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/llvm/lib/Target/Mips/MipsAsmPrinter.cpp b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp --- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp +++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp @@ -1306,7 +1306,7 @@ } // 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/llvm/lib/Target/Mips/MipsTargetMachine.cpp b/llvm/lib/Target/Mips/MipsTargetMachine.cpp --- a/llvm/lib/Target/Mips/MipsTargetMachine.cpp +++ b/llvm/lib/Target/Mips/MipsTargetMachine.cpp @@ -45,7 +45,7 @@ #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/llvm/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp b/llvm/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp --- a/llvm/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp +++ b/llvm/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp @@ -27,7 +27,7 @@ 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/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp --- a/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp +++ b/llvm/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp @@ -66,7 +66,7 @@ } // 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/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp --- a/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -2258,7 +2258,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeNVPTXAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeNVPTXAsmPrinter() { RegisterAsmPrinter X(getTheNVPTXTarget32()); RegisterAsmPrinter Y(getTheNVPTXTarget64()); } diff --git a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp --- a/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp +++ b/llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp @@ -72,7 +72,7 @@ } // 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/llvm/lib/Target/NVPTX/TargetInfo/NVPTXTargetInfo.cpp b/llvm/lib/Target/NVPTX/TargetInfo/NVPTXTargetInfo.cpp --- a/llvm/lib/Target/NVPTX/TargetInfo/NVPTXTargetInfo.cpp +++ b/llvm/lib/Target/NVPTX/TargetInfo/NVPTXTargetInfo.cpp @@ -19,7 +19,7 @@ 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/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp --- a/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp +++ b/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp @@ -1786,7 +1786,7 @@ /// 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/llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp b/llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp --- a/llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp +++ b/llvm/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp @@ -51,7 +51,7 @@ 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/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp --- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp +++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp @@ -294,7 +294,7 @@ 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/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -1936,7 +1936,7 @@ } // Force static initialization. -extern "C" void LLVMInitializePowerPCAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCAsmPrinter() { TargetRegistry::RegisterAsmPrinter(getThePPC32Target(), createPPCAsmPrinterPass); TargetRegistry::RegisterAsmPrinter(getThePPC64Target(), diff --git a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp --- a/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp +++ b/llvm/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -94,7 +94,7 @@ ReduceCRLogical("ppc-reduce-cr-logicals", cl::desc("Expand eligible cr-logical binary ops to branches"), cl::init(true), 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/llvm/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp b/llvm/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp --- a/llvm/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp +++ b/llvm/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp @@ -23,7 +23,7 @@ return ThePPC64LETarget; } -extern "C" void LLVMInitializePowerPCTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCTargetInfo() { RegisterTarget X(getThePPC32Target(), "ppc32", "PowerPC 32", "PPC"); diff --git a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp --- a/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ b/llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -1859,7 +1859,7 @@ return false; } -extern "C" void LLVMInitializeRISCVAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVAsmParser() { RegisterMCAsmParser X(getTheRISCV32Target()); RegisterMCAsmParser Y(getTheRISCV64Target()); } diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp --- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp +++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp @@ -49,7 +49,7 @@ 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/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp --- a/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp +++ b/llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp @@ -93,7 +93,7 @@ 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/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp b/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp --- a/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp +++ b/llvm/lib/Target/RISCV/RISCVAsmPrinter.cpp @@ -141,7 +141,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeRISCVAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVAsmPrinter() { RegisterAsmPrinter X(getTheRISCV32Target()); RegisterAsmPrinter Y(getTheRISCV64Target()); } diff --git a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp --- a/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp +++ b/llvm/lib/Target/RISCV/RISCVTargetMachine.cpp @@ -31,7 +31,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/llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp b/llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp --- a/llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp +++ b/llvm/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp @@ -20,7 +20,7 @@ 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/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp b/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp --- a/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp +++ b/llvm/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp @@ -1308,7 +1308,7 @@ 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/llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp b/llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp --- a/llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp +++ b/llvm/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp @@ -48,7 +48,7 @@ } -extern "C" void LLVMInitializeSparcDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSparcDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheSparcTarget(), createSparcDisassembler); diff --git a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp --- a/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp +++ b/llvm/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp @@ -91,7 +91,7 @@ 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/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp --- a/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp +++ b/llvm/lib/Target/Sparc/SparcAsmPrinter.cpp @@ -439,7 +439,7 @@ } // 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/llvm/lib/Target/Sparc/SparcTargetMachine.cpp b/llvm/lib/Target/Sparc/SparcTargetMachine.cpp --- a/llvm/lib/Target/Sparc/SparcTargetMachine.cpp +++ b/llvm/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/llvm/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp b/llvm/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp --- a/llvm/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp +++ b/llvm/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp @@ -23,7 +23,7 @@ return TheSparcelTarget; } -extern "C" void LLVMInitializeSparcTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSparcTargetInfo() { RegisterTarget X(getTheSparcTarget(), "sparc", "Sparc", "Sparc"); RegisterTarget Y( diff --git a/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp b/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp --- a/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp +++ b/llvm/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp @@ -1389,6 +1389,6 @@ } // Force static initialization. -extern "C" void LLVMInitializeSystemZAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZAsmParser() { RegisterMCAsmParser X(getTheSystemZTarget()); } diff --git a/llvm/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp b/llvm/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp --- a/llvm/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp +++ b/llvm/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp @@ -46,7 +46,7 @@ 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/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp --- a/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp +++ b/llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp @@ -183,7 +183,7 @@ 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/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp --- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp +++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp @@ -705,6 +705,6 @@ } // Force static initialization. -extern "C" void LLVMInitializeSystemZAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZAsmPrinter() { RegisterAsmPrinter X(getTheSystemZTarget()); } diff --git a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp b/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp --- a/llvm/lib/Target/SystemZ/SystemZTargetMachine.cpp +++ b/llvm/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/llvm/lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp b/llvm/lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp --- a/llvm/lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp +++ b/llvm/lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp @@ -16,7 +16,7 @@ return TheSystemZTarget; } -extern "C" void LLVMInitializeSystemZTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZTargetInfo() { RegisterTarget X( getTheSystemZTarget(), "systemz", "SystemZ", "SystemZ"); } diff --git a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp --- a/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp +++ b/llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp @@ -899,7 +899,7 @@ } // 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/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp b/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp --- a/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp +++ b/llvm/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp @@ -66,7 +66,7 @@ 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/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp --- a/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp +++ b/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp @@ -96,7 +96,7 @@ } // 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/llvm/lib/Target/WebAssembly/TargetInfo/WebAssemblyTargetInfo.cpp b/llvm/lib/Target/WebAssembly/TargetInfo/WebAssemblyTargetInfo.cpp --- a/llvm/lib/Target/WebAssembly/TargetInfo/WebAssemblyTargetInfo.cpp +++ b/llvm/lib/Target/WebAssembly/TargetInfo/WebAssemblyTargetInfo.cpp @@ -26,7 +26,7 @@ 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/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp --- a/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp @@ -425,7 +425,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeWebAssemblyAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyAsmPrinter() { RegisterAsmPrinter X(getTheWebAssemblyTarget32()); RegisterAsmPrinter Y(getTheWebAssemblyTarget64()); } diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp --- a/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -45,7 +45,7 @@ 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/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp --- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -3881,7 +3881,7 @@ } // 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/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp b/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp --- a/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp +++ b/llvm/lib/Target/X86/Disassembler/X86Disassembler.cpp @@ -844,7 +844,7 @@ 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/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp --- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp +++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp @@ -552,7 +552,7 @@ } // 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/llvm/lib/Target/X86/TargetInfo/X86TargetInfo.cpp b/llvm/lib/Target/X86/TargetInfo/X86TargetInfo.cpp --- a/llvm/lib/Target/X86/TargetInfo/X86TargetInfo.cpp +++ b/llvm/lib/Target/X86/TargetInfo/X86TargetInfo.cpp @@ -19,7 +19,7 @@ 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/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp --- a/llvm/lib/Target/X86/X86AsmPrinter.cpp +++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp @@ -728,7 +728,7 @@ //===----------------------------------------------------------------------===// // 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/llvm/lib/Target/X86/X86TargetMachine.cpp b/llvm/lib/Target/X86/X86TargetMachine.cpp --- a/llvm/lib/Target/X86/X86TargetMachine.cpp +++ b/llvm/lib/Target/X86/X86TargetMachine.cpp @@ -61,7 +61,7 @@ "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/llvm/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp b/llvm/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp --- a/llvm/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp +++ b/llvm/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp @@ -774,7 +774,7 @@ 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/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp b/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp --- a/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp +++ b/llvm/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp @@ -122,7 +122,7 @@ } // 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/llvm/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp b/llvm/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp --- a/llvm/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp +++ b/llvm/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp @@ -15,7 +15,7 @@ return TheXCoreTarget; } -extern "C" void LLVMInitializeXCoreTargetInfo() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXCoreTargetInfo() { RegisterTarget X(getTheXCoreTarget(), "xcore", "XCore", "XCore"); } diff --git a/llvm/lib/Target/XCore/XCoreAsmPrinter.cpp b/llvm/lib/Target/XCore/XCoreAsmPrinter.cpp --- a/llvm/lib/Target/XCore/XCoreAsmPrinter.cpp +++ b/llvm/lib/Target/XCore/XCoreAsmPrinter.cpp @@ -292,6 +292,6 @@ } // Force static initialization. -extern "C" void LLVMInitializeXCoreAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXCoreAsmPrinter() { RegisterAsmPrinter X(getTheXCoreTarget()); } diff --git a/llvm/lib/Target/XCore/XCoreTargetMachine.cpp b/llvm/lib/Target/XCore/XCoreTargetMachine.cpp --- a/llvm/lib/Target/XCore/XCoreTargetMachine.cpp +++ b/llvm/lib/Target/XCore/XCoreTargetMachine.cpp @@ -105,7 +105,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeXCoreTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXCoreTarget() { RegisterTargetMachine X(getTheXCoreTarget()); } diff --git a/llvm/unittests/CMakeLists.txt b/llvm/unittests/CMakeLists.txt --- a/llvm/unittests/CMakeLists.txt +++ b/llvm/unittests/CMakeLists.txt @@ -8,6 +8,12 @@ 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/llvm/unittests/Target/AArch64/CMakeLists.txt b/llvm/unittests/Target/AArch64/CMakeLists.txt --- a/llvm/unittests/Target/AArch64/CMakeLists.txt +++ b/llvm/unittests/Target/AArch64/CMakeLists.txt @@ -17,7 +17,7 @@ Target ) -add_llvm_unittest(AArch64Tests +add_llvm_target_unittest(AArch64Tests InstSizes.cpp TestStackOffset.cpp ) diff --git a/llvm/unittests/Target/ARM/CMakeLists.txt b/llvm/unittests/Target/ARM/CMakeLists.txt --- a/llvm/unittests/Target/ARM/CMakeLists.txt +++ b/llvm/unittests/Target/ARM/CMakeLists.txt @@ -15,6 +15,6 @@ Target ) -add_llvm_unittest(ARMTests +add_llvm_target_unittest(ARMTests MachineInstrTest.cpp ) diff --git a/llvm/unittests/Target/WebAssembly/CMakeLists.txt b/llvm/unittests/Target/WebAssembly/CMakeLists.txt --- a/llvm/unittests/Target/WebAssembly/CMakeLists.txt +++ b/llvm/unittests/Target/WebAssembly/CMakeLists.txt @@ -13,6 +13,6 @@ WebAssemblyInfo ) -add_llvm_unittest(WebAssemblyTests +add_llvm_target_unittest(WebAssemblyTests WebAssemblyExceptionInfoTest.cpp ) diff --git a/llvm/unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt b/llvm/unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt --- a/llvm/unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt +++ b/llvm/unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt @@ -13,7 +13,7 @@ AArch64 ) -add_llvm_unittest(LLVMExegesisAArch64Tests +add_llvm_target_unittest(LLVMExegesisAArch64Tests TargetTest.cpp ) target_link_libraries(LLVMExegesisAArch64Tests PRIVATE diff --git a/llvm/unittests/tools/llvm-exegesis/ARM/CMakeLists.txt b/llvm/unittests/tools/llvm-exegesis/ARM/CMakeLists.txt --- a/llvm/unittests/tools/llvm-exegesis/ARM/CMakeLists.txt +++ b/llvm/unittests/tools/llvm-exegesis/ARM/CMakeLists.txt @@ -13,7 +13,7 @@ ARM ) -add_llvm_unittest(LLVMExegesisARMTests +add_llvm_target_unittest(LLVMExegesisARMTests AssemblerTest.cpp ) target_link_libraries(LLVMExegesisARMTests PRIVATE LLVMExegesis) diff --git a/llvm/unittests/tools/llvm-exegesis/Mips/CMakeLists.txt b/llvm/unittests/tools/llvm-exegesis/Mips/CMakeLists.txt --- a/llvm/unittests/tools/llvm-exegesis/Mips/CMakeLists.txt +++ b/llvm/unittests/tools/llvm-exegesis/Mips/CMakeLists.txt @@ -13,7 +13,7 @@ Mips ) -add_llvm_unittest(LLVMExegesisMipsTests +add_llvm_target_unittest(LLVMExegesisMipsTests BenchmarkResultTest.cpp TargetTest.cpp ) diff --git a/llvm/unittests/tools/llvm-exegesis/PowerPC/CMakeLists.txt b/llvm/unittests/tools/llvm-exegesis/PowerPC/CMakeLists.txt --- a/llvm/unittests/tools/llvm-exegesis/PowerPC/CMakeLists.txt +++ b/llvm/unittests/tools/llvm-exegesis/PowerPC/CMakeLists.txt @@ -13,7 +13,7 @@ PowerPC ) -add_llvm_unittest(LLVMExegesisPowerPCTests +add_llvm_target_unittest(LLVMExegesisPowerPCTests AnalysisTest.cpp TargetTest.cpp ) diff --git a/llvm/unittests/tools/llvm-exegesis/X86/CMakeLists.txt b/llvm/unittests/tools/llvm-exegesis/X86/CMakeLists.txt --- a/llvm/unittests/tools/llvm-exegesis/X86/CMakeLists.txt +++ b/llvm/unittests/tools/llvm-exegesis/X86/CMakeLists.txt @@ -13,7 +13,7 @@ X86 ) -add_llvm_unittest(LLVMExegesisX86Tests +add_llvm_target_unittest(LLVMExegesisX86Tests AssemblerTest.cpp BenchmarkResultTest.cpp RegisterAliasingTest.cpp diff --git a/llvm/utils/unittest/CMakeLists.txt b/llvm/utils/unittest/CMakeLists.txt --- a/llvm/utils/unittest/CMakeLists.txt +++ b/llvm/utils/unittest/CMakeLists.txt @@ -71,3 +71,23 @@ ) 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)