Index: include/llvm/Support/Compiler.h =================================================================== --- include/llvm/Support/Compiler.h +++ include/llvm/Support/Compiler.h @@ -104,8 +104,10 @@ #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_EXPORT __attribute__ ((visibility("default"))) #else #define LLVM_LIBRARY_VISIBILITY +#define LLVM_EXPORT #endif #if defined(__GNUC__) Index: lib/Target/AArch64/AArch64AsmPrinter.cpp =================================================================== --- lib/Target/AArch64/AArch64AsmPrinter.cpp +++ lib/Target/AArch64/AArch64AsmPrinter.cpp @@ -923,7 +923,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeAArch64AsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeAArch64AsmPrinter() { RegisterAsmPrinter X(getTheAArch64leTarget()); RegisterAsmPrinter Y(getTheAArch64beTarget()); RegisterAsmPrinter Z(getTheARM64Target()); Index: lib/Target/AArch64/AArch64TargetMachine.cpp =================================================================== --- lib/Target/AArch64/AArch64TargetMachine.cpp +++ lib/Target/AArch64/AArch64TargetMachine.cpp @@ -151,7 +151,7 @@ cl::desc("Enable the AAcrh64 branch target pass"), cl::init(true)); -extern "C" void LLVMInitializeAArch64Target() { +extern "C" LLVM_EXPORT void LLVMInitializeAArch64Target() { // Register the target. RegisterTargetMachine X(getTheAArch64leTarget()); RegisterTargetMachine Y(getTheAArch64beTarget()); Index: lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp =================================================================== --- lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp +++ lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp @@ -5436,7 +5436,7 @@ } /// Force static initialization. -extern "C" void LLVMInitializeAArch64AsmParser() { +extern "C" LLVM_EXPORT void LLVMInitializeAArch64AsmParser() { RegisterMCAsmParser X(getTheAArch64leTarget()); RegisterMCAsmParser Y(getTheAArch64beTarget()); RegisterMCAsmParser Z(getTheARM64Target()); Index: lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp =================================================================== --- lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp +++ lib/Target/AArch64/Disassembler/AArch64Disassembler.cpp @@ -283,7 +283,7 @@ SymbolLookUp, DisInfo); } -extern "C" void LLVMInitializeAArch64Disassembler() { +extern "C" LLVM_EXPORT void LLVMInitializeAArch64Disassembler() { TargetRegistry::RegisterMCDisassembler(getTheAArch64leTarget(), createAArch64Disassembler); TargetRegistry::RegisterMCDisassembler(getTheAArch64beTarget(), Index: lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp =================================================================== --- lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp +++ lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp @@ -188,7 +188,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeAArch64TargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeAArch64TargetMC() { for (Target *T : {&getTheAArch64leTarget(), &getTheAArch64beTarget(), &getTheARM64Target()}) { // Register the MC asm info. Index: lib/Target/AArch64/TargetInfo/AArch64TargetInfo.cpp =================================================================== --- lib/Target/AArch64/TargetInfo/AArch64TargetInfo.cpp +++ lib/Target/AArch64/TargetInfo/AArch64TargetInfo.cpp @@ -25,7 +25,7 @@ } } // namespace llvm -extern "C" void LLVMInitializeAArch64TargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeAArch64TargetInfo() { // Now register the "arm64" name for use with "-march". We don't want it to // take possession of the Triple::aarch64 tag though. TargetRegistry::RegisterTarget(getTheARM64Target(), "arm64", Index: lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp +++ lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp @@ -89,7 +89,7 @@ return new AMDGPUAsmPrinter(tm, std::move(Streamer)); } -extern "C" void LLVMInitializeAMDGPUAsmPrinter() { +extern "C" void LLVM_EXPORT LLVMInitializeAMDGPUAsmPrinter() { TargetRegistry::RegisterAsmPrinter(getTheAMDGPUTarget(), llvm::createR600AsmPrinterPass); TargetRegistry::RegisterAsmPrinter(getTheGCNTarget(), Index: lib/Target/AMDGPU/AMDGPUTargetMachine.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -145,7 +145,7 @@ cl::init(false), cl::Hidden); -extern "C" void LLVMInitializeAMDGPUTarget() { +extern "C" LLVM_EXPORT void LLVMInitializeAMDGPUTarget() { // Register the target RegisterTargetMachine X(getTheAMDGPUTarget()); RegisterTargetMachine Y(getTheGCNTarget()); Index: lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp =================================================================== --- lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp +++ lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp @@ -5476,7 +5476,7 @@ } /// Force static initialization. -extern "C" void LLVMInitializeAMDGPUAsmParser() { +extern "C" LLVM_EXPORT void LLVMInitializeAMDGPUAsmParser() { RegisterMCAsmParser A(getTheAMDGPUTarget()); RegisterMCAsmParser B(getTheGCNTarget()); } Index: lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp =================================================================== --- lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp +++ lib/Target/AMDGPU/Disassembler/AMDGPUDisassembler.cpp @@ -937,7 +937,7 @@ return new AMDGPUDisassembler(STI, Ctx, T.createMCInstrInfo()); } -extern "C" void LLVMInitializeAMDGPUDisassembler() { +extern "C" LLVM_EXPORT void LLVMInitializeAMDGPUDisassembler() { TargetRegistry::RegisterMCDisassembler(getTheGCNTarget(), createAMDGPUDisassembler); TargetRegistry::RegisterMCSymbolizer(getTheGCNTarget(), Index: lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp =================================================================== --- lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp +++ lib/Target/AMDGPU/MCTargetDesc/AMDGPUMCTargetDesc.cpp @@ -104,7 +104,7 @@ std::move(Emitter), RelaxAll); } -extern "C" void LLVMInitializeAMDGPUTargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeAMDGPUTargetMC() { TargetRegistry::RegisterMCInstrInfo(getTheGCNTarget(), createAMDGPUMCInstrInfo); TargetRegistry::RegisterMCInstrInfo(getTheAMDGPUTarget(), createR600MCInstrInfo); Index: lib/Target/AMDGPU/TargetInfo/AMDGPUTargetInfo.cpp =================================================================== --- lib/Target/AMDGPU/TargetInfo/AMDGPUTargetInfo.cpp +++ lib/Target/AMDGPU/TargetInfo/AMDGPUTargetInfo.cpp @@ -29,7 +29,7 @@ } /// Extern function to initialize the targets for the AMDGPU backend -extern "C" void LLVMInitializeAMDGPUTargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeAMDGPUTargetInfo() { RegisterTarget R600(getTheAMDGPUTarget(), "r600", "AMD GPUs HD2XXX-HD6XXX", "AMDGPU"); RegisterTarget GCN(getTheGCNTarget(), "amdgcn", Index: lib/Target/ARC/ARCAsmPrinter.cpp =================================================================== --- lib/Target/ARC/ARCAsmPrinter.cpp +++ lib/Target/ARC/ARCAsmPrinter.cpp @@ -78,6 +78,6 @@ } // Force static initialization. -extern "C" void LLVMInitializeARCAsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeARCAsmPrinter() { RegisterAsmPrinter X(getTheARCTarget()); } Index: lib/Target/ARC/ARCTargetMachine.cpp =================================================================== --- lib/Target/ARC/ARCTargetMachine.cpp +++ lib/Target/ARC/ARCTargetMachine.cpp @@ -84,7 +84,7 @@ void ARCPassConfig::addPreRegAlloc() { addPass(createARCExpandPseudosPass()); } // Force static initialization. -extern "C" void LLVMInitializeARCTarget() { +extern "C" LLVM_EXPORT void LLVMInitializeARCTarget() { RegisterTargetMachine X(getTheARCTarget()); } Index: lib/Target/ARC/Disassembler/ARCDisassembler.cpp =================================================================== --- lib/Target/ARC/Disassembler/ARCDisassembler.cpp +++ lib/Target/ARC/Disassembler/ARCDisassembler.cpp @@ -365,7 +365,7 @@ return new ARCDisassembler(STI, Ctx, T.createMCInstrInfo()); } -extern "C" void LLVMInitializeARCDisassembler() { +extern "C" LLVM_EXPORT void LLVMInitializeARCDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheARCTarget(), createARCDisassembler); Index: lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp =================================================================== --- lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp +++ lib/Target/ARC/MCTargetDesc/ARCMCTargetDesc.cpp @@ -80,7 +80,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeARCTargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeARCTargetMC() { // Register the MC asm info. Target &TheARCTarget = getTheARCTarget(); RegisterMCAsmInfoFn X(TheARCTarget, createARCMCAsmInfo); Index: lib/Target/ARC/TargetInfo/ARCTargetInfo.cpp =================================================================== --- lib/Target/ARC/TargetInfo/ARCTargetInfo.cpp +++ lib/Target/ARC/TargetInfo/ARCTargetInfo.cpp @@ -17,6 +17,6 @@ return TheARCTarget; } -extern "C" void LLVMInitializeARCTargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeARCTargetInfo() { RegisterTarget X(getTheARCTarget(), "arc", "ARC", "ARC"); } Index: lib/Target/ARM/ARMAsmPrinter.cpp =================================================================== --- lib/Target/ARM/ARMAsmPrinter.cpp +++ lib/Target/ARM/ARMAsmPrinter.cpp @@ -2077,7 +2077,7 @@ //===----------------------------------------------------------------------===// // Force static initialization. -extern "C" void LLVMInitializeARMAsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeARMAsmPrinter() { RegisterAsmPrinter X(getTheARMLETarget()); RegisterAsmPrinter Y(getTheARMBETarget()); RegisterAsmPrinter A(getTheThumbLETarget()); Index: lib/Target/ARM/ARMTargetMachine.cpp =================================================================== --- lib/Target/ARM/ARMTargetMachine.cpp +++ lib/Target/ARM/ARMTargetMachine.cpp @@ -78,7 +78,7 @@ void initializeARMExecutionDomainFixPass(PassRegistry&); } -extern "C" void LLVMInitializeARMTarget() { +extern "C" LLVM_EXPORT void LLVMInitializeARMTarget() { // Register the target. RegisterTargetMachine X(getTheARMLETarget()); RegisterTargetMachine A(getTheThumbLETarget()); Index: lib/Target/ARM/AsmParser/ARMAsmParser.cpp =================================================================== --- lib/Target/ARM/AsmParser/ARMAsmParser.cpp +++ lib/Target/ARM/AsmParser/ARMAsmParser.cpp @@ -10357,7 +10357,7 @@ } /// Force static initialization. -extern "C" void LLVMInitializeARMAsmParser() { +extern "C" LLVM_EXPORT void LLVMInitializeARMAsmParser() { RegisterMCAsmParser X(getTheARMLETarget()); RegisterMCAsmParser Y(getTheARMBETarget()); RegisterMCAsmParser A(getTheThumbLETarget()); Index: lib/Target/ARM/Disassembler/ARMDisassembler.cpp =================================================================== --- lib/Target/ARM/Disassembler/ARMDisassembler.cpp +++ lib/Target/ARM/Disassembler/ARMDisassembler.cpp @@ -855,7 +855,7 @@ return MCDisassembler::Fail; } -extern "C" void LLVMInitializeARMDisassembler() { +extern "C" LLVM_EXPORT void LLVMInitializeARMDisassembler() { TargetRegistry::RegisterMCDisassembler(getTheARMLETarget(), createARMDisassembler); TargetRegistry::RegisterMCDisassembler(getTheARMBETarget(), Index: lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp =================================================================== --- lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp +++ lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp @@ -300,7 +300,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeARMTargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeARMTargetMC() { for (Target *T : {&getTheARMLETarget(), &getTheARMBETarget(), &getTheThumbLETarget(), &getTheThumbBETarget()}) { // Register the MC asm info. Index: lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp =================================================================== --- lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp +++ lib/Target/ARM/TargetInfo/ARMTargetInfo.cpp @@ -28,7 +28,7 @@ return TheThumbBETarget; } -extern "C" void LLVMInitializeARMTargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeARMTargetInfo() { RegisterTarget X(getTheARMLETarget(), "arm", "ARM", "ARM"); RegisterTarget Y(getTheARMBETarget(), "armeb", Index: lib/Target/AVR/AVRAsmPrinter.cpp =================================================================== --- lib/Target/AVR/AVRAsmPrinter.cpp +++ lib/Target/AVR/AVRAsmPrinter.cpp @@ -183,7 +183,7 @@ } // end of namespace llvm -extern "C" void LLVMInitializeAVRAsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeAVRAsmPrinter() { llvm::RegisterAsmPrinter X(llvm::getTheAVRTarget()); } Index: lib/Target/AVR/AVRTargetMachine.cpp =================================================================== --- lib/Target/AVR/AVRTargetMachine.cpp +++ lib/Target/AVR/AVRTargetMachine.cpp @@ -82,7 +82,7 @@ return new AVRPassConfig(*this, PM); } -extern "C" void LLVMInitializeAVRTarget() { +extern "C" LLVM_EXPORT void LLVMInitializeAVRTarget() { // Register the target. RegisterTargetMachine X(getTheAVRTarget()); Index: lib/Target/AVR/AsmParser/AVRAsmParser.cpp =================================================================== --- lib/Target/AVR/AsmParser/AVRAsmParser.cpp +++ lib/Target/AVR/AsmParser/AVRAsmParser.cpp @@ -662,7 +662,7 @@ return (parseMany(parseOne)); } -extern "C" void LLVMInitializeAVRAsmParser() { +extern "C" LLVM_EXPORT void LLVMInitializeAVRAsmParser() { RegisterMCAsmParser X(getTheAVRTarget()); } Index: lib/Target/AVR/Disassembler/AVRDisassembler.cpp =================================================================== --- lib/Target/AVR/Disassembler/AVRDisassembler.cpp +++ lib/Target/AVR/Disassembler/AVRDisassembler.cpp @@ -52,7 +52,7 @@ } -extern "C" void LLVMInitializeAVRDisassembler() { +extern "C" LLVM_EXPORT void LLVMInitializeAVRDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheAVRTarget(), createAVRDisassembler); Index: lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp =================================================================== --- lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp +++ lib/Target/AVR/MCTargetDesc/AVRMCTargetDesc.cpp @@ -89,7 +89,7 @@ return new AVRTargetAsmStreamer(S); } -extern "C" void LLVMInitializeAVRTargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeAVRTargetMC() { // Register the MC asm info. RegisterMCAsmInfo X(getTheAVRTarget()); Index: lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp =================================================================== --- lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp +++ lib/Target/AVR/TargetInfo/AVRTargetInfo.cpp @@ -16,7 +16,7 @@ } } -extern "C" void LLVMInitializeAVRTargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeAVRTargetInfo() { llvm::RegisterTarget X(llvm::getTheAVRTarget(), "avr", "Atmel AVR Microcontroller", "AVR"); } Index: lib/Target/BPF/AsmParser/BPFAsmParser.cpp =================================================================== --- lib/Target/BPF/AsmParser/BPFAsmParser.cpp +++ lib/Target/BPF/AsmParser/BPFAsmParser.cpp @@ -493,7 +493,7 @@ bool BPFAsmParser::ParseDirective(AsmToken DirectiveID) { return true; } -extern "C" void LLVMInitializeBPFAsmParser() { +extern "C" LLVM_EXPORT void LLVMInitializeBPFAsmParser() { RegisterMCAsmParser X(getTheBPFTarget()); RegisterMCAsmParser Y(getTheBPFleTarget()); RegisterMCAsmParser Z(getTheBPFbeTarget()); Index: lib/Target/BPF/BPFAsmPrinter.cpp =================================================================== --- lib/Target/BPF/BPFAsmPrinter.cpp +++ lib/Target/BPF/BPFAsmPrinter.cpp @@ -132,7 +132,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeBPFAsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeBPFAsmPrinter() { RegisterAsmPrinter X(getTheBPFleTarget()); RegisterAsmPrinter Y(getTheBPFbeTarget()); RegisterAsmPrinter Z(getTheBPFTarget()); Index: lib/Target/BPF/BPFTargetMachine.cpp =================================================================== --- lib/Target/BPF/BPFTargetMachine.cpp +++ 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_EXPORT void LLVMInitializeBPFTarget() { // Register the target. RegisterTargetMachine X(getTheBPFleTarget()); RegisterTargetMachine Y(getTheBPFbeTarget()); Index: lib/Target/BPF/Disassembler/BPFDisassembler.cpp =================================================================== --- lib/Target/BPF/Disassembler/BPFDisassembler.cpp +++ lib/Target/BPF/Disassembler/BPFDisassembler.cpp @@ -84,7 +84,7 @@ } -extern "C" void LLVMInitializeBPFDisassembler() { +extern "C" LLVM_EXPORT void LLVMInitializeBPFDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheBPFTarget(), createBPFDisassembler); Index: lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp =================================================================== --- lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp +++ lib/Target/BPF/MCTargetDesc/BPFMCTargetDesc.cpp @@ -98,7 +98,7 @@ return new BPFMCInstrAnalysis(Info); } -extern "C" void LLVMInitializeBPFTargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeBPFTargetMC() { for (Target *T : {&getTheBPFleTarget(), &getTheBPFbeTarget(), &getTheBPFTarget()}) { // Register the MC asm info. Index: lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp =================================================================== --- lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp +++ lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp @@ -26,7 +26,7 @@ } } // namespace llvm -extern "C" void LLVMInitializeBPFTargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeBPFTargetInfo() { TargetRegistry::RegisterTarget(getTheBPFTarget(), "bpf", "BPF (host endian)", "BPF", [](Triple::ArchType) { return false; }, true); Index: lib/Target/CMakeLists.txt =================================================================== --- lib/Target/CMakeLists.txt +++ 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: lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp =================================================================== --- lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp +++ lib/Target/Hexagon/AsmParser/HexagonAsmParser.cpp @@ -816,10 +816,10 @@ return true; } -// extern "C" void LLVMInitializeHexagonAsmLexer(); +// extern "C" LLVM_EXPORT void LLVMInitializeHexagonAsmLexer(); /// Force static initialization. -extern "C" void LLVMInitializeHexagonAsmParser() { +extern "C" LLVM_EXPORT void LLVMInitializeHexagonAsmParser() { RegisterMCAsmParser X(getTheHexagonTarget()); } Index: lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp =================================================================== --- lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp +++ lib/Target/Hexagon/Disassembler/HexagonDisassembler.cpp @@ -209,7 +209,7 @@ return new HexagonDisassembler(STI, Ctx, T.createMCInstrInfo()); } -extern "C" void LLVMInitializeHexagonDisassembler() { +extern "C" LLVM_EXPORT void LLVMInitializeHexagonDisassembler() { TargetRegistry::RegisterMCDisassembler(getTheHexagonTarget(), createHexagonDisassembler); } Index: lib/Target/Hexagon/HexagonAsmPrinter.cpp =================================================================== --- lib/Target/Hexagon/HexagonAsmPrinter.cpp +++ lib/Target/Hexagon/HexagonAsmPrinter.cpp @@ -779,6 +779,6 @@ OutStreamer->EmitInstruction(MCB, getSubtargetInfo()); } -extern "C" void LLVMInitializeHexagonAsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeHexagonAsmPrinter() { RegisterAsmPrinter X(getTheHexagonTarget()); } Index: lib/Target/Hexagon/HexagonTargetMachine.cpp =================================================================== --- lib/Target/Hexagon/HexagonTargetMachine.cpp +++ lib/Target/Hexagon/HexagonTargetMachine.cpp @@ -186,7 +186,7 @@ return CodeModel::Small; } -extern "C" void LLVMInitializeHexagonTarget() { +extern "C" LLVM_EXPORT void LLVMInitializeHexagonTarget() { // Register the target. RegisterTargetMachine X(getTheHexagonTarget()); Index: lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp =================================================================== --- lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp +++ lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp @@ -443,7 +443,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeHexagonTargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeHexagonTargetMC() { // Register the MC asm info. RegisterMCAsmInfoFn X(getTheHexagonTarget(), createHexagonMCAsmInfo); Index: lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp =================================================================== --- lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp +++ lib/Target/Hexagon/TargetInfo/HexagonTargetInfo.cpp @@ -17,7 +17,7 @@ return TheHexagonTarget; } -extern "C" void LLVMInitializeHexagonTargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeHexagonTargetInfo() { RegisterTarget X( getTheHexagonTarget(), "hexagon", "Hexagon", "Hexagon"); } Index: lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp =================================================================== --- lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp +++ lib/Target/Lanai/AsmParser/LanaiAsmParser.cpp @@ -1223,6 +1223,6 @@ #define GET_MATCHER_IMPLEMENTATION #include "LanaiGenAsmMatcher.inc" -extern "C" void LLVMInitializeLanaiAsmParser() { +extern "C" LLVM_EXPORT void LLVMInitializeLanaiAsmParser() { RegisterMCAsmParser x(getTheLanaiTarget()); } Index: lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp =================================================================== --- lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp +++ lib/Target/Lanai/Disassembler/LanaiDisassembler.cpp @@ -35,7 +35,7 @@ return new LanaiDisassembler(STI, Ctx); } -extern "C" void LLVMInitializeLanaiDisassembler() { +extern "C" LLVM_EXPORT void LLVMInitializeLanaiDisassembler() { // Register the disassembler TargetRegistry::RegisterMCDisassembler(getTheLanaiTarget(), createLanaiDisassembler); Index: lib/Target/Lanai/LanaiAsmPrinter.cpp =================================================================== --- lib/Target/Lanai/LanaiAsmPrinter.cpp +++ lib/Target/Lanai/LanaiAsmPrinter.cpp @@ -238,6 +238,6 @@ } // Force static initialization. -extern "C" void LLVMInitializeLanaiAsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeLanaiAsmPrinter() { RegisterAsmPrinter X(getTheLanaiTarget()); } Index: lib/Target/Lanai/LanaiTargetMachine.cpp =================================================================== --- lib/Target/Lanai/LanaiTargetMachine.cpp +++ lib/Target/Lanai/LanaiTargetMachine.cpp @@ -30,7 +30,7 @@ void initializeLanaiMemAluCombinerPass(PassRegistry &); } // namespace llvm -extern "C" void LLVMInitializeLanaiTarget() { +extern "C" LLVM_EXPORT void LLVMInitializeLanaiTarget() { // Register the target. RegisterTargetMachine registered_target( getTheLanaiTarget()); Index: lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp =================================================================== --- lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp +++ lib/Target/Lanai/MCTargetDesc/LanaiMCTargetDesc.cpp @@ -123,7 +123,7 @@ return new LanaiMCInstrAnalysis(Info); } -extern "C" void LLVMInitializeLanaiTargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeLanaiTargetMC() { // Register the MC asm info. RegisterMCAsmInfo X(getTheLanaiTarget()); Index: lib/Target/Lanai/TargetInfo/LanaiTargetInfo.cpp =================================================================== --- lib/Target/Lanai/TargetInfo/LanaiTargetInfo.cpp +++ lib/Target/Lanai/TargetInfo/LanaiTargetInfo.cpp @@ -19,7 +19,7 @@ } } // namespace llvm -extern "C" void LLVMInitializeLanaiTargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeLanaiTargetInfo() { RegisterTarget X(getTheLanaiTarget(), "lanai", "Lanai", "Lanai"); } Index: lib/Target/MSP430/MCTargetDesc/MSP430MCTargetDesc.cpp =================================================================== --- lib/Target/MSP430/MCTargetDesc/MSP430MCTargetDesc.cpp +++ lib/Target/MSP430/MCTargetDesc/MSP430MCTargetDesc.cpp @@ -57,7 +57,7 @@ return nullptr; } -extern "C" void LLVMInitializeMSP430TargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeMSP430TargetMC() { // Register the MC asm info. RegisterMCAsmInfo X(getTheMSP430Target()); Index: lib/Target/MSP430/MSP430AsmPrinter.cpp =================================================================== --- lib/Target/MSP430/MSP430AsmPrinter.cpp +++ lib/Target/MSP430/MSP430AsmPrinter.cpp @@ -154,6 +154,6 @@ } // Force static initialization. -extern "C" void LLVMInitializeMSP430AsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeMSP430AsmPrinter() { RegisterAsmPrinter X(getTheMSP430Target()); } Index: lib/Target/MSP430/MSP430TargetMachine.cpp =================================================================== --- lib/Target/MSP430/MSP430TargetMachine.cpp +++ lib/Target/MSP430/MSP430TargetMachine.cpp @@ -21,7 +21,7 @@ #include "llvm/Support/TargetRegistry.h" using namespace llvm; -extern "C" void LLVMInitializeMSP430Target() { +extern "C" LLVM_EXPORT void LLVMInitializeMSP430Target() { // Register the target. RegisterTargetMachine X(getTheMSP430Target()); } Index: lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp =================================================================== --- lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp +++ lib/Target/MSP430/TargetInfo/MSP430TargetInfo.cpp @@ -17,7 +17,7 @@ return TheMSP430Target; } -extern "C" void LLVMInitializeMSP430TargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeMSP430TargetInfo() { RegisterTarget X(getTheMSP430Target(), "msp430", "MSP430 [experimental]", "MSP430"); } Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp =================================================================== --- lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -8180,7 +8180,7 @@ return false; } -extern "C" void LLVMInitializeMipsAsmParser() { +extern "C" LLVM_EXPORT void LLVMInitializeMipsAsmParser() { RegisterMCAsmParser X(getTheMipsTarget()); RegisterMCAsmParser Y(getTheMipselTarget()); RegisterMCAsmParser A(getTheMips64Target()); Index: lib/Target/Mips/Disassembler/MipsDisassembler.cpp =================================================================== --- lib/Target/Mips/Disassembler/MipsDisassembler.cpp +++ lib/Target/Mips/Disassembler/MipsDisassembler.cpp @@ -564,7 +564,7 @@ return new MipsDisassembler(STI, Ctx, false); } -extern "C" void LLVMInitializeMipsDisassembler() { +extern "C" LLVM_EXPORT void LLVMInitializeMipsDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheMipsTarget(), createMipsDisassembler); Index: lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp =================================================================== --- lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp +++ lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp @@ -162,7 +162,7 @@ return new MipsMCInstrAnalysis(Info); } -extern "C" void LLVMInitializeMipsTargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeMipsTargetMC() { for (Target *T : {&getTheMipsTarget(), &getTheMipselTarget(), &getTheMips64Target(), &getTheMips64elTarget()}) { // Register the MC asm info. Index: lib/Target/Mips/MipsAsmPrinter.cpp =================================================================== --- lib/Target/Mips/MipsAsmPrinter.cpp +++ lib/Target/Mips/MipsAsmPrinter.cpp @@ -1250,7 +1250,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeMipsAsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeMipsAsmPrinter() { RegisterAsmPrinter X(getTheMipsTarget()); RegisterAsmPrinter Y(getTheMipselTarget()); RegisterAsmPrinter A(getTheMips64Target()); Index: lib/Target/Mips/MipsTargetMachine.cpp =================================================================== --- lib/Target/Mips/MipsTargetMachine.cpp +++ lib/Target/Mips/MipsTargetMachine.cpp @@ -44,7 +44,7 @@ #define DEBUG_TYPE "mips" -extern "C" void LLVMInitializeMipsTarget() { +extern "C" LLVM_EXPORT void LLVMInitializeMipsTarget() { // Register the target. RegisterTargetMachine X(getTheMipsTarget()); RegisterTargetMachine Y(getTheMipselTarget()); Index: lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp =================================================================== --- lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp +++ lib/Target/Mips/TargetInfo/MipsTargetInfo.cpp @@ -29,7 +29,7 @@ return TheMips64elTarget; } -extern "C" void LLVMInitializeMipsTargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeMipsTargetInfo() { RegisterTarget X(getTheMipsTarget(), "mips", "MIPS (32-bit big endian)", "Mips"); Index: lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp =================================================================== --- lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp +++ lib/Target/NVPTX/MCTargetDesc/NVPTXMCTargetDesc.cpp @@ -66,7 +66,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeNVPTXTargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeNVPTXTargetMC() { for (Target *T : {&getTheNVPTXTarget32(), &getTheNVPTXTarget64()}) { // Register the MC asm info. RegisterMCAsmInfo X(*T); Index: lib/Target/NVPTX/NVPTXAsmPrinter.cpp =================================================================== --- lib/Target/NVPTX/NVPTXAsmPrinter.cpp +++ lib/Target/NVPTX/NVPTXAsmPrinter.cpp @@ -2266,7 +2266,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeNVPTXAsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeNVPTXAsmPrinter() { RegisterAsmPrinter X(getTheNVPTXTarget32()); RegisterAsmPrinter Y(getTheNVPTXTarget64()); } Index: lib/Target/NVPTX/NVPTXTargetMachine.cpp =================================================================== --- lib/Target/NVPTX/NVPTXTargetMachine.cpp +++ lib/Target/NVPTX/NVPTXTargetMachine.cpp @@ -71,7 +71,7 @@ } // end namespace llvm -extern "C" void LLVMInitializeNVPTXTarget() { +extern "C" LLVM_EXPORT void LLVMInitializeNVPTXTarget() { // Register the target. RegisterTargetMachine X(getTheNVPTXTarget32()); RegisterTargetMachine Y(getTheNVPTXTarget64()); Index: lib/Target/NVPTX/TargetInfo/NVPTXTargetInfo.cpp =================================================================== --- lib/Target/NVPTX/TargetInfo/NVPTXTargetInfo.cpp +++ lib/Target/NVPTX/TargetInfo/NVPTXTargetInfo.cpp @@ -21,7 +21,7 @@ return TheNVPTXTarget64; } -extern "C" void LLVMInitializeNVPTXTargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeNVPTXTargetInfo() { RegisterTarget X(getTheNVPTXTarget32(), "nvptx", "NVIDIA PTX 32-bit", "NVPTX"); RegisterTarget Y(getTheNVPTXTarget64(), "nvptx64", Index: lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.cpp =================================================================== --- lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.cpp +++ lib/Target/Nios2/MCTargetDesc/Nios2MCTargetDesc.cpp @@ -77,7 +77,7 @@ return new Nios2TargetAsmStreamer(S, OS); } -extern "C" void LLVMInitializeNios2TargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeNios2TargetMC() { Target *T = &getTheNios2Target(); // Register the MC asm info. Index: lib/Target/Nios2/Nios2AsmPrinter.cpp =================================================================== --- lib/Target/Nios2/Nios2AsmPrinter.cpp +++ lib/Target/Nios2/Nios2AsmPrinter.cpp @@ -148,6 +148,6 @@ } // Force static initialization. -extern "C" void LLVMInitializeNios2AsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeNios2AsmPrinter() { RegisterAsmPrinter X(getTheNios2Target()); } Index: lib/Target/Nios2/Nios2TargetMachine.cpp =================================================================== --- lib/Target/Nios2/Nios2TargetMachine.cpp +++ lib/Target/Nios2/Nios2TargetMachine.cpp @@ -22,7 +22,7 @@ #define DEBUG_TYPE "nios2" -extern "C" void LLVMInitializeNios2Target() { +extern "C" LLVM_EXPORT void LLVMInitializeNios2Target() { // Register the target. RegisterTargetMachine X(getTheNios2Target()); } Index: lib/Target/Nios2/TargetInfo/Nios2TargetInfo.cpp =================================================================== --- lib/Target/Nios2/TargetInfo/Nios2TargetInfo.cpp +++ lib/Target/Nios2/TargetInfo/Nios2TargetInfo.cpp @@ -17,7 +17,7 @@ return TheNios2Target; } -extern "C" void LLVMInitializeNios2TargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeNios2TargetInfo() { RegisterTarget X(getTheNios2Target(), "nios2", "Nios2", "Nios2"); Index: lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp =================================================================== --- lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp +++ lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp @@ -1950,7 +1950,7 @@ /// Force static initialization. -extern "C" void LLVMInitializePowerPCAsmParser() { +extern "C" LLVM_EXPORT void LLVMInitializePowerPCAsmParser() { RegisterMCAsmParser A(getThePPC32Target()); RegisterMCAsmParser B(getThePPC64Target()); RegisterMCAsmParser C(getThePPC64LETarget()); Index: lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp =================================================================== --- lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp +++ lib/Target/PowerPC/Disassembler/PPCDisassembler.cpp @@ -49,7 +49,7 @@ return new PPCDisassembler(STI, Ctx, /*IsLittleEndian=*/true); } -extern "C" void LLVMInitializePowerPCDisassembler() { +extern "C" LLVM_EXPORT void LLVMInitializePowerPCDisassembler() { // Register the disassembler for each target. TargetRegistry::RegisterMCDisassembler(getThePPC32Target(), createPPCDisassembler); Index: lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp =================================================================== --- lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp +++ lib/Target/PowerPC/MCTargetDesc/PPCMCTargetDesc.cpp @@ -242,7 +242,7 @@ return new PPCInstPrinter(MAI, MII, MRI, T); } -extern "C" void LLVMInitializePowerPCTargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializePowerPCTargetMC() { for (Target *T : {&getThePPC32Target(), &getThePPC64Target(), &getThePPC64LETarget()}) { // Register the MC asm info. Index: lib/Target/PowerPC/PPCAsmPrinter.cpp =================================================================== --- lib/Target/PowerPC/PPCAsmPrinter.cpp +++ lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -1644,7 +1644,7 @@ } // Force static initialization. -extern "C" void LLVMInitializePowerPCAsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializePowerPCAsmPrinter() { TargetRegistry::RegisterAsmPrinter(getThePPC32Target(), createPPCAsmPrinterPass); TargetRegistry::RegisterAsmPrinter(getThePPC64Target(), Index: lib/Target/PowerPC/PPCTargetMachine.cpp =================================================================== --- lib/Target/PowerPC/PPCTargetMachine.cpp +++ lib/Target/PowerPC/PPCTargetMachine.cpp @@ -93,7 +93,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_EXPORT void LLVMInitializePowerPCTarget() { // Register the targets RegisterTargetMachine A(getThePPC32Target()); RegisterTargetMachine B(getThePPC64Target()); Index: lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp =================================================================== --- lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp +++ lib/Target/PowerPC/TargetInfo/PowerPCTargetInfo.cpp @@ -25,7 +25,7 @@ return ThePPC64LETarget; } -extern "C" void LLVMInitializePowerPCTargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializePowerPCTargetInfo() { RegisterTarget X(getThePPC32Target(), "ppc32", "PowerPC 32", "PPC"); Index: lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp =================================================================== --- lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -1478,7 +1478,7 @@ return false; } -extern "C" void LLVMInitializeRISCVAsmParser() { +extern "C" LLVM_EXPORT void LLVMInitializeRISCVAsmParser() { RegisterMCAsmParser X(getTheRISCV32Target()); RegisterMCAsmParser Y(getTheRISCV64Target()); } Index: lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp =================================================================== --- lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp +++ lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp @@ -48,7 +48,7 @@ return new RISCVDisassembler(STI, Ctx); } -extern "C" void LLVMInitializeRISCVDisassembler() { +extern "C" LLVM_EXPORT void LLVMInitializeRISCVDisassembler() { // Register the disassembler for each target. TargetRegistry::RegisterMCDisassembler(getTheRISCV32Target(), createRISCVDisassembler); Index: lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp =================================================================== --- lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp +++ lib/Target/RISCV/MCTargetDesc/RISCVMCTargetDesc.cpp @@ -84,7 +84,7 @@ return new RISCVTargetAsmStreamer(S, OS); } -extern "C" void LLVMInitializeRISCVTargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeRISCVTargetMC() { for (Target *T : {&getTheRISCV32Target(), &getTheRISCV64Target()}) { TargetRegistry::RegisterMCAsmInfo(*T, createRISCVMCAsmInfo); TargetRegistry::RegisterMCInstrInfo(*T, createRISCVMCInstrInfo); Index: lib/Target/RISCV/RISCVAsmPrinter.cpp =================================================================== --- lib/Target/RISCV/RISCVAsmPrinter.cpp +++ lib/Target/RISCV/RISCVAsmPrinter.cpp @@ -132,7 +132,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeRISCVAsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeRISCVAsmPrinter() { RegisterAsmPrinter X(getTheRISCV32Target()); RegisterAsmPrinter Y(getTheRISCV64Target()); } Index: lib/Target/RISCV/RISCVTargetMachine.cpp =================================================================== --- lib/Target/RISCV/RISCVTargetMachine.cpp +++ lib/Target/RISCV/RISCVTargetMachine.cpp @@ -24,7 +24,7 @@ #include "llvm/Target/TargetOptions.h" using namespace llvm; -extern "C" void LLVMInitializeRISCVTarget() { +extern "C" LLVM_EXPORT void LLVMInitializeRISCVTarget() { RegisterTargetMachine X(getTheRISCV32Target()); RegisterTargetMachine Y(getTheRISCV64Target()); auto PR = PassRegistry::getPassRegistry(); Index: lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp =================================================================== --- lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp +++ lib/Target/RISCV/TargetInfo/RISCVTargetInfo.cpp @@ -22,7 +22,7 @@ } } -extern "C" void LLVMInitializeRISCVTargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeRISCVTargetInfo() { RegisterTarget X(getTheRISCV32Target(), "riscv32", "32-bit RISC-V", "RISCV"); RegisterTarget Y(getTheRISCV64Target(), "riscv64", Index: lib/Target/Sparc/AsmParser/SparcAsmParser.cpp =================================================================== --- lib/Target/Sparc/AsmParser/SparcAsmParser.cpp +++ lib/Target/Sparc/AsmParser/SparcAsmParser.cpp @@ -1252,7 +1252,7 @@ return true; } -extern "C" void LLVMInitializeSparcAsmParser() { +extern "C" LLVM_EXPORT void LLVMInitializeSparcAsmParser() { RegisterMCAsmParser A(getTheSparcTarget()); RegisterMCAsmParser B(getTheSparcV9Target()); RegisterMCAsmParser C(getTheSparcelTarget()); Index: lib/Target/Sparc/Disassembler/SparcDisassembler.cpp =================================================================== --- lib/Target/Sparc/Disassembler/SparcDisassembler.cpp +++ lib/Target/Sparc/Disassembler/SparcDisassembler.cpp @@ -54,7 +54,7 @@ } -extern "C" void LLVMInitializeSparcDisassembler() { +extern "C" LLVM_EXPORT void LLVMInitializeSparcDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheSparcTarget(), createSparcDisassembler); Index: lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp =================================================================== --- lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp +++ lib/Target/Sparc/MCTargetDesc/SparcMCTargetDesc.cpp @@ -89,7 +89,7 @@ return new SparcInstPrinter(MAI, MII, MRI); } -extern "C" void LLVMInitializeSparcTargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeSparcTargetMC() { // Register the MC asm info. RegisterMCAsmInfoFn X(getTheSparcTarget(), createSparcMCAsmInfo); RegisterMCAsmInfoFn Y(getTheSparcV9Target(), createSparcV9MCAsmInfo); Index: lib/Target/Sparc/SparcAsmPrinter.cpp =================================================================== --- lib/Target/Sparc/SparcAsmPrinter.cpp +++ lib/Target/Sparc/SparcAsmPrinter.cpp @@ -442,7 +442,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeSparcAsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeSparcAsmPrinter() { RegisterAsmPrinter X(getTheSparcTarget()); RegisterAsmPrinter Y(getTheSparcV9Target()); RegisterAsmPrinter Z(getTheSparcelTarget()); Index: lib/Target/Sparc/SparcTargetMachine.cpp =================================================================== --- lib/Target/Sparc/SparcTargetMachine.cpp +++ lib/Target/Sparc/SparcTargetMachine.cpp @@ -20,7 +20,7 @@ #include "llvm/Support/TargetRegistry.h" using namespace llvm; -extern "C" void LLVMInitializeSparcTarget() { +extern "C" LLVM_EXPORT void LLVMInitializeSparcTarget() { // Register the target. RegisterTargetMachine X(getTheSparcTarget()); RegisterTargetMachine Y(getTheSparcV9Target()); Index: lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp =================================================================== --- lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp +++ lib/Target/Sparc/TargetInfo/SparcTargetInfo.cpp @@ -25,7 +25,7 @@ return TheSparcelTarget; } -extern "C" void LLVMInitializeSparcTargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeSparcTargetInfo() { RegisterTarget X(getTheSparcTarget(), "sparc", "Sparc", "Sparc"); RegisterTarget Y( Index: lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp =================================================================== --- lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp +++ lib/Target/SystemZ/AsmParser/SystemZAsmParser.cpp @@ -1370,6 +1370,6 @@ } // Force static initialization. -extern "C" void LLVMInitializeSystemZAsmParser() { +extern "C" LLVM_EXPORT void LLVMInitializeSystemZAsmParser() { RegisterMCAsmParser X(getTheSystemZTarget()); } Index: lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp =================================================================== --- lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp +++ lib/Target/SystemZ/Disassembler/SystemZDisassembler.cpp @@ -46,7 +46,7 @@ return new SystemZDisassembler(STI, Ctx); } -extern "C" void LLVMInitializeSystemZDisassembler() { +extern "C" LLVM_EXPORT void LLVMInitializeSystemZDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheSystemZTarget(), createSystemZDisassembler); Index: lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp =================================================================== --- lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp +++ lib/Target/SystemZ/MCTargetDesc/SystemZMCTargetDesc.cpp @@ -181,7 +181,7 @@ return new SystemZInstPrinter(MAI, MII, MRI); } -extern "C" void LLVMInitializeSystemZTargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeSystemZTargetMC() { // Register the MCAsmInfo. TargetRegistry::RegisterMCAsmInfo(getTheSystemZTarget(), createSystemZMCAsmInfo); Index: lib/Target/SystemZ/SystemZAsmPrinter.cpp =================================================================== --- lib/Target/SystemZ/SystemZAsmPrinter.cpp +++ lib/Target/SystemZ/SystemZAsmPrinter.cpp @@ -651,6 +651,6 @@ } // Force static initialization. -extern "C" void LLVMInitializeSystemZAsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeSystemZAsmPrinter() { RegisterAsmPrinter X(getTheSystemZTarget()); } Index: lib/Target/SystemZ/SystemZTargetMachine.cpp =================================================================== --- lib/Target/SystemZ/SystemZTargetMachine.cpp +++ lib/Target/SystemZ/SystemZTargetMachine.cpp @@ -29,7 +29,7 @@ using namespace llvm; -extern "C" void LLVMInitializeSystemZTarget() { +extern "C" LLVM_EXPORT void LLVMInitializeSystemZTarget() { // Register the target. RegisterTargetMachine X(getTheSystemZTarget()); } Index: lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp =================================================================== --- lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp +++ lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp @@ -17,7 +17,7 @@ return TheSystemZTarget; } -extern "C" void LLVMInitializeSystemZTargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeSystemZTargetInfo() { RegisterTarget X( getTheSystemZTarget(), "systemz", "SystemZ", "SystemZ"); } Index: lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp =================================================================== --- lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp +++ lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp @@ -466,7 +466,7 @@ } // end anonymous namespace // Force static initialization. -extern "C" void LLVMInitializeWebAssemblyAsmParser() { +extern "C" LLVM_EXPORT void LLVMInitializeWebAssemblyAsmParser() { RegisterMCAsmParser X(getTheWebAssemblyTarget32()); RegisterMCAsmParser Y(getTheWebAssemblyTarget64()); } Index: lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp =================================================================== --- lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp +++ lib/Target/WebAssembly/Disassembler/WebAssemblyDisassembler.cpp @@ -60,7 +60,7 @@ return new WebAssemblyDisassembler(STI, Ctx, std::move(MCII)); } -extern "C" void LLVMInitializeWebAssemblyDisassembler() { +extern "C" LLVM_EXPORT void LLVMInitializeWebAssemblyDisassembler() { // Register the disassembler for each target. TargetRegistry::RegisterMCDisassembler(getTheWebAssemblyTarget32(), createWebAssemblyDisassembler); Index: lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp =================================================================== --- lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp +++ lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCTargetDesc.cpp @@ -91,7 +91,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeWebAssemblyTargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeWebAssemblyTargetMC() { for (Target *T : {&getTheWebAssemblyTarget32(), &getTheWebAssemblyTarget64()}) { // Register the MC asm info. Index: lib/Target/WebAssembly/TargetInfo/WebAssemblyTargetInfo.cpp =================================================================== --- lib/Target/WebAssembly/TargetInfo/WebAssemblyTargetInfo.cpp +++ lib/Target/WebAssembly/TargetInfo/WebAssemblyTargetInfo.cpp @@ -28,7 +28,7 @@ return TheWebAssemblyTarget64; } -extern "C" void LLVMInitializeWebAssemblyTargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeWebAssemblyTargetInfo() { RegisterTarget X(getTheWebAssemblyTarget32(), "wasm32", "WebAssembly 32-bit", "WebAssembly"); RegisterTarget Y(getTheWebAssemblyTarget64(), "wasm64", Index: lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp +++ lib/Target/WebAssembly/WebAssemblyAsmPrinter.cpp @@ -324,7 +324,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeWebAssemblyAsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeWebAssemblyAsmPrinter() { RegisterAsmPrinter X(getTheWebAssemblyTarget32()); RegisterAsmPrinter Y(getTheWebAssemblyTarget64()); } Index: lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp =================================================================== --- lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp +++ lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp @@ -42,7 +42,7 @@ cl::desc("WebAssembly Emscripten-style setjmp/longjmp handling"), cl::init(false)); -extern "C" void LLVMInitializeWebAssemblyTarget() { +extern "C" LLVM_EXPORT void LLVMInitializeWebAssemblyTarget() { // Register the target. RegisterTargetMachine X( getTheWebAssemblyTarget32()); Index: lib/Target/X86/AsmParser/X86AsmParser.cpp =================================================================== --- lib/Target/X86/AsmParser/X86AsmParser.cpp +++ lib/Target/X86/AsmParser/X86AsmParser.cpp @@ -3457,7 +3457,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeX86AsmParser() { +extern "C" LLVM_EXPORT void LLVMInitializeX86AsmParser() { RegisterMCAsmParser X(getTheX86_32Target()); RegisterMCAsmParser Y(getTheX86_64Target()); } Index: lib/Target/X86/Disassembler/X86Disassembler.cpp =================================================================== --- lib/Target/X86/Disassembler/X86Disassembler.cpp +++ lib/Target/X86/Disassembler/X86Disassembler.cpp @@ -1045,7 +1045,7 @@ return new X86GenericDisassembler(STI, Ctx, std::move(MII)); } -extern "C" void LLVMInitializeX86Disassembler() { +extern "C" LLVM_EXPORT void LLVMInitializeX86Disassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheX86_32Target(), createX86Disassembler); Index: lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp =================================================================== --- lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp +++ lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp @@ -513,7 +513,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeX86TargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeX86TargetMC() { for (Target *T : {&getTheX86_32Target(), &getTheX86_64Target()}) { // Register the MC asm info. RegisterMCAsmInfoFn X(*T, createX86MCAsmInfo); Index: lib/Target/X86/TargetInfo/X86TargetInfo.cpp =================================================================== --- lib/Target/X86/TargetInfo/X86TargetInfo.cpp +++ lib/Target/X86/TargetInfo/X86TargetInfo.cpp @@ -20,7 +20,7 @@ return TheX86_64Target; } -extern "C" void LLVMInitializeX86TargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeX86TargetInfo() { RegisterTarget X( getTheX86_32Target(), "x86", "32-bit X86: Pentium-Pro and above", "X86"); Index: lib/Target/X86/X86AsmPrinter.cpp =================================================================== --- lib/Target/X86/X86AsmPrinter.cpp +++ lib/Target/X86/X86AsmPrinter.cpp @@ -711,7 +711,7 @@ //===----------------------------------------------------------------------===// // Force static initialization. -extern "C" void LLVMInitializeX86AsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeX86AsmPrinter() { RegisterAsmPrinter X(getTheX86_32Target()); RegisterAsmPrinter Y(getTheX86_64Target()); } Index: lib/Target/X86/X86TargetMachine.cpp =================================================================== --- lib/Target/X86/X86TargetMachine.cpp +++ lib/Target/X86/X86TargetMachine.cpp @@ -59,7 +59,7 @@ "folding pass"), cl::init(true), cl::Hidden); -extern "C" void LLVMInitializeX86Target() { +extern "C" LLVM_EXPORT void LLVMInitializeX86Target() { // Register the target. RegisterTargetMachine X(getTheX86_32Target()); RegisterTargetMachine Y(getTheX86_64Target()); Index: lib/Target/XCore/Disassembler/XCoreDisassembler.cpp =================================================================== --- lib/Target/XCore/Disassembler/XCoreDisassembler.cpp +++ lib/Target/XCore/Disassembler/XCoreDisassembler.cpp @@ -778,7 +778,7 @@ return new XCoreDisassembler(STI, Ctx); } -extern "C" void LLVMInitializeXCoreDisassembler() { +extern "C" LLVM_EXPORT void LLVMInitializeXCoreDisassembler() { // Register the disassembler. TargetRegistry::RegisterMCDisassembler(getTheXCoreTarget(), createXCoreDisassembler); Index: lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp =================================================================== --- lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp +++ lib/Target/XCore/MCTargetDesc/XCoreMCTargetDesc.cpp @@ -121,7 +121,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeXCoreTargetMC() { +extern "C" LLVM_EXPORT void LLVMInitializeXCoreTargetMC() { // Register the MC asm info. RegisterMCAsmInfoFn X(getTheXCoreTarget(), createXCoreMCAsmInfo); Index: lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp =================================================================== --- lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp +++ lib/Target/XCore/TargetInfo/XCoreTargetInfo.cpp @@ -17,7 +17,7 @@ return TheXCoreTarget; } -extern "C" void LLVMInitializeXCoreTargetInfo() { +extern "C" LLVM_EXPORT void LLVMInitializeXCoreTargetInfo() { RegisterTarget X(getTheXCoreTarget(), "xcore", "XCore", "XCore"); } Index: lib/Target/XCore/XCoreAsmPrinter.cpp =================================================================== --- lib/Target/XCore/XCoreAsmPrinter.cpp +++ lib/Target/XCore/XCoreAsmPrinter.cpp @@ -295,6 +295,6 @@ } // Force static initialization. -extern "C" void LLVMInitializeXCoreAsmPrinter() { +extern "C" LLVM_EXPORT void LLVMInitializeXCoreAsmPrinter() { RegisterAsmPrinter X(getTheXCoreTarget()); } Index: lib/Target/XCore/XCoreTargetMachine.cpp =================================================================== --- lib/Target/XCore/XCoreTargetMachine.cpp +++ lib/Target/XCore/XCoreTargetMachine.cpp @@ -104,7 +104,7 @@ } // Force static initialization. -extern "C" void LLVMInitializeXCoreTarget() { +extern "C" LLVM_EXPORT void LLVMInitializeXCoreTarget() { RegisterTargetMachine X(getTheXCoreTarget()); } Index: unittests/CMakeLists.txt =================================================================== --- unittests/CMakeLists.txt +++ 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: unittests/Target/AArch64/CMakeLists.txt =================================================================== --- unittests/Target/AArch64/CMakeLists.txt +++ unittests/Target/AArch64/CMakeLists.txt @@ -17,6 +17,6 @@ Target ) -add_llvm_unittest(AArch64Tests +add_llvm_target_unittest(AArch64Tests InstSizes.cpp ) Index: unittests/Target/WebAssembly/CMakeLists.txt =================================================================== --- unittests/Target/WebAssembly/CMakeLists.txt +++ unittests/Target/WebAssembly/CMakeLists.txt @@ -13,6 +13,6 @@ WebAssemblyInfo ) -add_llvm_unittest(WebAssemblyTests +add_llvm_target_unittest(WebAssemblyTests WebAssemblyExceptionInfoTest.cpp ) Index: unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt =================================================================== --- unittests/tools/llvm-exegesis/AArch64/CMakeLists.txt +++ 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: unittests/tools/llvm-exegesis/ARM/CMakeLists.txt =================================================================== --- unittests/tools/llvm-exegesis/ARM/CMakeLists.txt +++ 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: unittests/tools/llvm-exegesis/PowerPC/CMakeLists.txt =================================================================== --- unittests/tools/llvm-exegesis/PowerPC/CMakeLists.txt +++ 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: unittests/tools/llvm-exegesis/X86/CMakeLists.txt =================================================================== --- unittests/tools/llvm-exegesis/X86/CMakeLists.txt +++ unittests/tools/llvm-exegesis/X86/CMakeLists.txt @@ -13,7 +13,7 @@ X86 ) -add_llvm_unittest(LLVMExegesisX86Tests +add_llvm_target_unittest(LLVMExegesisX86Tests AssemblerTest.cpp AnalysisTest.cpp BenchmarkResultTest.cpp Index: utils/unittest/CMakeLists.txt =================================================================== --- utils/unittest/CMakeLists.txt +++ utils/unittest/CMakeLists.txt @@ -65,3 +65,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)