Skip to content

Commit fd79ea8

Browse files
committed
[build] Add a new flag to disable cross-compiling the compiler
This is useful when building cross-compilation toolchains where you want the stdlib and corelibs cross-compiled but don't want the Swift compiler cross-compiled too with '--cross-compile-hosts'. This pull demonstrates using the new flag for the Android build presets.
1 parent d8686f7 commit fd79ea8

File tree

3 files changed

+25
-4
lines changed

3 files changed

+25
-4
lines changed

utils/build-presets.ini

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ mixin-preset=
872872
buildbot_linux
873873
mixin_buildbot_linux,no_test
874874

875-
[preset: buildbot_linux_crosscompile_android,tools=RA,stdlib=RD,build]
875+
[preset: buildbot_linux_crosscompile_android_generic,tools=RA,stdlib=RD,build]
876876
mixin-preset=
877877
mixin_lightweight_assertions,no-stdlib-asserts
878878
mixin_linux_install_components_with_clang
@@ -889,6 +889,7 @@ lit-args=-v --time-tests
889889
build-ninja
890890
libicu
891891
libcxx
892+
xctest
892893

893894
android
894895
android-ndk=%(ndk_path)s
@@ -899,6 +900,10 @@ android-icu-i18n=%(arm_dir)s/libicui18nswift.so
899900
android-icu-i18n-include=%(arm_dir)s/icu/source/i18n
900901
android-icu-data=%(arm_dir)s/libicudataswift.so
901902

903+
cross-compile-deps-path=%(prebuilt_path)s
904+
cross-compile-build-swift-tools=0
905+
llvm-ninja-targets-for-cross-compile-hosts=help
906+
902907
build-swift-static-stdlib
903908
build-swift-static-sdk-overlay
904909
build-swift-stdlib-unittest-extra
@@ -914,20 +919,29 @@ host-test
914919
extra-cmake-options=-DSWIFT_ENABLE_LLD_LINKER:BOOL=OFF
915920

916921
install-prefix=/usr
917-
install-llvm
918922
install-swift
919923
install-libicu
920924
install-libcxx
925+
install-libdispatch
926+
install-foundation
927+
install-xctest
921928

922929
skip-test-linux
923930
skip-build-benchmarks
924931

925932
reconfigure
926933

934+
[preset: buildbot_linux_crosscompile_android,tools=RA,stdlib=RD,build]
935+
mixin-preset=buildbot_linux_crosscompile_android_generic,tools=RA,stdlib=RD,build
936+
937+
android-arch=armv7
938+
cross-compile-hosts=android-armv7
939+
927940
[preset: buildbot_linux_crosscompile_android,tools=RA,stdlib=RD,build,aarch64]
928-
mixin-preset=buildbot_linux_crosscompile_android,tools=RA,stdlib=RD,build
941+
mixin-preset=buildbot_linux_crosscompile_android_generic,tools=RA,stdlib=RD,build
929942

930943
android-arch=aarch64
944+
cross-compile-hosts=android-aarch64
931945

932946
# Ubuntu 18.04 preset for backwards compat and future customizations.
933947
[preset: buildbot_linux_1804]

utils/build-script-impl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ KNOWN_SETTINGS=(
230230
cross-compile-with-host-tools "" "set to use the clang we build for the host to then build the cross-compile hosts"
231231
cross-compile-install-prefixes "" "semicolon-separated list of install prefixes to use for the cross-compiled hosts. The list expands, so if there are more cross-compile hosts than prefixes, unmatched hosts use the last prefix in the list"
232232
cross-compile-deps-path "" "path for CMake to look for cross-compiled library dependencies, such as libXML2"
233+
cross-compile-build-swift-tools "1" "set to 1 to cross-compile the Swift host tools, like the Swift compiler"
233234
skip-merge-lipo-cross-compile-tools "" "set to skip running merge-lipo after installing cross-compiled host Swift tools"
234235
coverage-db "" "If set, coverage database to use when prioritizing testing"
235236
skip-local-host-install "" "If we are cross-compiling multiple targets, skip an install pass locally if the hosts match"
@@ -1909,6 +1910,12 @@ for host in "${ALL_HOSTS[@]}"; do
19091910
cmake_options=(
19101911
"${cmake_options[@]}"
19111912
-DLLVM_TABLEGEN=$(build_directory "${LOCAL_HOST}" llvm)/bin/llvm-tblgen
1913+
-DSWIFT_INCLUDE_TOOLS:BOOL=$(true_false "${CROSS_COMPILE_BUILD_SWIFT_TOOLS}")
1914+
)
1915+
else
1916+
cmake_options=(
1917+
"${cmake_options[@]}"
1918+
-DSWIFT_INCLUDE_TOOLS:BOOL=$(true_false "${BUILD_SWIFT_TOOLS}")
19121919
)
19131920
fi
19141921

@@ -1963,7 +1970,6 @@ for host in "${ALL_HOSTS[@]}"; do
19631970
-DSWIFT_NATIVE_LLVM_TOOLS_PATH:STRING="${native_llvm_tools_path}"
19641971
-DSWIFT_NATIVE_CLANG_TOOLS_PATH:STRING="${native_clang_tools_path}"
19651972
-DSWIFT_NATIVE_SWIFT_TOOLS_PATH:STRING="${native_swift_tools_path}"
1966-
-DSWIFT_INCLUDE_TOOLS:BOOL=$(true_false "${BUILD_SWIFT_TOOLS}")
19671973
-DSWIFT_BUILD_REMOTE_MIRROR:BOOL=$(true_false "${BUILD_SWIFT_REMOTE_MIRROR}")
19681974
-DSWIFT_STDLIB_SIL_DEBUGGING:BOOL=$(true_false "${BUILD_SIL_DEBUGGING_STDLIB}")
19691975
-DSWIFT_CHECK_INCREMENTAL_COMPILATION:BOOL=$(true_false "${CHECK_INCREMENTAL_COMPILATION}")

utils/build_swift/tests/build_swift/test_presets.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
'swift_install_destdir': '/tmp/install/swift',
4747
'symbols_package': '/path/to/symbols/package',
4848
'ndk_path': '/path/to/ndk',
49+
'prebuilt_path': '/path/to/prebuilt_library_dependencies',
4950
'arm_dir': '/path/to/arm',
5051
'toolchain_path': '/tmp/toolchain',
5152
}

0 commit comments

Comments
 (0)