Skip to content

Commit

Permalink
Re-enable tests (#24)
Browse files Browse the repository at this point in the history
* [WASM] Re-enable test targets

* [WASM] Support WASI OS target for lit.cfg

* [WASM] Link wasm32-wasi-unknown to wasm32-wasi

* [WASM] Add sysroot to clang_linker to find crt1.o

* [WASM] Separate WebAssembly test from linux

* [WASM] Add static-executable-args.lnk for wasm

* [WASM] First support of wasm in autolink-extract

* [WASM] Extract link flags from named data segment from wasm object file

* [WASM] Fix stdlib build on Linux

* [WASM] Fix ICU lib flag to specify lib file instead of dir

* [WASM] wip

* [WASM] Iterate all configured sdks

* [WASM] Remove object format specific code from macro

* [WASM] Copy libswiftImageInspection.a to lib/swift_static/wasi

* Use brew installed clang because Xcode version is old

* [WASM] Fix new wasm/wasi triple

* [WASM] Run executable test on wasmtime

* Fix typo

* [WASM] Cut environment from triple

* Move build script into wasm dir

* Run test on CI

* Cleanup unused scripts

* [WASM] Use -static instead of -static-executable to work emit-library

* Proxy arguments to build-script

* Ignore test failure temporarily

* Fix packing command

* Add missing x

* Use wasi-sdk's clang compiler

* [WASM] Avoid to build BlocksRuntime temporary due to os toolchains's clang limitation

* [WASM] Comment out utime.h from glibc

* [WASM] Change sysroot dir as wasi-sysroot

* [WASM] Avoid to build BlocksRuntime on linux

* [WASM] Add mman flag for wasi

This eliminate clang hack which defines _WASI_EMULATED_MMAN as a
predefined macro in clang
ref: swiftlang/llvm-project@swift/master...swiftwasm:swiftwasm#diff-773abe7c69fccf723aa2d75447faa136R63-R66

* [WASM] Use latest wasi-sdk

* [WASM] Avoid to build swift-reflection-test temporarily

* [WASM] Install wasmtime on CI

* [WASM] Set wasm as primary target to avoid to build SwiftRuntimeTests

* [WASM] Fix macro arguments validation

* [WASM] Copy ICU libs into toolchain

* [WASM] Fix to specify libicu on mac

* Remove extra space from build scripts
  • Loading branch information
kateinoigakukun committed Jan 24, 2020
1 parent 4a76eaf commit e13f38d
Show file tree
Hide file tree
Showing 23 changed files with 427 additions and 192 deletions.
19 changes: 16 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,19 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Build Linux installable archive
run: ./ci-linux.sh
run: ./utils/webassembly/ci-linux.sh
- name: Upload Linux installable archive
uses: actions/upload-artifact@v1
with:
name: linux-installable
path: ../swiftwasm-linux.tar.gz
- name: Pack test results
run: tar cJf swift-test-results.tar.gz ../build/*/swift-linux-x86_64/swift-test-results
- name: Upload test results
uses: actions/upload-artifact@v1
with:
name: linux-test-results
path: ./swift-test-results.tar.gz

macos_build:
timeout-minutes: 0
Expand All @@ -30,7 +37,7 @@ jobs:
steps:
- uses: actions/checkout@v1
- name: Build macOS installable archive
run: ./ci-mac.sh
run: ./utils/webassembly/ci-mac.sh
- name: Upload macOS installable archive
uses: actions/upload-artifact@v1
with:
Expand All @@ -41,7 +48,13 @@ jobs:
with:
name: packaging-scripts
path: utils/webassembly

- name: Pack test results
run: tar cJf swift-test-results.tar.gz ../build/*/swift-macosx-x86_64/swift-test-results
- name: Upload test results
uses: actions/upload-artifact@v1
with:
name: macos-test-results
path: ./swift-test-results.tar.gz
package:
name: Build SwiftWasm packages
needs:
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1117,8 +1117,8 @@ if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
endif()

if(SWIFT_INCLUDE_TESTS)
#add_subdirectory(test)
#add_subdirectory(unittests)
add_subdirectory(test)
add_subdirectory(unittests)
endif()
if(SWIFT_INCLUDE_DOCS)
add_subdirectory(docs)
Expand Down
30 changes: 0 additions & 30 deletions build-linux.sh

This file was deleted.

4 changes: 0 additions & 4 deletions buildstartend.sh

This file was deleted.

34 changes: 0 additions & 34 deletions ci-linux.sh

This file was deleted.

21 changes: 0 additions & 21 deletions ci-mac.sh

This file was deleted.

6 changes: 5 additions & 1 deletion cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,8 @@ function(_add_variant_c_compile_flags)
list(APPEND result -isystem;${path})
endforeach()
list(APPEND result "-D__ANDROID_API__=${SWIFT_ANDROID_API_LEVEL}")
elseif("${CFLAGS_SDK}" STREQUAL "WASI")
list(APPEND result "-D_WASI_EMULATED_MMAN")
elseif(CFLAGS_SDK STREQUAL WINDOWS)
swift_windows_include_for_arch(${CFLAGS_ARCH} ${CFLAGS_ARCH}_INCLUDE)
foreach(path ${${CFLAGS_ARCH}_INCLUDE})
Expand Down Expand Up @@ -439,6 +441,8 @@ function(_add_variant_swift_compile_flags
foreach(path IN LISTS ${arch}_swift_include)
list(APPEND result "\"${CMAKE_INCLUDE_FLAG_C}${path}\"")
endforeach()
elseif("${sdk}" STREQUAL "WASI")
list(APPEND result "-Xcc" "-D_WASI_EMULATED_MMAN")
endif()

if(NOT BUILD_STANDALONE)
Expand Down Expand Up @@ -552,7 +556,7 @@ function(_add_variant_link_flags)
list(APPEND library_search_directories ${path})
endforeach()
elseif("${LFLAGS_SDK}" STREQUAL "WASI")
# No extra libraries needed.
list(APPEND result "-Wl,wasi-emulated-mman")
else()
# If lto is enabled, we need to add the object path flag so that the LTO code
# generator leaves the intermediate object file in a place where it will not
Expand Down
9 changes: 4 additions & 5 deletions cmake/modules/SwiftConfigureSDK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,10 @@ macro(configure_sdk_unix name architectures)
if(NOT arch STREQUAL wasm32)
message(FATAL_ERROR "unsupported arch for WebAssembly: ${arch}")
endif()
set(SWIFT_SDK_WASI_ARCH_wasm32_PATH "${SWIFT_WASI_SDK_PATH}/share/sysroot")
# fixme: Wasi is wasm32-unknown-wasi-musl. This LLVM doesn't have it yet.
set(SWIFT_SDK_WASI_ARCH_wasm32_TRIPLE "wasm32-unknown-unknown-wasi")
set(SWIFT_SDK_WASI_ARCH_wasm32_LIBC_INCLUDE_DIRECTORY "${SWIFT_WASI_SDK_PATH}/share/sysroot/include")
set(SWIFT_SDK_WASI_ARCH_wasm32_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "${SWIFT_WASI_SDK_PATH}/share/sysroot/include")
set(SWIFT_SDK_WASI_ARCH_wasm32_PATH "${SWIFT_WASI_SDK_PATH}/share/wasi-sysroot")
set(SWIFT_SDK_WASI_ARCH_wasm32_TRIPLE "wasm32-unknown-wasi")
set(SWIFT_SDK_WASI_ARCH_wasm32_LIBC_INCLUDE_DIRECTORY "${SWIFT_WASI_SDK_PATH}/share/wasi-sysroot/include")
set(SWIFT_SDK_WASI_ARCH_wasm32_LIBC_ARCHITECTURE_INCLUDE_DIRECTORY "${SWIFT_WASI_SDK_PATH}/share/wasi-sysroot/include")
else()
message(FATAL_ERROR "unknown Unix OS: ${prefix}")
endif()
Expand Down
43 changes: 40 additions & 3 deletions lib/Driver/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,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" OR
"${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "WASM")
string(TOLOWER "${sdk}" lowercase_sdk)
string(TOLOWER "${sdk}" lowercase_sdk)
if("${SWIFT_SDK_${sdk}_OBJECT_FORMAT}" STREQUAL "ELF")
if(SWIFT_${SWIFT_HOST_VARIANT_SDK}_${SWIFT_HOST_VARIANT_ARCH}_ICU_STATICLIB)
set(ICU_STATICLIB "TRUE")
else()
Expand All @@ -62,6 +61,44 @@ if(SWIFT_BUILD_STATIC_STDLIB)
swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${linkfile}"
DESTINATION "lib/swift_static/${lowercase_sdk}"
COMPONENT stdlib)
elseif("${sdk}" STREQUAL "WASI")
set(linkfile_src "${SWIFT_SOURCE_DIR}/utils/webassembly/static-stdlib-args.lnk")
set(linkfile "${lowercase_sdk}/static-stdlib-args.lnk")
add_custom_command_target(swift_static_stdlib_${sdk}_args
COMMAND
"${CMAKE_COMMAND}" -E copy
"${linkfile_src}"
"${SWIFTSTATICLIB_DIR}/${linkfile}"
OUTPUT
"${SWIFTSTATICLIB_DIR}/${linkfile}"
DEPENDS
"${linkfile_src}")

list(APPEND static_stdlib_lnk_file_list ${swift_static_stdlib_${sdk}_args})
swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${linkfile}"
DESTINATION "lib/swift_static/${lowercase_sdk}"
COMPONENT stdlib)
set(swift_icu_libs_wasi_list)
set(icu_modules UC I18N DATA)
foreach(module IN LISTS icu_modules)
set(module_lib "${SWIFT_WASI_wasm32_ICU_${module}}")
get_filename_component(module_lib_name ${module_lib} NAME)
add_custom_command_target(swift_icu_${module}_${sdk}
COMMAND
"${CMAKE_COMMAND}" -E copy
"${module_lib}"
"${SWIFTSTATICLIB_DIR}/${lowercase_sdk}/${module_lib_name}"
OUTPUT
"${SWIFTSTATICLIB_DIR}/${lowercase_sdk}/${module_lib_name}"
DEPENDS
"${module_lib}")
list(APPEND swift_icu_libs_wasi_list ${swift_icu_${module}_${sdk}})
swift_install_in_component(FILES "${SWIFTSTATICLIB_DIR}/${lowercase_sdk}/${module_lib_name}"
DESTINATION "lib/swift_static/${lowercase_sdk}"
COMPONENT stdlib)
endforeach()
add_custom_target(swift_icu_libs_wasi ALL DEPENDS ${swift_icu_libs_wasi_list})
add_dependencies(stdlib swift_icu_libs_wasi)
endif()
endforeach()
add_custom_target(swift_static_lnk_args ALL DEPENDS ${static_stdlib_lnk_file_list})
Expand Down
17 changes: 0 additions & 17 deletions linkPlease.sh

This file was deleted.

2 changes: 2 additions & 0 deletions stdlib/public/Platform/glibc.modulemap.gyb
Original file line number Diff line number Diff line change
Expand Up @@ -529,10 +529,12 @@ module SwiftGlibc [system] {
header "${GLIBC_INCLUDE_PATH}/unistd.h"
export *
}
% if CMAKE_SDK != "WASI":
module utime {
header "${GLIBC_INCLUDE_PATH}/utime.h"
export *
}
% end
}
}

Expand Down
Loading

0 comments on commit e13f38d

Please sign in to comment.