@@ -319,6 +319,10 @@ lit_config.note('Using resource dir: ' + test_resource_dir)
319
319
320
320
# Parse the variant triple.
321
321
(run_cpu , run_vendor , run_os , run_vers ) = re .match ('([^-]+)-([^-]+)-([^0-9]+)(.*)' , config .variant_triple ).groups ()
322
+ if run_os == 'ios' and run_vers .endswith ('-macabi' ):
323
+ run_vers = run_vers [0 :- len ('-macabi' )]
324
+ run_os = 'maccatalyst'
325
+
322
326
run_ptrsize = '64' if ('64' in run_cpu or run_cpu == "s390x" ) else '32'
323
327
run_endian = 'little' if run_cpu != 's390x' else 'big'
324
328
@@ -602,7 +606,12 @@ if config.benchmark_o != 'Benchmark_O':
602
606
config .substitutions .append (('%target-triple' , config .variant_triple ))
603
607
604
608
if run_vendor == 'apple' :
605
- if True :
609
+ if run_os == 'maccatalyst' :
610
+ config .stable_abi_triple = '%s-%s-ios13.0-macabi' % (run_cpu , run_vendor )
611
+ config .pre_stable_abi_triple = config .stable_abi_triple
612
+ config .next_stable_abi_triple = config .stable_abi_triple
613
+ config .available_features .add ('swift_stable_abi' )
614
+ else :
606
615
# iOS 12.2 does not support 32-bit targets, so we cannot run tests that
607
616
# want to deploy to an iOS that has Swift in the OS.
608
617
if run_os == 'ios' and run_ptrsize == '32' :
@@ -612,6 +621,7 @@ if run_vendor == 'apple':
612
621
PRE_STABLE_VERSION = {
613
622
'macosx' : '10.14.3' ,
614
623
'ios' : '12.1' ,
624
+ 'maccatalyst' : '12.1' ,
615
625
'tvos' : '12.1' ,
616
626
'watchos' : '5.1'
617
627
}
@@ -622,6 +632,7 @@ if run_vendor == 'apple':
622
632
STABLE_VERSION = {
623
633
'macosx' : '10.14.4' ,
624
634
'ios' : '12.2' ,
635
+ 'maccatalyst' : '12.2' ,
625
636
'tvos' : '12.2' ,
626
637
'watchos' : '5.2'
627
638
}
@@ -632,6 +643,7 @@ if run_vendor == 'apple':
632
643
NEXT_STABLE_VERSION = {
633
644
'macosx' : '10.15' ,
634
645
'ios' : '13' ,
646
+ 'maccatalyst' : '13' ,
635
647
'tvos' : '13' ,
636
648
'watchos' : '6'
637
649
}
@@ -668,6 +680,17 @@ config.substitutions.append(('%sanitizers-target-triple',
668
680
config .variant_triple .replace ("ios7" , "ios8" )))
669
681
670
682
config .substitutions .append (('%target-cpu' , run_cpu ))
683
+
684
+ target_os_abi = run_os
685
+ target_os_is_maccatalyst = "FALSE"
686
+ if (run_os == 'maccatalyst' ):
687
+ # For purposes of ABI, treat maccatalyst as macosx since the maccatalyst ABI
688
+ # must match the macosx ABI.
689
+ target_os_abi = 'macosx'
690
+ target_os_is_maccatalyst = "TRUE"
691
+ config .available_features .add ("OS=ios" )
692
+ config .substitutions .append (('%target-os-abi' , target_os_abi ))
693
+ config .substitutions .append (('%target-os-is-maccatalyst' , target_os_is_maccatalyst ))
671
694
config .substitutions .append (('%target-endian' , run_endian ))
672
695
config .substitutions .append (('%target-os' , run_os ))
673
696
config .substitutions .append (('%target-ptrsize' , run_ptrsize ))
@@ -703,7 +726,12 @@ if 'swift_interpreter' in config.available_features:
703
726
704
727
config .target_runtime = "unknown"
705
728
706
- swift_reflection_test_name = 'swift-reflection-test' + config .variant_suffix
729
+ if (getattr (config , 'darwin_enable_maccatalyst' , False ) and
730
+ config .darwin_maccatalyst_build_flavor == "ios-like" ):
731
+ variant_suffix = config .darwin_osx_variant_suffix
732
+ else :
733
+ variant_suffix = config .variant_suffix
734
+ swift_reflection_test_name = 'swift-reflection-test' + variant_suffix
707
735
708
736
def use_interpreter_for_simple_runs ():
709
737
def make_simple_target_run (gyb = False , stdlib = False , parameterized = False ):
@@ -858,25 +886,49 @@ if run_vendor == 'apple':
858
886
lit_config .fatal ('Could not get or decode sw_vers output. ' +
859
887
'Perhaps the simulator is not working.' )
860
888
861
- elif run_os == 'macosx' :
889
+ elif run_os == 'macosx' or run_os == 'maccatalyst' :
862
890
# OS X
863
891
lit_config .note ("Testing OS X " + config .variant_triple )
864
892
865
893
xcrun_sdk_name = "macosx"
866
- config .target_cc_options = (
867
- "-arch %s -m%s-version-min=%s %s" %
868
- (run_cpu , run_os , run_vers , clang_mcp_opt ))
894
+
895
+ if run_os == 'maccatalyst' :
896
+ # For maccatalyst, pass the target triple to clang
897
+ # rather than arch and version separately.
898
+ config .target_cc_options = (
899
+ "-target %s %s" %
900
+ (config .variant_triple , clang_mcp_opt ))
901
+ else :
902
+ config .target_cc_options = (
903
+ "-arch %s -m%s-version-min=%s %s" %
904
+ (run_cpu , run_os , run_vers , clang_mcp_opt ))
905
+
906
+ maccatalyst_frameworks_component = ""
907
+ if run_os == 'maccatalyst' :
908
+ # Additional framework search paths for macCatalyst.
909
+ # These have to come before other search paths so that for
910
+ # unzippered twin frameworks the unzippered twin version
911
+ # is favored under macCatalyst.
912
+ maccatalyst_frameworks_dir = make_path (config .variant_sdk ,
913
+ "System" , "iOSSupport" , "System" , "Library" , "Frameworks" )
914
+ maccatalyst_frameworks_component = ( "-F %r" % maccatalyst_frameworks_dir )
915
+ # Module triples end in ios-macabi.
916
+ target_specific_module_triple = '{}-apple-ios-macabi' .format (
917
+ { 'aarch64' : 'arm64' , 'amd64' : 'x86_64' }.get (run_cpu , run_cpu )
918
+ )
869
919
870
920
config .target_build_swift = (
871
- ("%s %s %s -F %r -toolchain-stdlib-rpath "
921
+ ("%s %s %s %s -F %r -toolchain-stdlib-rpath "
872
922
+ "-Xlinker -rpath -Xlinker %r %s %s %s %s "
873
923
+ "-F %r -Xlinker -rpath -Xlinker %r" )
874
924
% (xcrun_prefix , config .swiftc , target_options ,
925
+ maccatalyst_frameworks_component ,
875
926
extra_frameworks_dir , extra_frameworks_dir ,
876
927
sdk_overlay_linker_opt , config .swift_test_options ,
877
928
config .swift_driver_test_options ,
878
929
swift_execution_tests_extra_flags , sourcekitd_framework_dir ,
879
930
sourcekitd_framework_dir ))
931
+
880
932
config .target_run = ""
881
933
target_future_version = "10.99"
882
934
@@ -896,9 +948,13 @@ if run_vendor == 'apple':
896
948
897
949
config .target_sdk_name = xcrun_sdk_name
898
950
config .target_ld = "%s ld -L%r" % (xcrun_prefix , make_path (test_resource_dir , config .target_sdk_name ))
951
+
952
+ maccatalyst_extra_frameworks = ""
953
+ if run_os == 'maccatalyst' :
954
+ maccatalyst_extra_frameworks = "-F {}/System/iOSSupport/System/Library/Frameworks" .format (config .variant_sdk )
899
955
config .target_swift_frontend = (
900
- "%s -frontend %s -sdk %r %s %s" %
901
- (config .swiftc , target_options , config .variant_sdk ,
956
+ "%s -frontend %s -sdk %r %s %s %s " %
957
+ (config .swiftc , target_options , config .variant_sdk , maccatalyst_extra_frameworks ,
902
958
config .swift_test_options , config .swift_frontend_test_options ))
903
959
subst_target_swift_frontend_mock_sdk = (
904
960
"%s -frontend %s -sdk %r %s %s" %
@@ -940,6 +996,7 @@ if run_vendor == 'apple':
940
996
config .target_add_rpath = r'-Xlinker -rpath -Xlinker \1'
941
997
942
998
target_future = format ('%s-apple-%s%s' % (run_cpu , run_os , target_future_version ))
999
+ config .otool_classic = ("%s otool-classic" % (xcrun_prefix ))
943
1000
944
1001
elif run_os in ['windows-msvc' ]:
945
1002
lit_config .note ('Testing Windows ' + config .variant_triple )
@@ -1480,6 +1537,13 @@ if platform.system() != 'Darwin' or swift_test_mode == 'optimize_none_with_impli
1480
1537
platform_module_dir = make_path (test_resource_dir , config .target_sdk_name )
1481
1538
if run_vendor != 'apple' :
1482
1539
platform_module_dir = make_path (platform_module_dir , run_cpu )
1540
+
1541
+ platform_dylib_dir = platform_module_dir
1542
+ if run_os == 'maccatalyst' and config .darwin_maccatalyst_build_flavor == "ios-like" :
1543
+ # When using the ios-macabi triple, look for module files
1544
+ # in the 'maccatalyst' compiler resource directory.
1545
+ platform_module_dir = make_path (test_resource_dir , 'maccatalyst' )
1546
+
1483
1547
lit_config .note ('Using platform module dir: ' + platform_module_dir )
1484
1548
if test_sdk_overlay_dir :
1485
1549
platform_sdk_overlay_dir = test_sdk_overlay_dir
@@ -1496,10 +1560,15 @@ if os.path.exists(static_libswiftCore_path):
1496
1560
1497
1561
# Set up testing with the standard libraries coming from the OS / just-built libraries
1498
1562
# default Swift tests to use the just-built libraries
1499
- target_stdlib_path = platform_module_dir
1563
+ target_stdlib_path = platform_dylib_dir
1500
1564
if not kIsWindows :
1501
1565
libdispatch_path = getattr (config , 'libdispatch_artifact_dir' , '' )
1502
1566
if 'use_os_stdlib' not in lit_config .params :
1567
+ if run_os == 'maccatalyst' :
1568
+ # Under macCatalyst we need to have the unzippered twin dylib dir come before
1569
+ # the zippered/macosx dylib dir so that unzippered twins are picked upload_dylibs
1570
+ # before the macOS variant.
1571
+ target_stdlib_path = "{0}:{1}" .format (platform_module_dir , target_stdlib_path )
1503
1572
lit_config .note ('Testing with the just-built libraries at ' + target_stdlib_path )
1504
1573
config .target_run = (
1505
1574
"/usr/bin/env "
@@ -1513,6 +1582,8 @@ if not kIsWindows:
1513
1582
if run_vendor == 'apple' :
1514
1583
#If we get swift-in-the-OS for non-Apple platforms, add a condition here
1515
1584
os_stdlib_path = "/usr/lib/swift"
1585
+ if run_os == 'maccatalyst' :
1586
+ os_stdlib_path = "/System/iOSSupport/usr/lib/swift:/usr/lib/swift"
1516
1587
all_stdlib_path = os .path .pathsep .join ((os_stdlib_path , target_stdlib_path ))
1517
1588
lit_config .note ('Testing with the standard libraries coming from the OS ' + all_stdlib_path )
1518
1589
config .target_run = (
@@ -1667,6 +1738,8 @@ config.substitutions.append(('%target-swift-emit-pcm',
1667
1738
1668
1739
config .substitutions .insert (0 , ('%platform-module-dir' , platform_module_dir ))
1669
1740
config .substitutions .insert (0 , ('%platform-sdk-overlay-dir' , platform_sdk_overlay_dir ))
1741
+ config .substitutions .insert (0 , ('%platform-dylib-dir' , platform_dylib_dir ))
1742
+ config .substitutions .insert (0 , ('%test-resource-dir' , test_resource_dir ))
1670
1743
1671
1744
if run_vendor != 'apple' :
1672
1745
extra_frameworks_dir = ''
@@ -1690,6 +1763,9 @@ config.substitutions.append(('%target-resilience-test', config.target_resilience
1690
1763
config .substitutions .append (('%llvm-profdata' , config .llvm_profdata ))
1691
1764
config .substitutions .append (('%llvm-cov' , config .llvm_cov ))
1692
1765
1766
+ if hasattr (config , 'otool_classic' ):
1767
+ config .substitutions .append (('%otool-classic' , config .otool_classic ))
1768
+
1693
1769
config .substitutions .append (('%FileCheck' ,
1694
1770
'%r %r --sanitize BUILD_DIR=%r --sanitize SOURCE_DIR=%r --use-filecheck %r %s' % (
1695
1771
sys .executable ,
0 commit comments