@@ -1245,6 +1245,7 @@ NINJA_SOURCE_DIR="${WORKSPACE}/ninja"
1245
1245
SWIFT_SOURCE_DIR=" ${WORKSPACE} /swift"
1246
1246
LLVM_SOURCE_DIR=" ${WORKSPACE} /llvm-project/llvm"
1247
1247
CMARK_SOURCE_DIR=" ${WORKSPACE} /cmark"
1248
+ USWIFT_SOURCE_DIR=" ${WORKSPACE} /uswift"
1248
1249
LLDB_SOURCE_DIR=" ${WORKSPACE} /llvm-project/lldb"
1249
1250
LLBUILD_SOURCE_DIR=" ${WORKSPACE} /llbuild"
1250
1251
STRESSTEST_PACKAGE_DIR=" ${WORKSPACE} /swift-stress-tester"
@@ -1266,6 +1267,7 @@ PRODUCTS=(llvm)
1266
1267
[[ " ${SKIP_BUILD_LIBCXX} " ]] || PRODUCTS+=(libcxx)
1267
1268
[[ " ${SKIP_BUILD_LIBICU} " ]] || PRODUCTS+=(libicu)
1268
1269
[[ " ${SKIP_BUILD_SWIFT} " ]] || PRODUCTS+=(swift)
1270
+ PRODUCTS+=(uswift)
1269
1271
[[ " ${SKIP_BUILD_LLDB} " ]] || PRODUCTS+=(lldb)
1270
1272
[[ " ${SKIP_BUILD_LIBDISPATCH} " ]] || PRODUCTS+=(libdispatch)
1271
1273
[[ " ${SKIP_BUILD_STATIC_LIBDISPATCH} " ]] || PRODUCTS+=(libdispatch_static)
@@ -1356,6 +1358,8 @@ function build_directory_bin() {
1356
1358
;;
1357
1359
libicu)
1358
1360
;;
1361
+ uswift)
1362
+ ;;
1359
1363
* )
1360
1364
echo " error: unknown product: ${product} "
1361
1365
exit 1
@@ -1759,6 +1763,91 @@ for host in "${ALL_HOSTS[@]}"; do
1759
1763
build_targets=(all)
1760
1764
;;
1761
1765
1766
+ uswift)
1767
+ uswift_targets=(
1768
+ " macos-arm64" " arm64-apple-macosx10.9"
1769
+ " macos-x86_64" " x86_64-apple-macosx10.9"
1770
+ " linux-armv7" " armv7-unknown-linux-androideabi"
1771
+ " windows-x86_64" " x86_64-unknown-windows-msvc"
1772
+ )
1773
+ uswift_targets_length=${# uswift_targets[@]}
1774
+
1775
+ cmake_options=(
1776
+ " ${cmake_options[@]} "
1777
+ -D BUILD_SHARED_LIBS=NO
1778
+ -D CMAKE_Swift_COMPILER_WORKS=YES
1779
+ -D CMAKE_BUILD_TYPE=Release
1780
+ -D CMAKE_Swift_COMPILER=$( build_directory ${host} swift) /bin/swiftc
1781
+ )
1782
+
1783
+ # Build uswift for each target.
1784
+ for (( i= 1 ; i< ${uswift_targets_length} + 1 ; i+= 2 )) ;
1785
+ do
1786
+ uswift_target_name=${uswift_targets[$i-1]}
1787
+ uswift_target=${uswift_targets[$i]}
1788
+ all_cmake_options=(
1789
+ " ${cmake_options[@]} "
1790
+ -D CMAKE_Swift_COMPILER_TARGET=${uswift_target}
1791
+ )
1792
+
1793
+ if [[ " $uswift_target_name " == " windows-x86_64" ]] ; then
1794
+ all_cmake_options=(
1795
+ " ${all_cmake_options[@]} "
1796
+ -D CMAKE_Swift_FLAGS=" -use-ld=$( build_directory ${LOCAL_HOST} llvm) /bin/lld-link"
1797
+ )
1798
+ else
1799
+ all_cmake_options=(
1800
+ " ${all_cmake_options[@]} "
1801
+ -D CMAKE_Swift_FLAGS=" -Xfrontend -disable-legacy-type-info"
1802
+ )
1803
+ fi
1804
+
1805
+ build_dir=$( build_directory ${uswift_target_name} ${product} )
1806
+
1807
+ generator_output_path=" "
1808
+ if [[ " ${CMAKE_GENERATOR} " == " Ninja" ]] ; then
1809
+ generator_output_path=" ${build_dir} /build.ninja"
1810
+ fi
1811
+
1812
+ # Configure if necessary.
1813
+ cmake_cache_path=" ${build_dir} /CMakeCache.txt"
1814
+ if [[ " ${RECONFIGURE} " || ! -f " ${cmake_cache_path} " || \
1815
+ ( ! -z " ${generator_output_path} " && ! -f " ${generator_output_path} " ) ]] ; then
1816
+ call mkdir -p " ${build_dir} "
1817
+
1818
+ # Use `cmake-file-api` in case it is available.
1819
+ call mkdir -p " ${build_dir} /.cmake/api/v1/query"
1820
+ call touch " ${build_dir} /.cmake/api/v1/query/codemodel-v2" " ${build_dir} /.cmake/api/v1/query/cache-v2"
1821
+
1822
+ if [[ -n " ${DISTCC} " ]]; then
1823
+ EXTRA_DISTCC_OPTIONS=(" DISTCC_HOSTS=localhost,lzo,cpp" )
1824
+ fi
1825
+ with_pushd " ${build_dir} " \
1826
+ call env " ${EXTRA_DISTCC_OPTIONS[@]} " " ${CMAKE} " " ${all_cmake_options[@]} " " ${EXTRA_CMAKE_OPTIONS[@]} " " ${source_dir} "
1827
+ fi
1828
+
1829
+ # Note: unconditionally build uswift because it is required for running some tests.
1830
+ if [[ " ${CMAKE_GENERATOR} " == " Xcode" ]] ; then
1831
+ # Xcode generator uses "ALL_BUILD" instead of "all".
1832
+ # Also, xcodebuild uses -target instead of bare names.
1833
+ build_targets=(" ${build_targets[@]/ all/ ALL_BUILD} " )
1834
+ build_targets=(" ${build_targets[@]/#/ ${BUILD_TARGET_FLAG} } " )
1835
+
1836
+ # Xcode can't restart itself if it turns out we need to reconfigure.
1837
+ # Do an advance build to handle that.
1838
+ call " ${CMAKE_BUILD[@]} " " ${build_dir} " $( cmake_config_opt ${product} )
1839
+ fi
1840
+
1841
+ call " ${CMAKE_BUILD[@]} " " ${build_dir} " $( cmake_config_opt ${product} ) -- " ${BUILD_ARGS[@]} " ${build_targets[@]}
1842
+
1843
+ # Copy over the uswift build.
1844
+ cp -a $( build_directory ${uswift_target_name} uswift) $( build_directory ${host} swift)
1845
+ done
1846
+
1847
+ # We've already run cmake/build so we can just break out here.
1848
+ continue
1849
+ ;;
1850
+
1762
1851
llvm)
1763
1852
if [[ -n " ${LLVM_NINJA_TARGETS_FOR_CROSS_COMPILE_HOSTS} " && $( is_cross_tools_host ${host} ) ]] ; then
1764
1853
build_targets=(" ${LLVM_NINJA_TARGETS_FOR_CROSS_COMPILE_HOSTS[@]} " )
@@ -1817,7 +1906,7 @@ for host in "${ALL_HOSTS[@]}"; do
1817
1906
" ${llvm_cmake_options[@]} "
1818
1907
)
1819
1908
1820
- llvm_enable_projects=(" clang" )
1909
+ llvm_enable_projects=(" clang" " lld " )
1821
1910
1822
1911
if [[ ! " ${SKIP_BUILD_COMPILER_RT} " && ! $( is_cross_tools_host ${host} ) ]]; then
1823
1912
llvm_enable_projects+=(" compiler-rt" )
@@ -1827,18 +1916,6 @@ for host in "${ALL_HOSTS[@]}"; do
1827
1916
llvm_enable_projects+=(" clang-tools-extra" )
1828
1917
fi
1829
1918
1830
- # On non-Darwin platforms, build lld so we can always have a
1831
- # linker that is compatible with the swift we are using to
1832
- # compile the stdlib.
1833
- #
1834
- # This makes it easier to build target stdlibs on systems that
1835
- # have old toolchains without more modern linker features.
1836
- if [[ " $( uname -s) " != " Darwin" ]] ; then
1837
- if [[ ! " ${SKIP_BUILD_LLD} " ]]; then
1838
- llvm_enable_projects+=(" lld" )
1839
- fi
1840
- fi
1841
-
1842
1919
cmake_options+=(
1843
1920
-DLLVM_ENABLE_PROJECTS=" $( join " ;" ${llvm_enable_projects[@]} ) "
1844
1921
)
@@ -1898,7 +1975,6 @@ for host in "${ALL_HOSTS[@]}"; do
1898
1975
;;
1899
1976
1900
1977
swift)
1901
-
1902
1978
if [[ " ${ANDROID_API_LEVEL} " ]]; then
1903
1979
cmake_options=(
1904
1980
" ${cmake_options[@]} "
@@ -2808,6 +2884,9 @@ for host in "${ALL_HOSTS[@]}"; do
2808
2884
libcxx)
2809
2885
continue # We don't test libc++
2810
2886
;;
2887
+ uswift)
2888
+ continue # We don't test uswift
2889
+ ;;
2811
2890
swift)
2812
2891
executable_target=
2813
2892
results_targets=
@@ -3159,6 +3238,9 @@ for host in "${ALL_HOSTS[@]}"; do
3159
3238
fi
3160
3239
INSTALL_TARGETS=install-swift-components
3161
3240
;;
3241
+ uswift)
3242
+ continue
3243
+ ;;
3162
3244
llbuild)
3163
3245
if [[ -z " ${INSTALL_LLBUILD} " ]] ; then
3164
3246
continue
0 commit comments