Skip to content

Commit 38a6374

Browse files
committed
[lld-macho] Only codesign by default on arm64 macOS
instead of doing it on all arm64 platforms. Reviewed By: #lld-macho, gkm Differential Revision: https://reviews.llvm.org/D98446
1 parent d8283d9 commit 38a6374

File tree

3 files changed

+63
-32
lines changed

3 files changed

+63
-32
lines changed

lld/MachO/Driver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -921,7 +921,8 @@ bool macho::link(ArrayRef<const char *> argsArr, bool canExitEarly,
921921

922922
config->adhocCodesign = args.hasFlag(
923923
OPT_adhoc_codesign, OPT_no_adhoc_codesign,
924-
config->target.Arch == AK_arm64 || config->target.Arch == AK_arm64e);
924+
(config->target.Arch == AK_arm64 || config->target.Arch == AK_arm64e) &&
925+
config->target.Platform == PlatformKind::macOS);
925926

926927
if (args.hasArg(OPT_v)) {
927928
message(getLLDVersion());
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
--- !tapi-tbd-v3
2-
archs: [ i386, x86_64 ]
3-
uuids: [ 'i386: 00000000-0000-0000-0000-000000000000', 'x86_64: 00000000-0000-0000-0000-000000000001' ]
2+
archs: [ i386, x86_64, arm64 ]
3+
uuids: [ 'i386: 00000000-0000-0000-0000-000000000000',
4+
'x86_64: 00000000-0000-0000-0000-000000000001',
5+
'arm64: 00000000-0000-0000-0000-000000000002' ]
46
platform: ios
57
install-name: '/usr/lib/libSystem.dylib'
68
current-version: 1281
79
exports:
8-
- archs: [ i386, x86_64 ]
10+
- archs: [ i386, x86_64, arm64 ]
911
re-exports: [ '/usr/lib/system/libcache.dylib' ]
1012
symbols: [ __crashreporter_info__, _cache_create ]
1113
--- !tapi-tbd-v3
12-
archs: [ i386, x86_64 ]
13-
uuids: [ 'i386: 00000000-0000-0000-0000-000000000002', 'x86_64: 00000000-0000-0000-0000-000000000003' ]
14+
archs: [ i386, x86_64, arm64 ]
15+
uuids: [ 'i386: 00000000-0000-0000-0000-000000000003',
16+
'x86_64: 00000000-0000-0000-0000-000000000004',
17+
'arm64: 00000000-0000-0000-0000-000000000005' ]
1418
platform: ios
1519
install-name: '/usr/lib/system/libcache.dylib'
1620
current-version: 83
@@ -24,11 +28,13 @@ exports:
2428
# The following TAPI document is not re-exported by any other document in this
2529
# TBD file, and should therefore be inaccessible.
2630
--- !tapi-tbd-v3
27-
archs: [ i386, x86_64 ]
28-
uuids: [ 'i386: 00000000-0000-0000-0000-000000000003', 'x86_64: 00000000-0000-0000-0000-000000000004' ]
31+
archs: [ i386, x86_64, arm64 ]
32+
uuids: [ 'i386: 00000000-0000-0000-0000-000000000006',
33+
'x86_64: 00000000-0000-0000-0000-000000000007',
34+
'arm64: 00000000-0000-0000-0000-000000000008' ]
2935
platform: ios
3036
install-name: '/usr/lib/libnotreexported.dylib'
3137
exports:
32-
- archs: [ i386, x86_64 ]
38+
- archs: [ i386, x86_64, arm64 ]
3339
symbols: [ _from_non_reexported_tapi_dylib ]
3440
...

lld/test/MachO/adhoc-codesign.s

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,79 @@
33
# RUN: rm -rf %t
44
# RUN: split-file %s %t
55

6-
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o %t/main-arm64.o %t/main.s
7-
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/main-x86_64.o %t/main.s
8-
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o %t/foo-arm64.o %t/foo.s
9-
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/foo-x86_64.o %t/foo.s
6+
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o %t/main-arm64-macos.o %t/main.s
7+
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-iossimulator -o %t/main-arm64-sim.o %t/main.s
8+
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/main-x86_64-macos.o %t/main.s
9+
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o %t/foo-arm64-macos.o %t/foo.s
10+
# RUN: llvm-mc -filetype=obj -triple=arm64-apple-iossimulator -o %t/foo-arm64-sim.o %t/foo.s
11+
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/foo-x86_64-macos.o %t/foo.s
1012

1113
# Exhaustive test for:
12-
# (x86_64, arm64) x (default, -adhoc_codesign, -no_adhoc-codesign) x (execute, dylib, bundle)
14+
# (x86_64-macos, arm64-macos, arm64-ios-simulator) x (default, -adhoc_codesign, -no_adhoc-codesign) x (execute, dylib, bundle)
1315

14-
# RUN: %lld -lSystem -arch x86_64 -execute -o %t/out %t/main-x86_64.o
16+
# RUN: %lld -lSystem -arch x86_64 -execute -o %t/out %t/main-x86_64-macos.o
1517
# RUN: llvm-objdump --macho --all-headers %t/out | FileCheck --check-prefix=NO-ADHOC %s
16-
# RUN: %lld -arch x86_64 -dylib -o %t/out %t/foo-x86_64.o
18+
# RUN: %lld -arch x86_64 -dylib -o %t/out %t/foo-x86_64-macos.o
1719
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
18-
# RUN: %lld -arch x86_64 -bundle -o %t/out %t/foo-x86_64.o
20+
# RUN: %lld -arch x86_64 -bundle -o %t/out %t/foo-x86_64-macos.o
1921
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
2022

21-
# RUN: %lld -lSystem -arch x86_64 -execute -adhoc_codesign -o %t/out %t/main-x86_64.o
23+
# RUN: %lld -lSystem -arch x86_64 -execute -adhoc_codesign -o %t/out %t/main-x86_64-macos.o
2224
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
23-
# RUN: %lld -arch x86_64 -dylib -adhoc_codesign -o %t/out %t/foo-x86_64.o
25+
# RUN: %lld -arch x86_64 -dylib -adhoc_codesign -o %t/out %t/foo-x86_64-macos.o
2426
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
25-
# RUN: %lld -arch x86_64 -bundle -adhoc_codesign -o %t/out %t/foo-x86_64.o
27+
# RUN: %lld -arch x86_64 -bundle -adhoc_codesign -o %t/out %t/foo-x86_64-macos.o
2628
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
2729

28-
# RUN: %lld -lSystem -arch x86_64 -execute -no_adhoc_codesign -o %t/out %t/main-x86_64.o
30+
# RUN: %lld -lSystem -arch x86_64 -execute -no_adhoc_codesign -o %t/out %t/main-x86_64-macos.o
2931
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
30-
# RUN: %lld -arch x86_64 -dylib -no_adhoc_codesign -o %t/out %t/foo-x86_64.o
32+
# RUN: %lld -arch x86_64 -dylib -no_adhoc_codesign -o %t/out %t/foo-x86_64-macos.o
3133
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
32-
# RUN: %lld -arch x86_64 -bundle -no_adhoc_codesign -o %t/out %t/foo-x86_64.o
34+
# RUN: %lld -arch x86_64 -bundle -no_adhoc_codesign -o %t/out %t/foo-x86_64-macos.o
3335
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
3436

3537

36-
# RUN: %lld -lSystem -arch arm64 -execute -o %t/out %t/main-arm64.o
38+
# RUN: %lld -lSystem -arch arm64 -execute -o %t/out %t/main-arm64-macos.o
3739
# RUN: llvm-objdump --macho --all-headers %t/out | FileCheck --check-prefix=ADHOC %s
38-
# RUN: %lld -arch arm64 -dylib -o %t/out %t/foo-arm64.o
40+
# RUN: %lld -arch arm64 -dylib -o %t/out %t/foo-arm64-macos.o
3941
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
40-
# RUN: %lld -arch arm64 -bundle -o %t/out %t/foo-arm64.o
42+
# RUN: %lld -arch arm64 -bundle -o %t/out %t/foo-arm64-macos.o
4143
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
4244

43-
# RUN: %lld -lSystem -arch arm64 -execute -adhoc_codesign -o %t/out %t/main-arm64.o
45+
# RUN: %lld -lSystem -arch arm64 -execute -adhoc_codesign -o %t/out %t/main-arm64-macos.o
4446
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
45-
# RUN: %lld -arch arm64 -dylib -adhoc_codesign -o %t/out %t/foo-arm64.o
47+
# RUN: %lld -arch arm64 -dylib -adhoc_codesign -o %t/out %t/foo-arm64-macos.o
4648
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
47-
# RUN: %lld -arch arm64 -bundle -adhoc_codesign -o %t/out %t/foo-arm64.o
49+
# RUN: %lld -arch arm64 -bundle -adhoc_codesign -o %t/out %t/foo-arm64-macos.o
4850
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
4951

50-
# RUN: %lld -lSystem -arch arm64 -execute -no_adhoc_codesign -o %t/out %t/main-arm64.o
52+
# RUN: %lld -lSystem -arch arm64 -execute -no_adhoc_codesign -o %t/out %t/main-arm64-macos.o
5153
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
52-
# RUN: %lld -arch arm64 -dylib -no_adhoc_codesign -o %t/out %t/foo-arm64.o
54+
# RUN: %lld -arch arm64 -dylib -no_adhoc_codesign -o %t/out %t/foo-arm64-macos.o
5355
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
54-
# RUN: %lld -arch arm64 -bundle -no_adhoc_codesign -o %t/out %t/foo-arm64.o
56+
# RUN: %lld -arch arm64 -bundle -no_adhoc_codesign -o %t/out %t/foo-arm64-macos.o
57+
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
58+
59+
60+
# RUN: ld64.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
61+
# RUN: llvm-objdump --macho --all-headers %t/out | FileCheck --check-prefix=NO-ADHOC %s
62+
# RUN: ld64.lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -dylib -o %t/out %t/foo-arm64-sim.o
63+
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
64+
# RUN: ld64.lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -bundle -o %t/out %t/foo-arm64-sim.o
65+
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
66+
67+
# RUN: ld64.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
68+
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
69+
# RUN: ld64.lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -dylib -adhoc_codesign -o %t/out %t/foo-arm64-sim.o
70+
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
71+
# RUN: ld64.lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -bundle -adhoc_codesign -o %t/out %t/foo-arm64-sim.o
72+
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s
73+
74+
# RUN: ld64.lld -lSystem -arch arm64 -platform_version ios-simulator 14.0 15.0 -execute -no_adhoc_codesign -o %t/out %t/main-arm64-sim.o -syslibroot %S/Inputs/iPhoneSimulator.sdk
75+
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
76+
# RUN: ld64.lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -dylib -no_adhoc_codesign -o %t/out %t/foo-arm64-sim.o
77+
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
78+
# RUN: ld64.lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -bundle -no_adhoc_codesign -o %t/out %t/foo-arm64-sim.o
5579
# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s
5680

5781
# ADHOC: cmd LC_CODE_SIGNATURE

0 commit comments

Comments
 (0)