[lld-macho] Remove linking bitcode support
Apple deprecated bitcode in the deployment process in Xcode 14.0. Last month Apple started requiring Xcode 14.1+ to submit apps to the App Store. Since there isn't a use for bundling bitcode outside of submitting to the App Store we should be safe to delete this handling entirely from LLD. Differential Revision: https://reviews.llvm.org/D150697
This commit is contained in:
@@ -99,10 +99,6 @@ if(LLD_BUILT_STANDALONE)
|
||||
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
|
||||
|
||||
@@ -54,13 +54,8 @@ add_lld_library(lldMachO
|
||||
LINK_LIBS
|
||||
lldCommon
|
||||
${LLVM_PTHREAD_LIB}
|
||||
${XAR_LIB}
|
||||
|
||||
DEPENDS
|
||||
MachOOptionsTableGen
|
||||
${tablegen_deps}
|
||||
)
|
||||
|
||||
if(LLVM_HAVE_LIBXAR)
|
||||
target_link_libraries(lldMachO PRIVATE ${XAR_LIB})
|
||||
endif()
|
||||
|
||||
@@ -131,7 +131,6 @@ struct Configuration {
|
||||
bool saveTemps = false;
|
||||
bool adhocCodesign = false;
|
||||
bool emitFunctionStarts = false;
|
||||
bool emitBitcodeBundle = false;
|
||||
bool emitDataInCodeInfo = false;
|
||||
bool emitEncryptionInfo = false;
|
||||
bool emitInitOffsets = false;
|
||||
|
||||
@@ -1614,7 +1614,6 @@ bool macho::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
|
||||
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 @@ bool macho::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
|
||||
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(
|
||||
|
||||
@@ -644,21 +644,6 @@ def add_ast_path : Separate<["-"], "add_ast_path">,
|
||||
HelpText<"AST paths will be emitted as STABS">,
|
||||
Group<grp_symtab>;
|
||||
|
||||
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<grp_bitcode>;
|
||||
def bitcode_hide_symbols : Flag<["-"], "bitcode_hide_symbols">,
|
||||
HelpText<"With -bitcode_bundle, hide all non-exported symbols from output bitcode bundle.">,
|
||||
Flags<[HelpHidden]>,
|
||||
Group<grp_bitcode>;
|
||||
def bitcode_symbol_map : Separate<["-"], "bitcode_symbol_map">,
|
||||
MetaVarName<"<path>">,
|
||||
HelpText<"Write the bitcode symbol reverse mapping to file <path>, or if a directory, to <path>/UUID.bcsymbolmap">,
|
||||
Flags<[HelpHidden]>,
|
||||
Group<grp_bitcode>;
|
||||
|
||||
def grp_rare : OptionGroup<"rare">, HelpText<"RARELY USED">;
|
||||
|
||||
def v : Flag<["-"], "v">,
|
||||
@@ -1200,6 +1185,28 @@ def slow_stubs : Flag<["-"], "slow_stubs">,
|
||||
Flags<[HelpHidden]>,
|
||||
Group<grp_obsolete>;
|
||||
|
||||
def bitcode_bundle : Flag<["-"], "bitcode_bundle">,
|
||||
HelpText<"Obsolete since the App Store no longer supports binaries with embedded bitcode">,
|
||||
Flags<[HelpHidden]>,
|
||||
Group<grp_obsolete>;
|
||||
def bitcode_hide_symbols : Flag<["-"], "bitcode_hide_symbols">,
|
||||
HelpText<"Obsolete since the App Store no longer supports binaries with embedded bitcode">,
|
||||
Flags<[HelpHidden]>,
|
||||
Group<grp_obsolete>;
|
||||
def bitcode_symbol_map : Separate<["-"], "bitcode_symbol_map">,
|
||||
MetaVarName<"<path>">,
|
||||
HelpText<"Obsolete since the App Store no longer supports binaries with embedded bitcode">,
|
||||
Flags<[HelpHidden]>,
|
||||
Group<grp_obsolete>;
|
||||
def bitcode_process_mode : Separate<["-"], "bitcode_process_mode">,
|
||||
HelpText<"Obsolete since the App Store no longer supports binaries with embedded bitcode">,
|
||||
Flags<[HelpHidden]>,
|
||||
Group<grp_obsolete>;
|
||||
def bitcode_verify : Flag<["-"], "bitcode_verify">,
|
||||
HelpText<"Obsolete since the App Store no longer supports binaries with embedded bitcode">,
|
||||
Flags<[HelpHidden]>,
|
||||
Group<grp_obsolete>;
|
||||
|
||||
def grp_undocumented : OptionGroup<"undocumented">, HelpText<"UNDOCUMENTED">;
|
||||
|
||||
def add_linker_option : Flag<["-"], "add_linker_option">,
|
||||
@@ -1226,14 +1233,6 @@ def allow_simulator_linking_to_macosx_dylibs : Flag<["-"], "allow_simulator_link
|
||||
HelpText<"This option is undocumented in ld64">,
|
||||
Flags<[HelpHidden]>,
|
||||
Group<grp_undocumented>;
|
||||
def bitcode_process_mode : Separate<["-"], "bitcode_process_mode">,
|
||||
HelpText<"This option is undocumented in ld64">,
|
||||
Flags<[HelpHidden]>,
|
||||
Group<grp_undocumented>;
|
||||
def bitcode_verify : Flag<["-"], "bitcode_verify">,
|
||||
HelpText<"This option is undocumented in ld64">,
|
||||
Flags<[HelpHidden]>,
|
||||
Group<grp_undocumented>;
|
||||
def classic_linker : Flag<["-"], "classic_linker">,
|
||||
HelpText<"This option is undocumented in ld64">,
|
||||
Flags<[HelpHidden]>,
|
||||
|
||||
@@ -35,13 +35,6 @@
|
||||
#include "llvm/Support/SHA256.h"
|
||||
#endif
|
||||
|
||||
#ifdef LLVM_HAVE_LIBXAR
|
||||
#include <fcntl.h>
|
||||
extern "C" {
|
||||
#include <xar/xar.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
using namespace llvm;
|
||||
using namespace llvm::MachO;
|
||||
using namespace llvm::support;
|
||||
@@ -1553,62 +1546,6 @@ void CodeSignatureSection::writeTo(uint8_t *buf) const {
|
||||
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;
|
||||
|
||||
@@ -533,18 +533,6 @@ public:
|
||||
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);
|
||||
|
||||
@@ -978,8 +978,6 @@ template <class LP> void Writer::createOutputSections() {
|
||||
dataInCodeSection = make<DataInCodeSection>();
|
||||
if (config->emitFunctionStarts)
|
||||
functionStartsSection = make<FunctionStartsSection>();
|
||||
if (config->emitBitcodeBundle)
|
||||
make<BitcodeBundleSection>();
|
||||
|
||||
switch (config->outputType) {
|
||||
case MH_EXECUTE:
|
||||
|
||||
@@ -4,7 +4,6 @@ llvm_canonicalize_cmake_booleans(
|
||||
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
|
||||
|
||||
@@ -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: <?xml version="1.0" encoding="UTF-8"?>
|
||||
; CHECK-NEXT: <xar>
|
||||
; CHECK-NEXT: <toc>
|
||||
; CHECK-NEXT: <checksum style="sha1">
|
||||
; CHECK-NEXT: <size>20</size>
|
||||
; CHECK-NEXT: <offset>0</offset>
|
||||
; CHECK-NEXT: </checksum>
|
||||
; CHECK-NEXT: <creation-time>{{.*}}</creation-time>
|
||||
; CHECK-NEXT: </toc>
|
||||
; CHECK-NEXT: </xar>
|
||||
|
||||
;; __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
|
||||
}
|
||||
@@ -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"
|
||||
@@ -125,9 +125,6 @@ if lit.util.which("cvtres", config.environment["PATH"]) or config.have_libxml2:
|
||||
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")
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ config.target_triple = "@LLVM_TARGET_TRIPLE@"
|
||||
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@
|
||||
|
||||
Reference in New Issue
Block a user