Skip to content

wasmtime: fix build on Windows. #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Feb 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
b4873af
wasmtime: fix build on Windows.
PiotrSikora Jan 12, 2022
a8ecd36
review: use --cxxopt=/std:c++17.
PiotrSikora Jan 12, 2022
f9cb0cf
review: add --enable_runfiles on Windows.
PiotrSikora Jan 12, 2022
fb6fcca
review: add some libraries.
PiotrSikora Jan 12, 2022
d76a8bf
review: --windows_enable_symlinks.
PiotrSikora Jan 12, 2022
0673fda
Merge remote-tracking branch 'origin/master' into PiotrSikora/wasmtim…
PiotrSikora Jan 12, 2022
0527050
review: update Bazel to v4.2.2.
PiotrSikora Jan 12, 2022
a775908
review: use another multiline format.
PiotrSikora Jan 12, 2022
aec8d90
review: limit runners to a minimum while testing.
PiotrSikora Jan 12, 2022
f02c643
review: multiline fix?
PiotrSikora Jan 12, 2022
591d721
Merge remote-tracking branch 'origin/master' into PiotrSikora/wasmtim…
PiotrSikora Jan 13, 2022
1fc037a
review: workaround for a zero-length arrays.
PiotrSikora Jan 13, 2022
33517dd
review: add --subcommands.
PiotrSikora Jan 13, 2022
4d9584b
Merge remote-tracking branch 'origin/master' into PiotrSikora/wasmtim…
PiotrSikora Jan 28, 2022
cf26bd6
review: drop cache.
PiotrSikora Jan 28, 2022
e4d3a4c
review: define _WIN32 on Windows.
PiotrSikora Jan 31, 2022
87ba2ae
review: "undefine" WASM_API_EXTERN.
PiotrSikora Jan 31, 2022
737110e
Merge remote-tracking branch 'origin/master' into PiotrSikora/wasmtim…
PiotrSikora Feb 17, 2022
18f0f3f
Merge remote-tracking branch 'origin/master' into PiotrSikora/wasmtim…
PiotrSikora Feb 18, 2022
d0ba910
review: fix format.
PiotrSikora Feb 18, 2022
6a61c78
review: global -DWASM_API_EXTERN=.
PiotrSikora Feb 18, 2022
6299951
review: add bcrypt.lib.
PiotrSikora Feb 18, 2022
8d27a97
review: fix clock test on Windows.
PiotrSikora Feb 18, 2022
c26f512
review: use bash.
PiotrSikora Feb 18, 2022
6f72978
review: cleanup.
PiotrSikora Feb 18, 2022
36a5e97
review: skip Wasm signatures test on Windows.
PiotrSikora Feb 18, 2022
054b649
review: restore other test targets.
PiotrSikora Feb 18, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ build:macos --cxxopt=-std=c++17
build:windows --enable_runfiles
build:windows --cxxopt="/std:c++17"
# See https://bytecodealliance.github.io/wasmtime/c-api/
# build:windows --linkopt="ws2_32.lib advapi32.lib userenv.lib ntdll.lib shell32.lib ole32.lib"
build:windows --copt="/DWASM_API_EXTERN="
build:windows --linkopt="ws2_32.lib advapi32.lib userenv.lib ntdll.lib shell32.lib ole32.lib bcrypt.lib"
8 changes: 7 additions & 1 deletion .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,12 @@ jobs:
os: macos-11
arch: x86_64
action: test
- name: 'Wasmtime on Windows/x86_64'
engine: 'wasmtime'
repo: 'com_github_bytecodealliance_wasmtime'
os: windows-2019
arch: x86_64
action: test
- name: 'WAVM on Linux/x86_64'
engine: 'wavm'
repo: 'com_github_wavm_wavm'
Expand Down Expand Up @@ -257,7 +263,7 @@ jobs:
//test/...

- name: Bazel build/test (signed Wasm module)
if: ${{ matrix.engine != 'null' }}
if: ${{ matrix.engine != 'null' && !startsWith(matrix.os, 'windows') }}
run: >
${{ matrix.run_under }}
bazel ${{ matrix.action }}
Expand Down
24 changes: 2 additions & 22 deletions include/proxy-wasm/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -239,30 +239,10 @@ class ContextBase : public RootInterface,
}
uint32_t getLogLevel() override { return static_cast<uint32_t>(LogLevel::info); }
uint64_t getCurrentTimeNanoseconds() override {
#if !defined(_MSC_VER)
struct timespec tpe;
clock_gettime(CLOCK_REALTIME, &tpe);
uint64_t t = tpe.tv_sec;
t *= 1000000000;
t += tpe.tv_nsec;
return t;
#else
unimplemented();
return 0;
#endif
return std::chrono::system_clock::now().time_since_epoch().count();
}
uint64_t getMonotonicTimeNanoseconds() override {
#if !defined(_MSC_VER)
struct timespec tpe;
clock_gettime(CLOCK_MONOTONIC, &tpe);
uint64_t t = tpe.tv_sec;
t *= 1000000000;
t += tpe.tv_nsec;
return t;
#else
unimplemented();
return 0;
#endif
return std::chrono::steady_clock::now().time_since_epoch().count();
}
std::string_view getConfiguration() override {
unimplemented();
Expand Down
18 changes: 14 additions & 4 deletions src/wasmtime/wasmtime.cc
Original file line number Diff line number Diff line change
Expand Up @@ -585,8 +585,13 @@ void Wasmtime::getModuleFunctionImpl(std::string_view function_name,
}

*function = [func, function_name, this](ContextBase *context, Args... args) -> void {
wasm_val_t params_arr[] = {makeVal(args)...};
const wasm_val_vec_t params = WASM_ARRAY_VEC(params_arr);
wasm_val_vec_t params;
if constexpr (sizeof...(args) > 0) {
wasm_val_t params_arr[] = {makeVal(args)...};
params = WASM_ARRAY_VEC(params_arr);
} else {
params = WASM_EMPTY_VEC;
}
wasm_val_vec_t results = WASM_EMPTY_VEC;
const bool log = cmpLogLevel(LogLevel::trace);
if (log) {
Expand Down Expand Up @@ -633,8 +638,13 @@ void Wasmtime::getModuleFunctionImpl(std::string_view function_name,
}

*function = [func, function_name, this](ContextBase *context, Args... args) -> R {
wasm_val_t params_arr[] = {makeVal(args)...};
const wasm_val_vec_t params = WASM_ARRAY_VEC(params_arr);
wasm_val_vec_t params;
if constexpr (sizeof...(args) > 0) {
wasm_val_t params_arr[] = {makeVal(args)...};
params = WASM_ARRAY_VEC(params_arr);
} else {
params = WASM_EMPTY_VEC;
}
wasm_val_t results_arr[1];
wasm_val_vec_t results = WASM_ARRAY_VEC(results_arr);
const bool log = cmpLogLevel(LogLevel::trace);
Expand Down