@@ -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
@@ -140,11 +128,46 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: TargetAbi) -> LinkArgs {
140128 let mut args =
141129 TargetOptions :: link_args ( LinkerFlavor :: Darwin ( Cc :: No , Lld :: No ) , & [ "-arch" , arch. ld_arch ( ) ] ) ;
142130
131+ // From the man page for ld64 (`man ld`):
132+ // > This is set to indicate the platform, oldest supported version of
133+ // > that platform that output is to be used on, and the SDK that the
134+ // > output was built against. platform [...] may be one of the following
135+ // > strings:
136+ // > - macos
137+ // > - ios
138+ // > - tvos
139+ // > - watchos
140+ // > - bridgeos
141+ // > - visionos
142+ // > - xros
143+ // > - mac-catalyst
144+ // > - ios-simulator
145+ // > - tvos-simulator
146+ // > - watchos-simulator
147+ // > - visionos-simulator
148+ // > - xros-simulator
149+ // > - driverkit
150+ //
151+ // Like with `-arch`, the linker can figure out the platform versions
152+ // itself from the binaries being linked, but to be safe, we specify the
153+ // desired versions here explicitly.
154+ let platform_name: StaticCow < str > = match abi {
155+ TargetAbi :: Normal => os. into ( ) ,
156+ TargetAbi :: Simulator => format ! ( "{os}-simulator" ) . into ( ) ,
157+ TargetAbi :: MacCatalyst => "mac-catalyst" . into ( ) ,
158+ } ;
159+ let min_version: StaticCow < str > = {
160+ let ( major, minor, patch) = deployment_target ( os, arch, abi) ;
161+ format ! ( "{major}.{minor}.{patch}" ) . into ( )
162+ } ;
163+ // Lie about the SDK version, we don't know it here
164+ let sdk_version = min_version. clone ( ) ;
143165 add_link_args_iter (
144166 & mut args,
145167 LinkerFlavor :: Darwin ( Cc :: No , Lld :: No ) ,
146168 [ "-platform_version" . into ( ) , platform_name, min_version, sdk_version] . into_iter ( ) ,
147169 ) ;
170+
148171 if abi != TargetAbi :: MacCatalyst {
149172 // CC forwards the `-arch` to the linker, so we use the same value
150173 // here intentionally.
0 commit comments