diff --git a/build_metadata_generator.sh b/build_metadata_generator.sh index d3544fe4..e7a84326 100755 --- a/build_metadata_generator.sh +++ b/build_metadata_generator.sh @@ -25,7 +25,7 @@ checkpoint "Building metadata generator for x86_64 ..." build "x86_64" # make sure the binary is linked against the system libc++ instead of an @rpath one (which happens when compiling on arm64) # todo: perhaps there is a better way to do this with cmake? -install_name_tool -change @rpath/libc++.1.dylib /usr/lib/libc++.1.dylib dist/x86_64/bin/objc-metadata-generator +#install_name_tool -change @rpath/libc++.1.dylib /usr/lib/libc++.1.dylib dist/x86_64/bin/objc-metadata-generator otool -L dist/x86_64/bin/objc-metadata-generator checkpoint "Building metadata generator for arm64 ..." diff --git a/download_llvm.sh b/download_llvm.sh index cc04f23f..568d7720 100755 --- a/download_llvm.sh +++ b/download_llvm.sh @@ -2,7 +2,7 @@ set -e source "$(dirname "$0")/build_utils.sh" -LLVM_VERSION="15.0.7" +LLVM_VERSION="17.0.6" function download_llvm() { checkpoint "Downloading llvm (version $LLVM_VERSION)..." diff --git a/metadata-generator/CMakeLists.txt b/metadata-generator/CMakeLists.txt index 5c6dc8d4..a8974978 100644 --- a/metadata-generator/CMakeLists.txt +++ b/metadata-generator/CMakeLists.txt @@ -13,7 +13,7 @@ if (NOT LIBXML2_FOUND) message(FATAL_ERROR "libXML2 not found") endif () -get_filename_component(LLVM_ROOT "../../llvm/15.0.7" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") +get_filename_component(LLVM_ROOT "../../llvm/17.0.6" REALPATH BASE_DIR "${CMAKE_BINARY_DIR}") set(CMAKE_OSX_DEPLOYMENT_TARGET 13.0) set(LLVM_SYSTEM_LIBS "-lz -lcurses -lm -lxml2") @@ -21,7 +21,7 @@ set(LLVM_PREPROCESSOR_FLAGS "-I${LLVM_ROOT}/include -D__STDC_CONSTANT_MACROS -D_ # these are all available libs currently, we probably don't need all #set(LLVM_LIBS "-lLLVMCFGuard -lLLVMMipsInfo -lclangFrontend -lclangToolingRefactoring -lLLVMGlobalISel -lLLVMFileCheck -lLLVMAnalysis -lLLVMAArch64AsmParser -lLLVMBPFAsmParser -lclangToolingASTDiff -lLLVMAArch64Utils -lLLVMMCA -lclangHandleLLVM -lLLVMMIRParser -lLLVMHexagonAsmParser -lLLVMLanaiDesc -lLLVMSparcDisassembler -llldELF -lLLVMMipsAsmParser -lLLVMDebugInfoDWARF -lLLVMAVRDisassembler -lLLVMWebAssemblyInfo -lLLVMHexagonInfo -lLLVMARMCodeGen -lLLVMPowerPCCodeGen -lLLVMXRay -lLLVMMSP430CodeGen -lLLVMVectorize -lLLVMHexagonCodeGen -lclangCrossTU -lLLVMSupport -lLLVMDWP -lLLVMWindowsManifest -lclangToolingInclusions -lLLVMNVPTXDesc -lc++ -lLLVMXCoreCodeGen -lLLVMSystemZInfo -lclangFormat -lLLVMWebAssemblyUtils -lLLVMCFIVerify -lLLVMXCoreInfo -lLLVMAVRDesc -lLLVMARMDisassembler -lclangAPINotes -lLLVMSparcDesc -llldCOFF -lLLVMAggressiveInstCombine -lLLVMAMDGPUDesc -lLLVMMSP430AsmParser -lclangIndexSerialization -lLLVMExtensions -lLLVMInstCombine -lLLVMDWARFLinker -lclangHandleCXX -lLLVMRISCVDisassembler -lclangDependencyScanning -lLLVMRISCVAsmParser -lLLVMFuzzMutate -lLLVMExegesisMips -lclangDynamicASTMatchers -lclangTransformer -lclangCodeGen -lLLVMScalarOpts -lLLVMTextAPI -lclangSerialization -lLLVMPasses -lLLVMBPFInfo -lLLVMLinker -lLLVMObject -lLLVMMCJIT -lPollyISL -lLLVMExegesisPowerPC -lLLVMCore -lLLVMLanaiCodeGen -lLLVMipo -lLLVMAArch64Info -lLLVMMC -lLLVMObjCARCOpts -lclangRewrite -lLLVMCodeGen -lclangAST -lLLVMTarget -lLLVMX86AsmParser -lLLVMFrontendOpenACC -llldYAML -lLLVMDebugInfoPDB -lLLVMMCDisassembler -lclangEdit -lLLVMX86CodeGen -lLLVMX86Info -lLLVMBPFCodeGen -lLLVMDebugInfoGSYM -lLLVMBPFDisassembler -lclangRewriteFrontend -lclangLex -lLLVMRISCVInfo -lLLVMJITLink -lLLVMBitReader -lLLVMHexagonDisassembler -lLLVMExecutionEngine -lLLVMMSP430Desc -lLLVMPowerPCDesc -llldCommon -lLLVMWebAssemblyAsmParser -lclangBasic -lLLVMSystemZAsmParser -lLLVMLTO -lLLVMSystemZCodeGen -lLLVMRemarks -lLLVMOption -lLLVMARMDesc -lLLVMAMDGPUUtils -lclangAnalysis -lLLVMPowerPCAsmParser -lLLVMOrcTargetProcess -lLLVMInterfaceStub -lclangStaticAnalyzerCore -lclangASTMatchers -lLLVMIRReader -llldWasm -lLLVMFrontendOpenMP -llldDriver -lLLVMAArch64Desc -lclangDirectoryWatcher -lLLVMAVRCodeGen -lLLVMWebAssemblyDisassembler -lLLVMLanaiAsmParser -lLLVMRISCVCodeGen -lLLVMBPFDesc -lLLVMMSP430Disassembler -lclangDriver -lLLVMTransformUtils -lLLVMLibDriver -lLLVMCoverage -lLLVMARMInfo -lLLVMExegesisAArch64 -lclangParse -lLLVMInterpreter -lLLVMPowerPCInfo -lLLVMRuntimeDyld -lLLVMMSP430Info -lLLVMProfileData -lLLVMSymbolize -lLLVMSelectionDAG -lLLVMRISCVDesc -lLLVMExegesisX86 -lLLVMX86Desc -lLLVMSparcCodeGen -lLLVMBitWriter -lclangStaticAnalyzerCheckers -lLLVMObjectYAML -lclangTooling -lLLVMBinaryFormat -lLLVMMCParser -lLLVMWebAssemblyDesc -lLLVMHexagonDesc -lLLVMAMDGPUCodeGen -lLLVMX86Disassembler -lclangToolingCore -lLLVMDemangle -lLLVMARMAsmParser -lLLVMLanaiDisassembler -lLLVMLineEditor -lLLVMMipsCodeGen -lclangTesting -lLLVMLanaiInfo -lLLVMOrcJIT -lclangInterpreter -llldReaderWriter -lLLVMAsmPrinter -lLLVMExegesis -lLLVMAArch64Disassembler -lLLVMTableGenGlobalISel -lclangToolingSyntax -lLLVMMipsDesc -lPolly -lLLVMMCACustomBehaviourAMDGPU -llldMinGW -lLLVMXCoreDisassembler -lLLVMTableGen -lLLVMAArch64CodeGen -llldMachO -lLLVMCoroutines -llldMachO2 -lLLVMAVRAsmParser -lLLVMPowerPCDisassembler -lLLVMDebugInfoCodeView -lLLVMNVPTXCodeGen -lclangFrontendTool -lLLVMAMDGPUInfo -llldCore -lLLVMWebAssemblyCodeGen -lLLVMSystemZDisassembler -lLLVMSparcInfo -lLLVMAMDGPUDisassembler -lLLVMAVRInfo -lclangARCMigrate -lLLVMSparcAsmParser -lLLVMXCoreDesc -lLLVMAsmParser -lLLVMDebugInfoMSF -lLLVMOrcShared -lLLVMSystemZDesc -lLLVMNVPTXInfo -lLLVMBitstreamReader -lclangStaticAnalyzerFrontend -lclangIndex -lLLVMInstrumentation -lclangSema -lLLVMDlltoolDriver -lLLVMARMUtils -lLLVMMipsDisassembler -lLLVMAMDGPUAsmParser") # these come from the older llvm plus some added ones at the end -set(LLVM_LIBS "-lLLVMLTO -lLLVMPasses -lLLVMObjCARCOpts -lLLVMMIRParser -lLLVMSymbolize -lLLVMDebugInfoPDB -lLLVMDebugInfoDWARF -lLLVMCoverage -lLLVMMCA -lLLVMTableGen -lLLVMDlltoolDriver -lLLVMXRay -lLLVMOrcJIT -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMWebAssemblyDisassembler -lLLVMWebAssemblyCodeGen -lLLVMWebAssemblyDesc -lLLVMWebAssemblyAsmParser -lLLVMWebAssemblyInfo -lLLVMSystemZDisassembler -lLLVMSystemZCodeGen -lLLVMSystemZAsmParser -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSparcDisassembler -lLLVMSparcCodeGen -lLLVMSparcAsmParser -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMPowerPCDisassembler -lLLVMPowerPCCodeGen -lLLVMPowerPCAsmParser -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMMSP430Disassembler -lLLVMMSP430CodeGen -lLLVMMSP430AsmParser -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMLanaiDisassembler -lLLVMLanaiCodeGen -lLLVMLanaiAsmParser -lLLVMLanaiDesc -lLLVMLanaiInfo -lLLVMHexagonDisassembler -lLLVMHexagonCodeGen -lLLVMHexagonAsmParser -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMBPFDisassembler -lLLVMBPFCodeGen -lLLVMBPFAsmParser -lLLVMBPFDesc -lLLVMBPFInfo -lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMInfo -lLLVMARMUtils -lLLVMAMDGPUDisassembler -lLLVMAMDGPUCodeGen -lLLVMAMDGPUAsmParser -lLLVMAMDGPUDesc -lLLVMAMDGPUInfo -lLLVMAMDGPUUtils -lLLVMAArch64Disassembler -lLLVMAArch64CodeGen -lLLVMAArch64AsmParser -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64Utils -lLLVMObjectYAML -lLLVMLibDriver -lLLVMOption -lLLVMWindowsManifest -lLLVMTextAPI -lLLVMFuzzMutate -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86Info -lLLVMMCJIT -lLLVMLineEditor -lLLVMInterpreter -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMCodeGen -lLLVMTarget -lLLVMCoroutines -lLLVMipo -lLLVMInstrumentation -lLLVMVectorize -lLLVMScalarOpts -lLLVMLinker -lLLVMIRReader -lLLVMAsmParser -lLLVMInstCombine -lLLVMBitWriter -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle -lLLVMRemarks -lLLVMFrontendOpenMP -lLLVMBitstreamReader -lclangASTMatchers -lLLVMRISCVAsmParser -lclangSupport -lLLVMWindowsDriver") +set(LLVM_LIBS "-lLLVMLTO -lLLVMPasses -lLLVMObjCARCOpts -lLLVMMIRParser -lLLVMSymbolize -lLLVMDebugInfoPDB -lLLVMDebugInfoDWARF -lLLVMCoverage -lLLVMMCA -lLLVMTableGen -lLLVMDlltoolDriver -lLLVMXRay -lLLVMOrcJIT -lLLVMXCoreDisassembler -lLLVMXCoreCodeGen -lLLVMXCoreDesc -lLLVMXCoreInfo -lLLVMWebAssemblyDisassembler -lLLVMWebAssemblyCodeGen -lLLVMWebAssemblyDesc -lLLVMWebAssemblyAsmParser -lLLVMWebAssemblyInfo -lLLVMSystemZDisassembler -lLLVMSystemZCodeGen -lLLVMSystemZAsmParser -lLLVMSystemZDesc -lLLVMSystemZInfo -lLLVMSparcDisassembler -lLLVMSparcCodeGen -lLLVMSparcAsmParser -lLLVMSparcDesc -lLLVMSparcInfo -lLLVMPowerPCDisassembler -lLLVMPowerPCCodeGen -lLLVMPowerPCAsmParser -lLLVMPowerPCDesc -lLLVMPowerPCInfo -lLLVMNVPTXCodeGen -lLLVMNVPTXDesc -lLLVMNVPTXInfo -lLLVMMSP430Disassembler -lLLVMMSP430CodeGen -lLLVMMSP430AsmParser -lLLVMMSP430Desc -lLLVMMSP430Info -lLLVMMipsDisassembler -lLLVMMipsCodeGen -lLLVMMipsAsmParser -lLLVMMipsDesc -lLLVMMipsInfo -lLLVMLanaiDisassembler -lLLVMLanaiCodeGen -lLLVMLanaiAsmParser -lLLVMLanaiDesc -lLLVMLanaiInfo -lLLVMHexagonDisassembler -lLLVMHexagonCodeGen -lLLVMHexagonAsmParser -lLLVMHexagonDesc -lLLVMHexagonInfo -lLLVMBPFDisassembler -lLLVMBPFCodeGen -lLLVMBPFAsmParser -lLLVMBPFDesc -lLLVMBPFInfo -lLLVMARMDisassembler -lLLVMARMCodeGen -lLLVMARMAsmParser -lLLVMARMDesc -lLLVMARMInfo -lLLVMARMUtils -lLLVMAMDGPUDisassembler -lLLVMAMDGPUCodeGen -lLLVMAMDGPUAsmParser -lLLVMAMDGPUDesc -lLLVMAMDGPUInfo -lLLVMAMDGPUUtils -lLLVMAArch64Disassembler -lLLVMAArch64CodeGen -lLLVMAArch64AsmParser -lLLVMAArch64Desc -lLLVMAArch64Info -lLLVMAArch64Utils -lLLVMObjectYAML -lLLVMLibDriver -lLLVMOption -lLLVMWindowsManifest -lLLVMTextAPI -lLLVMFuzzMutate -lLLVMX86Disassembler -lLLVMX86AsmParser -lLLVMX86CodeGen -lLLVMGlobalISel -lLLVMSelectionDAG -lLLVMAsmPrinter -lLLVMX86Desc -lLLVMMCDisassembler -lLLVMX86Info -lLLVMMCJIT -lLLVMLineEditor -lLLVMInterpreter -lLLVMExecutionEngine -lLLVMRuntimeDyld -lLLVMCodeGen -lLLVMTarget -lLLVMCoroutines -lLLVMipo -lLLVMInstrumentation -lLLVMVectorize -lLLVMScalarOpts -lLLVMLinker -lLLVMIRReader -lLLVMAsmParser -lLLVMInstCombine -lLLVMBitWriter -lLLVMAggressiveInstCombine -lLLVMTransformUtils -lLLVMAnalysis -lLLVMProfileData -lLLVMObject -lLLVMMCParser -lLLVMMC -lLLVMDebugInfoCodeView -lLLVMDebugInfoMSF -lLLVMBitReader -lLLVMCore -lLLVMBinaryFormat -lLLVMSupport -lLLVMDemangle -lLLVMRemarks -lLLVMFrontendOpenMP -lLLVMBitstreamReader -lclangASTMatchers -lLLVMRISCVAsmParser -lclangSupport -lLLVMWindowsDriver -lLLVMTargetParser -lLLVMCAS -lclangCAS -lclangAPINotes -lLLVMCodeGenTypes") set(LLVM_LIBDIR "${LLVM_ROOT}/lib_${METADATA_BINARY_ARCH}") set(LLVM_LINKER_FLAGS "-L${LLVM_LIBDIR} -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-dead_strip") diff --git a/metadata-generator/build-step-metadata-generator.py b/metadata-generator/build-step-metadata-generator.py index 78e3603f..4c593f44 100755 --- a/metadata-generator/build-step-metadata-generator.py +++ b/metadata-generator/build-step-metadata-generator.py @@ -152,11 +152,6 @@ def generate_metadata(arch): deployment_target_flag_name + "=" + deployment_target]) else: generator_call.extend(["-target", "{}-{}-{}{}".format(arch, llvm_target_triple_vendor, llvm_target_triple_os_version, llvm_target_triple_suffix)]) - # since iPhoneOS 17.4 sdk TARGET_OS_IPHONE and TARGET_OS_IOS is not defined for non-simulator builds - # this seems to be a bug on Apple's side - if effective_platform_name == "-iphoneos" and not llvm_target_triple_suffix: - generator_call.extend(["-DTARGET_OS_IPHONE=1"]) - generator_call.extend(["-DTARGET_OS_IOS=1"]) generator_call.extend(header_search_paths_parsed) # HEADER_SEARCH_PATHS generator_call.extend(framework_search_paths_parsed) # FRAMEWORK_SEARCH_PATHS diff --git a/metadata-generator/src/HeadersParser/Parser.cpp b/metadata-generator/src/HeadersParser/Parser.cpp index 4d2a0706..41307597 100644 --- a/metadata-generator/src/HeadersParser/Parser.cpp +++ b/metadata-generator/src/HeadersParser/Parser.cpp @@ -42,15 +42,17 @@ static std::error_code collectModuleHeaderIncludes(FileManager& fileMgr, ModuleM if (!module->isAvailable()) return std::error_code(); - if (const FileEntry* umbrellaHeader = module->getUmbrellaHeader().Entry) { + if (module->Umbrella && module->Umbrella.is()) { + const FileEntry* umbrellaHeader = module->Umbrella.get(); if (std::error_code err = addHeaderInclude(umbrellaHeader, includes)) return err; } - else if (const DirectoryEntry* umbrellaDir = module->getUmbrellaDir().Entry) { + else if (module->Umbrella && module->Umbrella.is()) { + const DirectoryEntryRef umbrellaDir = module->Umbrella.get(); // Add all of the headers we find in this subdirectory. std::error_code ec; SmallString<128> dirNative; - path::native(umbrellaDir->getName(), dirNative); + path::native(umbrellaDir.getName(), dirNative); for (fs::recursive_directory_iterator dir(dirNative.str(), ec), dirEnd; dir != dirEnd && !ec; dir.increment(ec)) { // Check whether this entry has an extension typically associated with headers. if (!llvm::StringSwitch(path::extension(dir->path())) @@ -59,7 +61,8 @@ static std::error_code collectModuleHeaderIncludes(FileManager& fileMgr, ModuleM continue; // If this header is marked 'unavailable' in this module, don't include it. - if (const llvm::ErrorOr header = fileMgr.getFile(dir->path())) { + auto header = fileMgr.getFileRef(dir->path()); + if (header) { if (modMap.isHeaderUnavailableInModule(*header, module)) continue; @@ -114,7 +117,7 @@ static std::error_code CreateUmbrellaHeaderForAmbientModules(const std::vectorsubmodule_begin(), module->submodule_end(), collector); + std::for_each(module->submodules().begin(), module->submodules().end(), collector); }; std::for_each(modules.begin(), modules.end(), collector); diff --git a/metadata-generator/src/Meta/MetaFactory.cpp b/metadata-generator/src/Meta/MetaFactory.cpp index a6d1aea8..e84010f3 100644 --- a/metadata-generator/src/Meta/MetaFactory.cpp +++ b/metadata-generator/src/Meta/MetaFactory.cpp @@ -535,10 +535,10 @@ void MetaFactory::populateIdentificationFields(const clang::NamedDecl& decl, Met // calculate file name and module clang::SourceLocation location = _sourceManager.getFileLoc(decl.getLocation()); clang::FileID fileId = _sourceManager.getDecomposedLoc(location).first; - const clang::FileEntry* entry = _sourceManager.getFileEntryForID(fileId); + const clang::OptionalFileEntryRef entry = _sourceManager.getFileEntryRefForID(fileId); if (entry != nullptr) { meta.fileName = entry->getName(); - meta.module = _headerSearch.findModuleForHeader(entry).getModule(); + meta.module = _headerSearch.findModuleForHeader(*entry).getModule(); } // calculate js name @@ -715,8 +715,8 @@ Version MetaFactory::convertVersion(clang::VersionTuple clangVersion) { Version result = { .Major = (int)clangVersion.getMajor(), - .Minor = (int)(clangVersion.getMinor().hasValue() ? clangVersion.getMinor().getValue() : -1), - .SubMinor = (int)(clangVersion.getSubminor().hasValue() ? clangVersion.getSubminor().getValue() : -1) + .Minor = (int)(clangVersion.getMinor().has_value() ? clangVersion.getMinor().value() : -1), + .SubMinor = (int)(clangVersion.getSubminor().has_value() ? clangVersion.getSubminor().value() : -1) }; return result; }