diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -125,20 +125,85 @@ return {}; } -static TargetInfo *createTargetInfo(opt::InputArgList &args) { - // TODO: should unspecified arch be an error rather than defaulting? - // Jez: ld64 seems to make unspecified arch an error when LTO is - // being used. I'm not sure why though. Feels like we should be able - // to infer the arch from our input files regardless - StringRef archName = args.getLastArgValue(OPT_arch, "x86_64"); - config->arch = MachO::getArchitectureFromName(archName); - switch (MachO::getCPUTypeFromArchitecture(config->arch).first) { - case MachO::CPU_TYPE_X86_64: +// Read the first few bytes of \p path and try to determine its type. +static MachO::Architecture inferMachineType(StringRef path) { + auto mbOrErr = MemoryBuffer::getFileSlice( + path, /*MapSize=*/sizeof(mach_header_64), /*Offset=*/0); + if (auto ec = mbOrErr.getError()) { + error("cannot open " + path + ": " + ec.message()); + return AK_unknown; + } + + std::unique_ptr &mb = *mbOrErr; + MemoryBufferRef mbref = mb->getMemBufferRef(); + + const char *buf = mbref.getBufferStart(); + auto *hdr = reinterpret_cast(buf); + if (support::endian::read32be(&hdr->magic) == MachO::FAT_MAGIC) + return AK_unknown; + + if (identify_magic(mbref.getBuffer()) == file_magic::macho_object) { + // It doesn't matter whether we cast to the 32- or 64-bit versions of the + // mach header, the two fields we care about have the same size & layout. + auto *hdr = reinterpret_cast(buf); + return MachO::getArchitectureFromCpuType(hdr->cputype, hdr->cpusubtype); + } + + return AK_unknown; +} + +// We only consider non-fat object files when inferring the machine type. +static MachO::Architecture inferMachineType(const opt::InputArgList &args) { + for (const auto &arg : args) { + const auto &opt = arg->getOption(); + switch (opt.getID()) { + case OPT_INPUT: { + auto arch = inferMachineType(arg->getValue()); + if (arch != AK_unknown) + return arch; + break; + } + case OPT_filelist: + Optional buffer = readFile(arg->getValue()); + if (!buffer) + continue; + for (StringRef path : args::getLines(*buffer)) { + auto arch = inferMachineType(path); + if (arch != AK_unknown) + return arch; + } + break; + } + } + return AK_unknown; +} + +static TargetInfo *createTargetInfo(const opt::InputArgList &args) { + if (args.hasArg(OPT_arch)) { + StringRef archName = args.getLastArgValue(OPT_arch); + config->arch = MachO::getArchitectureFromName(archName); + if (config->arch == AK_unknown) + error("invalid -arch " + archName); + } else { + config->arch = inferMachineType(args); + if (config->arch == AK_unknown) + error("unable to infer architecture from input files, please use -arch " + "to specify"); + } + + switch (config->arch) { + case MachO::AK_x86_64: + case MachO::AK_x86_64h: return createX86_64TargetInfo(); - case MachO::CPU_TYPE_ARM64: + case MachO::AK_arm64: + case MachO::AK_arm64e: return createARM64TargetInfo(); + case MachO::AK_unknown: + return createUnknownTargetInfo(); default: - fatal("missing or unsupported -arch " + archName); + error("unsupported architecture " + getArchitectureName(config->arch)); + config->arch = AK_unknown; + return createUnknownTargetInfo(); } } @@ -664,7 +729,8 @@ // TODO: add logic here as we support more archs. E.g. i386 should default // to PIE from 10.7 - assert(config->arch == AK_x86_64 || config->arch == AK_x86_64h); + assert(config->arch == AK_unknown || config->arch == AK_x86_64 || + config->arch == AK_x86_64h); PlatformKind kind = config->platform.kind; if (kind == PlatformKind::macOS && @@ -749,7 +815,6 @@ config = make(); symtab = make(); - target = createTargetInfo(args); config->entry = symtab->addUndefined(args.getLastArgValue(OPT_e, "_main"), /*file=*/nullptr, @@ -827,7 +892,9 @@ return !errorCount(); } - initLLVM(); // must be run before any call to addFile() + // These must be run before any call to addFile(). + target = createTargetInfo(args); + initLLVM(); for (const auto &arg : args) { const auto &opt = arg->getOption(); diff --git a/lld/MachO/Target.h b/lld/MachO/Target.h --- a/lld/MachO/Target.h +++ b/lld/MachO/Target.h @@ -111,6 +111,7 @@ TargetInfo *createX86_64TargetInfo(); TargetInfo *createARM64TargetInfo(); +TargetInfo *createUnknownTargetInfo(); extern TargetInfo *target; diff --git a/lld/MachO/Target.cpp b/lld/MachO/Target.cpp --- a/lld/MachO/Target.cpp +++ b/lld/MachO/Target.cpp @@ -43,4 +43,45 @@ return valid; } +// Dummy target that we use when we cannot figure out the right target. We +// obviously cannot emit any valid binaries with this target; it's just +// initialized in order that we can emit additional error messages before +// exiting. +class UnknownTarget : public TargetInfo { +public: + UnknownTarget(); + + uint64_t + getEmbeddedAddend(llvm::MemoryBufferRef, const llvm::MachO::section_64 &, + const llvm::MachO::relocation_info) const override { + return 0; + } + + void relocateOne(uint8_t *loc, const Reloc &, uint64_t va, + uint64_t pc) const override {} + + void writeStub(uint8_t *buf, const Symbol &) const override {} + void writeStubHelperHeader(uint8_t *buf) const override {} + void writeStubHelperEntry(uint8_t *buf, const DylibSymbol &, + uint64_t entryAddr) const override {} + + void relaxGotLoad(uint8_t *loc, uint8_t type) const override {} + + const RelocAttrs &getRelocAttrs(uint8_t type) const override { + llvm_unreachable("unknown arch has no relocations"); + } + + uint64_t getPageSize() const override { return 1024; } +}; + +UnknownTarget::UnknownTarget() { + cpuType = 0; + cpuSubtype = 0; +} + +TargetInfo *macho::createUnknownTargetInfo() { + static UnknownTarget t; + return &t; +} + TargetInfo *macho::target = nullptr; diff --git a/lld/test/MachO/arch.s b/lld/test/MachO/arch.s --- a/lld/test/MachO/arch.s +++ b/lld/test/MachO/arch.s @@ -1,8 +1,15 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-darwin %s -o %t.o # RUN: %lld -o /dev/null %t.o -# RUN: not %lld -arch i386 -o /dev/null %t.o 2>&1 | FileCheck %s -# CHECK: error: missing or unsupported -arch i386 +# RUN: not %lld -arch i386 -o /dev/null %t.o 2>&1 | FileCheck %s --check-prefix=I386 +# RUN: not %lld -arch foo -o /dev/null %t.o 2>&1 | FileCheck %s --check-prefix=FOO +# RUN: rm -f %t.a +# RUN: llvm-ar rcs %t.a %t.o +# RUN: not %lld -o /dev/null %t.a 2>&1 | FileCheck %s --check-prefix=ARCHIVE + +# I386: error: unsupported architecture i386 +# FOO: error: invalid -arch foo +# ARCHIVE: error: unable to infer architecture from input files, please use -arch to specify .text .global _main diff --git a/lld/test/MachO/arm64-reloc-got-load.s b/lld/test/MachO/arm64-reloc-got-load.s --- a/lld/test/MachO/arm64-reloc-got-load.s +++ b/lld/test/MachO/arm64-reloc-got-load.s @@ -4,11 +4,11 @@ # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/main.s -o %t/main.o # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/foobar.s -o %t/foobar.o -# RUN: %lld -lSystem -arch arm64 -o %t/static %t/main.o %t/foobar.o +# RUN: %lld -lSystem -o %t/static %t/main.o %t/foobar.o # RUN: llvm-objdump --macho -d --no-show-raw-insn --syms %t/static | FileCheck %s --check-prefix=STATIC -# RUN: %lld -lSystem -arch arm64 -dylib -o %t/libfoo.dylib %t/foobar.o -# RUN: %lld -lSystem -arch arm64 -o %t/main %t/main.o %t/libfoo.dylib +# RUN: %lld -lSystem -dylib -o %t/libfoo.dylib %t/foobar.o +# RUN: %lld -lSystem -o %t/main %t/main.o %t/libfoo.dylib # RUN: llvm-objdump --macho -d --no-show-raw-insn --section-headers %t/main | FileCheck %s --check-prefix=DYLIB # STATIC-LABEL: _main: diff --git a/lld/test/MachO/arm64-reloc-pointer-to-got.s b/lld/test/MachO/arm64-reloc-pointer-to-got.s --- a/lld/test/MachO/arm64-reloc-pointer-to-got.s +++ b/lld/test/MachO/arm64-reloc-pointer-to-got.s @@ -1,7 +1,7 @@ # REQUIRES: aarch64 # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t.o -# RUN: %lld -lSystem -arch arm64 -o %t %t.o +# RUN: %lld -lSystem -o %t %t.o # RUN: llvm-objdump --macho -d --full-contents --section-headers %t | FileCheck %s ## FIXME: Even though we have reserved a GOT slot for _foo due to diff --git a/lld/test/MachO/arm64-relocs.s b/lld/test/MachO/arm64-relocs.s --- a/lld/test/MachO/arm64-relocs.s +++ b/lld/test/MachO/arm64-relocs.s @@ -1,6 +1,6 @@ # REQUIRES: aarch64, shell # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t.o -# RUN: %lld -dylib -arch arm64 -lSystem -o %t %t.o +# RUN: %lld -dylib -lSystem -o %t %t.o # RUN: (llvm-objdump --syms %t; llvm-objdump --macho -d --section=__const %t) | FileCheck %s # CHECK-LABEL: SYMBOL TABLE: diff --git a/lld/test/MachO/codemodel.ll b/lld/test/MachO/codemodel.ll --- a/lld/test/MachO/codemodel.ll +++ b/lld/test/MachO/codemodel.ll @@ -1,7 +1,7 @@ ; REQUIRES: x86 ; RUN: llvm-as %s -o %t.o -; RUN: %lld -lSystem %t.o -o %ts -mllvm -code-model=small -; RUN: %lld -lSystem %t.o -o %tl -mllvm -code-model=large +; RUN: %lld -arch x86_64 -lSystem %t.o -o %ts -mllvm -code-model=small +; RUN: %lld -arch x86_64 -lSystem %t.o -o %tl -mllvm -code-model=large ; RUN: llvm-objdump -d %ts | FileCheck %s --check-prefix=CHECK-SMALL ; RUN: llvm-objdump -d %tl | FileCheck %s --check-prefix=CHECK-LARGE diff --git a/lld/test/MachO/cpu-string.ll b/lld/test/MachO/cpu-string.ll --- a/lld/test/MachO/cpu-string.ll +++ b/lld/test/MachO/cpu-string.ll @@ -1,11 +1,11 @@ ; REQUIRES: x86 ; RUN: llvm-as %s -o %t.o -; RUN: %lld %t.o -o %t.dylib -dylib +; RUN: %lld -arch x86_64 %t.o -o %t.dylib -dylib ; RUN: llvm-objdump -d --section="__text" --no-leading-addr --no-show-raw-insn %t.dylib | FileCheck %s ; CHECK: nop{{$}} -; RUN: %lld -mcpu znver1 %t.o -o %t.znver1.dylib -dylib +; RUN: %lld -arch x86_64 -mcpu znver1 %t.o -o %t.znver1.dylib -dylib ; RUN: llvm-objdump -d --section="__text" --no-leading-addr --no-show-raw-insn %t.znver1.dylib | FileCheck %s --check-prefix=ZNVER1 ; ZNVER1: nopw diff --git a/lld/test/MachO/fat-arch.s b/lld/test/MachO/fat-arch.s --- a/lld/test/MachO/fat-arch.s +++ b/lld/test/MachO/fat-arch.s @@ -2,10 +2,10 @@ # RUN: llvm-mc -filetype=obj -triple=i386-apple-darwin %s -o %t.i386.o # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.x86_64.o # RUN: llvm-lipo %t.i386.o %t.x86_64.o -create -o %t.fat.o -# RUN: %lld -o /dev/null %t.fat.o +# RUN: %lld -arch x86_64 -o /dev/null %t.fat.o # RUN: llvm-lipo %t.i386.o -create -o %t.noarch.o -# RUN: not %lld -o /dev/null %t.noarch.o 2>&1 | \ +# RUN: not %lld -arch x86_64 -o /dev/null %t.noarch.o 2>&1 | \ # RUN: FileCheck %s -DFILE=%t.noarch.o # CHECK: error: unable to find matching architecture in [[FILE]] diff --git a/lld/test/MachO/header.s b/lld/test/MachO/header.s --- a/lld/test/MachO/header.s +++ b/lld/test/MachO/header.s @@ -2,10 +2,10 @@ # RUN: rm -rf %t && mkdir -p %t # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/x86_64-test.o # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t/arm64-test.o -# RUN: %lld -arch x86_64 -platform_version macos 10.5.0 11.0 -o %t/x86-64-executable %t/x86_64-test.o -# RUN: %lld -arch arm64 -o %t/arm64-executable %t/arm64-test.o -# RUN: %lld -arch x86_64 -dylib -o %t/x86-64-dylib %t/x86_64-test.o -# RUN: %lld -arch arm64 -dylib -o %t/arm64-dylib %t/arm64-test.o +# RUN: %lld -platform_version macos 10.5.0 11.0 -o %t/x86-64-executable %t/x86_64-test.o +# RUN: %lld -o %t/arm64-executable %t/arm64-test.o +# RUN: %lld -dylib -o %t/x86-64-dylib %t/x86_64-test.o +# RUN: %lld -dylib -o %t/arm64-dylib %t/arm64-test.o # RUN: llvm-objdump --macho --all-headers %t/x86-64-executable | FileCheck %s -DCAPS=LIB64 # RUN: llvm-objdump --macho --all-headers %t/arm64-executable | FileCheck %s -DCAPS=0x00 diff --git a/lld/test/MachO/invalid/invalid-executable.s b/lld/test/MachO/invalid/invalid-executable.s --- a/lld/test/MachO/invalid/invalid-executable.s +++ b/lld/test/MachO/invalid/invalid-executable.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-darwin %s -o %t.o -# RUN: %lld -o %t %t.o -# RUN: not %lld -o /dev/null %t 2>&1 | FileCheck %s -DFILE=%t +# RUN: %lld -lSystem -o %t %t.o +# RUN: not %lld -lSystem -o /dev/null %t 2>&1 | FileCheck %s -DFILE=%t # CHECK: error: [[FILE]]: unhandled file type .text diff --git a/lld/test/MachO/invalid/invalid-fat-offset.s b/lld/test/MachO/invalid/invalid-fat-offset.s --- a/lld/test/MachO/invalid/invalid-fat-offset.s +++ b/lld/test/MachO/invalid/invalid-fat-offset.s @@ -1,6 +1,6 @@ # REQUIRES: x86 # RUN: yaml2obj %s -o %t.o -# RUN: not %lld -o /dev/null %t.o 2>&1 | \ +# RUN: not %lld -arch x86_64 -o /dev/null %t.o 2>&1 | \ # RUN: FileCheck %s -DFILE=%t.o # CHECK: error: [[FILE]]: slice extends beyond end of file diff --git a/lld/test/MachO/invalid/invalid-relocation-pcrel.yaml b/lld/test/MachO/invalid/invalid-relocation-pcrel.yaml --- a/lld/test/MachO/invalid/invalid-relocation-pcrel.yaml +++ b/lld/test/MachO/invalid/invalid-relocation-pcrel.yaml @@ -2,7 +2,7 @@ # RUN: rm -rf %t; mkdir %t # RUN: yaml2obj %s -o %t/test.o # RUN: llvm-ar rcs %t/test.a %t/test.o -# RUN: not %lld -o /dev/null %t/test.a 2>&1 | FileCheck %s +# RUN: not %lld -arch x86_64 -o /dev/null %t/test.a 2>&1 | FileCheck %s # # CHECK: error: UNSIGNED relocation must not be PC-relative at offset 1 of __TEXT,__text in {{.*}}test.a(test.o) diff --git a/lld/test/MachO/lc-linker-option.ll b/lld/test/MachO/lc-linker-option.ll --- a/lld/test/MachO/lc-linker-option.ll +++ b/lld/test/MachO/lc-linker-option.ll @@ -3,7 +3,7 @@ # RUN: split-file %s %t # RUN: llvm-as %t/framework.ll -o %t/framework.o -# RUN: %lld %t/framework.o -o %t/frame +# RUN: %lld -arch x86_64 %t/framework.o -o %t/frame # RUN: llvm-objdump --macho --all-headers %t/frame | FileCheck --check-prefix=FRAME %s \ # RUN: --implicit-check-not LC_LOAD_DYLIB # FRAME: cmd LC_LOAD_DYLIB @@ -11,12 +11,12 @@ # FRAME-NEXT: name /System/Library/Frameworks/CoreFoundation.framework/CoreFoundation # RUN: llvm-as %t/l.ll -o %t/l.o -# RUN: %lld %t/l.o -o %t/l +# RUN: %lld -arch x86_64 %t/l.o -o %t/l # RUN: llvm-objdump --macho --all-headers %t/l | FileCheck --check-prefix=LIB %s \ # RUN: --implicit-check-not LC_LOAD_DYLIB ## Check that we don't create duplicate LC_LOAD_DYLIBs. -# RUN: %lld -lSystem %t/l.o -o %t/l +# RUN: %lld -arch x86_64 -lSystem %t/l.o -o %t/l # RUN: llvm-objdump --macho --all-headers %t/l | FileCheck --check-prefix=LIB %s \ # RUN: --implicit-check-not LC_LOAD_DYLIB # LIB: cmd LC_LOAD_DYLIB @@ -24,7 +24,7 @@ # LIB-NEXT: name /usr/lib/libSystem.B.dylib # RUN: llvm-as %t/invalid.ll -o %t/invalid.o -# RUN: not %lld %t/invalid.o -o /dev/null 2>&1 | FileCheck --check-prefix=INVALID %s +# RUN: not %lld -arch x86_64 %t/invalid.o -o /dev/null 2>&1 | FileCheck --check-prefix=INVALID %s # INVALID: error: -why_load is not allowed in LC_LINKER_OPTION #--- framework.ll diff --git a/lld/test/MachO/linkonce.ll b/lld/test/MachO/linkonce.ll --- a/lld/test/MachO/linkonce.ll +++ b/lld/test/MachO/linkonce.ll @@ -2,9 +2,9 @@ ; RUN: rm -rf %t; split-file %s %t ; RUN: opt -module-summary %t/first.ll -o %t/first.o ; RUN: opt -module-summary %t/second.ll -o %t/second.o -; RUN: %lld -dylib -lSystem %t/first.o %t/second.o -o %t/12 +; RUN: %lld -arch x86_64 -dylib -lSystem %t/first.o %t/second.o -o %t/12 ; RUN: llvm-objdump --syms %t/12 | FileCheck %s --check-prefix=FIRST -; RUN: %lld -dylib -lSystem %t/second.o %t/first.o -o %t/21 +; RUN: %lld -arch x86_64 -dylib -lSystem %t/second.o %t/first.o -o %t/21 ; RUN: llvm-objdump --syms %t/21 | FileCheck %s --check-prefix=SECOND ; FIRST: w O __TEXT,first _foo diff --git a/lld/test/MachO/lto-object-path.ll b/lld/test/MachO/lto-object-path.ll --- a/lld/test/MachO/lto-object-path.ll +++ b/lld/test/MachO/lto-object-path.ll @@ -4,10 +4,10 @@ ; RUN: rm -rf %t; mkdir %t ; RUN: llvm-as %s -o %t/test.o -; RUN: %lld %t/test.o -o %t/test +; RUN: %lld -arch x86_64 %t/test.o -o %t/test ; RUN: llvm-nm -pa %t/test | FileCheck %s --check-prefixes CHECK,NOOBJPATH -; RUN: %lld %t/test.o -o %t/test -object_path_lto %t/lto-temps +; RUN: %lld -arch x86_64 %t/test.o -o %t/test -object_path_lto %t/lto-temps ; RUN: llvm-nm -pa %t/test | FileCheck %s --check-prefixes CHECK,OBJPATH -DDIR=%t/lto-temps ; CHECK: 0000000000000000 - 00 0000 SO /tmp/test.cpp diff --git a/lld/test/MachO/lto-save-temps.ll b/lld/test/MachO/lto-save-temps.ll --- a/lld/test/MachO/lto-save-temps.ll +++ b/lld/test/MachO/lto-save-temps.ll @@ -6,14 +6,14 @@ ; RUN: rm -rf %t; split-file %s %t ; RUN: llvm-as %t/foo.ll -o %t/foo.o ; RUN: llvm-as %t/test.ll -o %t/test.o -; RUN: %lld -save-temps %t/foo.o %t/test.o -o %t/test +; RUN: %lld -arch x86_64 -save-temps %t/foo.o %t/test.o -o %t/test ; RUN: llvm-objdump -d --no-show-raw-insn %t/test.lto.o | FileCheck %s --check-prefix=ALL ; RUN: llvm-objdump -d --no-show-raw-insn %t/test | FileCheck %s --check-prefix=ALL ; RUN: rm -rf %t; split-file %s %t ; RUN: opt -module-summary %t/foo.ll -o %t/foo.o ; RUN: opt -module-summary %t/test.ll -o %t/test.o -; RUN: %lld -save-temps %t/foo.o %t/test.o -o %t/test +; RUN: %lld -arch x86_64 -save-temps %t/foo.o %t/test.o -o %t/test ; RUN: llvm-objdump -d --no-show-raw-insn %t/test1.lto.o | FileCheck %s --check-prefix=FOO ; RUN: llvm-objdump -d --no-show-raw-insn %t/test2.lto.o | FileCheck %s --check-prefix=MAIN ; RUN: llvm-objdump -d --no-show-raw-insn %t/test | FileCheck %s --check-prefix=ALL diff --git a/lld/test/MachO/mattrs.ll b/lld/test/MachO/mattrs.ll --- a/lld/test/MachO/mattrs.ll +++ b/lld/test/MachO/mattrs.ll @@ -3,10 +3,10 @@ ;; Verify that LTO behavior can be tweaked using -mattr. -; RUN: %lld -mcpu haswell -mllvm -mattr=+fma %t.o -o %t.dylib -dylib +; RUN: %lld -arch x86_64 -mcpu haswell -mllvm -mattr=+fma %t.o -o %t.dylib -dylib ; RUN: llvm-objdump -d --section="__text" --no-leading-addr --no-show-raw-insn %t.dylib | FileCheck %s --check-prefix=FMA -; RUN: %lld -mcpu haswell -mllvm -mattr=-fma %t.o -o %t.dylib -dylib +; RUN: %lld -arch x86_64 -mcpu haswell -mllvm -mattr=-fma %t.o -o %t.dylib -dylib ; RUN: llvm-objdump -d --section="__text" --no-leading-addr --no-show-raw-insn %t.dylib | FileCheck %s --check-prefix=NO-FMA ; FMA: <_foo>: diff --git a/lld/test/MachO/module-asm.ll b/lld/test/MachO/module-asm.ll --- a/lld/test/MachO/module-asm.ll +++ b/lld/test/MachO/module-asm.ll @@ -1,6 +1,6 @@ ; REQUIRES: x86 ; RUN: llvm-as %s -o %t.o -; RUN: %lld %t.o -o %t +; RUN: %lld -arch x86_64 %t.o -o %t ; RUN: llvm-objdump -d %t | FileCheck %s ; CHECK: <_foo>: diff --git a/lld/test/MachO/objc-arc-contract.ll b/lld/test/MachO/objc-arc-contract.ll --- a/lld/test/MachO/objc-arc-contract.ll +++ b/lld/test/MachO/objc-arc-contract.ll @@ -5,15 +5,15 @@ ;; which doesn't know how to handle it. ; RUN: llvm-as %s -o %t.o -; RUN: %lld -dylib -lSystem %t.o -o %t --lto-legacy-pass-manager +; RUN: %lld -arch x86_64 -dylib -lSystem %t.o -o %t --lto-legacy-pass-manager ; RUN: llvm-objdump -d %t | FileCheck %s -; RUN: %lld -dylib -lSystem %t.o -o %t --no-lto-legacy-pass-manager +; RUN: %lld -arch x86_64 -dylib -lSystem %t.o -o %t --no-lto-legacy-pass-manager ; RUN: llvm-objdump -d %t | FileCheck %s ; RUN: opt -module-summary %s -o %t.o -; RUN: %lld -dylib -lSystem %t.o -o %t --lto-legacy-pass-manager +; RUN: %lld -arch x86_64 -dylib -lSystem %t.o -o %t --lto-legacy-pass-manager ; RUN: llvm-objdump -d %t | FileCheck %s -; RUN: %lld -dylib -lSystem %t.o -o %t --no-lto-legacy-pass-manager +; RUN: %lld -arch x86_64 -dylib -lSystem %t.o -o %t --no-lto-legacy-pass-manager ; RUN: llvm-objdump -d %t | FileCheck %s ; CHECK: <_foo>: diff --git a/lld/test/MachO/reloc-subtractor.s b/lld/test/MachO/reloc-subtractor.s --- a/lld/test/MachO/reloc-subtractor.s +++ b/lld/test/MachO/reloc-subtractor.s @@ -4,7 +4,7 @@ # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %s -o %t/arm64.o # RUN: %lld -lSystem %t/x86_64.o -o %t/x86_64 # RUN: llvm-objdump --syms --full-contents --rebase %t/x86_64 | FileCheck %s -# RUN: %lld -arch arm64 -lSystem %t/arm64.o -o %t/arm64 +# RUN: %lld -lSystem %t/arm64.o -o %t/arm64 # RUN: llvm-objdump --syms --full-contents --rebase %t/arm64 | FileCheck %s # CHECK-LABEL: SYMBOL TABLE: diff --git a/lld/test/MachO/reproduce-thin-archives.s b/lld/test/MachO/reproduce-thin-archives.s --- a/lld/test/MachO/reproduce-thin-archives.s +++ b/lld/test/MachO/reproduce-thin-archives.s @@ -6,10 +6,10 @@ # RUN: cd %t.dir # RUN: llvm-ar rcsT foo.a foo.o -# RUN: %lld foo.a -o /dev/null --reproduce repro.tar +# RUN: %lld -arch x86_64 foo.a -o /dev/null --reproduce repro.tar # RUN: tar tf repro.tar | FileCheck -DPATH='repro/%:t.dir' %s -# RUN: %lld -all_load foo.a -o /dev/null --reproduce repro2.tar +# RUN: %lld -arch x86_64 -all_load foo.a -o /dev/null --reproduce repro2.tar # RUN: tar tf repro2.tar | FileCheck -DPATH='repro2/%:t.dir' %s # CHECK-DAG: [[PATH]]/foo.a