From 7b563ccc3dc4c79b02541e08d8490a88fa6661f4 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 28 Oct 2019 10:47:08 +0000 Subject: [PATCH 01/20] Add simple GitHub Actions config for macOS --- .github/workflows/main.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000000000..62acd4e73caa0 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,37 @@ +name: CI + +on: + pull_request: + branches: + - swiftwasm + +jobs: + macos_build: + timeout-minutes: 0 + runs-on: macOS-10.14 + + steps: + - uses: actions/checkout@v1 + - name: Run a multi-line script + run: | + ./utils/build-script --debug --wasm \ + --skip-build-benchmarks \ + --extra-cmake-options=" \ + -DSWIFT_PRIMARY_VARIANT_SDK:STRING=WASM \ + -DSWIFT_PRIMARY_VARIANT_ARCH:STRING=wasm32 \ + -DSWIFT_OSX_x86_64_ICU_STATICLIB=TRUE \ + -DSWIFT_BUILD_SOURCEKIT=FALSE \ + -DSWIFT_ENABLE_SOURCEKIT_TESTS=FALSE \ + " \ + --stdlib-deployment-targets "wasm-wasm32" \ + --build-stdlib-deployment-targets "wasm-wasm32" \ + --llvm-targets-to-build "X86;WebAssembly" \ + --build-swift-dynamic-sdk-overlay false \ + --build-swift-static-sdk-overlay false \ + --wasm-wasi-sdk "$sourcedir/wasi-sdk" \ + --wasm-icu-uc "$sourcedir/icu_out/lib/libicuuc.a" \ + --wasm-icu-uc-include "$sourcedir/icu_out/include" \ + --wasm-icu-i18n "$sourcedir/icu_out/lib/libicui18n.a" \ + --wasm-icu-i18n-include "$sourcedir/icu_out/include" \ + --wasm-icu-data "todo-icu-data" \ + --build-swift-static-stdlib From 544c068f336ef8b4cbaf01cd132bf18629ae8278 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 28 Oct 2019 10:54:44 +0000 Subject: [PATCH 02/20] Add brew install to the macOS GH action --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 62acd4e73caa0..ef8ffd8a207e9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -14,6 +14,7 @@ jobs: - uses: actions/checkout@v1 - name: Run a multi-line script run: | + brew install cmake ninja ./utils/build-script --debug --wasm \ --skip-build-benchmarks \ --extra-cmake-options=" \ From 1de065645b743241eb331849b74f24e434a38c9c Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 28 Oct 2019 10:57:54 +0000 Subject: [PATCH 03/20] Add update-checkout call to macOS GH action --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ef8ffd8a207e9..a9523f2d73327 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,6 +15,7 @@ jobs: - name: Run a multi-line script run: | brew install cmake ninja + ./utils/update-checkout --clone --scheme wasm ./utils/build-script --debug --wasm \ --skip-build-benchmarks \ --extra-cmake-options=" \ From 3998824a15874d00c70ec94f7a7414ed96077e89 Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Mon, 28 Oct 2019 12:55:38 +0000 Subject: [PATCH 04/20] Export sourcedir shell variable in macOS GH action --- .github/workflows/main.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a9523f2d73327..b34833cab8672 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,6 +16,7 @@ jobs: run: | brew install cmake ninja ./utils/update-checkout --clone --scheme wasm + export sourcedir=$PWD/.. ./utils/build-script --debug --wasm \ --skip-build-benchmarks \ --extra-cmake-options=" \ From f4c22057514b4dfc92365bd2befe9912b0ef6697 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sat, 19 Oct 2019 12:19:04 +0900 Subject: [PATCH 05/20] [WASM] Use prebuilt llvm-ar only on Linux --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4aba6c55eff53..20d7da25359b0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,9 +31,6 @@ ENABLE_LANGUAGE(C) include(SwiftUtils) include(CheckSymbolExists) -# WebAssembly: hack: use llvm-ar for creating static libraries; Ubuntu's GNU ar doesn't work with wasm-ld -set(CMAKE_AR "${SWIFT_WASM_WASI_SDK_PATH}/bin/llvm-ar") - # # User-configurable options that control the inclusion and default build # behavior for components which may not strictly be necessary (tools, examples, @@ -853,6 +850,11 @@ if(swift_build_wasm AND NOT "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "WASM") # message(FATAL_ERROR "A Darwin or Linux host is required to build the Swift runtime for Android") #endif() + if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Linux") + # WebAssembly: hack: use llvm-ar for creating static libraries; Ubuntu's GNU ar doesn't work with wasm-ld + set(CMAKE_AR "${SWIFT_WASM_WASI_SDK_PATH}/bin/llvm-ar") + endif() + if("${SWIFT_SDK_WASM_ARCHITECTURES}" STREQUAL "") set(SWIFT_SDK_WASM_ARCHITECTURES wasm32) endif() From 1b3daf9d425ecf8373d1263acf89ba20fb1ddd55 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 24 Oct 2019 16:43:49 +0900 Subject: [PATCH 06/20] [WASM] Added new Object format WASM to distinguish from ELF --- cmake/modules/AddSwift.cmake | 3 ++- cmake/modules/SwiftConfigureSDK.cmake | 2 ++ lib/Driver/CMakeLists.txt | 3 ++- stdlib/public/runtime/CMakeLists.txt | 16 +++++++++++++++- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/cmake/modules/AddSwift.cmake b/cmake/modules/AddSwift.cmake index f8d41cd692b94..47b03eaab7664 100644 --- a/cmake/modules/AddSwift.cmake +++ b/cmake/modules/AddSwift.cmake @@ -1000,7 +1000,8 @@ function(_add_swift_library_single target name) ${INCORPORATED_OBJECT_LIBRARIES_EXPRESSIONS} ${SWIFTLIB_SINGLE_XCODE_WORKAROUND_SOURCES}) if(("${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_OBJECT_FORMAT}" STREQUAL "ELF" OR - "${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_OBJECT_FORMAT}" STREQUAL "COFF") AND + "${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_OBJECT_FORMAT}" STREQUAL "COFF" OR + "${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_OBJECT_FORMAT}" STREQUAL "WASM") AND SWIFTLIB_SINGLE_TARGET_LIBRARY) if("${libkind}" STREQUAL "SHARED" AND NOT SWIFTLIB_SINGLE_NOSWIFTRT) # TODO(compnerd) switch to the generator expression when cmake is upgraded diff --git a/cmake/modules/SwiftConfigureSDK.cmake b/cmake/modules/SwiftConfigureSDK.cmake index 33fb3f439fb29..5f4b745a2b09c 100644 --- a/cmake/modules/SwiftConfigureSDK.cmake +++ b/cmake/modules/SwiftConfigureSDK.cmake @@ -203,6 +203,8 @@ macro(configure_sdk_unix name architectures) set(SWIFT_SDK_${prefix}_ARCHITECTURES "${architectures}") if("${prefix}" STREQUAL "CYGWIN") set(SWIFT_SDK_${prefix}_OBJECT_FORMAT "COFF") + elseif("${prefix}" STREQUAL "WASM") + set(SWIFT_SDK_${prefix}_OBJECT_FORMAT "WASM") else() set(SWIFT_SDK_${prefix}_OBJECT_FORMAT "ELF") endif() diff --git a/lib/Driver/CMakeLists.txt b/lib/Driver/CMakeLists.txt index ed21de8722ad2..4ef5832738f6f 100644 --- a/lib/Driver/CMakeLists.txt +++ b/lib/Driver/CMakeLists.txt @@ -31,7 +31,8 @@ target_link_libraries(swiftDriver PRIVATE if(SWIFT_BUILD_STATIC_STDLIB) set(static_stdlib_lnk_file_list) foreach(sdk ${SWIFT_CONFIGURED_SDKS}) - if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "ELF") + if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "ELF" OR + "${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "WASM") string(TOLOWER "${sdk}" lowercase_sdk) if(SWIFT_${SWIFT_HOST_VARIANT_SDK}_${SWIFT_HOST_VARIANT_ARCH}_ICU_STATICLIB) set(ICU_STATICLIB "TRUE") diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt index fbe6cc277b9f7..b4c8f9a7772e7 100644 --- a/stdlib/public/runtime/CMakeLists.txt +++ b/stdlib/public/runtime/CMakeLists.txt @@ -173,11 +173,14 @@ add_swift_target_library(swiftRuntime OBJECT_LIBRARY set(ELFISH_SDKS) set(COFF_SDKS) +set(WASM_SDKS) foreach(sdk ${SWIFT_CONFIGURED_SDKS}) if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "ELF") list(APPEND ELFISH_SDKS ${sdk}) elseif("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "COFF") list(APPEND COFF_SDKS ${sdk}) + elseif("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "WASM") + list(APPEND WASM_SDKS ${sdk}) endif() endforeach() @@ -189,6 +192,16 @@ add_swift_target_library(swiftImageRegistrationObjectELF TARGET_SDKS ${ELFISH_SDKS} SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} INSTALL_IN_COMPONENT none) + +add_swift_target_library(swiftImageRegistrationObjectWASM + OBJECT_LIBRARY IS_STDLIB IS_STDLIB_CORE + SwiftRT-WASM.cpp + C_COMPILE_FLAGS ${SWIFT_RUNTIME_CORE_CXX_FLAGS} + LINK_FLAGS ${SWIFT_RUNTIME_CORE_LINK_FLAGS} + TARGET_SDKS ${WASM_SDKS} + SWIFT_COMPILE_FLAGS ${SWIFT_STANDARD_LIBRARY_SWIFT_FLAGS} + INSTALL_IN_COMPONENT none) + # FIXME(compnerd) this should be compiled twice, once for static and once for # shared. The static version should be used for building the standard library. add_swift_target_library(swiftImageRegistrationObjectCOFF @@ -206,7 +219,8 @@ foreach(sdk ${SWIFT_CONFIGURED_SDKS}) set(arch_suffix "${SWIFT_SDK_${sdk}_LIB_SUBDIR}-${arch}") if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "ELF" OR - "${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "COFF") + "${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "COFF" OR + "${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "WASM") # TODO(compnerd) switch to the generator expression when cmake is upgraded # to a version which supports it. # set(swiftrtObject "$") From 08549c72501927893e25ee2e5b2772fd62e50380 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 24 Oct 2019 20:20:12 +0900 Subject: [PATCH 07/20] [WASM] Separate SwiftRT from ELF --- stdlib/public/runtime/CMakeLists.txt | 1 + stdlib/public/runtime/SwiftRT-ELF.cpp | 7 ------- stdlib/public/runtime/SwiftRT-WASM.cpp | 11 +++++++++++ 3 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 stdlib/public/runtime/SwiftRT-WASM.cpp diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt index b4c8f9a7772e7..a89665ac1d210 100644 --- a/stdlib/public/runtime/CMakeLists.txt +++ b/stdlib/public/runtime/CMakeLists.txt @@ -79,6 +79,7 @@ endif(LLVM_ENABLE_ASSERTIONS) set(LLVM_OPTIONAL_SOURCES SwiftRT-COFF.cpp SwiftRT-ELF.cpp + SwiftRT-WASM.cpp ${swift_runtime_sources} ${swift_runtime_objc_sources} ${swift_runtime_leaks_sources}) diff --git a/stdlib/public/runtime/SwiftRT-ELF.cpp b/stdlib/public/runtime/SwiftRT-ELF.cpp index 65ae9f2aba91b..fa585a8a68241 100644 --- a/stdlib/public/runtime/SwiftRT-ELF.cpp +++ b/stdlib/public/runtime/SwiftRT-ELF.cpp @@ -46,16 +46,9 @@ static swift::MetadataSections sections{}; __attribute__((__constructor__)) static void swift_image_constructor() { -#ifndef __wasm__ #define SWIFT_SECTION_RANGE(name) \ { reinterpret_cast(&__start_##name), \ static_cast(&__stop_##name - &__start_##name) } -#else -// WebAssembly hack: ok this should really go in its own file -#define SWIFT_SECTION_RANGE(name) \ - { reinterpret_cast(&__start_##name) + sizeof(void*), \ - static_cast(&__stop_##name - &__start_##name - sizeof(void*)) } -#endif sections = { swift::CurrentSectionMetadataVersion, diff --git a/stdlib/public/runtime/SwiftRT-WASM.cpp b/stdlib/public/runtime/SwiftRT-WASM.cpp new file mode 100644 index 0000000000000..6812763e9b1e7 --- /dev/null +++ b/stdlib/public/runtime/SwiftRT-WASM.cpp @@ -0,0 +1,11 @@ +//===--- SwiftRT-WASM.cpp --------------------------------------------------===// +// +// This source file is part of the Swift.org open source project +// +// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors +// Licensed under Apache License v2.0 with Runtime Library Exception +// +// See https://swift.org/LICENSE.txt for license information +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors +// +//===----------------------------------------------------------------------===// From cad6531753e4d095cd87a7dee1e037ac50131ae0 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 24 Oct 2019 20:21:02 +0900 Subject: [PATCH 08/20] [WASM] Add preprocessor condition for wasm32 to track latest upstream --- stdlib/public/core/StringStorage.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/public/core/StringStorage.swift b/stdlib/public/core/StringStorage.swift index c7ed0854f6f34..a3b27b1de4855 100644 --- a/stdlib/public/core/StringStorage.swift +++ b/stdlib/public/core/StringStorage.swift @@ -416,7 +416,7 @@ extension __StringStorage { let count = try initializer(buffer) let countAndFlags = CountAndFlags(mortalCount: count, isASCII: false) - #if arch(i386) || arch(arm) + #if arch(i386) || arch(arm) || arch(wasm32) storage._count = countAndFlags.count storage._flags = countAndFlags.flags #else From 19ca6b1a7ad640d8c0e26fe346704e77e3b4ed0b Mon Sep 17 00:00:00 2001 From: Max Desiatov Date: Wed, 30 Oct 2019 15:28:16 +0000 Subject: [PATCH 09/20] Add wasi-sdk and icu install steps to the script --- .github/workflows/main.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b34833cab8672..91dd26bcda915 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,6 +17,17 @@ jobs: brew install cmake ninja ./utils/update-checkout --clone --scheme wasm export sourcedir=$PWD/.. + cd $sourcedir + wget -O wasi-sdk.tar.gz https://github.com/swiftwasm/wasi-sdk/releases/download/20190421.6/wasi-sdk-3.19gefb17cb478f9.m-linux.tar.gz + tar xfz wasi-sdk.tar.gz + mv wasi-sdk-3.19gefb17cb478f9+m/opt/wasi-sdk ./wasi-sdk + # Link sysroot/usr/include to sysroot/include because Darwin sysroot doesn't + # find header files in sysroot/include but sysroot/usr/include + mkdir wasi-sdk/share/sysroot/usr/ + ln -s ../include wasi-sdk/share/sysroot/usr/include + wget -O icu.tar.xz "https://github.com/swiftwasm/icu4c-wasi/releases/download/20190421.3/icu4c-wasi.tar.xz" + tar xf icu.tar.xz + cd swift ./utils/build-script --debug --wasm \ --skip-build-benchmarks \ --extra-cmake-options=" \ From f09c3704e14f1704d3d331080d3c26ab5147e953 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 30 Oct 2019 23:08:13 +0000 Subject: [PATCH 10/20] [WASM] Set LIBC_INCLUDE_DIRECTORY without CACHE attribute to force new value --- cmake/modules/SwiftConfigureSDK.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/modules/SwiftConfigureSDK.cmake b/cmake/modules/SwiftConfigureSDK.cmake index 5f4b745a2b09c..746318c98f8b1 100644 --- a/cmake/modules/SwiftConfigureSDK.cmake +++ b/cmake/modules/SwiftConfigureSDK.cmake @@ -326,8 +326,8 @@ macro(configure_sdk_unix name architectures) set(SWIFT_SDK_WASM_ARCH_wasm32_PATH "${SWIFT_WASM_WASI_SDK_PATH}/share/sysroot") # fixme: Wasi is wasm32-unknown-wasi-musl. This LLVM doesn't have it yet. set(SWIFT_SDK_WASM_ARCH_wasm32_TRIPLE "wasm32-unknown-unknown-wasm") - set(SWIFT_SDK_WASM_ARCH_wasm32_LIBC_INCLUDE_DIRECTORY "${SWIFT_WASM_WASI_SDK_PATH}/share/sysroot/include" CACHE STRING "Path to C library headers") - set(SWIFT_SDK_WASM_ARCH_wasm32_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "${SWIFT_WASM_WASI_SDK_PATH}/sysroot/include" CACHE STRING "Path to C library architecture headers") + set(SWIFT_SDK_WASM_ARCH_wasm32_LIBC_INCLUDE_DIRECTORY "${SWIFT_WASM_WASI_SDK_PATH}/share/sysroot/include") + set(SWIFT_SDK_WASM_ARCH_wasm32_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "${SWIFT_WASM_WASI_SDK_PATH}/sysroot/include") else() message(FATAL_ERROR "unknown Unix OS: ${prefix}") endif() From 258f25e28d50ab0b4c63fef9787eec69d4f91b6f Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Wed, 30 Oct 2019 23:42:35 +0000 Subject: [PATCH 11/20] [WASM] Adding share path to point correct directory --- cmake/modules/SwiftConfigureSDK.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/modules/SwiftConfigureSDK.cmake b/cmake/modules/SwiftConfigureSDK.cmake index 746318c98f8b1..a529c4f99ae7f 100644 --- a/cmake/modules/SwiftConfigureSDK.cmake +++ b/cmake/modules/SwiftConfigureSDK.cmake @@ -327,7 +327,7 @@ macro(configure_sdk_unix name architectures) # fixme: Wasi is wasm32-unknown-wasi-musl. This LLVM doesn't have it yet. set(SWIFT_SDK_WASM_ARCH_wasm32_TRIPLE "wasm32-unknown-unknown-wasm") set(SWIFT_SDK_WASM_ARCH_wasm32_LIBC_INCLUDE_DIRECTORY "${SWIFT_WASM_WASI_SDK_PATH}/share/sysroot/include") - set(SWIFT_SDK_WASM_ARCH_wasm32_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "${SWIFT_WASM_WASI_SDK_PATH}/sysroot/include") + set(SWIFT_SDK_WASM_ARCH_wasm32_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "${SWIFT_WASM_WASI_SDK_PATH}/share/sysroot/include") else() message(FATAL_ERROR "unknown Unix OS: ${prefix}") endif() From 8d90ac3eabad05ad92b733a48d513794d5bca470 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 31 Oct 2019 01:20:22 +0000 Subject: [PATCH 12/20] [WASM] Add Linux CI job --- .github/workflows/main.yml | 59 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 91dd26bcda915..dccb8045bcbf6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -6,6 +6,65 @@ on: - swiftwasm jobs: + linux_build: + timeout-minutes: 0 + runs-on: ubuntu-18.04 + + steps: + - uses: actions/checkout@v1 + - name: Run a multi-line script + run: | + sudo apt update + sudo apt install \ + git ninja-build clang python \ + uuid-dev libicu-dev icu-devtools libbsd-dev \ + libedit-dev libxml2-dev libsqlite3-dev swig \ + libpython-dev libncurses5-dev pkg-config \ + libblocksruntime-dev libcurl4-openssl-dev \ + systemtap-sdt-dev tzdata rsync + + ./utils/update-checkout --clone --scheme wasm + export sourcedir=$PWD/.. + cd $sourcedir + + wget -O install_cmake.sh "https://github.com/Kitware/CMake/releases/download/v3.15.3/cmake-3.15.3-Linux-x86_64.sh" + chmod +x install_cmake.sh + sudo mkdir -p /opt/cmake + sudo ./install_cmake.sh --skip-license --prefix=/opt/cmake + sudo ln -sf /opt/cmake/bin/* /usr/local/bin + cmake --version + + wget -O wasi-sdk.tar.gz https://github.com/swiftwasm/wasi-sdk/releases/download/20190421.6/wasi-sdk-3.19gefb17cb478f9.m-linux.tar.gz + tar xfz wasi-sdk.tar.gz + mv wasi-sdk-3.19gefb17cb478f9+m/opt/wasi-sdk ./wasi-sdk + + wget -O icu.tar.xz "https://github.com/swiftwasm/icu4c-wasi/releases/download/20190421.3/icu4c-wasi.tar.xz" + tar xf icu.tar.xz + + cd swift + utils/build-script --debug --wasm --verbose \ + --skip-build-benchmarks \ + --extra-cmake-options=" \ + -DSWIFT_PRIMARY_VARIANT_SDK:STRING=WASM \ + -DSWIFT_PRIMARY_VARIANT_ARCH:STRING=wasm32 \ + -DSWIFT_OSX_x86_64_ICU_STATICLIB=TRUE \ + -DSWIFT_BUILD_SOURCEKIT=FALSE \ + -DSWIFT_ENABLE_SOURCEKIT_TESTS=FALSE \ + " \ + --llvm-targets-to-build "X86;WebAssembly" \ + --build-stdlib-deployment-targets "wasm-wasm32" \ + --wasm-wasi-sdk "$sourcedir/wasi-sdk" \ + --wasm-icu-uc "$sourcedir/icu_out/lib/libicuuc.a" \ + --wasm-icu-uc-include "$sourcedir/icu_out/include" \ + --wasm-icu-i18n "$sourcedir/icu_out/lib/libicui18n.a" \ + --wasm-icu-i18n-include "$sourcedir/icu_out/include" \ + --wasm-icu-data "todo-icu-data" \ + --build-swift-static-stdlib \ + --install-swift \ + --install-prefix="/opt/swiftwasm-sdk" \ + --install-destdir="$sourcedir/install" \ + --installable-package="$sourcedir/swiftwasm.tar.gz" + macos_build: timeout-minutes: 0 runs-on: macOS-10.14 From 8c87d29e8d65ca37a88490bf37de4e503cddc0fb Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 31 Oct 2019 01:27:59 +0000 Subject: [PATCH 13/20] [WASM] Checkout branch after checking out Swift repos --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index dccb8045bcbf6..84730aff27fc8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,6 +24,7 @@ jobs: systemtap-sdt-dev tzdata rsync ./utils/update-checkout --clone --scheme wasm + git checkout $GITHUB_SHA export sourcedir=$PWD/.. cd $sourcedir @@ -75,6 +76,7 @@ jobs: run: | brew install cmake ninja ./utils/update-checkout --clone --scheme wasm + git checkout $GITHUB_SHA export sourcedir=$PWD/.. cd $sourcedir wget -O wasi-sdk.tar.gz https://github.com/swiftwasm/wasi-sdk/releases/download/20190421.6/wasi-sdk-3.19gefb17cb478f9.m-linux.tar.gz From 72cd60595837ce9be85fc93e01b2de8732133404 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Thu, 31 Oct 2019 13:26:46 +0900 Subject: [PATCH 14/20] [WASM] Use release build to reduce artifact size --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 84730aff27fc8..7c631b1de4267 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -43,7 +43,7 @@ jobs: tar xf icu.tar.xz cd swift - utils/build-script --debug --wasm --verbose \ + utils/build-script --release --wasm --verbose \ --skip-build-benchmarks \ --extra-cmake-options=" \ -DSWIFT_PRIMARY_VARIANT_SDK:STRING=WASM \ @@ -89,7 +89,7 @@ jobs: wget -O icu.tar.xz "https://github.com/swiftwasm/icu4c-wasi/releases/download/20190421.3/icu4c-wasi.tar.xz" tar xf icu.tar.xz cd swift - ./utils/build-script --debug --wasm \ + ./utils/build-script --release --wasm \ --skip-build-benchmarks \ --extra-cmake-options=" \ -DSWIFT_PRIMARY_VARIANT_SDK:STRING=WASM \ From 5e3916e19657f93321707ebbf1499a8d9f8f4e8c Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Fri, 1 Nov 2019 15:23:45 +0000 Subject: [PATCH 15/20] [WASM] Use SWIFT_PRIMARY_VARIANT_SDK instead of HOST_SDK In this case, SWIFT_PRIMARY_VARIANT_ARCH is used but host SDK was not PRIMARY_SDK. --- stdlib/public/runtime/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt index a89665ac1d210..c81d5e2b6be0d 100644 --- a/stdlib/public/runtime/CMakeLists.txt +++ b/stdlib/public/runtime/CMakeLists.txt @@ -88,7 +88,7 @@ set(swift_runtime_library_compile_flags ${swift_runtime_compile_flags}) list(APPEND swift_runtime_library_compile_flags -DswiftCore_EXPORTS) list(APPEND swift_runtime_library_compile_flags -I${SWIFT_SOURCE_DIR}/include) -set(sdk "${SWIFT_HOST_VARIANT_SDK}") +set(sdk "${SWIFT_PRIMARY_VARIANT_SDK}") if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX") list(REMOVE_ITEM swift_runtime_sources ImageInspectionELF.cpp) set(static_binary_lnk_file_list) From a089ff250fe8f9df80887a8cc4ea17739cf7a89f Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sat, 2 Nov 2019 00:36:12 +0000 Subject: [PATCH 16/20] [WASM] Remove ICU_STATICLIB on Linux --- .github/workflows/main.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7c631b1de4267..97a81959b264a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,7 +48,6 @@ jobs: --extra-cmake-options=" \ -DSWIFT_PRIMARY_VARIANT_SDK:STRING=WASM \ -DSWIFT_PRIMARY_VARIANT_ARCH:STRING=wasm32 \ - -DSWIFT_OSX_x86_64_ICU_STATICLIB=TRUE \ -DSWIFT_BUILD_SOURCEKIT=FALSE \ -DSWIFT_ENABLE_SOURCEKIT_TESTS=FALSE \ " \ From a19bb18f912c023a0b921a19a701b282c4b6019f Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sat, 2 Nov 2019 07:31:23 +0000 Subject: [PATCH 17/20] [WASM] Output build log verbose --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 97a81959b264a..35a7e7ad51785 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -88,7 +88,7 @@ jobs: wget -O icu.tar.xz "https://github.com/swiftwasm/icu4c-wasi/releases/download/20190421.3/icu4c-wasi.tar.xz" tar xf icu.tar.xz cd swift - ./utils/build-script --release --wasm \ + ./utils/build-script --release --wasm --verbose \ --skip-build-benchmarks \ --extra-cmake-options=" \ -DSWIFT_PRIMARY_VARIANT_SDK:STRING=WASM \ From b320192447b1eb10c44dfabddcc96f66d4e3e8c7 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sat, 2 Nov 2019 10:54:39 +0000 Subject: [PATCH 18/20] [WASM] Set ICU lib directory instead of archive --- .github/workflows/main.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 35a7e7ad51785..093777ac5ef8d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,17 +46,17 @@ jobs: utils/build-script --release --wasm --verbose \ --skip-build-benchmarks \ --extra-cmake-options=" \ - -DSWIFT_PRIMARY_VARIANT_SDK:STRING=WASM \ - -DSWIFT_PRIMARY_VARIANT_ARCH:STRING=wasm32 \ + -DSWIFT_SDKS='WASM;LINUX' \ -DSWIFT_BUILD_SOURCEKIT=FALSE \ -DSWIFT_ENABLE_SOURCEKIT_TESTS=FALSE \ " \ --llvm-targets-to-build "X86;WebAssembly" \ + --stdlib-deployment-targets "wasm-wasm32" \ --build-stdlib-deployment-targets "wasm-wasm32" \ --wasm-wasi-sdk "$sourcedir/wasi-sdk" \ - --wasm-icu-uc "$sourcedir/icu_out/lib/libicuuc.a" \ + --wasm-icu-uc "$sourcedir/icu_out/lib" \ --wasm-icu-uc-include "$sourcedir/icu_out/include" \ - --wasm-icu-i18n "$sourcedir/icu_out/lib/libicui18n.a" \ + --wasm-icu-i18n "$sourcedir/icu_out/lib" \ --wasm-icu-i18n-include "$sourcedir/icu_out/include" \ --wasm-icu-data "todo-icu-data" \ --build-swift-static-stdlib \ @@ -103,9 +103,9 @@ jobs: --build-swift-dynamic-sdk-overlay false \ --build-swift-static-sdk-overlay false \ --wasm-wasi-sdk "$sourcedir/wasi-sdk" \ - --wasm-icu-uc "$sourcedir/icu_out/lib/libicuuc.a" \ + --wasm-icu-uc "$sourcedir/icu_out/lib" \ --wasm-icu-uc-include "$sourcedir/icu_out/include" \ - --wasm-icu-i18n "$sourcedir/icu_out/lib/libicui18n.a" \ + --wasm-icu-i18n "$sourcedir/icu_out/lib" \ --wasm-icu-i18n-include "$sourcedir/icu_out/include" \ --wasm-icu-data "todo-icu-data" \ --build-swift-static-stdlib From 6e88e0af3fe15ea07531fc044cf132ce125add67 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sat, 2 Nov 2019 10:56:29 +0000 Subject: [PATCH 19/20] [WASM] Sort build options --- .github/workflows/main.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 093777ac5ef8d..ba665370d2b70 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -50,20 +50,20 @@ jobs: -DSWIFT_BUILD_SOURCEKIT=FALSE \ -DSWIFT_ENABLE_SOURCEKIT_TESTS=FALSE \ " \ + --build-stdlib-deployment-targets "wasm-wasm32" \ + --build-swift-static-stdlib \ + --install-destdir="$sourcedir/install" \ + --install-prefix="/opt/swiftwasm-sdk" \ + --install-swift \ + --installable-package="$sourcedir/swiftwasm.tar.gz" \ --llvm-targets-to-build "X86;WebAssembly" \ --stdlib-deployment-targets "wasm-wasm32" \ - --build-stdlib-deployment-targets "wasm-wasm32" \ - --wasm-wasi-sdk "$sourcedir/wasi-sdk" \ - --wasm-icu-uc "$sourcedir/icu_out/lib" \ - --wasm-icu-uc-include "$sourcedir/icu_out/include" \ + --wasm-icu-data "todo-icu-data" \ --wasm-icu-i18n "$sourcedir/icu_out/lib" \ --wasm-icu-i18n-include "$sourcedir/icu_out/include" \ - --wasm-icu-data "todo-icu-data" \ - --build-swift-static-stdlib \ - --install-swift \ - --install-prefix="/opt/swiftwasm-sdk" \ - --install-destdir="$sourcedir/install" \ - --installable-package="$sourcedir/swiftwasm.tar.gz" + --wasm-icu-uc "$sourcedir/icu_out/lib" \ + --wasm-icu-uc-include "$sourcedir/icu_out/include" \ + --wasm-wasi-sdk "$sourcedir/wasi-sdk" macos_build: timeout-minutes: 0 @@ -97,15 +97,15 @@ jobs: -DSWIFT_BUILD_SOURCEKIT=FALSE \ -DSWIFT_ENABLE_SOURCEKIT_TESTS=FALSE \ " \ - --stdlib-deployment-targets "wasm-wasm32" \ --build-stdlib-deployment-targets "wasm-wasm32" \ - --llvm-targets-to-build "X86;WebAssembly" \ --build-swift-dynamic-sdk-overlay false \ --build-swift-static-sdk-overlay false \ - --wasm-wasi-sdk "$sourcedir/wasi-sdk" \ - --wasm-icu-uc "$sourcedir/icu_out/lib" \ - --wasm-icu-uc-include "$sourcedir/icu_out/include" \ + --build-swift-static-stdlib \ + --llvm-targets-to-build "X86;WebAssembly" \ + --stdlib-deployment-targets "wasm-wasm32" \ + --wasm-icu-data "todo-icu-data" \ --wasm-icu-i18n "$sourcedir/icu_out/lib" \ --wasm-icu-i18n-include "$sourcedir/icu_out/include" \ - --wasm-icu-data "todo-icu-data" \ - --build-swift-static-stdlib + --wasm-icu-uc "$sourcedir/icu_out/lib" \ + --wasm-icu-uc-include "$sourcedir/icu_out/include" \ + --wasm-wasi-sdk "$sourcedir/wasi-sdk" From df43f212722d902e25bbb28878cff1b4611c2b3a Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sat, 2 Nov 2019 10:58:49 +0000 Subject: [PATCH 20/20] Revert "[WASM] Use SWIFT_PRIMARY_VARIANT_SDK instead of HOST_SDK" This reverts commit 5e3916e19657f93321707ebbf1499a8d9f8f4e8c. --- stdlib/public/runtime/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/public/runtime/CMakeLists.txt b/stdlib/public/runtime/CMakeLists.txt index c81d5e2b6be0d..a89665ac1d210 100644 --- a/stdlib/public/runtime/CMakeLists.txt +++ b/stdlib/public/runtime/CMakeLists.txt @@ -88,7 +88,7 @@ set(swift_runtime_library_compile_flags ${swift_runtime_compile_flags}) list(APPEND swift_runtime_library_compile_flags -DswiftCore_EXPORTS) list(APPEND swift_runtime_library_compile_flags -I${SWIFT_SOURCE_DIR}/include) -set(sdk "${SWIFT_PRIMARY_VARIANT_SDK}") +set(sdk "${SWIFT_HOST_VARIANT_SDK}") if(SWIFT_BUILD_STATIC_STDLIB AND "${sdk}" STREQUAL "LINUX") list(REMOVE_ITEM swift_runtime_sources ImageInspectionELF.cpp) set(static_binary_lnk_file_list)