diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt --- a/lld/CMakeLists.txt +++ b/lld/CMakeLists.txt @@ -99,10 +99,6 @@ set(LLVM_INCLUDE_TESTS OFF) endif() endif() - - if(LLVM_HAVE_LIBXAR) - set(XAR_LIB xar) - endif() endif() # standalone set(LLD_TOOLS_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH diff --git a/lld/MachO/CMakeLists.txt b/lld/MachO/CMakeLists.txt --- a/lld/MachO/CMakeLists.txt +++ b/lld/MachO/CMakeLists.txt @@ -54,13 +54,8 @@ LINK_LIBS lldCommon ${LLVM_PTHREAD_LIB} - ${XAR_LIB} DEPENDS MachOOptionsTableGen ${tablegen_deps} ) - -if(LLVM_HAVE_LIBXAR) - target_link_libraries(lldMachO PRIVATE ${XAR_LIB}) -endif() diff --git a/lld/MachO/Config.h b/lld/MachO/Config.h --- a/lld/MachO/Config.h +++ b/lld/MachO/Config.h @@ -131,7 +131,6 @@ bool saveTemps = false; bool adhocCodesign = false; bool emitFunctionStarts = false; - bool emitBitcodeBundle = false; bool emitDataInCodeInfo = false; bool emitEncryptionInfo = false; bool emitInitOffsets = false; diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -1614,7 +1614,6 @@ config->implicitDylibs = !args.hasArg(OPT_no_implicit_dylibs); config->emitFunctionStarts = args.hasFlag(OPT_function_starts, OPT_no_function_starts, true); - config->emitBitcodeBundle = args.hasArg(OPT_bitcode_bundle); config->emitDataInCodeInfo = args.hasFlag(OPT_data_in_code_info, OPT_no_data_in_code_info, true); config->emitChainedFixups = shouldEmitChainedFixups(args); @@ -1654,11 +1653,6 @@ args.hasFlag(OPT_encryptable, OPT_no_encryption, is_contained(encryptablePlatforms, config->platform())); -#ifndef LLVM_HAVE_LIBXAR - if (config->emitBitcodeBundle) - error("-bitcode_bundle unsupported because LLD wasn't built with libxar"); -#endif - if (const Arg *arg = args.getLastArg(OPT_install_name)) { if (config->warnDylibInstallName && config->outputType != MH_DYLIB) warn( diff --git a/lld/MachO/Options.td b/lld/MachO/Options.td --- a/lld/MachO/Options.td +++ b/lld/MachO/Options.td @@ -644,21 +644,6 @@ HelpText<"AST paths will be emitted as STABS">, Group; -def grp_bitcode : OptionGroup<"bitcode">, HelpText<"BITCODE BUILD FLOW">; - -def bitcode_bundle : Flag<["-"], "bitcode_bundle">, - HelpText<"Generate an embedded bitcode bundle in the __LLVM,__bundle section of the output">, - Group; -def bitcode_hide_symbols : Flag<["-"], "bitcode_hide_symbols">, - HelpText<"With -bitcode_bundle, hide all non-exported symbols from output bitcode bundle.">, - Flags<[HelpHidden]>, - Group; -def bitcode_symbol_map : Separate<["-"], "bitcode_symbol_map">, - MetaVarName<"">, - HelpText<"Write the bitcode symbol reverse mapping to file , or if a directory, to /UUID.bcsymbolmap">, - Flags<[HelpHidden]>, - Group; - def grp_rare : OptionGroup<"rare">, HelpText<"RARELY USED">; def v : Flag<["-"], "v">, @@ -1200,6 +1185,28 @@ Flags<[HelpHidden]>, Group; +def bitcode_bundle : Flag<["-"], "bitcode_bundle">, + HelpText<"Obsolete since the App Store no longer supports binaries with embedded bitcode">, + Flags<[HelpHidden]>, + Group; +def bitcode_hide_symbols : Flag<["-"], "bitcode_hide_symbols">, + HelpText<"Obsolete since the App Store no longer supports binaries with embedded bitcode">, + Flags<[HelpHidden]>, + Group; +def bitcode_symbol_map : Separate<["-"], "bitcode_symbol_map">, + MetaVarName<"">, + HelpText<"Obsolete since the App Store no longer supports binaries with embedded bitcode">, + Flags<[HelpHidden]>, + Group; +def bitcode_process_mode : Separate<["-"], "bitcode_process_mode">, + HelpText<"Obsolete since the App Store no longer supports binaries with embedded bitcode">, + Flags<[HelpHidden]>, + Group; +def bitcode_verify : Flag<["-"], "bitcode_verify">, + HelpText<"Obsolete since the App Store no longer supports binaries with embedded bitcode">, + Flags<[HelpHidden]>, + Group; + def grp_undocumented : OptionGroup<"undocumented">, HelpText<"UNDOCUMENTED">; def add_linker_option : Flag<["-"], "add_linker_option">, @@ -1226,14 +1233,6 @@ HelpText<"This option is undocumented in ld64">, Flags<[HelpHidden]>, Group; -def bitcode_process_mode : Separate<["-"], "bitcode_process_mode">, - HelpText<"This option is undocumented in ld64">, - Flags<[HelpHidden]>, - Group; -def bitcode_verify : Flag<["-"], "bitcode_verify">, - HelpText<"This option is undocumented in ld64">, - Flags<[HelpHidden]>, - Group; def classic_linker : Flag<["-"], "classic_linker">, HelpText<"This option is undocumented in ld64">, Flags<[HelpHidden]>, diff --git a/lld/MachO/SyntheticSections.h b/lld/MachO/SyntheticSections.h --- a/lld/MachO/SyntheticSections.h +++ b/lld/MachO/SyntheticSections.h @@ -533,18 +533,6 @@ void writeHashes(uint8_t *buf) const; }; -class BitcodeBundleSection final : public SyntheticSection { -public: - BitcodeBundleSection(); - uint64_t getSize() const override { return xarSize; } - void finalize() override; - void writeTo(uint8_t *buf) const override; - -private: - llvm::SmallString<261> xarPath; - uint64_t xarSize; -}; - class CStringSection : public SyntheticSection { public: CStringSection(const char *name); diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp --- a/lld/MachO/SyntheticSections.cpp +++ b/lld/MachO/SyntheticSections.cpp @@ -35,13 +35,6 @@ #include "llvm/Support/SHA256.h" #endif -#ifdef LLVM_HAVE_LIBXAR -#include -extern "C" { -#include -} -#endif - using namespace llvm; using namespace llvm::MachO; using namespace llvm::support; @@ -1553,62 +1546,6 @@ memset(id + fileName.size(), 0, fileNamePad); } -BitcodeBundleSection::BitcodeBundleSection() - : SyntheticSection(segment_names::llvm, section_names::bitcodeBundle) {} - -class ErrorCodeWrapper { -public: - explicit ErrorCodeWrapper(std::error_code ec) : errorCode(ec.value()) {} - explicit ErrorCodeWrapper(int ec) : errorCode(ec) {} - operator int() const { return errorCode; } - -private: - int errorCode; -}; - -#define CHECK_EC(exp) \ - do { \ - ErrorCodeWrapper ec(exp); \ - if (ec) \ - fatal(Twine("operation failed with error code ") + Twine(ec) + ": " + \ - #exp); \ - } while (0); - -void BitcodeBundleSection::finalize() { -#ifdef LLVM_HAVE_LIBXAR - using namespace llvm::sys::fs; - CHECK_EC(createTemporaryFile("bitcode-bundle", "xar", xarPath)); - -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - xar_t xar(xar_open(xarPath.data(), O_RDWR)); -#pragma clang diagnostic pop - if (!xar) - fatal("failed to open XAR temporary file at " + xarPath); - CHECK_EC(xar_opt_set(xar, XAR_OPT_COMPRESSION, XAR_OPT_VAL_NONE)); - // FIXME: add more data to XAR - CHECK_EC(xar_close(xar)); - - file_size(xarPath, xarSize); -#endif // defined(LLVM_HAVE_LIBXAR) -} - -void BitcodeBundleSection::writeTo(uint8_t *buf) const { - using namespace llvm::sys::fs; - file_t handle = - CHECK(openNativeFile(xarPath, CD_OpenExisting, FA_Read, OF_None), - "failed to open XAR file"); - std::error_code ec; - mapped_file_region xarMap(handle, mapped_file_region::mapmode::readonly, - xarSize, 0, ec); - if (ec) - fatal("failed to map XAR file"); - memcpy(buf, xarMap.const_data(), xarSize); - - closeFile(handle); - remove(xarPath); -} - CStringSection::CStringSection(const char *name) : SyntheticSection(segment_names::text, name) { flags = S_CSTRING_LITERALS; diff --git a/lld/MachO/Writer.cpp b/lld/MachO/Writer.cpp --- a/lld/MachO/Writer.cpp +++ b/lld/MachO/Writer.cpp @@ -978,8 +978,6 @@ dataInCodeSection = make(); if (config->emitFunctionStarts) functionStartsSection = make(); - if (config->emitBitcodeBundle) - make(); switch (config->outputType) { case MH_EXECUTE: diff --git a/lld/test/CMakeLists.txt b/lld/test/CMakeLists.txt --- a/lld/test/CMakeLists.txt +++ b/lld/test/CMakeLists.txt @@ -4,7 +4,6 @@ LLVM_ENABLE_ZSTD LLVM_ENABLE_LIBXML2 LLD_DEFAULT_LD_LLD_IS_MINGW - LLVM_HAVE_LIBXAR LLVM_BUILD_EXAMPLES LLVM_ENABLE_PLUGINS LLVM_BYE_LINK_INTO_TOOLS diff --git a/lld/test/MachO/bitcode-bundle.ll b/lld/test/MachO/bitcode-bundle.ll deleted file mode 100644 --- a/lld/test/MachO/bitcode-bundle.ll +++ /dev/null @@ -1,69 +0,0 @@ -; REQUIRES: x86, xar -; RUN: rm -rf %t; split-file %s %t -; RUN: opt -module-summary %t/test.ll -o %t/test.o -; RUN: opt -module-summary %t/foo.ll -o %t/foo.o -; RUN: %lld -lSystem -bitcode_bundle %t/test.o %t/foo.o -o %t/test -; RUN: llvm-objdump --macho --section=__LLVM,__bundle %t/test | FileCheck %s -; RUN: llvm-readobj --macho-segment %t/test | FileCheck %s --check-prefix=SEGMENT - -; CHECK: Contents of (__LLVM,__bundle) section -; CHECK-NEXT: For (__LLVM,__bundle) section: xar header -; CHECK-NEXT: magic XAR_HEADER_MAGIC -; CHECK-NEXT: size 28 -; CHECK-NEXT: version 1 -; CHECK-NEXT: toc_length_compressed -; CHECK-NEXT: toc_length_uncompressed -; CHECK-NEXT: cksum_alg XAR_CKSUM_SHA1 -; CHECK-NEXT: For (__LLVM,__bundle) section: xar table of contents: -; CHECK-NEXT: -; CHECK-NEXT: -; CHECK-NEXT: -; CHECK-NEXT: -; CHECK-NEXT: 20 -; CHECK-NEXT: 0 -; CHECK-NEXT: -; CHECK-NEXT: {{.*}} -; CHECK-NEXT: -; CHECK-NEXT: - -;; __LLVM must directly precede __LINKEDIT. -; SEGMENT: Name: __LLVM -; SEGMENT-NEXT: Size: 152 -; SEGMENT-NEXT: vmaddr: 0x[[#%X,LLVM_ADDR:]] -; SEGMENT-NEXT: vmsize: 0x[[#%X,LLVM_VMSIZE:]] -; SEGMENT-NEXT: fileoff: [[#LLVM_OFF:]] -; SEGMENT-NEXT: filesize: [[#LLVM_FILESIZE:]] -; SEGMENT-NEXT: maxprot: rw- -; SEGMENT-NEXT: initprot: rw- -; SEGMENT-NEXT: nsects: 1 -; SEGMENT-NEXT: flags: 0x0 -; SEGMENT-NEXT: } -; SEGMENT-NEXT: Segment { -; SEGMENT-NEXT: Cmd: LC_SEGMENT_64 -; SEGMENT-NEXT: Name: __LINKEDIT -; SEGMENT-NEXT: Size: 72 -; SEGMENT-NEXT: vmaddr: 0x[[#LLVM_ADDR + LLVM_VMSIZE]] -; SEGMENT-NEXT: vmsize: -; SEGMENT-NEXT: fileoff: [[#LLVM_OFF + LLVM_FILESIZE]] -; SEGMENT-NEXT: filesize: -; SEGMENT-NEXT: maxprot: r-- -; SEGMENT-NEXT: initprot: r-- -; SEGMENT-NEXT: nsects: 0 -; SEGMENT-NEXT: flags: 0x0 -; SEGMENT-NEXT: } - -;--- foo.ll -target triple = "x86_64-apple-darwin" -target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - -define void @foo() { - ret void -} - -;--- test.ll -target triple = "x86_64-apple-darwin" -target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - -define void @main() { - ret void -} diff --git a/lld/test/MachO/invalid/no-libxar.ll b/lld/test/MachO/invalid/no-bitcode-support.ll rename from lld/test/MachO/invalid/no-libxar.ll rename to lld/test/MachO/invalid/no-bitcode-support.ll --- a/lld/test/MachO/invalid/no-libxar.ll +++ b/lld/test/MachO/invalid/no-bitcode-support.ll @@ -1,8 +1,7 @@ ; REQUIRES: x86 -; UNSUPPORTED: xar ; RUN: opt -module-summary %s -o %t.o ; RUN: not %lld -lSystem -bitcode_bundle %t.o -o /dev/null 2>&1 | FileCheck %s -; CHECK: error: -bitcode_bundle unsupported because LLD wasn't built with libxar +; CHECK: error: Option `-bitcode_bundle' is obsolete. Please modernize your usage. target triple = "x86_64-apple-darwin" target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" diff --git a/lld/test/lit.cfg.py b/lld/test/lit.cfg.py --- a/lld/test/lit.cfg.py +++ b/lld/test/lit.cfg.py @@ -125,9 +125,6 @@ if config.enable_backtrace: config.available_features.add("backtrace") -if config.have_libxar: - config.available_features.add("xar") - if config.have_libxml2: config.available_features.add("libxml2") diff --git a/lld/test/lit.site.cfg.py.in b/lld/test/lit.site.cfg.py.in --- a/lld/test/lit.site.cfg.py.in +++ b/lld/test/lit.site.cfg.py.in @@ -20,7 +20,6 @@ config.python_executable = "@Python3_EXECUTABLE@" 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.sizeof_void_p = @CMAKE_SIZEOF_VOID_P@ config.ld_lld_default_mingw = @LLD_DEFAULT_LD_LLD_IS_MINGW@