@@ -102,6 +102,7 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: &'static str) -> LinkArgs {
102102 "ios" => ios_deployment_target ( arch, abi) ,
103103 "tvos" => tvos_deployment_target ( ) ,
104104 "watchos" => watchos_deployment_target ( ) ,
105+ "visionos" => visionos_deployment_target ( ) ,
105106 "macos" => macos_deployment_target ( arch) ,
106107 _ => unreachable ! ( ) ,
107108 } ;
@@ -202,6 +203,8 @@ pub fn sdk_version(platform: u32) -> Option<(u32, u32)> {
202203 | object:: macho:: PLATFORM_TVOSSIMULATOR
203204 | object:: macho:: PLATFORM_MACCATALYST => Some ( ( 16 , 2 ) ) ,
204205 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 ) ) ,
205208 _ => None ,
206209 }
207210}
@@ -216,6 +219,9 @@ pub fn platform(target: &Target) -> Option<u32> {
216219 ( "watchos" , _) => object:: macho:: PLATFORM_WATCHOS ,
217220 ( "tvos" , "sim" ) => object:: macho:: PLATFORM_TVOSSIMULATOR ,
218221 ( "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 ,
219225 _ => return None ,
220226 } )
221227}
@@ -240,6 +246,7 @@ pub fn deployment_target(target: &Target) -> Option<(u32, u32)> {
240246 }
241247 "watchos" => watchos_deployment_target ( ) ,
242248 "tvos" => tvos_deployment_target ( ) ,
249+ "visionos" => visionos_deployment_target ( ) ,
243250 _ => return None ,
244251 } ;
245252
@@ -290,6 +297,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow<str>]> {
290297 || sdkroot. contains ( "AppleTVSimulator.platform" )
291298 || sdkroot. contains ( "WatchOS.platform" )
292299 || sdkroot. contains ( "WatchSimulator.platform" )
300+ || sdkroot. contains ( "XROS.platform" )
293301 {
294302 env_remove. push ( "SDKROOT" . into ( ) )
295303 }
@@ -299,6 +307,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow<str>]> {
299307 // although this is apparently ignored when using the linker at "/usr/bin/ld".
300308 env_remove. push ( "IPHONEOS_DEPLOYMENT_TARGET" . into ( ) ) ;
301309 env_remove. push ( "TVOS_DEPLOYMENT_TARGET" . into ( ) ) ;
310+ env_remove. push ( "XROS_DEPLOYMENT_TARGET" . into ( ) ) ;
302311 env_remove. into ( )
303312 } else {
304313 // 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 {
363372 let ( major, minor) = watchos_deployment_target ( ) ;
364373 format ! ( "{}-apple-watchos{}.{}.0-simulator" , arch. target_name( ) , major, minor)
365374}
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