@@ -98,18 +98,6 @@ impl TargetAbi {
98
98
}
99
99
100
100
fn 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
-
113
101
let mut args = LinkArgs :: new ( ) ;
114
102
// From the man page for ld64 (`man ld`):
115
103
// > The linker accepts universal (multiple-architecture) input files,
@@ -137,11 +125,46 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: TargetAbi) -> LinkArgs {
137
125
} ;
138
126
add_link_args ( & mut args, LinkerFlavor :: Darwin ( Cc :: No , Lld :: No ) , & [ "-arch" , ld_arch] ) ;
139
127
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 ( ) ;
140
162
add_link_args_iter (
141
163
& mut args,
142
164
LinkerFlavor :: Darwin ( Cc :: No , Lld :: No ) ,
143
165
[ "-platform_version" . into ( ) , platform_name, min_version, sdk_version] . into_iter ( ) ,
144
166
) ;
167
+
145
168
if abi != TargetAbi :: MacCatalyst {
146
169
add_link_args ( & mut args, LinkerFlavor :: Darwin ( Cc :: Yes , Lld :: No ) , & [ "-arch" , ld_arch] ) ;
147
170
} else {
0 commit comments