diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp --- a/lld/MachO/Driver.cpp +++ b/lld/MachO/Driver.cpp @@ -921,7 +921,8 @@ config->adhocCodesign = args.hasFlag( OPT_adhoc_codesign, OPT_no_adhoc_codesign, - config->target.Arch == AK_arm64 || config->target.Arch == AK_arm64e); + (config->target.Arch == AK_arm64 || config->target.Arch == AK_arm64e) && + config->target.Platform == PlatformKind::macOS); if (args.hasArg(OPT_v)) { message(getLLDVersion()); diff --git a/lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libSystem.tbd b/lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libSystem.tbd --- a/lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libSystem.tbd +++ b/lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libSystem.tbd @@ -1,16 +1,20 @@ --- !tapi-tbd-v3 -archs: [ i386, x86_64 ] -uuids: [ 'i386: 00000000-0000-0000-0000-000000000000', 'x86_64: 00000000-0000-0000-0000-000000000001' ] +archs: [ i386, x86_64, arm64 ] +uuids: [ 'i386: 00000000-0000-0000-0000-000000000000', + 'x86_64: 00000000-0000-0000-0000-000000000001', + 'arm64: 00000000-0000-0000-0000-000000000002' ] platform: ios install-name: '/usr/lib/libSystem.dylib' current-version: 1281 exports: - - archs: [ i386, x86_64 ] + - archs: [ i386, x86_64, arm64 ] re-exports: [ '/usr/lib/system/libcache.dylib' ] symbols: [ __crashreporter_info__, _cache_create ] --- !tapi-tbd-v3 -archs: [ i386, x86_64 ] -uuids: [ 'i386: 00000000-0000-0000-0000-000000000002', 'x86_64: 00000000-0000-0000-0000-000000000003' ] +archs: [ i386, x86_64, arm64 ] +uuids: [ 'i386: 00000000-0000-0000-0000-000000000003', + 'x86_64: 00000000-0000-0000-0000-000000000004', + 'arm64: 00000000-0000-0000-0000-000000000005' ] platform: ios install-name: '/usr/lib/system/libcache.dylib' current-version: 83 @@ -24,11 +28,13 @@ # The following TAPI document is not re-exported by any other document in this # TBD file, and should therefore be inaccessible. --- !tapi-tbd-v3 -archs: [ i386, x86_64 ] -uuids: [ 'i386: 00000000-0000-0000-0000-000000000003', 'x86_64: 00000000-0000-0000-0000-000000000004' ] +archs: [ i386, x86_64, arm64 ] +uuids: [ 'i386: 00000000-0000-0000-0000-000000000006', + 'x86_64: 00000000-0000-0000-0000-000000000007', + 'arm64: 00000000-0000-0000-0000-000000000008' ] platform: ios install-name: '/usr/lib/libnotreexported.dylib' exports: - - archs: [ i386, x86_64 ] + - archs: [ i386, x86_64, arm64 ] symbols: [ _from_non_reexported_tapi_dylib ] ... diff --git a/lld/test/MachO/adhoc-codesign.s b/lld/test/MachO/adhoc-codesign.s --- a/lld/test/MachO/adhoc-codesign.s +++ b/lld/test/MachO/adhoc-codesign.s @@ -3,55 +3,79 @@ # RUN: rm -rf %t # RUN: split-file %s %t -# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o %t/main-arm64.o %t/main.s -# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/main-x86_64.o %t/main.s -# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o %t/foo-arm64.o %t/foo.s -# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/foo-x86_64.o %t/foo.s +# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o %t/main-arm64-macos.o %t/main.s +# RUN: llvm-mc -filetype=obj -triple=arm64-apple-iossimulator -o %t/main-arm64-sim.o %t/main.s +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/main-x86_64-macos.o %t/main.s +# RUN: llvm-mc -filetype=obj -triple=arm64-apple-macos -o %t/foo-arm64-macos.o %t/foo.s +# RUN: llvm-mc -filetype=obj -triple=arm64-apple-iossimulator -o %t/foo-arm64-sim.o %t/foo.s +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/foo-x86_64-macos.o %t/foo.s # Exhaustive test for: -# (x86_64, arm64) x (default, -adhoc_codesign, -no_adhoc-codesign) x (execute, dylib, bundle) +# (x86_64-macos, arm64-macos, arm64-ios-simulator) x (default, -adhoc_codesign, -no_adhoc-codesign) x (execute, dylib, bundle) -# RUN: %lld -lSystem -arch x86_64 -execute -o %t/out %t/main-x86_64.o +# RUN: %lld -lSystem -arch x86_64 -execute -o %t/out %t/main-x86_64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out | FileCheck --check-prefix=NO-ADHOC %s -# RUN: %lld -arch x86_64 -dylib -o %t/out %t/foo-x86_64.o +# RUN: %lld -arch x86_64 -dylib -o %t/out %t/foo-x86_64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s -# RUN: %lld -arch x86_64 -bundle -o %t/out %t/foo-x86_64.o +# RUN: %lld -arch x86_64 -bundle -o %t/out %t/foo-x86_64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s -# RUN: %lld -lSystem -arch x86_64 -execute -adhoc_codesign -o %t/out %t/main-x86_64.o +# RUN: %lld -lSystem -arch x86_64 -execute -adhoc_codesign -o %t/out %t/main-x86_64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s -# RUN: %lld -arch x86_64 -dylib -adhoc_codesign -o %t/out %t/foo-x86_64.o +# RUN: %lld -arch x86_64 -dylib -adhoc_codesign -o %t/out %t/foo-x86_64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s -# RUN: %lld -arch x86_64 -bundle -adhoc_codesign -o %t/out %t/foo-x86_64.o +# RUN: %lld -arch x86_64 -bundle -adhoc_codesign -o %t/out %t/foo-x86_64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s -# RUN: %lld -lSystem -arch x86_64 -execute -no_adhoc_codesign -o %t/out %t/main-x86_64.o +# RUN: %lld -lSystem -arch x86_64 -execute -no_adhoc_codesign -o %t/out %t/main-x86_64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s -# RUN: %lld -arch x86_64 -dylib -no_adhoc_codesign -o %t/out %t/foo-x86_64.o +# RUN: %lld -arch x86_64 -dylib -no_adhoc_codesign -o %t/out %t/foo-x86_64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s -# RUN: %lld -arch x86_64 -bundle -no_adhoc_codesign -o %t/out %t/foo-x86_64.o +# RUN: %lld -arch x86_64 -bundle -no_adhoc_codesign -o %t/out %t/foo-x86_64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s -# RUN: %lld -lSystem -arch arm64 -execute -o %t/out %t/main-arm64.o +# RUN: %lld -lSystem -arch arm64 -execute -o %t/out %t/main-arm64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out | FileCheck --check-prefix=ADHOC %s -# RUN: %lld -arch arm64 -dylib -o %t/out %t/foo-arm64.o +# RUN: %lld -arch arm64 -dylib -o %t/out %t/foo-arm64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s -# RUN: %lld -arch arm64 -bundle -o %t/out %t/foo-arm64.o +# RUN: %lld -arch arm64 -bundle -o %t/out %t/foo-arm64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s -# RUN: %lld -lSystem -arch arm64 -execute -adhoc_codesign -o %t/out %t/main-arm64.o +# RUN: %lld -lSystem -arch arm64 -execute -adhoc_codesign -o %t/out %t/main-arm64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s -# RUN: %lld -arch arm64 -dylib -adhoc_codesign -o %t/out %t/foo-arm64.o +# RUN: %lld -arch arm64 -dylib -adhoc_codesign -o %t/out %t/foo-arm64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s -# RUN: %lld -arch arm64 -bundle -adhoc_codesign -o %t/out %t/foo-arm64.o +# RUN: %lld -arch arm64 -bundle -adhoc_codesign -o %t/out %t/foo-arm64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s -# RUN: %lld -lSystem -arch arm64 -execute -no_adhoc_codesign -o %t/out %t/main-arm64.o +# RUN: %lld -lSystem -arch arm64 -execute -no_adhoc_codesign -o %t/out %t/main-arm64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s -# RUN: %lld -arch arm64 -dylib -no_adhoc_codesign -o %t/out %t/foo-arm64.o +# RUN: %lld -arch arm64 -dylib -no_adhoc_codesign -o %t/out %t/foo-arm64-macos.o # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s -# RUN: %lld -arch arm64 -bundle -no_adhoc_codesign -o %t/out %t/foo-arm64.o +# RUN: %lld -arch arm64 -bundle -no_adhoc_codesign -o %t/out %t/foo-arm64-macos.o +# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s + + +# 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 +# RUN: llvm-objdump --macho --all-headers %t/out | FileCheck --check-prefix=NO-ADHOC %s +# RUN: ld64.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: ld64.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: 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 +# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s +# RUN: ld64.lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -dylib -adhoc_codesign -o %t/out %t/foo-arm64-sim.o +# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s +# RUN: ld64.lld -arch arm64 -platform_version ios-simulator 14.0 15.0 -bundle -adhoc_codesign -o %t/out %t/foo-arm64-sim.o +# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=ADHOC %s + +# 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 +# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s +# 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 +# RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s +# 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 # RUN: llvm-objdump --macho --all-headers %t/out| FileCheck --check-prefix=NO-ADHOC %s # ADHOC: cmd LC_CODE_SIGNATURE