@@ -142,11 +142,46 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: TargetAbi) -> LinkArgs {
142142        & [ "-arch" ,  arch. ld_arch ( ) ] , 
143143    ) ; 
144144
145+     // From the man page for ld64 (`man ld`): 
146+     // > This is set to indicate the platform, oldest supported version of 
147+     // > that platform that output is to be used on, and the SDK that the 
148+     // > output was built against. platform [...] may be one of the following 
149+     // > strings: 
150+     // > - macos 
151+     // > - ios 
152+     // > - tvos 
153+     // > - watchos 
154+     // > - bridgeos 
155+     // > - visionos 
156+     // > - xros 
157+     // > - mac-catalyst 
158+     // > - ios-simulator 
159+     // > - tvos-simulator 
160+     // > - watchos-simulator 
161+     // > - visionos-simulator 
162+     // > - xros-simulator 
163+     // > - driverkit 
164+     // 
165+     // Like with `-arch`, the linker can figure out the platform versions 
166+     // itself from the binaries being linked, but to be safe, we specify the 
167+     // desired versions here explicitly. 
168+     let  platform_name:  StaticCow < str >  = match  abi { 
169+         TargetAbi :: Normal  => os. into ( ) , 
170+         TargetAbi :: Simulator  => format ! ( "{os}-simulator" ) . into ( ) , 
171+         TargetAbi :: MacCatalyst  => "mac-catalyst" . into ( ) , 
172+     } ; 
173+     let  min_version:  StaticCow < str >  = { 
174+         let  ( major,  minor,  patch)  = deployment_target ( os,  arch,  abi) ; 
175+         format ! ( "{major}.{minor}.{patch}" ) . into ( ) 
176+     } ; 
177+     // Lie about the SDK version, we don't know it here 
178+     let  sdk_version = min_version. clone ( ) ; 
145179    add_link_args_iter ( 
146180        & mut  args, 
147181        LinkerFlavor :: Darwin ( Cc :: No ,  Lld :: No ) , 
148182        [ "-platform_version" . into ( ) ,  platform_name,  min_version,  sdk_version] . into_iter ( ) , 
149183    ) ; 
184+ 
150185    if  abi != TargetAbi :: MacCatalyst  { 
151186        // CC forwards the `-arch` to the linker, so we use the same value 
152187        // here intentionally. 
0 commit comments