-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #329 from wasmx/wasi
Add fizzy-wasi tool
- Loading branch information
Showing
14 changed files
with
423 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
if(ProjectUVWASIIncluded) | ||
return() | ||
endif() | ||
set(ProjectUVWASIIncluded TRUE) | ||
|
||
include(ExternalProject) | ||
|
||
set(prefix ${CMAKE_BINARY_DIR}/_deps) | ||
set(source_dir ${prefix}/src/uvwasi) | ||
set(binary_dir ${prefix}/src/uvwasi-build) | ||
set(include_dir ${source_dir}/include) | ||
set(uvwasi_library ${binary_dir}/${CMAKE_STATIC_LIBRARY_PREFIX}uvwasi_a${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
set(uv_library ${binary_dir}/_deps/libuv-build/${CMAKE_STATIC_LIBRARY_PREFIX}uv_a${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
|
||
if(UNIX AND NOT APPLE) | ||
set(system_libs "pthread;dl;rt") | ||
endif() | ||
|
||
ExternalProject_Add(uvwasi | ||
EXCLUDE_FROM_ALL 1 | ||
PREFIX ${prefix} | ||
DOWNLOAD_NAME uvwasi-0.0.10.tar.gz | ||
DOWNLOAD_DIR ${prefix}/downloads | ||
SOURCE_DIR ${source_dir} | ||
BINARY_DIR ${binary_dir} | ||
URL https://github.com/cjihrig/uvwasi/archive/v0.0.10.tar.gz | ||
URL_HASH SHA256=39135f4dd4a44013399ceed7166391ffc5c09655e4bfbf851da2be039e6985df | ||
CMAKE_ARGS | ||
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> | ||
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} | ||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} | ||
-DUVWASI_DEBUG_LOG=OFF | ||
-DCODE_COVERAGE=OFF | ||
-DASAN=OFF | ||
-DUVWASI_BUILD_TESTS=OFF | ||
BUILD_BYPRODUCTS ${uvwasi_library} ${uv_library} | ||
) | ||
|
||
add_library(uvwasi::uvwasi STATIC IMPORTED) | ||
|
||
file(MAKE_DIRECTORY ${include_dir}) | ||
|
||
set_target_properties( | ||
uvwasi::uvwasi | ||
PROPERTIES | ||
IMPORTED_CONFIGURATIONS Release | ||
IMPORTED_LOCATION_RELEASE ${uvwasi_library} | ||
INTERFACE_INCLUDE_DIRECTORIES "${include_dir};${binary_dir}" | ||
INTERFACE_LINK_LIBRARIES "${uv_library};${system_libs}" | ||
) | ||
|
||
add_dependencies(uvwasi::uvwasi uvwasi) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,6 @@ | |
|
||
add_subdirectory(benchmarks) | ||
add_subdirectory(spectests) | ||
if(FIZZY_WASI) | ||
add_subdirectory(wasi) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
# Fizzy: A fast WebAssembly interpreter | ||
# Copyright 2020 The Fizzy Authors. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
add_test( | ||
NAME fizzy/smoketests/wasi/cli-missing-arg | ||
COMMAND fizzy-wasi | ||
) | ||
set_tests_properties( | ||
fizzy/smoketests/wasi/cli-missing-arg | ||
PROPERTIES | ||
PASS_REGULAR_EXPRESSION "Missing executable argument" | ||
) | ||
|
||
add_test( | ||
NAME fizzy/smoketests/wasi/cli-invalid-file | ||
COMMAND fizzy-wasi ${CMAKE_CURRENT_LIST_DIR} | ||
) | ||
set_tests_properties( | ||
fizzy/smoketests/wasi/cli-invalid-file | ||
PROPERTIES | ||
PASS_REGULAR_EXPRESSION "File does not exists or is irregular:" | ||
) | ||
|
||
add_test( | ||
NAME fizzy/smoketests/wasi/cli-missing-file | ||
COMMAND fizzy-wasi ${CMAKE_CURRENT_LIST_DIR}/helloworld.nonexistent.wasm | ||
) | ||
set_tests_properties( | ||
fizzy/smoketests/wasi/cli-missing-file | ||
PROPERTIES | ||
PASS_REGULAR_EXPRESSION "File does not exists or is irregular:" | ||
) | ||
|
||
add_test( | ||
NAME fizzy/smoketests/wasi/helloworld | ||
COMMAND fizzy-wasi ${CMAKE_CURRENT_LIST_DIR}/helloworld.wasm | ||
) | ||
set_tests_properties( | ||
fizzy/smoketests/wasi/helloworld | ||
PROPERTIES | ||
PASS_REGULAR_EXPRESSION "hello world" | ||
) | ||
|
||
add_test( | ||
NAME fizzy/smoketests/wasi/missing-start | ||
COMMAND fizzy-wasi ${CMAKE_CURRENT_LIST_DIR}/missingstart.wasm | ||
) | ||
set_tests_properties( | ||
fizzy/smoketests/wasi/missing-start | ||
PROPERTIES | ||
PASS_REGULAR_EXPRESSION "File is not WASI compatible \\(_start not found\\)" | ||
) | ||
|
||
add_test( | ||
NAME fizzy/smoketests/wasi/invalid-start | ||
COMMAND fizzy-wasi ${CMAKE_CURRENT_LIST_DIR}/invalidstart.wasm | ||
) | ||
set_tests_properties( | ||
fizzy/smoketests/wasi/invalid-start | ||
PROPERTIES | ||
PASS_REGULAR_EXPRESSION "File is not WASI compatible \\(_start has invalid signature\\)" | ||
) | ||
|
||
add_test( | ||
NAME fizzy/smoketests/wasi/missing-memory | ||
COMMAND fizzy-wasi ${CMAKE_CURRENT_LIST_DIR}/missingmemory.wasm | ||
) | ||
set_tests_properties( | ||
fizzy/smoketests/wasi/missing-memory | ||
PROPERTIES | ||
PASS_REGULAR_EXPRESSION "File is not WASI compatible \\(no memory exported\\)" | ||
) | ||
|
||
add_test( | ||
NAME fizzy/smoketests/wasi/trap | ||
COMMAND fizzy-wasi ${CMAKE_CURRENT_LIST_DIR}/trap.wasm | ||
) | ||
set_tests_properties( | ||
fizzy/smoketests/wasi/trap | ||
PROPERTIES | ||
PASS_REGULAR_EXPRESSION "Execution aborted with WebAssembly trap" | ||
) | ||
|
||
# Dump coverage data to distinct files (otherwise file will be overwritten). | ||
set_tests_properties( | ||
fizzy/smoketests/wasi/cli-missing-arg | ||
fizzy/smoketests/wasi/cli-missing-file | ||
fizzy/smoketests/wasi/cli-invalid-file | ||
fizzy/smoketests/wasi/helloworld | ||
fizzy/smoketests/wasi/missing-start | ||
fizzy/smoketests/wasi/invalid-start | ||
fizzy/smoketests/wasi/missing-memory | ||
fizzy/smoketests/wasi/trap | ||
PROPERTIES | ||
ENVIRONMENT LLVM_PROFILE_FILE=${CMAKE_BINARY_DIR}/wasi-%p.profraw | ||
) |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Fizzy: A fast WebAssembly interpreter | ||
# Copyright 2019-2020 The Fizzy Authors. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
include(ProjectUVWASI) | ||
|
||
set(fizzy_include_dir ${PROJECT_SOURCE_DIR}/lib/fizzy) | ||
|
||
add_executable(fizzy-wasi wasi.cpp) | ||
target_compile_features(fizzy-wasi PRIVATE cxx_std_17) | ||
target_link_libraries(fizzy-wasi PRIVATE fizzy::fizzy-internal uvwasi::uvwasi) | ||
target_include_directories(fizzy-wasi PRIVATE ${fizzy_include_dir}) | ||
|
||
if(UNIX AND NOT APPLE) | ||
# For libstdc++ up to version 8 (included) this is needed for proper <filesystem> support. | ||
# Otherwise, the result program will crash on first use (no linker errors). | ||
# For libstdc++ 9, this is not needed, but cause no harm. | ||
# Clang compiler on linux may select libstdc++8 in some configurations. | ||
target_link_libraries(fizzy-wasi PRIVATE stdc++fs) | ||
endif() |
Oops, something went wrong.