diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake index a01e17de8677aa..64c63e199ffa4e 100644 --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -252,17 +252,6 @@ else() set(LLVM_ENABLE_TERMINFO 0) endif() -check_library_exists(xar xar_open "" LLVM_HAVE_LIBXAR) -if(LLVM_HAVE_LIBXAR) - message(STATUS "The xar file format has been deprecated: LLVM_HAVE_LIBXAR might be removed in the future.") - # The xar file format has been deprecated since macOS 12.0. - if (CMAKE_OSX_DEPLOYMENT_TARGET VERSION_GREATER_EQUAL 12) - set(LLVM_HAVE_LIBXAR 0) - else() - set(XAR_LIB xar) - endif() -endif() - # function checks check_symbol_exists(arc4random "stdlib.h" HAVE_DECL_ARC4RANDOM) find_package(Backtrace) diff --git a/llvm/cmake/modules/LLVMConfig.cmake.in b/llvm/cmake/modules/LLVMConfig.cmake.in index 5465e981f23554..74e1c6bf52e230 100644 --- a/llvm/cmake/modules/LLVMConfig.cmake.in +++ b/llvm/cmake/modules/LLVMConfig.cmake.in @@ -140,8 +140,6 @@ set(LLVM_ENABLE_SHARED_LIBS @BUILD_SHARED_LIBS@) set(LLVM_DEFAULT_EXTERNAL_LIT "@LLVM_CONFIG_DEFAULT_EXTERNAL_LIT@") set(LLVM_LIT_ARGS "@LLVM_LIT_ARGS@") -set(LLVM_HAVE_LIBXAR "@LLVM_HAVE_LIBXAR@") - if(NOT TARGET LLVMSupport) @LLVM_CONFIG_INCLUDE_EXPORTS@ @llvm_config_include_buildtree_only_exports@ diff --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake index 012ae2174cc2a1..8d0a1bc5dc5658 100644 --- a/llvm/include/llvm/Config/llvm-config.h.cmake +++ b/llvm/include/llvm/Config/llvm-config.h.cmake @@ -104,9 +104,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYSEXITS_H ${HAVE_SYSEXITS_H} -/* Define if the xar_open() function is supported on this platform. */ -#cmakedefine LLVM_HAVE_LIBXAR ${LLVM_HAVE_LIBXAR} - /* Define if building libLLVM shared library */ #cmakedefine LLVM_BUILD_LLVM_DYLIB diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt index ddfe7107ce68d8..8aa652240081ce 100644 --- a/llvm/test/CMakeLists.txt +++ b/llvm/test/CMakeLists.txt @@ -1,6 +1,5 @@ llvm_canonicalize_cmake_booleans( BUILD_SHARED_LIBS - LLVM_HAVE_LIBXAR HAVE_OCAMLOPT LLVM_ENABLE_DIA_SDK LLVM_ENABLE_FFI diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py index 7a1e30b49b0c3d..ab245b71cdd16a 100644 --- a/llvm/test/lit.cfg.py +++ b/llvm/test/lit.cfg.py @@ -583,9 +583,6 @@ def have_ld64_plugin_support(): ) and not re.match(r"^arm64(e)?-apple-(macos|darwin)", config.target_triple): config.available_features.add("debug_frame") -if config.have_libxar: - config.available_features.add("xar") - if config.enable_threads: config.available_features.add("thread_support") diff --git a/llvm/test/lit.site.cfg.py.in b/llvm/test/lit.site.cfg.py.in index 57ee2100dfb7d0..6f3ab6561c9ec9 100644 --- a/llvm/test/lit.site.cfg.py.in +++ b/llvm/test/lit.site.cfg.py.in @@ -35,7 +35,6 @@ config.llvm_use_intel_jitevents = @LLVM_USE_INTEL_JITEVENTS@ config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@" config.have_zlib = @LLVM_ENABLE_ZLIB@ config.have_zstd = @LLVM_ENABLE_ZSTD@ -config.have_libxar = @LLVM_HAVE_LIBXAR@ config.have_libxml2 = @LLVM_ENABLE_LIBXML2@ config.have_curl = @LLVM_ENABLE_CURL@ config.have_httplib = @LLVM_ENABLE_HTTPLIB@ diff --git a/llvm/tools/llvm-driver/CMakeLists.txt b/llvm/tools/llvm-driver/CMakeLists.txt index 1c473c99cc1bf1..83e084069b96ac 100644 --- a/llvm/tools/llvm-driver/CMakeLists.txt +++ b/llvm/tools/llvm-driver/CMakeLists.txt @@ -27,11 +27,6 @@ set_target_properties(llvm-driver PROPERTIES OUTPUT_NAME llvm) target_link_libraries(llvm-driver PUBLIC ${LLVM_DRIVER_OBJLIBS}) target_link_libraries(llvm-driver PUBLIC LLVMDebuginfod) -if(LLVM_HAVE_LIBXAR) - # used by llvm-objdump - target_link_libraries(llvm-driver PUBLIC ${XAR_LIB}) -endif() - if(APPLE) # dsymutil uses some CoreFoundation stuff on Darwin... target_link_libraries(llvm-driver PRIVATE "-framework CoreFoundation") diff --git a/llvm/tools/llvm-objdump/CMakeLists.txt b/llvm/tools/llvm-objdump/CMakeLists.txt index ae173957b22607..0306736388979b 100644 --- a/llvm/tools/llvm-objdump/CMakeLists.txt +++ b/llvm/tools/llvm-objdump/CMakeLists.txt @@ -42,10 +42,6 @@ if(NOT LLVM_TOOL_LLVM_DRIVER_BUILD) target_link_libraries(llvm-objdump PRIVATE LLVMDebuginfod) endif() -if(LLVM_HAVE_LIBXAR AND NOT LLVM_TOOL_LLVM_DRIVER_BUILD) - target_link_libraries(llvm-objdump PRIVATE ${XAR_LIB}) -endif() - add_llvm_tool_symlink(llvm-otool llvm-objdump) if(LLVM_INSTALL_BINUTILS_SYMLINKS) diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index 296cd698304d0a..0e4aa25005d979 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -53,12 +53,6 @@ #include #include -#ifdef LLVM_HAVE_LIBXAR -extern "C" { -#include -} -#endif - using namespace llvm; using namespace llvm::object; using namespace llvm::objdump; @@ -212,39 +206,6 @@ typedef std::pair DiceTableEntry; typedef std::vector DiceTable; typedef DiceTable::iterator dice_table_iterator; -#ifdef LLVM_HAVE_LIBXAR -namespace { -struct ScopedXarFile { - xar_t xar; - ScopedXarFile(const char *filename, int32_t flags) { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - xar = xar_open(filename, flags); -#pragma clang diagnostic pop - } - ~ScopedXarFile() { - if (xar) - xar_close(xar); - } - ScopedXarFile(const ScopedXarFile &) = delete; - ScopedXarFile &operator=(const ScopedXarFile &) = delete; - operator xar_t() { return xar; } -}; - -struct ScopedXarIter { - xar_iter_t iter; - ScopedXarIter() : iter(xar_iter_new()) {} - ~ScopedXarIter() { - if (iter) - xar_iter_free(iter); - } - ScopedXarIter(const ScopedXarIter &) = delete; - ScopedXarIter &operator=(const ScopedXarIter &) = delete; - operator xar_iter_t() { return iter; } -}; -} // namespace -#endif // defined(LLVM_HAVE_LIBXAR) - // This is used to search for a data in code table entry for the PC being // disassembled. The j parameter has the PC in j.first. A single data in code // table entry can cover many bytes for each of its Kind's. So if the offset, @@ -1961,13 +1922,6 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, StringRef DisSegName, StringRef DisSectName); static void DumpProtocolSection(MachOObjectFile *O, const char *sect, uint32_t size, uint32_t addr); -#ifdef LLVM_HAVE_LIBXAR -static void DumpBitcodeSection(MachOObjectFile *O, const char *sect, - uint32_t size, bool verbose, - bool PrintXarHeader, bool PrintXarFileHeaders, - std::string XarMemberName); -#endif // defined(LLVM_HAVE_LIBXAR) - static void DumpSectionContents(StringRef Filename, MachOObjectFile *O, bool verbose) { SymbolAddressMap AddrMap; @@ -2037,13 +1991,6 @@ static void DumpSectionContents(StringRef Filename, MachOObjectFile *O, DumpProtocolSection(O, sect, sect_size, sect_addr); continue; } -#ifdef LLVM_HAVE_LIBXAR - if (SegName == "__LLVM" && SectName == "__bundle") { - DumpBitcodeSection(O, sect, sect_size, verbose, SymbolicOperands, - ArchiveHeaders, ""); - continue; - } -#endif // defined(LLVM_HAVE_LIBXAR) switch (section_type) { case MachO::S_REGULAR: DumpRawSectionContents(O, sect, sect_size, sect_addr); @@ -6732,371 +6679,6 @@ static void DumpProtocolSection(MachOObjectFile *O, const char *sect, } } -#ifdef LLVM_HAVE_LIBXAR -static inline void swapStruct(struct xar_header &xar) { - sys::swapByteOrder(xar.magic); - sys::swapByteOrder(xar.size); - sys::swapByteOrder(xar.version); - sys::swapByteOrder(xar.toc_length_compressed); - sys::swapByteOrder(xar.toc_length_uncompressed); - sys::swapByteOrder(xar.cksum_alg); -} - -static void PrintModeVerbose(uint32_t mode) { - switch(mode & S_IFMT){ - case S_IFDIR: - outs() << "d"; - break; - case S_IFCHR: - outs() << "c"; - break; - case S_IFBLK: - outs() << "b"; - break; - case S_IFREG: - outs() << "-"; - break; - case S_IFLNK: - outs() << "l"; - break; - case S_IFSOCK: - outs() << "s"; - break; - default: - outs() << "?"; - break; - } - - /* owner permissions */ - if(mode & S_IREAD) - outs() << "r"; - else - outs() << "-"; - if(mode & S_IWRITE) - outs() << "w"; - else - outs() << "-"; - if(mode & S_ISUID) - outs() << "s"; - else if(mode & S_IEXEC) - outs() << "x"; - else - outs() << "-"; - - /* group permissions */ - if(mode & (S_IREAD >> 3)) - outs() << "r"; - else - outs() << "-"; - if(mode & (S_IWRITE >> 3)) - outs() << "w"; - else - outs() << "-"; - if(mode & S_ISGID) - outs() << "s"; - else if(mode & (S_IEXEC >> 3)) - outs() << "x"; - else - outs() << "-"; - - /* other permissions */ - if(mode & (S_IREAD >> 6)) - outs() << "r"; - else - outs() << "-"; - if(mode & (S_IWRITE >> 6)) - outs() << "w"; - else - outs() << "-"; - if(mode & S_ISVTX) - outs() << "t"; - else if(mode & (S_IEXEC >> 6)) - outs() << "x"; - else - outs() << "-"; -} - -static void PrintXarFilesSummary(const char *XarFilename, xar_t xar) { - xar_file_t xf; - const char *key, *type, *mode, *user, *group, *size, *mtime, *name, *m; - char *endp; - uint32_t mode_value; - - ScopedXarIter xi; - if (!xi) { - WithColor::error(errs(), "llvm-objdump") - << "can't obtain an xar iterator for xar archive " << XarFilename - << "\n"; - return; - } - - // Go through the xar's files. - for (xf = xar_file_first(xar, xi); xf; xf = xar_file_next(xi)) { - ScopedXarIter xp; - if(!xp){ - WithColor::error(errs(), "llvm-objdump") - << "can't obtain an xar iterator for xar archive " << XarFilename - << "\n"; - return; - } - type = nullptr; - mode = nullptr; - user = nullptr; - group = nullptr; - size = nullptr; - mtime = nullptr; - name = nullptr; - for(key = xar_prop_first(xf, xp); key; key = xar_prop_next(xp)){ - const char *val = nullptr; - xar_prop_get(xf, key, &val); -#if 0 // Useful for debugging. - outs() << "key: " << key << " value: " << val << "\n"; -#endif - if(strcmp(key, "type") == 0) - type = val; - if(strcmp(key, "mode") == 0) - mode = val; - if(strcmp(key, "user") == 0) - user = val; - if(strcmp(key, "group") == 0) - group = val; - if(strcmp(key, "data/size") == 0) - size = val; - if(strcmp(key, "mtime") == 0) - mtime = val; - if(strcmp(key, "name") == 0) - name = val; - } - if(mode != nullptr){ - mode_value = strtoul(mode, &endp, 8); - if(*endp != '\0') - outs() << "(mode: \"" << mode << "\" contains non-octal chars) "; - if(strcmp(type, "file") == 0) - mode_value |= S_IFREG; - PrintModeVerbose(mode_value); - outs() << " "; - } - if(user != nullptr) - outs() << format("%10s/", user); - if(group != nullptr) - outs() << format("%-10s ", group); - if(size != nullptr) - outs() << format("%7s ", size); - if(mtime != nullptr){ - for(m = mtime; *m != 'T' && *m != '\0'; m++) - outs() << *m; - if(*m == 'T') - m++; - outs() << " "; - for( ; *m != 'Z' && *m != '\0'; m++) - outs() << *m; - outs() << " "; - } - if(name != nullptr) - outs() << name; - outs() << "\n"; - } -} - -static void DumpBitcodeSection(MachOObjectFile *O, const char *sect, - uint32_t size, bool verbose, - bool PrintXarHeader, bool PrintXarFileHeaders, - std::string XarMemberName) { - if(size < sizeof(struct xar_header)) { - outs() << "size of (__LLVM,__bundle) section too small (smaller than size " - "of struct xar_header)\n"; - return; - } - struct xar_header XarHeader; - memcpy(&XarHeader, sect, sizeof(struct xar_header)); - if (sys::IsLittleEndianHost) - swapStruct(XarHeader); - if (PrintXarHeader) { - if (!XarMemberName.empty()) - outs() << "In xar member " << XarMemberName << ": "; - else - outs() << "For (__LLVM,__bundle) section: "; - outs() << "xar header\n"; - if (XarHeader.magic == XAR_HEADER_MAGIC) - outs() << " magic XAR_HEADER_MAGIC\n"; - else - outs() << " magic " - << format_hex(XarHeader.magic, 10, true) - << " (not XAR_HEADER_MAGIC)\n"; - outs() << " size " << XarHeader.size << "\n"; - outs() << " version " << XarHeader.version << "\n"; - outs() << " toc_length_compressed " << XarHeader.toc_length_compressed - << "\n"; - outs() << "toc_length_uncompressed " << XarHeader.toc_length_uncompressed - << "\n"; - outs() << " cksum_alg "; - switch (XarHeader.cksum_alg) { - case XAR_CKSUM_NONE: - outs() << "XAR_CKSUM_NONE\n"; - break; - case XAR_CKSUM_SHA1: - outs() << "XAR_CKSUM_SHA1\n"; - break; - case XAR_CKSUM_MD5: - outs() << "XAR_CKSUM_MD5\n"; - break; -#ifdef XAR_CKSUM_SHA256 - case XAR_CKSUM_SHA256: - outs() << "XAR_CKSUM_SHA256\n"; - break; -#endif -#ifdef XAR_CKSUM_SHA512 - case XAR_CKSUM_SHA512: - outs() << "XAR_CKSUM_SHA512\n"; - break; -#endif - default: - outs() << XarHeader.cksum_alg << "\n"; - } - } - - SmallString<128> XarFilename; - int FD; - std::error_code XarEC = - sys::fs::createTemporaryFile("llvm-objdump", "xar", FD, XarFilename); - if (XarEC) { - WithColor::error(errs(), "llvm-objdump") << XarEC.message() << "\n"; - return; - } - ToolOutputFile XarFile(XarFilename, FD); - raw_fd_ostream &XarOut = XarFile.os(); - StringRef XarContents(sect, size); - XarOut << XarContents; - XarOut.close(); - if (XarOut.has_error()) - return; - - ScopedXarFile xar(XarFilename.c_str(), READ); - if (!xar) { - WithColor::error(errs(), "llvm-objdump") - << "can't create temporary xar archive " << XarFilename << "\n"; - return; - } - - SmallString<128> TocFilename; - std::error_code TocEC = - sys::fs::createTemporaryFile("llvm-objdump", "toc", TocFilename); - if (TocEC) { - WithColor::error(errs(), "llvm-objdump") << TocEC.message() << "\n"; - return; - } - xar_serialize(xar, TocFilename.c_str()); - - if (PrintXarFileHeaders) { - if (!XarMemberName.empty()) - outs() << "In xar member " << XarMemberName << ": "; - else - outs() << "For (__LLVM,__bundle) section: "; - outs() << "xar archive files:\n"; - PrintXarFilesSummary(XarFilename.c_str(), xar); - } - - ErrorOr> FileOrErr = - MemoryBuffer::getFileOrSTDIN(TocFilename.c_str()); - if (std::error_code EC = FileOrErr.getError()) { - WithColor::error(errs(), "llvm-objdump") << EC.message() << "\n"; - return; - } - std::unique_ptr &Buffer = FileOrErr.get(); - - if (!XarMemberName.empty()) - outs() << "In xar member " << XarMemberName << ": "; - else - outs() << "For (__LLVM,__bundle) section: "; - outs() << "xar table of contents:\n"; - outs() << Buffer->getBuffer() << "\n"; - - // TODO: Go through the xar's files. - ScopedXarIter xi; - if(!xi){ - WithColor::error(errs(), "llvm-objdump") - << "can't obtain an xar iterator for xar archive " - << XarFilename.c_str() << "\n"; - return; - } - for(xar_file_t xf = xar_file_first(xar, xi); xf; xf = xar_file_next(xi)){ - const char *key; - const char *member_name, *member_type, *member_size_string; - size_t member_size; - - ScopedXarIter xp; - if(!xp){ - WithColor::error(errs(), "llvm-objdump") - << "can't obtain an xar iterator for xar archive " - << XarFilename.c_str() << "\n"; - return; - } - member_name = NULL; - member_type = NULL; - member_size_string = NULL; - for(key = xar_prop_first(xf, xp); key; key = xar_prop_next(xp)){ - const char *val = nullptr; - xar_prop_get(xf, key, &val); -#if 0 // Useful for debugging. - outs() << "key: " << key << " value: " << val << "\n"; -#endif - if (strcmp(key, "name") == 0) - member_name = val; - if (strcmp(key, "type") == 0) - member_type = val; - if (strcmp(key, "data/size") == 0) - member_size_string = val; - } - /* - * If we find a file with a name, date/size and type properties - * and with the type being "file" see if that is a xar file. - */ - if (member_name != NULL && member_type != NULL && - strcmp(member_type, "file") == 0 && - member_size_string != NULL){ - // Extract the file into a buffer. - char *endptr; - member_size = strtoul(member_size_string, &endptr, 10); - if (*endptr == '\0' && member_size != 0) { - char *buffer; - if (xar_extract_tobuffersz(xar, xf, &buffer, &member_size) == 0) { -#if 0 // Useful for debugging. - outs() << "xar member: " << member_name << " extracted\n"; -#endif - // Set the XarMemberName we want to see printed in the header. - std::string OldXarMemberName; - // If XarMemberName is already set this is nested. So - // save the old name and create the nested name. - if (!XarMemberName.empty()) { - OldXarMemberName = XarMemberName; - XarMemberName = - (Twine("[") + XarMemberName + "]" + member_name).str(); - } else { - OldXarMemberName = ""; - XarMemberName = member_name; - } - // See if this is could be a xar file (nested). - if (member_size >= sizeof(struct xar_header)) { -#if 0 // Useful for debugging. - outs() << "could be a xar file: " << member_name << "\n"; -#endif - memcpy((char *)&XarHeader, buffer, sizeof(struct xar_header)); - if (sys::IsLittleEndianHost) - swapStruct(XarHeader); - if (XarHeader.magic == XAR_HEADER_MAGIC) - DumpBitcodeSection(O, buffer, member_size, verbose, - PrintXarHeader, PrintXarFileHeaders, - XarMemberName); - } - XarMemberName = OldXarMemberName; - delete buffer; - } - } - } - } -} -#endif // defined(LLVM_HAVE_LIBXAR) - static void printObjcMetaData(MachOObjectFile *O, bool verbose) { if (O->is64Bit()) printObjc2_64bit_MetaData(O, verbose); diff --git a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn index 174261ac44dbaf..64352d791679d1 100644 --- a/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/include/llvm/Config/BUILD.gn @@ -374,12 +374,6 @@ write_cmake_config("llvm-config") { ] } - if (llvm_enable_libxar) { - values += [ "LLVM_HAVE_LIBXAR=1" ] - } else { - values += [ "LLVM_HAVE_LIBXAR=" ] - } - if (llvm_enable_dia_sdk) { values += [ "LLVM_ENABLE_DIA_SDK=1" ] } else { diff --git a/llvm/utils/gn/secondary/llvm/test/BUILD.gn b/llvm/utils/gn/secondary/llvm/test/BUILD.gn index d1c4449ee1db7e..f859af249faf5f 100644 --- a/llvm/utils/gn/secondary/llvm/test/BUILD.gn +++ b/llvm/utils/gn/secondary/llvm/test/BUILD.gn @@ -176,12 +176,6 @@ write_lit_config("lit_site_cfg") { extra_values += [ "ENABLE_ASSERTIONS=0" ] # Must be 0. } - if (llvm_enable_libxar) { - extra_values += [ "LLVM_HAVE_LIBXAR=1" ] - } else { - extra_values += [ "LLVM_HAVE_LIBXAR=0" ] # Must be 0. - } - if (llvm_enable_dia_sdk) { extra_values += [ "LLVM_ENABLE_DIA_SDK=1" ] } else { diff --git a/utils/bazel/llvm_configs/llvm-config.h.cmake b/utils/bazel/llvm_configs/llvm-config.h.cmake index 012ae2174cc2a1..8d0a1bc5dc5658 100644 --- a/utils/bazel/llvm_configs/llvm-config.h.cmake +++ b/utils/bazel/llvm_configs/llvm-config.h.cmake @@ -104,9 +104,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_SYSEXITS_H ${HAVE_SYSEXITS_H} -/* Define if the xar_open() function is supported on this platform. */ -#cmakedefine LLVM_HAVE_LIBXAR ${LLVM_HAVE_LIBXAR} - /* Define if building libLLVM shared library */ #cmakedefine LLVM_BUILD_LLVM_DYLIB