From 1113cffd4be9befd64a1de48038786b42d3d7fae Mon Sep 17 00:00:00 2001 From: Kuba Mracek Date: Tue, 28 May 2024 07:50:41 -0700 Subject: [PATCH 1/2] [embedded] Avoid building embedded stdlib when cross-compiling --- utils/build-script-impl | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/utils/build-script-impl b/utils/build-script-impl index 8f1163ac68a49..88d3a35ceea28 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -792,6 +792,15 @@ function set_build_options_for_host() { -DCMAKE_OSX_ARCHITECTURES="${architecture}" ) + # Avoid building the embedded stdlib and other embedded libraries when cross-compiling. + # Those are already provided by the local host build, and are identical and only cause + # trouble when lipo-ing if they are produced in cross-compile builds too. + if [[ $(is_cross_tools_host "${host}") ]] ; then + swift_cmake_options+=( + -DSWIFT_SHOULD_BUILD_EMBEDDED_STDLIB:BOOL=FALSE + ) + fi + lldb_cmake_options+=( -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING="${cmake_osx_deployment_target}" -DCMAKE_OSX_SYSROOT:PATH="${cmake_os_sysroot}" From 56016a864930d502a2c3feb2925e47516095f3dd Mon Sep 17 00:00:00 2001 From: Kuba Mracek Date: Tue, 28 May 2024 14:03:15 -0700 Subject: [PATCH 2/2] [embedded] Avoid strip-ing .a embedded libraries --- utils/build-script-impl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/build-script-impl b/utils/build-script-impl index 88d3a35ceea28..b9ab195a7caf3 100755 --- a/utils/build-script-impl +++ b/utils/build-script-impl @@ -3345,10 +3345,11 @@ for host in "${ALL_HOSTS[@]}"; do printJSONEndTimestamp dsymutil # Strip executables, shared libraries and static libraries in - # `host_install_destdir`. Avoid touching clang builtins .a files. + # `host_install_destdir`. Avoid touching .a clang builtins and embedded libraries. find "${CURRENT_INSTALL_DIR}${CURRENT_PREFIX}/" \ '(' -perm -0111 -or -name "*.a" ')' -type f -print | \ grep_that_allows_no_matches -v "/clang/lib/darwin/" | \ + grep_that_allows_no_matches -v "/lib/swift/embedded/" | \ xargs -t -n 1 -P ${BUILD_JOBS} $(xcrun_find_tool strip) -S # Codesign dylibs and executables in usr/bin after strip tool