Skip to content

Commit b6df6ef

Browse files
authored
Merge pull request #30843 from DougGregor/consistent-simulator-triples
[Build] Use simulator triples consistently
2 parents 5a3d2a9 + 7a2c28d commit b6df6ef

File tree

8 files changed

+66
-24
lines changed

8 files changed

+66
-24
lines changed

cmake/modules/SwiftConfigureSDK.cmake

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ function(_report_sdk prefix)
3030
message(STATUS " Deployment version: ${SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION}")
3131
message(STATUS " Version min name: ${SWIFT_SDK_${prefix}_VERSION_MIN_NAME}")
3232
message(STATUS " Triple name: ${SWIFT_SDK_${prefix}_TRIPLE_NAME}")
33+
message(STATUS " Simulator: ${SWIFT_SDK_${prefix}_IS_SIMULATOR}")
3334
endif()
3435
if(SWIFT_SDK_${prefix}_MODULE_ARCHITECTURES)
3536
message(STATUS " Module Architectures: ${SWIFT_SDK_${prefix}_MODULE_ARCHITECTURES}")
@@ -112,6 +113,7 @@ endfunction()
112113
# SWIFT_SDK_${prefix}_VERSION_MIN_NAME Version min name for this SDK
113114
# SWIFT_SDK_${prefix}_TRIPLE_NAME Triple name for this SDK
114115
# SWIFT_SDK_${prefix}_ARCHITECTURES Architectures (as a list)
116+
# SWIFT_SDK_${prefix}_IS_SIMULATOR Whether this is a simulator target.
115117
# SWIFT_SDK_${prefix}_ARCH_${ARCH}_TRIPLE Triple name
116118
macro(configure_sdk_darwin
117119
prefix name deployment_version xcrun_name
@@ -172,6 +174,13 @@ macro(configure_sdk_darwin
172174
"${SWIFT_SDK_${prefix}_ARCHITECTURES}" # rhs
173175
SWIFT_SDK_${prefix}_MODULE_ARCHITECTURES) # result
174176

177+
# Determine whether this is a simulator SDK.
178+
if ( ${xcrun_name} MATCHES "simulator" )
179+
set(SWIFT_SDK_${prefix}_IS_SIMULATOR TRUE)
180+
else()
181+
set(SWIFT_SDK_${prefix}_IS_SIMULATOR FALSE)
182+
endif()
183+
175184
# Configure variables for _all_ architectures even if we aren't "building"
176185
# them because they aren't supported.
177186
foreach(arch ${architectures})
@@ -181,6 +190,12 @@ macro(configure_sdk_darwin
181190
set(SWIFT_SDK_${prefix}_ARCH_${arch}_TRIPLE
182191
"${arch}-apple-${SWIFT_SDK_${prefix}_TRIPLE_NAME}")
183192

193+
# If this is a simulator target, append -simulator.
194+
if (SWIFT_SDK_${prefix}_IS_SIMULATOR)
195+
set(SWIFT_SDK_${prefix}_ARCH_${arch}_TRIPLE
196+
"${SWIFT_SDK_${prefix}_ARCH_${arch}_TRIPLE}-simulator")
197+
endif ()
198+
184199
if(SWIFT_ENABLE_MACCATALYST AND "${prefix}" STREQUAL "OSX")
185200
# For macCatalyst append the '-macabi' environment to the target triple.
186201
set(SWIFT_SDK_MACCATALYST_ARCH_${arch}_TRIPLE

cmake/modules/macCatalystUtils.cmake

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ function(get_maccatalyst_build_flavor out_var sdk flavor)
3535
endif()
3636
endfunction()
3737

38+
# Form a versioned target triple for the given SDK.
39+
function(get_versioned_target_triple target_out_var sdk arch version)
40+
if (SWIFT_SDK_${sdk}_IS_SIMULATOR)
41+
# The version goes before the "-simulator".
42+
set(target "${SWIFT_SDK_${sdk}_ARCH_${arch}_TRIPLE}")
43+
string(REPLACE "-simulator" "" target "${target}")
44+
set(target "${target}${version}-simulator")
45+
else ()
46+
set(target "${SWIFT_SDK_${sdk}_ARCH_${arch}_TRIPLE}${version}")
47+
endif()
48+
49+
set(${target_out_var} "${target}" PARENT_SCOPE)
50+
endfunction()
3851

3952
# Sets target_out_var to the target triple for the given SDK and maccatalyst flavor.
4053
# For zippered flavors also sets the target_variant_out_var. For other
@@ -53,7 +66,8 @@ function(get_target_triple target_out_var target_variant_out_var sdk arch)
5366
set(deployment_version "${TARGET_DEPLOYMENT_VERSION}")
5467

5568
# Default target triple
56-
set(target "${SWIFT_SDK_${sdk}_ARCH_${arch}_TRIPLE}${deployment_version}")
69+
get_versioned_target_triple(target ${sdk} ${arch} "${deployment_version}")
70+
5771
set(target_variant)
5872

5973
get_maccatalyst_build_flavor(maccatalyst_build_flavor

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ foreach(SDK ${SWIFT_SDKS})
194194
foreach(BUILD_FLAVOR ${build_flavors})
195195
# Configure variables for this subdirectory.
196196
set(VARIANT_SUFFIX "-${SWIFT_SDK_${SDK}_LIB_SUBDIR}-${ARCH}")
197-
set(VARIANT_TRIPLE "${SWIFT_SDK_${SDK}_ARCH_${ARCH}_TRIPLE}${SWIFT_SDK_${SDK}_DEPLOYMENT_VERSION}")
197+
get_versioned_target_triple(VARIANT_TRIPLE ${SDK} ${ARCH} "${SWIFT_SDK_${SDK}_DEPLOYMENT_VERSION}")
198198
set(VARIANT_SDK "${SWIFT_SDK_${SDK}_ARCH_${ARCH}_PATH}")
199199
set(DEFAULT_OSX_VARIANT_SUFFIX "")
200200

test/IRGen/objc_properties_ios.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %swift -target x86_64-apple-ios9 %S/objc_properties.swift -disable-target-os-checking -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-NEW %S/objc_properties.swift
2-
// RUN: %swift -target x86_64-apple-ios8 %S/objc_properties.swift -disable-target-os-checking -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-OLD %S/objc_properties.swift
1+
// RUN: %swift -target x86_64-apple-ios9-simulator %S/objc_properties.swift -disable-target-os-checking -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-NEW %S/objc_properties.swift
2+
// RUN: %swift -target x86_64-apple-ios8-simulator %S/objc_properties.swift -disable-target-os-checking -emit-ir -disable-objc-attr-requires-foundation-module | %FileCheck -check-prefix=CHECK -check-prefix=CHECK-OLD %S/objc_properties.swift
33

44
// REQUIRES: OS=ios
55
// REQUIRES: CPU=x86_64

test/TBD/Inputs/install-name-map-toasterkit.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
{
88
"module": "ToasterKit",
99
"install_name": "/System/Previous/iOS/ToasterKit.dylib",
10-
"platforms": ["iOS"]
10+
"platforms": ["iOS", "iOS_sim"]
1111
}
12-
]
12+
]

test/TBD/linker-directives-ld-previous-ios.swift

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
// RUN: %empty-directory(%t)
44

55
// RUN: %target-swift-frontend -typecheck %S/Inputs/linker-directive.swift -tbd-is-installapi -emit-tbd -emit-tbd-path %t/linker_directives.tbd -previous-module-installname-map-file %S/Inputs/install-name-map-toasterkit.json
6-
// RUN: %FileCheck %s < %t/linker_directives.tbd
6+
// RUN: %FileCheck --check-prefix=CHECK-objc-simulator-%target-is-simulator %s < %t/linker_directives.tbd
77
// RUN: %target-swift-frontend -typecheck %S/Inputs/linker-directive.swift -emit-tbd -emit-tbd-path %t/linker_directives.tbd -previous-module-installname-map-file %S/Inputs/install-name-map-toasterkit.json
8-
// RUN: %FileCheck %s < %t/linker_directives.tbd
8+
// RUN: %FileCheck --check-prefix=CHECK-objc-simulator-%target-is-simulator %s < %t/linker_directives.tbd
99

10-
// CHECK: $ld$previous$/System/Previous/iOS/ToasterKit.dylib$$2$10.2$13.0$_$s10ToasterKit5toastyyF$
11-
// CHECK: $ld$previous$/System/Previous/iOS/ToasterKit.dylib$$2$10.2$13.0$_$s10ToasterKit7VehicleV4moveyyF$
12-
// CHECK: $ld$previous$/System/Previous/iOS/ToasterKit.dylib$$2$10.2$13.0$_$s10ToasterKit7VehicleVMa$
13-
// CHECK: $ld$previous$/System/Previous/iOS/ToasterKit.dylib$$2$10.2$13.0$_$s10ToasterKit7VehicleVMn$
14-
// CHECK: $ld$previous$/System/Previous/iOS/ToasterKit.dylib$$2$10.2$13.0$_$s10ToasterKit7VehicleVN$
10+
// CHECK-objc-simulator-false: $ld$previous$/System/Previous/iOS/ToasterKit.dylib$$2$10.2$13.0$_$s10ToasterKit5toastyyF$
11+
// CHECK-objc-simulator-false: $ld$previous$/System/Previous/iOS/ToasterKit.dylib$$2$10.2$13.0$_$s10ToasterKit7VehicleV4moveyyF$
12+
// CHECK-objc-simulator-false: $ld$previous$/System/Previous/iOS/ToasterKit.dylib$$2$10.2$13.0$_$s10ToasterKit7VehicleVMa$
13+
// CHECK-objc-simulator-false: $ld$previous$/System/Previous/iOS/ToasterKit.dylib$$2$10.2$13.0$_$s10ToasterKit7VehicleVMn$
14+
// CHECK-objc-simulator-false: $ld$previous$/System/Previous/iOS/ToasterKit.dylib$$2$10.2$13.0$_$s10ToasterKit7VehicleVN$
15+
16+
// CHECK-objc-simulator-true: $ld$previous$/System/Previous/iOS/ToasterKit.dylib$$7$10.2$13.0$_$s10ToasterKit5toastyyF$
17+
// CHECK-objc-simulator-true: $ld$previous$/System/Previous/iOS/ToasterKit.dylib$$7$10.2$13.0$_$s10ToasterKit7VehicleV4moveyyF$
18+
// CHECK-objc-simulator-true: $ld$previous$/System/Previous/iOS/ToasterKit.dylib$$7$10.2$13.0$_$s10ToasterKit7VehicleVMa$
19+
// CHECK-objc-simulator-true: $ld$previous$/System/Previous/iOS/ToasterKit.dylib$$7$10.2$13.0$_$s10ToasterKit7VehicleVMn$
20+
// CHECK-objc-simulator-true: $ld$previous$/System/Previous/iOS/ToasterKit.dylib$$7$10.2$13.0$_$s10ToasterKit7VehicleVN$

test/lit.cfg

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,11 @@ lit_config.note('Using resource dir: ' + test_resource_dir)
326326
if run_os == 'ios' and run_vers.endswith('-macabi'):
327327
run_vers = run_vers[0:-len('-macabi')]
328328
run_os = 'maccatalyst'
329+
if run_vers.endswith('-simulator'):
330+
run_vers = run_vers[0:-len('-simulator')]
331+
run_environment='-simulator'
332+
else:
333+
run_environment=''
329334

330335
run_ptrsize = '64' if ('64' in run_cpu or run_cpu == "s390x") else '32'
331336
run_ptrauth = 'ptrauth' if run_cpu == 'arm64e' else 'noptrauth'
@@ -633,8 +638,8 @@ if run_vendor == 'apple':
633638
}
634639
pre_stable_version = PRE_STABLE_VERSION.get(run_os, '')
635640

636-
config.pre_stable_abi_triple = '%s-%s-%s%s' % (run_cpu, run_vendor, run_os,
637-
pre_stable_version)
641+
config.pre_stable_abi_triple = '%s-%s-%s%s%s' % (run_cpu, run_vendor, run_os,
642+
pre_stable_version, run_environment)
638643
STABLE_VERSION = {
639644
'macosx': '10.14.4',
640645
'ios': '12.2',
@@ -643,8 +648,8 @@ if run_vendor == 'apple':
643648
'watchos': '5.2'
644649
}
645650
stable_version = STABLE_VERSION.get(run_os, '')
646-
config.stable_abi_triple = '%s-%s-%s%s' % (run_cpu, run_vendor, run_os,
647-
stable_version)
651+
config.stable_abi_triple = '%s-%s-%s%s%s' % (run_cpu, run_vendor, run_os,
652+
stable_version, run_environment)
648653

649654
NEXT_STABLE_VERSION = {
650655
'macosx': '10.15',
@@ -654,8 +659,9 @@ if run_vendor == 'apple':
654659
'watchos': '6'
655660
}
656661
next_stable_version = NEXT_STABLE_VERSION.get(run_os, '')
657-
config.next_stable_abi_triple = '%s-%s-%s%s' % (run_cpu, run_vendor, run_os,
658-
next_stable_version)
662+
config.next_stable_abi_triple = '%s-%s-%s%s%s' % (run_cpu, run_vendor, run_os,
663+
next_stable_version, run_environment)
664+
659665
else:
660666
config.pre_stable_abi_triple = config.variant_triple
661667
config.stable_abi_triple = config.variant_triple
@@ -1010,7 +1016,8 @@ if run_vendor == 'apple':
10101016
% (config.target_build_swift))
10111017
config.target_add_rpath = r'-Xlinker -rpath -Xlinker \1'
10121018

1013-
target_future = format('%s-apple-%s%s' % (run_cpu, run_os, target_future_version))
1019+
target_future = format('%s-apple-%s%s%s' % (run_cpu, run_os, target_future_version, run_environment))
1020+
10141021
config.otool_classic = ("%s otool-classic" % (xcrun_prefix))
10151022

10161023
elif run_os in ['windows-msvc']:

utils/build-script-impl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,14 +489,14 @@ function set_build_options_for_host() {
489489
cmake_osx_deployment_target="${DARWIN_DEPLOYMENT_VERSION_OSX}"
490490
;;
491491
iphonesimulator-i386)
492-
SWIFT_HOST_TRIPLE="i386-apple-ios${DARWIN_DEPLOYMENT_VERSION_IOS}"
492+
SWIFT_HOST_TRIPLE="i386-apple-ios${DARWIN_DEPLOYMENT_VERSION_IOS}-simulator"
493493
llvm_target_arch="X86"
494494

495495
SWIFT_HOST_VARIANT_SDK="IOS_SIMULATOR"
496496
cmake_osx_deployment_target=""
497497
;;
498498
iphonesimulator-x86_64)
499-
SWIFT_HOST_TRIPLE="x86_64-apple-ios${DARWIN_DEPLOYMENT_VERSION_IOS}"
499+
SWIFT_HOST_TRIPLE="x86_64-apple-ios${DARWIN_DEPLOYMENT_VERSION_IOS}-simulator"
500500
llvm_target_arch="X86"
501501

502502
SWIFT_HOST_VARIANT_SDK="IOS_SIMULATOR"
@@ -531,7 +531,7 @@ function set_build_options_for_host() {
531531
cmake_osx_deployment_target=""
532532
;;
533533
appletvsimulator-x86_64)
534-
SWIFT_HOST_TRIPLE="x86_64-apple-tvos${DARWIN_DEPLOYMENT_VERSION_TVOS}"
534+
SWIFT_HOST_TRIPLE="x86_64-apple-tvos${DARWIN_DEPLOYMENT_VERSION_TVOS}-simulator"
535535
llvm_target_arch="X86"
536536

537537
SWIFT_HOST_VARIANT_SDK="TVOS_SIMULATOR"
@@ -545,7 +545,7 @@ function set_build_options_for_host() {
545545
cmake_osx_deployment_target=""
546546
;;
547547
watchsimulator-i386)
548-
SWIFT_HOST_TRIPLE="i386-apple-watchos${DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
548+
SWIFT_HOST_TRIPLE="i386-apple-watchos${DARWIN_DEPLOYMENT_VERSION_WATCHOS}-simulator"
549549
llvm_target_arch="X86"
550550

551551
SWIFT_HOST_VARIANT_SDK="WATCHOS_SIMULATOR"

0 commit comments

Comments
 (0)