Skip to content

Commit 273014d

Browse files
vkensouGordonSmith
authored andcommitted
chore: bump vcpkg and fix win32 CI build
Signed-off-by: Gordon Smith <GordonJSmith@gmail.com>
1 parent 45f4dd0 commit 273014d

10 files changed

Lines changed: 51 additions & 25 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ cmake_minimum_required(VERSION 3.5)
22

33
project(cmcpp LANGUAGES CXX)
44

5-
option(BUILD_SAMPLES "Build samples" ON)
5+
# Determine default for BUILD_SAMPLES: OFF on Windows, ON elsewhere
6+
set(_BUILD_SAMPLES_DEFAULT ON)
7+
if (WIN32)
8+
set(_BUILD_SAMPLES_DEFAULT OFF)
9+
endif()
10+
option(BUILD_SAMPLES "Build samples" ${_BUILD_SAMPLES_DEFAULT})
611
option(BUILD_TESTING "Build tests" ON)
712

813
add_library(cmcpp INTERFACE)

include/cmcpp/context.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,14 +109,14 @@ namespace cmcpp
109109
public:
110110
CanonicalOptions opts;
111111
ComponentInstance inst;
112-
func_t<R, Args...> ft;
112+
func_t<R(Args...)> ft;
113113
std::optional<Task> supertask;
114114
std::optional<std::function<void()>> on_return;
115115
std::function<std::future<void>(std::future<void>)> on_block;
116116
int num_borrows = 0;
117117
ContextLocalStorage context();
118118

119-
Task(CanonicalOptions &opts, ComponentInstance &inst, func_t<R, Args...> &ft, std::optional<Task> &supertask = std::nullopt, std::optional<std::function<void()>> &on_return = std::nullopt, std::function<std::future<void>(std::future<void>)> &on_block = std::nullopt)
119+
Task(CanonicalOptions &opts, ComponentInstance &inst, func_t<R(Args...)> &ft, std::optional<Task> &supertask = std::nullopt, std::optional<std::function<void()>> &on_return = std::nullopt, std::function<std::future<void>(std::future<void>)> &on_block = std::nullopt)
120120
: opts(opts), inst(inst), ft(ft), supertask(supertask), on_return(on_return), on_block(on_block) {}
121121
};
122122

include/cmcpp/lift.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ namespace cmcpp
5353
}
5454

5555
template <Field T>
56-
inline T lift_flat_values(const LiftLowerContext &cx, uint max_flat, const CoreValueIter &vi)
56+
inline T lift_flat_values(const LiftLowerContext &cx, uint32_t max_flat, const CoreValueIter &vi)
5757
{
5858
auto flat_types = ValTrait<T>::flat_types;
5959
if (flat_types.size() > max_flat)

include/cmcpp/lower.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ namespace cmcpp
7676
}
7777

7878
template <Field... Ts>
79-
inline WasmValVector lower_flat_values(LiftLowerContext &cx, uint max_flat, uint32_t *out_param, Ts &&...vs)
79+
inline WasmValVector lower_flat_values(LiftLowerContext &cx, uint32_t max_flat, uint32_t *out_param, Ts &&...vs)
8080
{
8181
WasmValVector retVal = {};
8282
// cx.inst.may_leave=false;

include/cmcpp/traits.hpp

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ namespace cmcpp
2323
using bytes = uint32_t;
2424
using size = uint32_t;
2525

26+
static constexpr int ceil_log2(std::size_t n) {
27+
return (n <= 1) ? 0 : 1 + ceil_log2((n + 1) / 2);
28+
}
29+
30+
static constexpr int ceil_div8(int bits) {
31+
return (bits + 7) / 8;
32+
}
33+
2634
enum class WasmValType : uint8_t
2735
{
2836
UNKNOWN,
@@ -666,7 +674,7 @@ namespace cmcpp
666674
static constexpr ValType type = ValType::Variant;
667675
using inner_type = typename std::variant<Ts...>;
668676

669-
static constexpr int match = static_cast<int>(std::ceil(std::log2(std::variant_size_v<inner_type>) / 8.0));
677+
static constexpr int match = ceil_div8(ceil_log2(std::variant_size_v<inner_type>));
670678
using discriminant_type = std::conditional_t<match == 0, uint8_t, std::conditional_t<match == 1, uint8_t, std::conditional_t<match == 2, uint16_t, std::conditional_t<match == 3, uint32_t, void>>>>;
671679
static constexpr uint32_t max_case_alignment = []() constexpr
672680
{
@@ -696,18 +704,26 @@ namespace cmcpp
696704
((i = std::max(i, ValTrait<Ts>::flat_types.size())), ...);
697705
return i + 1;
698706
}();
707+
template<size_t StartIndex, typename First, typename... Rest>
708+
static constexpr void process_types(std::array<WasmValType, flat_types_len>& flat)
709+
{
710+
for (auto& ft : ValTrait<First>::flat_types) {
711+
if (StartIndex < flat_types_len) {
712+
flat[StartIndex] = join(flat[StartIndex], ft);
713+
process_types<StartIndex + 1, Rest...>(flat);
714+
}
715+
}
716+
}
717+
template<size_t StartIndex>
718+
static constexpr void process_types(std::array<WasmValType, flat_types_len>& flat)
719+
{
720+
}
699721
static constexpr std::array<WasmValType, flat_types_len> flat_types = []() constexpr
700722
{
701723
std::array<WasmValType, flat_types_len> flat;
702724
flat.fill(WasmValType::i32);
703725
flat[0] = ValTrait<discriminant_type>::flat_types[0];
704-
([&]()
705-
{
706-
size_t i = 1;
707-
for (auto &ft : ValTrait<Ts>::flat_types) {
708-
flat[i] = join(flat[i], ft);
709-
++i;
710-
} }(), ...);
726+
process_types<1, Ts...>(flat);
711727
return flat;
712728
}();
713729
};
@@ -739,8 +755,8 @@ namespace cmcpp
739755
using enum_t = uint32_t;
740756

741757
// Func --------------------------------------------------------------------
742-
constexpr uint MAX_FLAT_PARAMS = 16;
743-
constexpr uint MAX_FLAT_RESULTS = 1;
758+
constexpr uint32_t MAX_FLAT_PARAMS = 16;
759+
constexpr uint32_t MAX_FLAT_RESULTS = 1;
744760

745761
template <typename>
746762
struct func_t_impl;

include/wamr.hpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1+
#ifndef CMCPP_WAMR_HPP
2+
#define CMCPP_WAMR_HPP
3+
14
#include "wasm_export.h"
25
#include "cmcpp.hpp"
36

47
namespace cmcpp
58
{
69

7-
void trap(const char *msg)
10+
inline void trap(const char *msg)
811
{
912
throw new std::runtime_error(msg);
1013
}
1114

12-
std::vector<wasm_val_t> wasmVal2wam_val_t(const WasmValVector &values)
15+
inline std::vector<wasm_val_t> wasmVal2wam_val_t(const WasmValVector &values)
1316
{
1417
std::vector<wasm_val_t> result;
1518
result.reserve(values.size());
@@ -41,7 +44,7 @@ namespace cmcpp
4144
return result;
4245
}
4346

44-
WasmValVector wam_val_t2wasmVal(size_t count, const wasm_val_t *values)
47+
inline WasmValVector wam_val_t2wasmVal(size_t count, const wasm_val_t *values)
4548
{
4649
WasmValVector result;
4750
result.reserve(count);
@@ -94,7 +97,7 @@ namespace cmcpp
9497
std::vector<wasm_val_t> inputs = wasmVal2wam_val_t(lowered_args);
9598

9699
constexpr size_t output_size = std::is_same<result_t, void>::value ? 0 : 1;
97-
wasm_val_t outputs[output_size];
100+
wasm_val_t outputs[output_size == 0 ? 1 : output_size];
98101

99102
bool success = wasm_runtime_call_wasm_a(exec_env, guest_func,
100103
output_size, outputs,
@@ -121,7 +124,7 @@ namespace cmcpp
121124
};
122125
}
123126

124-
std::pair<void *, size_t> convert(void *dest, uint32_t dest_byte_len, const void *src, uint32_t src_byte_len, Encoding from_encoding, Encoding to_encoding)
127+
inline std::pair<void *, size_t> convert(void *dest, uint32_t dest_byte_len, const void *src, uint32_t src_byte_len, Encoding from_encoding, Encoding to_encoding)
125128
{
126129
if (from_encoding == to_encoding)
127130
{
@@ -236,9 +239,11 @@ namespace cmcpp
236239
return symbol;
237240
}
238241

239-
bool host_module(const char *module_name, NativeSymbol *native_symbols, uint32_t n_native_symbols)
242+
inline bool host_module(const char *module_name, NativeSymbol *native_symbols, uint32_t n_native_symbols)
240243
{
241244
return wasm_runtime_register_natives_raw(module_name, native_symbols, n_native_symbols);
242245
}
243246

244247
}
248+
249+
#endif

vcpkg

Submodule vcpkg updated 8361 files

vcpkg-configuration.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"default-registry": {
33
"kind": "git",
4-
"baseline": "fba75d09065fcc76a25dcf386b1d00d33f5175af",
4+
"baseline": "120deac3062162151622ca4860575a33844ba10b",
55
"repository": "https://github.com/microsoft/vcpkg"
66
},
77
"registries": [

vcpkg_overlays/wasm-micro-runtime/portfile.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ vcpkg_from_github(
22
OUT_SOURCE_PATH SOURCE_PATH
33
REPO bytecodealliance/wasm-micro-runtime
44
REF "WAMR-${VERSION}"
5-
SHA512 9a1dc0dd17dbf9111cf66a2d6a49565d52a005e5a024a20291cb274d826077aac46ff050c63b71503083301dfb32179a0fd3bfe2eddffce0cfb81a42a60fa439
5+
SHA512 6f8b145172e8e79c8a20255e4875de5e4778c79f0ddf22d7e2e4258390d0770e180a8fdc75383bfb12310a2035bc8286ae76b474a8c2071a7be885c1d56c4b8c
66
HEAD_REF main
77
)
88

vcpkg_overlays/wasm-micro-runtime/vcpkg.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wasm-micro-runtime",
3-
"version": "2.2.0",
3+
"version": "2.4.1",
44
"port-version": 0,
55
"description": "WebAssembly Micro Runtime (WAMR) is a lightweight standalone WebAssembly (Wasm) runtime with small footprint, high performance and highly configurable features.",
66
"homepage": "https://github.com/bytecodealliance/wasm-micro-runtime",

0 commit comments

Comments
 (0)