Skip to content

Commit 58f7a10

Browse files
authored
Merge pull request swiftlang#35406 from CodaFi/versionilitude
Trade Usages of -m${platform}-version-min For -target
2 parents f655d3b + b436825 commit 58f7a10

File tree

12 files changed

+41
-67
lines changed

12 files changed

+41
-67
lines changed

CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -655,9 +655,10 @@ endif()
655655
#
656656

657657
if(XCODE)
658-
# FIXME: Cannot cross-compile the standard library using Xcode. Xcode
659-
# insists on passing -mmacosx-version-min to the compiler, and we need
660-
# to pass -mios-version-min. Clang sees both options and complains.
658+
# FIXME: It used to be the case that Xcode would force
659+
# -m${platform}-version-min flags that would conflict with those computed
660+
# by build-script. version-min flags are deprecated in favor of -target since
661+
# clang-11, so we might be able to undo this.
661662
set(SWIFT_SDKS "OSX")
662663
endif()
663664

cmake/modules/AddSwift.cmake

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ function(_add_host_variant_c_compile_link_flags name)
114114
# side effects are introduced should a new search path be added.
115115
target_compile_options(${name} PRIVATE
116116
-arch ${SWIFT_HOST_VARIANT_ARCH}
117-
"-F${SWIFT_SDK_${SWIFT_HOST_VARIANT_ARCH}_PATH}/../../../Developer/Library/Frameworks"
118-
"-m${SWIFT_SDK_${SWIFT_HOST_VARIANT_SDK}_VERSION_MIN_NAME}-version-min=${DEPLOYMENT_VERSION}")
117+
"-F${SWIFT_SDK_${SWIFT_HOST_VARIANT_ARCH}_PATH}/../../../Developer/Library/Frameworks")
119118
endif()
120119

121120
_compute_lto_flag("${SWIFT_TOOLS_ENABLE_LTO}" _lto_flag_out)

cmake/modules/DarwinSDKs.cmake

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ is_sdk_requested(OSX swift_build_osx)
2020
if(swift_build_osx)
2121
configure_sdk_darwin(
2222
OSX "OS X" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_OSX}"
23-
macosx macosx macosx macos "${SUPPORTED_OSX_ARCHS}")
23+
macosx macosx macos "${SUPPORTED_OSX_ARCHS}")
2424
configure_target_variant(OSX-DA "OS X Debug+Asserts" OSX DA "Debug+Asserts")
2525
configure_target_variant(OSX-RA "OS X Release+Asserts" OSX RA "Release+Asserts")
2626
configure_target_variant(OSX-R "OS X Release" OSX R "Release")
@@ -38,7 +38,7 @@ if(swift_build_freestanding)
3838
"Which architectures to build when building the FREESTANDING stdlib")
3939
configure_sdk_darwin(
4040
FREESTANDING "FREESTANDING" ""
41-
"${SWIFT_FREESTANDING_SDK}" freestanding
41+
"${SWIFT_FREESTANDING_SDK}"
4242
"${SWIFT_FREESTANDING_TRIPLE_NAME}" "${SWIFT_FREESTANDING_MODULE_NAME}" "${SWIFT_FREESTANDING_ARCHS}")
4343
set(SWIFT_SDK_FREESTANDING_LIB_SUBDIR "freestanding")
4444
configure_target_variant(FREESTANDING-DA "FREESTANDING Debug+Asserts" FREESTANDING DA "Debug+Asserts")
@@ -54,7 +54,7 @@ is_sdk_requested(IOS swift_build_ios)
5454
if(swift_build_ios)
5555
configure_sdk_darwin(
5656
IOS "iOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_IOS}"
57-
iphoneos ios ios ios "${SUPPORTED_IOS_ARCHS}")
57+
iphoneos ios ios "${SUPPORTED_IOS_ARCHS}")
5858
configure_target_variant(IOS-DA "iOS Debug+Asserts" IOS DA "Debug+Asserts")
5959
configure_target_variant(IOS-RA "iOS Release+Asserts" IOS RA "Release+Asserts")
6060
configure_target_variant(IOS-R "iOS Release" IOS R "Release")
@@ -64,7 +64,7 @@ is_sdk_requested(IOS_SIMULATOR swift_build_ios_simulator)
6464
if(swift_build_ios_simulator)
6565
configure_sdk_darwin(
6666
IOS_SIMULATOR "iOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_IOS}"
67-
iphonesimulator ios-simulator ios ios-simulator
67+
iphonesimulator ios ios-simulator
6868
"${SUPPORTED_IOS_SIMULATOR_ARCHS}")
6969
configure_target_variant(
7070
IOS_SIMULATOR-DA "iOS Debug+Asserts" IOS_SIMULATOR DA "Debug+Asserts")
@@ -78,7 +78,7 @@ is_sdk_requested(TVOS swift_build_tvos)
7878
if(swift_build_tvos)
7979
configure_sdk_darwin(
8080
TVOS "tvOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
81-
appletvos tvos tvos tvos "${SUPPORTED_TVOS_ARCHS}")
81+
appletvos tvos tvos "${SUPPORTED_TVOS_ARCHS}")
8282
configure_target_variant(TVOS-DA "tvOS Debug+Asserts" TVOS DA "Debug+Asserts")
8383
configure_target_variant(TVOS-RA "tvOS Release+Asserts" TVOS RA "Release+Asserts")
8484
configure_target_variant(TVOS-R "tvOS Release" TVOS R "Release")
@@ -88,7 +88,7 @@ is_sdk_requested(TVOS_SIMULATOR swift_build_tvos_simulator)
8888
if(swift_build_tvos_simulator)
8989
configure_sdk_darwin(
9090
TVOS_SIMULATOR "tvOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS}"
91-
appletvsimulator tvos-simulator tvos tvos-simulator
91+
appletvsimulator tvos tvos-simulator
9292
"${SUPPORTED_TVOS_SIMULATOR_ARCHS}")
9393
configure_target_variant(
9494
TVOS_SIMULATOR-DA "tvOS Debug+Asserts" TVOS_SIMULATOR DA "Debug+Asserts")
@@ -102,7 +102,7 @@ is_sdk_requested(WATCHOS swift_build_watchos)
102102
if(swift_build_watchos)
103103
configure_sdk_darwin(
104104
WATCHOS "watchOS" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
105-
watchos watchos watchos watchos "${SUPPORTED_WATCHOS_ARCHS}")
105+
watchos watchos watchos "${SUPPORTED_WATCHOS_ARCHS}")
106106
configure_target_variant(WATCHOS-DA "watchOS Debug+Asserts" WATCHOS DA "Debug+Asserts")
107107
configure_target_variant(WATCHOS-RA "watchOS Release+Asserts" WATCHOS RA "Release+Asserts")
108108
configure_target_variant(WATCHOS-R "watchOS Release" WATCHOS R "Release")
@@ -112,7 +112,7 @@ is_sdk_requested(WATCHOS_SIMULATOR swift_build_watchos_simulator)
112112
if(swift_build_watchos_simulator)
113113
configure_sdk_darwin(
114114
WATCHOS_SIMULATOR "watchOS Simulator" "${SWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
115-
watchsimulator watchos-simulator watchos watchos-simulator
115+
watchsimulator watchos watchos-simulator
116116
"${SUPPORTED_WATCHOS_SIMULATOR_ARCHS}")
117117
configure_target_variant(WATCHOS_SIMULATOR-DA "watchOS Debug+Asserts" WATCHOS_SIMULATOR DA "Debug+Asserts")
118118
configure_target_variant(WATCHOS_SIMULATOR-RA "watchOS Release+Asserts" WATCHOS_SIMULATOR RA "Release+Asserts")

cmake/modules/SwiftConfigureSDK.cmake

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ function(_report_sdk prefix)
2828
message(STATUS " Version: ${SWIFT_SDK_${prefix}_VERSION}")
2929
message(STATUS " Build number: ${SWIFT_SDK_${prefix}_BUILD_NUMBER}")
3030
message(STATUS " Deployment version: ${SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION}")
31-
message(STATUS " Version min name: ${SWIFT_SDK_${prefix}_VERSION_MIN_NAME}")
3231
message(STATUS " Triple name: ${SWIFT_SDK_${prefix}_TRIPLE_NAME}")
3332
message(STATUS " Simulator: ${SWIFT_SDK_${prefix}_IS_SIMULATOR}")
3433
endif()
@@ -125,7 +124,6 @@ endfunction()
125124
# name # Display name for this SDK
126125
# deployment_version # Deployment version
127126
# xcrun_name # SDK name to use with xcrun
128-
# version_min_name # The name used in the -mOS-version-min flag
129127
# triple_name # The name used in Swift's -triple
130128
# architectures # A list of architectures this SDK supports
131129
# )
@@ -143,7 +141,6 @@ endfunction()
143141
# SWIFT_SDK_${prefix}_BUILD_NUMBER SDK build number (e.g., 14A389a)
144142
# SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION Deployment version (e.g., 10.9, 7.0)
145143
# SWIFT_SDK_${prefix}_LIB_SUBDIR Library subdir for this SDK
146-
# SWIFT_SDK_${prefix}_VERSION_MIN_NAME Version min name for this SDK
147144
# SWIFT_SDK_${prefix}_TRIPLE_NAME Triple name for this SDK
148145
# SWIFT_SDK_${prefix}_OBJECT_FORMAT The object file format (e.g. MACHO)
149146
# SWIFT_SDK_${prefix}_USE_ISYSROOT Whether to use -isysroot
@@ -153,7 +150,7 @@ endfunction()
153150
# SWIFT_SDK_${prefix}_ARCH_${ARCH}_MODULE Module triple name for this SDK
154151
macro(configure_sdk_darwin
155152
prefix name deployment_version xcrun_name
156-
version_min_name triple_name module_name architectures)
153+
triple_name module_name architectures)
157154
# Note: this has to be implemented as a macro because it sets global
158155
# variables.
159156

@@ -186,7 +183,6 @@ macro(configure_sdk_darwin
186183
set(SWIFT_SDK_${prefix}_NAME "${name}")
187184
set(SWIFT_SDK_${prefix}_DEPLOYMENT_VERSION "${deployment_version}")
188185
set(SWIFT_SDK_${prefix}_LIB_SUBDIR "${xcrun_name}")
189-
set(SWIFT_SDK_${prefix}_VERSION_MIN_NAME "${version_min_name}")
190186
set(SWIFT_SDK_${prefix}_TRIPLE_NAME "${triple_name}")
191187
set(SWIFT_SDK_${prefix}_OBJECT_FORMAT "MACHO")
192188
set(SWIFT_SDK_${prefix}_USE_ISYSROOT TRUE)
@@ -495,7 +491,6 @@ function(configure_target_variant prefix name sdk build_config lib_subdir)
495491
set(SWIFT_VARIANT_${prefix}_BUILD_NUMBER ${SWIFT_SDK_${sdk}_BUILD_NUMBER})
496492
set(SWIFT_VARIANT_${prefix}_DEPLOYMENT_VERSION ${SWIFT_SDK_${sdk}_DEPLOYMENT_VERSION})
497493
set(SWIFT_VARIANT_${prefix}_LIB_SUBDIR "${lib_subdir}/${SWIFT_SDK_${sdk}_LIB_SUBDIR}")
498-
set(SWIFT_VARIANT_${prefix}_VERSION_MIN_NAME ${SWIFT_SDK_${sdk}_VERSION_MIN_NAME})
499494
set(SWIFT_VARIANT_${prefix}_TRIPLE_NAME ${SWIFT_SDK_${sdk}_TRIPLE_NAME})
500495
set(SWIFT_VARIANT_${prefix}_ARCHITECTURES ${SWIFT_SDK_${sdk}_ARCHITECTURES})
501496
endfunction()

stdlib/cmake/modules/AddSwiftStdlib.cmake

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,20 +105,6 @@ function(_add_target_variant_c_compile_link_flags)
105105
list(APPEND result
106106
"-arch" "${CFLAGS_ARCH}"
107107
"-F${SWIFT_SDK_${CFLAGS_SDK}_PATH}/../../../Developer/Library/Frameworks")
108-
109-
set(add_explicit_version TRUE)
110-
111-
# iOS-like and zippered libraries get their deployment version from the
112-
# target triple
113-
if(maccatalyst_build_flavor STREQUAL "ios-like" OR
114-
maccatalyst_build_flavor STREQUAL "zippered")
115-
set(add_explicit_version FALSE)
116-
endif()
117-
118-
if(add_explicit_version)
119-
list(APPEND result
120-
"-m${SWIFT_SDK_${CFLAGS_SDK}_VERSION_MIN_NAME}-version-min=${DEPLOYMENT_VERSION}")
121-
endif()
122108
endif()
123109

124110
if(CFLAGS_ANALYZE_CODE_COVERAGE)

test/Interpreter/objc_class_properties_runtime.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %empty-directory(%t)
22

3-
// RUN: %clang -arch %target-cpu -mmacosx-version-min=10.11 -isysroot %sdk -fobjc-arc %S/Inputs/ObjCClasses/ObjCClasses.m -c -o %t/ObjCClasses.o
3+
// RUN: %clang -arch %target-cpu -target %target-cpu-apple-macosx10.11 -isysroot %sdk -fobjc-arc %S/Inputs/ObjCClasses/ObjCClasses.m -c -o %t/ObjCClasses.o
44

55
// RUN: %swiftc_driver -target $(echo '%target-triple' | sed -E -e 's/macosx10.(9|10).*/macosx10.11/') -sdk %sdk -I %S/Inputs/ObjCClasses/ %t/ObjCClasses.o %s -o %t/a.out
66
// RUN: %target-codesign %t/a.out

test/lit.cfg

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -920,8 +920,8 @@ if run_vendor == 'apple':
920920
target_future_version = "9.99.0"
921921

922922
config.target_cc_options = (
923-
"-arch %s -m%s-version-min=%s %s" %
924-
(run_cpu, run_os, run_vers, clang_mcp_opt))
923+
"-arch %s %s" %
924+
(run_cpu, clang_mcp_opt))
925925

926926
config.target_build_swift = (
927927
("%s %s %s -F %r -toolchain-stdlib-rpath " +
@@ -960,8 +960,8 @@ if run_vendor == 'apple':
960960
target_specific_module_triple += "-simulator"
961961

962962
config.target_cc_options = (
963-
"-arch %s -m%s-simulator-version-min=%s %s" %
964-
(run_cpu, run_os, run_vers, clang_mcp_opt))
963+
"-arch %s %s" %
964+
(run_cpu, clang_mcp_opt))
965965

966966
config.target_build_swift = (
967967
("%s %s %s -F %r -toolchain-stdlib-rpath %s " +
@@ -1004,8 +1004,8 @@ if run_vendor == 'apple':
10041004
(config.variant_triple, clang_mcp_opt))
10051005
else:
10061006
config.target_cc_options = (
1007-
"-arch %s -m%s-version-min=%s %s" %
1008-
(run_cpu, run_os, run_vers, clang_mcp_opt))
1007+
"-arch %s %s" %
1008+
(run_cpu, clang_mcp_opt))
10091009

10101010
maccatalyst_frameworks_component = ""
10111011
if run_os == 'maccatalyst':

tools/SourceKit/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
6363

6464
# Sadly there are two OS naming conventions.
6565
# xcrun SDK name: macosx iphoneos iphonesimulator (+ "internal" or version)
66-
# -mOS-version-min: macosx ios ios-simulator
66+
# triple name: macosx ios ios-simulator
6767

6868
if (SOURCEKIT_DEPLOYMENT_OS MATCHES "^iphoneos")
6969
set(version_min_os "ios")
@@ -89,10 +89,6 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
8989
else()
9090
set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET ${SOURCEKIT_DEPLOYMENT_TARGET})
9191
endif()
92-
else()
93-
add_compile_options(-m${version_min_os}-version-min=${SOURCEKIT_DEPLOYMENT_TARGET})
94-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m${version_min_os}-version-min=${SOURCEKIT_DEPLOYMENT_TARGET}")
95-
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m${version_min_os}-version-min=${SOURCEKIT_DEPLOYMENT_TARGET}")
9692
endif()
9793
endif()
9894

utils/build-parser-lib

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class Builder(object):
105105
"-DCMAKE_OSX_DEPLOYMENT_TARGET=" + deployment_version,
106106
"-DSWIFT_DARWIN_DEPLOYMENT_VERSION_IOS=" + deployment_version,
107107
]
108-
llvm_c_flags += " -mios-simulator-version-min=" + deployment_version
108+
llvm_c_flags += " -target " + host_triple
109109

110110
elif self.host == "iphoneos":
111111
deployment_version = "10.0"
@@ -115,7 +115,7 @@ class Builder(object):
115115
"-DCMAKE_OSX_DEPLOYMENT_TARGET=" + deployment_version,
116116
"-DSWIFT_DARWIN_DEPLOYMENT_VERSION_IOS=" + deployment_version,
117117
]
118-
llvm_c_flags += " -miphoneos-version-min=" + deployment_version
118+
llvm_c_flags += " -target " + host_triple
119119

120120
elif self.host == "appletvsimulator":
121121
deployment_version = "10.0"
@@ -125,7 +125,7 @@ class Builder(object):
125125
"-DCMAKE_OSX_DEPLOYMENT_TARGET=" + deployment_version,
126126
"-DSWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS=" + deployment_version,
127127
]
128-
llvm_c_flags += " -mtvos-simulator-version-min=" + deployment_version
128+
llvm_c_flags += " -target " + host_triple
129129

130130
elif self.host == "appletvos":
131131
deployment_version = "10.0"
@@ -135,7 +135,7 @@ class Builder(object):
135135
"-DCMAKE_OSX_DEPLOYMENT_TARGET=" + deployment_version,
136136
"-DSWIFT_DARWIN_DEPLOYMENT_VERSION_TVOS=" + deployment_version,
137137
]
138-
llvm_c_flags += " -mtvos-version-min=" + deployment_version
138+
llvm_c_flags += " -target " + host_triple
139139

140140
elif self.host == "watchsimulator":
141141
deployment_version = "3.0"
@@ -148,7 +148,7 @@ class Builder(object):
148148
"-DCMAKE_OSX_DEPLOYMENT_TARGET=" + deployment_version,
149149
"-DSWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS=" + deployment_version,
150150
]
151-
llvm_c_flags += " -mwatchos-simulator-version-min=" + deployment_version
151+
llvm_c_flags += " -target " + host_triple
152152

153153
elif self.host == "watchos":
154154
deployment_version = "3.0"
@@ -158,7 +158,7 @@ class Builder(object):
158158
"-DCMAKE_OSX_DEPLOYMENT_TARGET=" + deployment_version,
159159
"-DSWIFT_DARWIN_DEPLOYMENT_VERSION_WATCHOS=" + deployment_version,
160160
]
161-
llvm_c_flags += " -mwatchos-version-min=" + deployment_version
161+
llvm_c_flags += " -target " + host_triple
162162

163163
assert host_triple
164164
assert host_sdk

utils/build-script-impl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1289,25 +1289,25 @@ function common_cross_c_flags() {
12891289

12901290
case $host in
12911291
macosx-*)
1292-
echo -n " -arch ${arch} "
1292+
echo -n " -arch ${arch} -target ${arch}-apple-macosx${SWIFT_DARWIN_DEPLOYMENT_VERSION_OSX}"
12931293
;;
12941294
iphonesimulator-*)
1295-
echo -n " -arch ${arch} -mios-simulator-version-min=${DARWIN_DEPLOYMENT_VERSION_IOS}"
1295+
echo -n " -arch ${arch} -target ${arch}-apple-ios-simulator${DARWIN_DEPLOYMENT_VERSION_IOS}"
12961296
;;
12971297
iphoneos-*)
1298-
echo -n " -arch ${arch} -miphoneos-version-min=${DARWIN_DEPLOYMENT_VERSION_IOS}"
1298+
echo -n " -arch ${arch} -target ${arch}-apple-iphoneos${DARWIN_DEPLOYMENT_VERSION_IOS}"
12991299
;;
13001300
appletvsimulator-*)
1301-
echo -n " -arch ${arch} -mtvos-simulator-version-min=${DARWIN_DEPLOYMENT_VERSION_TVOS}"
1301+
echo -n " -arch ${arch} -target ${arch}-apple-tvos-simulator${DARWIN_DEPLOYMENT_VERSION_TVOS}"
13021302
;;
13031303
appletvos-*)
1304-
echo -n " -arch ${arch} -mtvos-version-min=${DARWIN_DEPLOYMENT_VERSION_TVOS}"
1304+
echo -n " -arch ${arch} -target ${arch}-apple-tvos${DARWIN_DEPLOYMENT_VERSION_TVOS}"
13051305
;;
13061306
watchsimulator-*)
1307-
echo -n " -arch ${arch} -mwatchos-simulator-version-min=${DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
1307+
echo -n " -arch ${arch} -target ${arch}-apple-watchos-simulator${DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
13081308
;;
13091309
watchos-*)
1310-
echo -n " -arch ${arch} -mwatchos-version-min=${DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
1310+
echo -n " -arch ${arch} -target ${arch}-apple-watchos${DARWIN_DEPLOYMENT_VERSION_WATCHOS}"
13111311
;;
13121312
esac
13131313

0 commit comments

Comments
 (0)