@@ -524,28 +524,99 @@ fn asm_flags() {
524524}
525525
526526#[ test]
527- fn gnu_apple_darwin ( ) {
528- for ( arch , ld64_arch , version ) in & [ ( "x86_64 ", "x86_64" , "10.7" ) , ( "aarch64" , "arm64" , "11.0" ) ]
529- {
530- let target = format ! ( "{}-apple-darwin" , arch ) ;
527+ fn gnu_apple_sysroot ( ) {
528+ let targets = [ "aarch64-apple-darwin ", "x86_64-apple-darwin" ] ;
529+
530+ for target in targets {
531531 let test = Test :: gnu ( ) ;
532532 test. shim ( "fake-gcc" )
533533 . gcc ( )
534534 . compiler ( "fake-gcc" )
535535 . target ( & target)
536536 . host ( & target)
537- // Avoid test maintenance when minimum supported OSes change.
538- . __set_env ( "MACOSX_DEPLOYMENT_TARGET" , version)
539537 . file ( "foo.c" )
540538 . compile ( "foo" ) ;
541539
542540 let cmd = test. cmd ( 0 ) ;
543- cmd. must_have_in_order ( "-arch" , ld64_arch) ;
544- cmd. must_have ( format ! ( "-mmacosx-version-min={version}" ) ) ;
545541 cmd. must_not_have ( "-isysroot" ) ;
546542 }
547543}
548544
545+ #[ test]
546+ #[ cfg( target_os = "macos" ) ] // Invokes xcrun
547+ fn gnu_apple_arch ( ) {
548+ let cases = [
549+ ( "x86_64-apple-darwin" , "x86_64" ) ,
550+ ( "x86_64h-apple-darwin" , "x86_64h" ) ,
551+ ( "aarch64-apple-darwin" , "arm64" ) ,
552+ ( "arm64e-apple-darwin" , "arm64e" ) ,
553+ ( "i686-apple-darwin" , "i386" ) ,
554+ ( "aarch64-apple-ios" , "arm64" ) ,
555+ ( "armv7s-apple-ios" , "armv7s" ) ,
556+ ( "arm64_32-apple-watchos" , "arm64_32" ) ,
557+ ( "armv7k-apple-watchos" , "armv7k" ) ,
558+ ] ;
559+
560+ for ( target, arch) in cases {
561+ let test = Test :: gnu ( ) ;
562+ test. shim ( "fake-gcc" )
563+ . gcc ( )
564+ . compiler ( "fake-gcc" )
565+ . target ( & target)
566+ . host ( & "aarch64-apple-darwin" )
567+ . file ( "foo.c" )
568+ . compile ( "foo" ) ;
569+
570+ let cmd = test. cmd ( 0 ) ;
571+ cmd. must_have_in_order ( "-arch" , arch) ;
572+ }
573+ }
574+
575+ #[ test]
576+ #[ cfg( target_os = "macos" ) ] // Invokes xcrun
577+ fn gnu_apple_deployment_target ( ) {
578+ let cases = [
579+ ( "x86_64-apple-darwin" , "-mmacosx-version-min=10.12" ) ,
580+ ( "aarch64-apple-darwin" , "-mmacosx-version-min=10.12" ) ,
581+ ( "aarch64-apple-ios" , "-miphoneos-version-min=10.0" ) ,
582+ ( "aarch64-apple-ios-sim" , "-mios-simulator-version-min=10.0" ) ,
583+ ( "x86_64-apple-ios" , "-mios-simulator-version-min=10.0" ) ,
584+ ( "aarch64-apple-ios-macabi" , "-mtargetos=ios10.0-macabi" ) ,
585+ ( "aarch64-apple-tvos" , "-mappletvos-version-min=10.0" ) ,
586+ (
587+ "aarch64-apple-tvos-sim" ,
588+ "-mappletvsimulator-version-min=10.0" ,
589+ ) ,
590+ ( "aarch64-apple-watchos" , "-mwatchos-version-min=5.0" ) ,
591+ (
592+ "aarch64-apple-watchos-sim" ,
593+ "-mwatchsimulator-version-min=5.0" ,
594+ ) ,
595+ ( "aarch64-apple-visionos" , "-mtargetos=xros1.0" ) ,
596+ ( "aarch64-apple-visionos-sim" , "-mtargetos=xros1.0-simulator" ) ,
597+ ] ;
598+
599+ for ( target, os_version_flag) in cases {
600+ let test = Test :: gnu ( ) ;
601+ test. shim ( "fake-gcc" )
602+ . gcc ( )
603+ . compiler ( "fake-gcc" )
604+ . target ( & target)
605+ . host ( & "aarch64-apple-darwin" )
606+ // Avoid dependency on environment in test.
607+ . __set_env ( "MACOSX_DEPLOYMENT_TARGET" , "10.12" )
608+ . __set_env ( "IPHONEOS_DEPLOYMENT_TARGET" , "10.0" )
609+ . __set_env ( "TVOS_DEPLOYMENT_TARGET" , "10.0" )
610+ . __set_env ( "WATCHOS_DEPLOYMENT_TARGET" , "5.0" )
611+ . __set_env ( "XROS_DEPLOYMENT_TARGET" , "1.0" )
612+ . file ( "foo.c" )
613+ . compile ( "foo" ) ;
614+
615+ let cmd = test. cmd ( 0 ) ;
616+ cmd. must_have ( os_version_flag) ;
617+ }
618+ }
619+
549620#[ cfg( target_os = "macos" ) ]
550621#[ test]
551622fn macos_cpp_minimums ( ) {
@@ -616,7 +687,7 @@ fn clang_apple_tvos() {
616687 . file ( "foo.c" )
617688 . compile ( "foo" ) ;
618689
619- test. cmd ( 0 ) . must_have_in_order ( "-arch" , " arm64") ;
690+ test. cmd ( 0 ) . must_have ( "--target= arm64-apple-tvos " ) ;
620691 test. cmd ( 0 ) . must_have ( "-mappletvos-version-min=9.0" ) ;
621692}
622693
@@ -640,10 +711,9 @@ fn clang_apple_mac_catalyst() {
640711 . compile ( "foo" ) ;
641712 let execution = test. cmd ( 0 ) ;
642713
643- execution. must_have_in_order ( "-arch" , " arm64") ;
714+ execution. must_have ( "--target= arm64-apple-ios15.0-macabi " ) ;
644715 // --target and -mtargetos= don't mix
645- execution. must_not_have ( "--target=arm64-apple-ios-macabi" ) ;
646- execution. must_have ( "-mtargetos=ios15.0-macabi" ) ;
716+ execution. must_not_have ( "-mtargetos=" ) ;
647717 execution. must_have_in_order ( "-isysroot" , sdkroot) ;
648718 execution. must_have_in_order (
649719 "-isystem" ,
@@ -672,7 +742,8 @@ fn clang_apple_tvsimulator() {
672742 . file ( "foo.c" )
673743 . compile ( "foo" ) ;
674744
675- test. cmd ( 0 ) . must_have_in_order ( "-arch" , "x86_64" ) ;
745+ test. cmd ( 0 )
746+ . must_have ( "--target=x86_64-apple-tvos-simulator" ) ;
676747 test. cmd ( 0 ) . must_have ( "-mappletvsimulator-version-min=9.0" ) ;
677748}
678749
@@ -697,10 +768,9 @@ fn clang_apple_visionos() {
697768
698769 dbg ! ( test. cmd( 0 ) . args) ;
699770
700- test. cmd ( 0 ) . must_have_in_order ( "-arch" , " arm64") ;
771+ test. cmd ( 0 ) . must_have ( "--target= arm64-apple-xros1.0 " ) ;
701772 // --target and -mtargetos= don't mix.
702- test. cmd ( 0 ) . must_not_have ( "--target=arm64-apple-xros" ) ;
703- test. cmd ( 0 ) . must_have ( "-mtargetos=xros1.0" ) ;
773+ test. cmd ( 0 ) . must_not_have ( "-mtargetos=" ) ;
704774
705775 // Flags that don't exist.
706776 test. cmd ( 0 ) . must_not_have ( "-mxros-version-min=1.0" ) ;
0 commit comments