@@ -102,6 +102,7 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: &'static str) -> LinkArgs {
102
102
"ios" => ios_deployment_target ( arch, abi) ,
103
103
"tvos" => tvos_deployment_target ( ) ,
104
104
"watchos" => watchos_deployment_target ( ) ,
105
+ "visionos" => visionos_deployment_target ( ) ,
105
106
"macos" => macos_deployment_target ( arch) ,
106
107
_ => unreachable ! ( ) ,
107
108
} ;
@@ -202,6 +203,8 @@ pub fn sdk_version(platform: u32) -> Option<(u32, u32)> {
202
203
| object:: macho:: PLATFORM_TVOSSIMULATOR
203
204
| object:: macho:: PLATFORM_MACCATALYST => Some ( ( 16 , 2 ) ) ,
204
205
object:: macho:: PLATFORM_WATCHOS | object:: macho:: PLATFORM_WATCHOSSIMULATOR => Some ( ( 9 , 1 ) ) ,
206
+ // FIXME: Upgrade to `object-rs` 0.33+ implementation with visionOS platform definition
207
+ 11 | 12 => Some ( ( 1 , 0 ) ) ,
205
208
_ => None ,
206
209
}
207
210
}
@@ -216,6 +219,9 @@ pub fn platform(target: &Target) -> Option<u32> {
216
219
( "watchos" , _) => object:: macho:: PLATFORM_WATCHOS ,
217
220
( "tvos" , "sim" ) => object:: macho:: PLATFORM_TVOSSIMULATOR ,
218
221
( "tvos" , _) => object:: macho:: PLATFORM_TVOS ,
222
+ // FIXME: Upgrade to `object-rs` 0.33+ implementation with visionOS platform definition
223
+ ( "visionos" , "sim" ) => 12 ,
224
+ ( "visionos" , _) => 11 ,
219
225
_ => return None ,
220
226
} )
221
227
}
@@ -240,6 +246,7 @@ pub fn deployment_target(target: &Target) -> Option<(u32, u32)> {
240
246
}
241
247
"watchos" => watchos_deployment_target ( ) ,
242
248
"tvos" => tvos_deployment_target ( ) ,
249
+ "visionos" => visionos_deployment_target ( ) ,
243
250
_ => return None ,
244
251
} ;
245
252
@@ -290,6 +297,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow<str>]> {
290
297
|| sdkroot. contains ( "AppleTVSimulator.platform" )
291
298
|| sdkroot. contains ( "WatchOS.platform" )
292
299
|| sdkroot. contains ( "WatchSimulator.platform" )
300
+ || sdkroot. contains ( "XROS.platform" )
293
301
{
294
302
env_remove. push ( "SDKROOT" . into ( ) )
295
303
}
@@ -299,6 +307,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow<str>]> {
299
307
// although this is apparently ignored when using the linker at "/usr/bin/ld".
300
308
env_remove. push ( "IPHONEOS_DEPLOYMENT_TARGET" . into ( ) ) ;
301
309
env_remove. push ( "TVOS_DEPLOYMENT_TARGET" . into ( ) ) ;
310
+ env_remove. push ( "XROS_DEPLOYMENT_TARGET" . into ( ) ) ;
302
311
env_remove. into ( )
303
312
} else {
304
313
// Otherwise if cross-compiling for a different OS/SDK (including Mac Catalyst), remove any part
@@ -363,3 +372,18 @@ pub fn watchos_sim_llvm_target(arch: Arch) -> String {
363
372
let ( major, minor) = watchos_deployment_target ( ) ;
364
373
format ! ( "{}-apple-watchos{}.{}.0-simulator" , arch. target_name( ) , major, minor)
365
374
}
375
+
376
+ fn visionos_deployment_target ( ) -> ( u32 , u32 ) {
377
+ // If you are looking for the default deployment target, prefer `rustc --print deployment-target`.
378
+ from_set_deployment_target ( "XROS_DEPLOYMENT_TARGET" ) . unwrap_or ( ( 1 , 0 ) )
379
+ }
380
+
381
+ pub fn visionos_llvm_target ( arch : Arch ) -> String {
382
+ let ( major, minor) = visionos_deployment_target ( ) ;
383
+ format ! ( "{}-apple-visionos{}.{}.0" , arch. target_name( ) , major, minor)
384
+ }
385
+
386
+ pub fn visionos_sim_llvm_target ( arch : Arch ) -> String {
387
+ let ( major, minor) = visionos_deployment_target ( ) ;
388
+ format ! ( "{}-apple-visionos{}.{}.0-simulator" , arch. target_name( ) , major, minor)
389
+ }
0 commit comments