@@ -117,18 +117,6 @@ impl TargetAbi {
117117}
118118
119119fn pre_link_args ( os : & ' static str , arch : Arch , abi : TargetAbi ) -> LinkArgs {
120- let platform_name: StaticCow < str > = match abi {
121- TargetAbi :: Normal => os. into ( ) ,
122- TargetAbi :: Simulator => format ! ( "{os}-simulator" ) . into ( ) ,
123- TargetAbi :: MacCatalyst => "mac-catalyst" . into ( ) ,
124- } ;
125-
126- let min_version: StaticCow < str > = {
127- let ( major, minor, patch) = deployment_target ( os, arch, abi) ;
128- format ! ( "{major}.{minor}.{patch}" ) . into ( )
129- } ;
130- let sdk_version = min_version. clone ( ) ;
131-
132120 // From the man page for ld64 (`man ld`):
133121 // > The linker accepts universal (multiple-architecture) input files,
134122 // > but always creates a "thin" (single-architecture), standard Mach-O
@@ -142,11 +130,46 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: TargetAbi) -> LinkArgs {
142130 & [ "-arch" , arch. ld_arch ( ) ] ,
143131 ) ;
144132
133+ // From the man page for ld64 (`man ld`):
134+ // > This is set to indicate the platform, oldest supported version of
135+ // > that platform that output is to be used on, and the SDK that the
136+ // > output was built against. platform [...] may be one of the following
137+ // > strings:
138+ // > - macos
139+ // > - ios
140+ // > - tvos
141+ // > - watchos
142+ // > - bridgeos
143+ // > - visionos
144+ // > - xros
145+ // > - mac-catalyst
146+ // > - ios-simulator
147+ // > - tvos-simulator
148+ // > - watchos-simulator
149+ // > - visionos-simulator
150+ // > - xros-simulator
151+ // > - driverkit
152+ //
153+ // Like with `-arch`, the linker can figure out the platform versions
154+ // itself from the binaries being linked, but to be safe, we specify the
155+ // desired versions here explicitly.
156+ let platform_name: StaticCow < str > = match abi {
157+ TargetAbi :: Normal => os. into ( ) ,
158+ TargetAbi :: Simulator => format ! ( "{os}-simulator" ) . into ( ) ,
159+ TargetAbi :: MacCatalyst => "mac-catalyst" . into ( ) ,
160+ } ;
161+ let min_version: StaticCow < str > = {
162+ let ( major, minor, patch) = deployment_target ( os, arch, abi) ;
163+ format ! ( "{major}.{minor}.{patch}" ) . into ( )
164+ } ;
165+ // Lie about the SDK version, we don't know it here
166+ let sdk_version = min_version. clone ( ) ;
145167 add_link_args_iter (
146168 & mut args,
147169 LinkerFlavor :: Darwin ( Cc :: No , Lld :: No ) ,
148170 [ "-platform_version" . into ( ) , platform_name, min_version, sdk_version] . into_iter ( ) ,
149171 ) ;
172+
150173 if abi != TargetAbi :: MacCatalyst {
151174 // CC forwards the `-arch` to the linker, so we use the same value
152175 // here intentionally.
0 commit comments