Skip to content

Commit

Permalink
[lld-macho] Update -adhoc_codesign default
Browse files Browse the repository at this point in the history
With newer versions of ld64 it generates an adhoc signature by default
for all arm64 simulator targets. This default is especially important
for unit test targets that rarely have custom codesigning requirements
but otherwise won't run on arm64 macs.

Differential Revision: https://reviews.llvm.org/D139672
  • Loading branch information
keith committed Dec 8, 2022
1 parent 928c81f commit bd57070
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
12 changes: 10 additions & 2 deletions lld/MachO/Driver.cpp
Expand Up @@ -936,6 +936,15 @@ static bool supportsNoPie() {
config->arch() == AK_arm64_32);
}

static bool shouldAdhocSignByDefault(Architecture arch, PlatformType platform) {
if (arch != AK_arm64 && arch != AK_arm64e)
return false;

return platform == PLATFORM_MACOS || platform == PLATFORM_IOSSIMULATOR ||
platform == PLATFORM_TVOSSIMULATOR ||
platform == PLATFORM_WATCHOSSIMULATOR;
}

static bool dataConstDefault(const InputArgList &args) {
static const std::array<std::pair<PlatformType, VersionTuple>, 5> minVersion =
{{{PLATFORM_MACOS, VersionTuple(10, 15)},
Expand Down Expand Up @@ -1735,8 +1744,7 @@ bool macho::link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,

config->adhocCodesign = args.hasFlag(
OPT_adhoc_codesign, OPT_no_adhoc_codesign,
(config->arch() == AK_arm64 || config->arch() == AK_arm64e) &&
config->platform() == PLATFORM_MACOS);
shouldAdhocSignByDefault(config->arch(), config->platform()));

if (args.hasArg(OPT_v)) {
message(getLLDVersion(), lld::errs());
Expand Down
6 changes: 3 additions & 3 deletions lld/test/MachO/adhoc-codesign.s
Expand Up @@ -57,11 +57,11 @@


# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -execute -o %t/out %t/main-arm64-sim.o -syslibroot %S/Inputs/iPhoneSimulator.sdk -lSystem
# RUN: llvm-objdump --macho --all-headers %t/out | FileCheck --check-prefix=NO-ADHOC %s
# RUN: llvm-objdump --macho --all-headers %t/out | FileCheck --check-prefix=ADHOC %s
# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -dylib -o %t/out %t/foo-arm64-sim.o
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -bundle -o %t/out %t/foo-arm64-sim.o
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s

# RUN: %no-arg-lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -execute -adhoc_codesign -o %t/out %t/main-arm64-sim.o -syslibroot %S/Inputs/iPhoneSimulator.sdk -lSystem
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
Expand Down

0 comments on commit bd57070

Please sign in to comment.