From 7e3c7089aa53582f75cab09a64aaffd38676adb6 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Tue, 7 May 2024 07:31:12 +0000 Subject: [PATCH] [Build] Repair the build for non-static-only static stdlib builds When SWIFT_BUILD_STATIC_STDLIB=ON, SWIFT_BUILD_DYNAMIC_STDLIB=OFF, and the sdk being built is not a static-only (e.g. WASI), the build fails due to duplicate custom command rules against the same output path. In the case of WASI, the static archive should be copied into lib/swift by the first lipo target, and then the second lipo target should copy it into lib/swift_static. ``` CMake Error at cmake/modules/SwiftAddCustomCommandTarget.cmake:144 (add_custom_command): Attempt to add a custom rule to output /home/build-user/build/buildbot_linux/wasmstdlib-linux-x86_64/lib/swift_static/wasi/libswiftCore.a.rule which already has a custom rule. Call Stack (most recent call first): stdlib/cmake/modules/AddSwiftStdlib.cmake:673 (add_custom_command_target) stdlib/cmake/modules/AddSwiftStdlib.cmake:2657 (_add_swift_lipo_target) stdlib/public/core/CMakeLists.txt:401 (add_swift_target_library) ``` --- stdlib/cmake/modules/AddSwiftStdlib.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stdlib/cmake/modules/AddSwiftStdlib.cmake b/stdlib/cmake/modules/AddSwiftStdlib.cmake index c3ad95c05c6a0..8bef94ac1529a 100644 --- a/stdlib/cmake/modules/AddSwiftStdlib.cmake +++ b/stdlib/cmake/modules/AddSwiftStdlib.cmake @@ -2492,10 +2492,10 @@ function(add_swift_target_library name) "${SWIFTLIB_DIR}/${library_subdir}/${CMAKE_SHARED_LIBRARY_PREFIX}${name}${CMAKE_SHARED_LIBRARY_SUFFIX}") endif() else() - if(SWIFTLIB_INSTALL_WITH_SHARED) - set(lib_dir "${SWIFTLIB_DIR}") - else() + if(SWIFT_SDK_${sdk}_STATIC_ONLY) set(lib_dir "${SWIFTSTATICLIB_DIR}") + else() + set(lib_dir "${SWIFTLIB_DIR}") endif() if("${sdk}" STREQUAL "WINDOWS")