@@ -117,18 +117,6 @@ impl TargetAbi {
117
117
}
118
118
119
119
fn 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
-
132
120
// From the man page for ld64 (`man ld`):
133
121
// > The linker accepts universal (multiple-architecture) input files,
134
122
// > 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 {
140
128
let mut args =
141
129
TargetOptions :: link_args ( LinkerFlavor :: Darwin ( Cc :: No , Lld :: No ) , & [ "-arch" , arch. ld_arch ( ) ] ) ;
142
130
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 ( ) ;
143
165
add_link_args_iter (
144
166
& mut args,
145
167
LinkerFlavor :: Darwin ( Cc :: No , Lld :: No ) ,
146
168
[ "-platform_version" . into ( ) , platform_name, min_version, sdk_version] . into_iter ( ) ,
147
169
) ;
170
+
148
171
if abi != TargetAbi :: MacCatalyst {
149
172
// CC forwards the `-arch` to the linker, so we use the same value
150
173
// here intentionally.
0 commit comments