@@ -524,28 +524,99 @@ fn asm_flags() {
524
524
}
525
525
526
526
#[ 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 {
531
531
let test = Test :: gnu ( ) ;
532
532
test. shim ( "fake-gcc" )
533
533
. gcc ( )
534
534
. compiler ( "fake-gcc" )
535
535
. target ( & target)
536
536
. host ( & target)
537
- // Avoid test maintenance when minimum supported OSes change.
538
- . __set_env ( "MACOSX_DEPLOYMENT_TARGET" , version)
539
537
. file ( "foo.c" )
540
538
. compile ( "foo" ) ;
541
539
542
540
let cmd = test. cmd ( 0 ) ;
543
- cmd. must_have_in_order ( "-arch" , ld64_arch) ;
544
- cmd. must_have ( format ! ( "-mmacosx-version-min={version}" ) ) ;
545
541
cmd. must_not_have ( "-isysroot" ) ;
546
542
}
547
543
}
548
544
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
+
549
620
#[ cfg( target_os = "macos" ) ]
550
621
#[ test]
551
622
fn macos_cpp_minimums ( ) {
0 commit comments