Index: llvm/trunk/include/llvm/Support/Compiler.h =================================================================== --- llvm/trunk/include/llvm/Support/Compiler.h +++ llvm/trunk/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__) Index: llvm/trunk/lib/Target/AArch64/AArch64AsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/AArch64/AArch64AsmPrinter.cpp +++ llvm/trunk/lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -1129,7 +1129,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeAArch64AsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAArch64AsmPrinter() { RegisterAsmPrinter X(getTheAArch64leTarget()); RegisterAsmPrinter Y(getTheAArch64beTarget()); RegisterAsmPrinter Z(getTheARM64Target()); Index: llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp +++ llvm/trunk/lib/Target/AArch64/AArch64TargetMachine.cpp @@ -152,7 +152,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()); Index: llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -5514,7 +5514,7 @@ } /// Force static initialization. -extern "C" void LLVMInitializeAArch64AsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAArch64AsmParser() { RegisterMCAsmParser X(getTheAArch64leTarget()); RegisterMCAsmParser Y(getTheAArch64beTarget()); RegisterMCAsmParser Z(getTheARM64Target()); Index: llvm/trunk/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp =================================================================== --- llvm/trunk/lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp +++ llvm/trunk/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(), Index: llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp +++ llvm/trunk/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp @@ -365,7 +365,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()}) { Index: llvm/trunk/lib/Target/AArch64/TargetInfo/AArch64TargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/AArch64/TargetInfo/AArch64TargetInfo.cpp +++ llvm/trunk/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", Index: llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp +++ llvm/trunk/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp @@ -91,7 +91,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(), Index: llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -182,7 +182,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()); Index: llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ llvm/trunk/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -6404,7 +6404,7 @@ } /// Force static initialization. -extern "C" void LLVMInitializeAMDGPUAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeAMDGPUAsmParser() { RegisterMCAsmParser A(getTheAMDGPUTarget()); RegisterMCAsmParser B(getTheGCNTarget()); } Index: llvm/trunk/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp =================================================================== --- llvm/trunk/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp +++ llvm/trunk/lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp @@ -1091,7 +1091,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(), Index: llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp +++ llvm/trunk/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); Index: llvm/trunk/lib/Target/AMDGPU/TargetInfo/AMDGPUTargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/AMDGPU/TargetInfo/AMDGPUTargetInfo.cpp +++ llvm/trunk/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", Index: llvm/trunk/lib/Target/ARC/ARCAsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/ARC/ARCAsmPrinter.cpp +++ llvm/trunk/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()); } Index: llvm/trunk/lib/Target/ARC/ARCTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/ARC/ARCTargetMachine.cpp +++ llvm/trunk/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()); } Index: llvm/trunk/lib/Target/ARC/Disassembler/ARCDisassembler.cpp =================================================================== --- llvm/trunk/lib/Target/ARC/Disassembler/ARCDisassembler.cpp +++ llvm/trunk/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); Index: llvm/trunk/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp +++ llvm/trunk/lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp @@ -81,7 +81,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); Index: llvm/trunk/lib/Target/ARC/TargetInfo/ARCTargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/ARC/TargetInfo/ARCTargetInfo.cpp +++ llvm/trunk/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"); } Index: llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp +++ llvm/trunk/lib/Target/ARM/ARMAsmPrinter.cpp @@ -2066,7 +2066,7 @@ //===----------------------------------------------------------------------===// // Force static initialization. -extern "C" void LLVMInitializeARMAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARMAsmPrinter() { RegisterAsmPrinter X(getTheARMLETarget()); RegisterAsmPrinter Y(getTheARMBETarget()); RegisterAsmPrinter A(getTheThumbLETarget()); Index: llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp +++ llvm/trunk/lib/Target/ARM/ARMTargetMachine.cpp @@ -78,7 +78,7 @@ void initializeARMExecutionDomainFixPass(PassRegistry&); } -extern "C" void LLVMInitializeARMTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARMTarget() { // Register the target. RegisterTargetMachine X(getTheARMLETarget()); RegisterTargetMachine A(getTheThumbLETarget()); Index: llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ llvm/trunk/lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -10390,7 +10390,7 @@ } /// Force static initialization. -extern "C" void LLVMInitializeARMAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARMAsmParser() { RegisterMCAsmParser X(getTheARMLETarget()); RegisterMCAsmParser Y(getTheARMBETarget()); RegisterMCAsmParser A(getTheThumbLETarget()); Index: llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp =================================================================== --- llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp +++ llvm/trunk/lib/Target/ARM/Disassembler/ARMDisassembler.cpp @@ -874,7 +874,7 @@ return MCDisassembler::Fail; } -extern "C" void LLVMInitializeARMDisassembler() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeARMDisassembler() { TargetRegistry::RegisterMCDisassembler(getTheARMLETarget(), createARMDisassembler); TargetRegistry::RegisterMCDisassembler(getTheARMBETarget(), Index: llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp +++ llvm/trunk/lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp @@ -300,7 +300,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. Index: llvm/trunk/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp +++ llvm/trunk/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", Index: llvm/trunk/lib/Target/AVR/AVRAsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/AVR/AVRAsmPrinter.cpp +++ llvm/trunk/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()); } Index: llvm/trunk/lib/Target/AVR/AVRTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/AVR/AVRTargetMachine.cpp +++ llvm/trunk/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()); Index: llvm/trunk/lib/Target/AVR/AsmParser/AVRAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/AVR/AsmParser/AVRAsmParser.cpp +++ llvm/trunk/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()); } Index: llvm/trunk/lib/Target/AVR/Disassembler/AVRDisassembler.cpp =================================================================== --- llvm/trunk/lib/Target/AVR/Disassembler/AVRDisassembler.cpp +++ llvm/trunk/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); Index: llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp +++ llvm/trunk/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()); Index: llvm/trunk/lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp +++ llvm/trunk/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"); } Index: llvm/trunk/lib/Target/BPF/AsmParser/BPFAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/BPF/AsmParser/BPFAsmParser.cpp +++ llvm/trunk/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()); Index: llvm/trunk/lib/Target/BPF/BPFAsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/BPF/BPFAsmPrinter.cpp +++ llvm/trunk/lib/Target/BPF/BPFAsmPrinter.cpp @@ -142,7 +142,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeBPFAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeBPFAsmPrinter() { RegisterAsmPrinter X(getTheBPFleTarget()); RegisterAsmPrinter Y(getTheBPFbeTarget()); RegisterAsmPrinter Z(getTheBPFTarget()); Index: llvm/trunk/lib/Target/BPF/BPFTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/BPF/BPFTargetMachine.cpp +++ llvm/trunk/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()); Index: llvm/trunk/lib/Target/BPF/Disassembler/BPFDisassembler.cpp =================================================================== --- llvm/trunk/lib/Target/BPF/Disassembler/BPFDisassembler.cpp +++ llvm/trunk/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); Index: llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp +++ llvm/trunk/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. Index: llvm/trunk/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp +++ llvm/trunk/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); Index: llvm/trunk/lib/Target/CMakeLists.txt =================================================================== --- llvm/trunk/lib/Target/CMakeLists.txt +++ llvm/trunk/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) + # 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}) Index: llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp +++ llvm/trunk/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()); } Index: llvm/trunk/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp =================================================================== --- llvm/trunk/lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp +++ llvm/trunk/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); } Index: llvm/trunk/lib/Target/Hexagon/HexagonAsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/Hexagon/HexagonAsmPrinter.cpp +++ llvm/trunk/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()); } Index: llvm/trunk/lib/Target/Hexagon/HexagonTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/Hexagon/HexagonTargetMachine.cpp +++ llvm/trunk/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()); Index: llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp +++ llvm/trunk/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp @@ -456,7 +456,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeHexagonTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeHexagonTargetMC() { // Register the MC asm info. RegisterMCAsmInfoFn X(getTheHexagonTarget(), createHexagonMCAsmInfo); Index: llvm/trunk/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp +++ llvm/trunk/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"); } Index: llvm/trunk/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp +++ llvm/trunk/lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp @@ -1223,6 +1223,6 @@ #define GET_MATCHER_IMPLEMENTATION #include "LanaiGenAsmMatcher.inc" -extern "C" void LLVMInitializeLanaiAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeLanaiAsmParser() { RegisterMCAsmParser x(getTheLanaiTarget()); } Index: llvm/trunk/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp =================================================================== --- llvm/trunk/lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp +++ llvm/trunk/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); Index: llvm/trunk/lib/Target/Lanai/LanaiAsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/Lanai/LanaiAsmPrinter.cpp +++ llvm/trunk/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()); } Index: llvm/trunk/lib/Target/Lanai/LanaiTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/Lanai/LanaiTargetMachine.cpp +++ llvm/trunk/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()); Index: llvm/trunk/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp +++ llvm/trunk/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()); Index: llvm/trunk/lib/Target/Lanai/TargetInfo/LanaiTargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/Lanai/TargetInfo/LanaiTargetInfo.cpp +++ llvm/trunk/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"); } Index: llvm/trunk/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/MSP430/AsmParser/MSP430AsmParser.cpp +++ llvm/trunk/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()); } Index: llvm/trunk/lib/Target/MSP430/Disassembler/MSP430Disassembler.cpp =================================================================== --- llvm/trunk/lib/Target/MSP430/Disassembler/MSP430Disassembler.cpp +++ llvm/trunk/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); } Index: llvm/trunk/lib/Target/MSP430/MCTargetDesc/MSP430MCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/MSP430/MCTargetDesc/MSP430MCTargetDesc.cpp +++ llvm/trunk/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); Index: llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp +++ llvm/trunk/lib/Target/MSP430/MSP430AsmPrinter.cpp @@ -183,6 +183,6 @@ } // Force static initialization. -extern "C" void LLVMInitializeMSP430AsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMSP430AsmPrinter() { RegisterAsmPrinter X(getTheMSP430Target()); } Index: llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/MSP430/MSP430TargetMachine.cpp +++ llvm/trunk/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()); } Index: llvm/trunk/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp +++ llvm/trunk/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"); } Index: llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -8190,7 +8190,7 @@ return false; } -extern "C" void LLVMInitializeMipsAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsAsmParser() { RegisterMCAsmParser X(getTheMipsTarget()); RegisterMCAsmParser Y(getTheMipselTarget()); RegisterMCAsmParser A(getTheMips64Target()); Index: llvm/trunk/lib/Target/Mips/Disassembler/MipsDisassembler.cpp =================================================================== --- llvm/trunk/lib/Target/Mips/Disassembler/MipsDisassembler.cpp +++ llvm/trunk/lib/Target/Mips/Disassembler/MipsDisassembler.cpp @@ -555,7 +555,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); Index: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp +++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp @@ -162,7 +162,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. Index: llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp +++ llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp @@ -1296,7 +1296,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeMipsAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeMipsAsmPrinter() { RegisterAsmPrinter X(getTheMipsTarget()); RegisterAsmPrinter Y(getTheMipselTarget()); RegisterAsmPrinter A(getTheMips64Target()); Index: llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp +++ llvm/trunk/lib/Target/Mips/MipsTargetMachine.cpp @@ -44,7 +44,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()); Index: llvm/trunk/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp +++ llvm/trunk/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"); Index: llvm/trunk/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp +++ llvm/trunk/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); Index: llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ llvm/trunk/lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -2260,7 +2260,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeNVPTXAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeNVPTXAsmPrinter() { RegisterAsmPrinter X(getTheNVPTXTarget32()); RegisterAsmPrinter Y(getTheNVPTXTarget64()); } Index: llvm/trunk/lib/Target/NVPTX/NVPTXTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/NVPTX/NVPTXTargetMachine.cpp +++ llvm/trunk/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()); Index: llvm/trunk/lib/Target/NVPTX/TargetInfo/NVPTXTargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/NVPTX/TargetInfo/NVPTXTargetInfo.cpp +++ llvm/trunk/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", Index: llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp +++ llvm/trunk/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()); Index: llvm/trunk/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp =================================================================== --- llvm/trunk/lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp +++ llvm/trunk/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); Index: llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp +++ llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp @@ -260,7 +260,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. Index: llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -1651,7 +1651,7 @@ } // Force static initialization. -extern "C" void LLVMInitializePowerPCAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCAsmPrinter() { TargetRegistry::RegisterAsmPrinter(getThePPC32Target(), createPPCAsmPrinterPass); TargetRegistry::RegisterAsmPrinter(getThePPC64Target(), Index: llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/PowerPC/PPCTargetMachine.cpp +++ llvm/trunk/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(false), cl::Hidden); -extern "C" void LLVMInitializePowerPCTarget() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializePowerPCTarget() { // Register the targets RegisterTargetMachine A(getThePPC32Target()); RegisterTargetMachine B(getThePPC64Target()); Index: llvm/trunk/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp +++ llvm/trunk/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"); Index: llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ llvm/trunk/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -1754,7 +1754,7 @@ return false; } -extern "C" void LLVMInitializeRISCVAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVAsmParser() { RegisterMCAsmParser X(getTheRISCV32Target()); RegisterMCAsmParser Y(getTheRISCV64Target()); } Index: llvm/trunk/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp =================================================================== --- llvm/trunk/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp +++ llvm/trunk/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp @@ -48,7 +48,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); Index: llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp +++ llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp @@ -84,7 +84,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); Index: llvm/trunk/lib/Target/RISCV/RISCVAsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/RISCV/RISCVAsmPrinter.cpp +++ llvm/trunk/lib/Target/RISCV/RISCVAsmPrinter.cpp @@ -123,7 +123,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeRISCVAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVAsmPrinter() { RegisterAsmPrinter X(getTheRISCV32Target()); RegisterAsmPrinter Y(getTheRISCV64Target()); } Index: llvm/trunk/lib/Target/RISCV/RISCVTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/RISCV/RISCVTargetMachine.cpp +++ llvm/trunk/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(); Index: llvm/trunk/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp +++ llvm/trunk/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", Index: llvm/trunk/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp +++ llvm/trunk/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()); Index: llvm/trunk/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp =================================================================== --- llvm/trunk/lib/Target/Sparc/Disassembler/SparcDisassembler.cpp +++ llvm/trunk/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); Index: llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp +++ llvm/trunk/lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp @@ -89,7 +89,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); Index: llvm/trunk/lib/Target/Sparc/SparcAsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/Sparc/SparcAsmPrinter.cpp +++ llvm/trunk/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()); Index: llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/Sparc/SparcTargetMachine.cpp +++ llvm/trunk/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()); Index: llvm/trunk/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp +++ llvm/trunk/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( Index: llvm/trunk/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp +++ llvm/trunk/lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp @@ -1371,6 +1371,6 @@ } // Force static initialization. -extern "C" void LLVMInitializeSystemZAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZAsmParser() { RegisterMCAsmParser X(getTheSystemZTarget()); } Index: llvm/trunk/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp =================================================================== --- llvm/trunk/lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp +++ llvm/trunk/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); Index: llvm/trunk/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp +++ llvm/trunk/lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp @@ -182,7 +182,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); Index: llvm/trunk/lib/Target/SystemZ/SystemZAsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZAsmPrinter.cpp +++ llvm/trunk/lib/Target/SystemZ/SystemZAsmPrinter.cpp @@ -644,6 +644,6 @@ } // Force static initialization. -extern "C" void LLVMInitializeSystemZAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSystemZAsmPrinter() { RegisterAsmPrinter X(getTheSystemZTarget()); } Index: llvm/trunk/lib/Target/SystemZ/SystemZTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/SystemZ/SystemZTargetMachine.cpp +++ llvm/trunk/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()); } Index: llvm/trunk/lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp +++ llvm/trunk/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"); } Index: llvm/trunk/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp +++ llvm/trunk/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp @@ -764,7 +764,7 @@ } // end anonymous namespace // Force static initialization. -extern "C" void LLVMInitializeWebAssemblyAsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyAsmParser() { RegisterMCAsmParser X(getTheWebAssemblyTarget32()); RegisterMCAsmParser Y(getTheWebAssemblyTarget64()); } Index: llvm/trunk/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp +++ llvm/trunk/lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp @@ -65,7 +65,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); Index: llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp +++ llvm/trunk/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp @@ -95,7 +95,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. Index: llvm/trunk/lib/Target/WebAssembly/TargetInfo/WebAssemblyTargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/TargetInfo/WebAssemblyTargetInfo.cpp +++ llvm/trunk/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", Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp +++ llvm/trunk/lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp @@ -443,7 +443,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeWebAssemblyAsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyAsmPrinter() { RegisterAsmPrinter X(getTheWebAssemblyTarget32()); RegisterAsmPrinter Y(getTheWebAssemblyTarget64()); } Index: llvm/trunk/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ llvm/trunk/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()); Index: llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp =================================================================== --- llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp +++ llvm/trunk/lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -3709,7 +3709,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeX86AsmParser() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeX86AsmParser() { RegisterMCAsmParser X(getTheX86_32Target()); RegisterMCAsmParser Y(getTheX86_64Target()); } Index: llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp =================================================================== --- llvm/trunk/lib/Target/X86/Disassembler/X86Disassembler.cpp +++ llvm/trunk/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); Index: llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp +++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp @@ -523,7 +523,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); Index: llvm/trunk/lib/Target/X86/TargetInfo/X86TargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/X86/TargetInfo/X86TargetInfo.cpp +++ llvm/trunk/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"); Index: llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp +++ llvm/trunk/lib/Target/X86/X86AsmPrinter.cpp @@ -727,7 +727,7 @@ //===----------------------------------------------------------------------===// // Force static initialization. -extern "C" void LLVMInitializeX86AsmPrinter() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeX86AsmPrinter() { RegisterAsmPrinter X(getTheX86_32Target()); RegisterAsmPrinter Y(getTheX86_64Target()); } Index: llvm/trunk/lib/Target/X86/X86TargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/X86/X86TargetMachine.cpp +++ llvm/trunk/lib/Target/X86/X86TargetMachine.cpp @@ -60,7 +60,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()); Index: llvm/trunk/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp =================================================================== --- llvm/trunk/lib/Target/XCore/Disassembler/XCoreDisassembler.cpp +++ llvm/trunk/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); Index: llvm/trunk/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp =================================================================== --- llvm/trunk/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp +++ llvm/trunk/lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp @@ -121,7 +121,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeXCoreTargetMC() { +extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXCoreTargetMC() { // Register the MC asm info. RegisterMCAsmInfoFn X(getTheXCoreTarget(), createXCoreMCAsmInfo); Index: llvm/trunk/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp =================================================================== --- llvm/trunk/lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp +++ llvm/trunk/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"); } Index: llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp =================================================================== --- llvm/trunk/lib/Target/XCore/XCoreAsmPrinter.cpp +++ llvm/trunk/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()); } Index: llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp =================================================================== --- llvm/trunk/lib/Target/XCore/XCoreTargetMachine.cpp +++ llvm/trunk/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()); } Index: llvm/trunk/unittests/CMakeLists.txt =================================================================== --- llvm/trunk/unittests/CMakeLists.txt +++ llvm/trunk/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) Index: llvm/trunk/unittests/Target/AArch64/CMakeLists.txt =================================================================== --- llvm/trunk/unittests/Target/AArch64/CMakeLists.txt +++ llvm/trunk/unittests/Target/AArch64/CMakeLists.txt @@ -17,6 +17,6 @@ Target ) -add_llvm_unittest(AArch64Tests +add_llvm_target_unittest(AArch64Tests InstSizes.cpp ) Index: llvm/trunk/unittests/Target/WebAssembly/CMakeLists.txt =================================================================== --- llvm/trunk/unittests/Target/WebAssembly/CMakeLists.txt +++ llvm/trunk/unittests/Target/WebAssembly/CMakeLists.txt @@ -13,6 +13,6 @@ WebAssemblyInfo ) -add_llvm_unittest(WebAssemblyTests +add_llvm_target_unittest(WebAssemblyTests WebAssemblyExceptionInfoTest.cpp ) Index: llvm/trunk/unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt =================================================================== --- llvm/trunk/unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt +++ llvm/trunk/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 Index: llvm/trunk/unittests/tools/llvm-exegesis/ARM/CMakeLists.txt =================================================================== --- llvm/trunk/unittests/tools/llvm-exegesis/ARM/CMakeLists.txt +++ llvm/trunk/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) Index: llvm/trunk/unittests/tools/llvm-exegesis/PowerPC/CMakeLists.txt =================================================================== --- llvm/trunk/unittests/tools/llvm-exegesis/PowerPC/CMakeLists.txt +++ llvm/trunk/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 ) Index: llvm/trunk/unittests/tools/llvm-exegesis/X86/CMakeLists.txt =================================================================== --- llvm/trunk/unittests/tools/llvm-exegesis/X86/CMakeLists.txt +++ llvm/trunk/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 Index: llvm/trunk/utils/unittest/CMakeLists.txt =================================================================== --- llvm/trunk/utils/unittest/CMakeLists.txt +++ llvm/trunk/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)