@@ -98,18 +98,6 @@ impl TargetAbi {
9898}
9999
100100fn pre_link_args ( os : & ' static str , arch : Arch , abi : TargetAbi ) -> LinkArgs {
101- let platform_name: StaticCow < str > = match abi {
102- TargetAbi :: Normal => os. into ( ) ,
103- TargetAbi :: Simulator => format ! ( "{os}-simulator" ) . into ( ) ,
104- TargetAbi :: MacCatalyst => "mac-catalyst" . into ( ) ,
105- } ;
106-
107- let min_version: StaticCow < str > = {
108- let ( major, minor, patch) = deployment_target ( os, arch, abi) ;
109- format ! ( "{major}.{minor}.{patch}" ) . into ( )
110- } ;
111- let sdk_version = min_version. clone ( ) ;
112-
113101 let mut args = LinkArgs :: new ( ) ;
114102 // From the man page for ld64 (`man ld`):
115103 // > The linker accepts universal (multiple-architecture) input files,
@@ -137,11 +125,46 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: TargetAbi) -> LinkArgs {
137125 } ;
138126 add_link_args ( & mut args, LinkerFlavor :: Darwin ( Cc :: No , Lld :: No ) , & [ "-arch" , ld_arch] ) ;
139127
128+ // From the man page for ld64 (`man ld`):
129+ // > This is set to indicate the platform, oldest supported version of
130+ // > that platform that output is to be used on, and the SDK that the
131+ // > output was built against. platform [...] may be one of the following
132+ // > strings:
133+ // > - macos
134+ // > - ios
135+ // > - tvos
136+ // > - watchos
137+ // > - bridgeos
138+ // > - visionos
139+ // > - xros
140+ // > - mac-catalyst
141+ // > - ios-simulator
142+ // > - tvos-simulator
143+ // > - watchos-simulator
144+ // > - visionos-simulator
145+ // > - xros-simulator
146+ // > - driverkit
147+ //
148+ // Like with `-arch`, the linker can figure out the platform versions
149+ // itself from the binaries being linked, but to be safe, we specify the
150+ // desired versions here explicitly.
151+ let platform_name: StaticCow < str > = match abi {
152+ TargetAbi :: Normal => os. into ( ) ,
153+ TargetAbi :: Simulator => format ! ( "{os}-simulator" ) . into ( ) ,
154+ TargetAbi :: MacCatalyst => "mac-catalyst" . into ( ) ,
155+ } ;
156+ let min_version: StaticCow < str > = {
157+ let ( major, minor, patch) = deployment_target ( os, arch, abi) ;
158+ format ! ( "{major}.{minor}.{patch}" ) . into ( )
159+ } ;
160+ // Lie about the SDK version, we don't know it here
161+ let sdk_version = min_version. clone ( ) ;
140162 add_link_args_iter (
141163 & mut args,
142164 LinkerFlavor :: Darwin ( Cc :: No , Lld :: No ) ,
143165 [ "-platform_version" . into ( ) , platform_name, min_version, sdk_version] . into_iter ( ) ,
144166 ) ;
167+
145168 if abi != TargetAbi :: MacCatalyst {
146169 add_link_args ( & mut args, LinkerFlavor :: Darwin ( Cc :: Yes , Lld :: No ) , & [ "-arch" , ld_arch] ) ;
147170 } else {
0 commit comments