Skip to content
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

Fix clang-15 build and WAVM #2011

Merged
merged 4 commits into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
8 changes: 4 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ jobs:
options:
- name: "Self-hosted: Linux: gcc-12 ASAN"
run: ./housekeeping/make_build.sh -DCLEAR_OBJS=ON -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/gcc-12_cxx20.cmake -DASAN=ON
- name: "Self-hosted: Linux: clang-15 TSAN"
run: ./housekeeping/make_build.sh -DCLEAR_OBJS=ON -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/clang-15_cxx20.cmake -DTSAN=ON
- name: "Self-hosted: Linux: clang-15 TSAN WAVM"
run: ./housekeeping/make_build.sh -DCLEAR_OBJS=ON -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/clang-15_cxx20.cmake -DTSAN=ON -DWASM_COMPILER=WAVM
- name: "Self-hosted: Linux: clang-15 UBSAN"
run: ./housekeeping/make_build.sh -DCLEAR_OBJS=ON -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/clang-15_cxx20.cmake -DUBSAN=ON
- name: "Self-hosted: Linux: clang-15 External Project"
Expand Down Expand Up @@ -124,8 +124,8 @@ jobs:
options:
- name: "Self-hosted: Linux: gcc-12 ASAN"
run: ./housekeeping/make_build.sh -DCLEAR_OBJS=ON -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/gcc-12_cxx20.cmake -DASAN=ON
- name: "Self-hosted: Linux: clang-15 TSAN"
run: ./housekeeping/make_build.sh -DCLEAR_OBJS=ON -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/clang-15_cxx20.cmake -DTSAN=ON
- name: "Self-hosted: Linux: clang-15 TSAN WAVM"
run: ./housekeeping/make_build.sh -DCLEAR_OBJS=ON -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/clang-15_cxx20.cmake -DTSAN=ON -DWASM_COMPILER=WAVM
- name: "Self-hosted: Linux: clang-15 UBSAN"
run: ./housekeeping/make_build.sh -DCLEAR_OBJS=ON -DCMAKE_TOOLCHAIN_FILE=cmake/toolchain/clang-15_cxx20.cmake -DUBSAN=ON
- name: "Self-hosted: Linux: clang-15 External Project"
Expand Down
18 changes: 15 additions & 3 deletions core/parachain/validator/fragment_tree.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,14 @@ namespace kagome::parachain::fragment {
}

std::vector<CandidateHash> getCandidates() const {
auto kv = std::views::keys(candidates);
return {kv.begin(), kv.end()};
// doesn't compile in clang-15 due to a bug
// std::views::keys(candidates)
std::vector<CandidateHash> res;
res.reserve(candidates.size());
for (auto &pair : candidates) {
res.push_back(pair.first);
}
return res;
}

template <typename Func>
Expand Down Expand Up @@ -659,7 +665,13 @@ namespace kagome::parachain::fragment {
hasher_->blake2b_256(child_constraints.required_parent);

storage.iterParaChildren(
required_head_hash, [&](const CandidateEntry &candidate) {
required_head_hash,
// clang-15 doesn't like capturing structured bindings into
// lambdas
[&,
earliest_rp = earliest_rp,
child_depth = child_depth,
modifications = modifications](const CandidateEntry &candidate) {
auto pending =
scope.getPendingAvailability(candidate.candidate_hash);
Option<RelayChainBlockInfo> relay_parent_opt;
Expand Down
13 changes: 11 additions & 2 deletions core/runtime/wavm/intrinsics/intrinsic_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ namespace kagome::runtime::wavm {
return WAVM::IR::ValueType::i64;
}

template <>
WAVM::IR::ValueType get_wavm_type<uint32_t>() {
return WAVM::IR::ValueType::i32;
}

template <>
WAVM::IR::ValueType get_wavm_type<uint64_t>() {
return WAVM::IR::ValueType::i64;
}

template <auto Method, typename... Args>
auto host_method_thunk(WAVM::Runtime::ContextRuntimeData *, Args... args) {
return std::invoke(Method, peekHostApi(), args...);
Expand All @@ -77,10 +87,9 @@ namespace kagome::runtime::wavm {
}
#define REGISTER_HOST_METHOD(Ret, name, ...) \
registerMethod<&host_api::HostApi::name, Ret __VA_OPT__(, ) __VA_ARGS__>( \
module, #name); \
module, #name);

REGISTER_HOST_METHODS

}

} // namespace kagome::runtime::wavm
16 changes: 8 additions & 8 deletions test/core/parachain/prospective_parachains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ class ProspectiveParachainsTest : public testing::Test {
EXPECT_CALL(*block_tree_, getBlockHeader(hash))
.WillRepeatedly(Return(header));

BlockNumber min_min = [&]() -> BlockNumber {
BlockNumber min_min = [&, number = number]() -> BlockNumber {
std::optional<BlockNumber> min_min;
for (const auto &[_, data] : leaf.para_data) {
min_min = min_min ? std::min(*min_min, data.min_relay_parent)
Expand Down Expand Up @@ -438,7 +438,7 @@ class ProspectiveParachainsTest : public testing::Test {
}
}

prospective_parachain_->onActiveLeavesUpdate(network::ExViewRef{
(void)prospective_parachain_->onActiveLeavesUpdate(network::ExViewRef{
Harrm marked this conversation as resolved.
Show resolved Hide resolved
.new_head = {update.new_head},
.lost = update.lost,
});
Expand Down Expand Up @@ -568,7 +568,7 @@ class ProspectiveParachainsTest : public testing::Test {
.new_head = {},
.lost = {hash},
};
prospective_parachain_->onActiveLeavesUpdate(network::ExViewRef{
(void)prospective_parachain_->onActiveLeavesUpdate(network::ExViewRef{
.new_head = {},
.lost = update.lost,
});
Expand Down Expand Up @@ -608,7 +608,7 @@ TEST_F(ProspectiveParachainsTest, shouldDoNoWorkIfAsyncBackingDisabledForLeaf) {
.WillRepeatedly(
Return(outcome::failure(ParachainProcessorImpl::Error::NO_STATE)));

prospective_parachain_->onActiveLeavesUpdate(network::ExViewRef{
(void)prospective_parachain_->onActiveLeavesUpdate(network::ExViewRef{
.new_head = {update.new_head},
.lost = update.lost,
});
Expand Down Expand Up @@ -1348,7 +1348,7 @@ TEST_F(ProspectiveParachainsTest, FragmentTree_usesAncestryOnlyWithinSession) {
}
}

prospective_parachain_->onActiveLeavesUpdate(network::ExViewRef{
(void)prospective_parachain_->onActiveLeavesUpdate(network::ExViewRef{
.new_head = {update.new_head},
.lost = update.lost,
});
Expand Down Expand Up @@ -1393,7 +1393,7 @@ TEST_F(ProspectiveParachainsTest, FragmentTree_correctlyUpdatesLeaves) {
activate_leaf(leaf_b, test_state, async_backing_params);
activate_leaf(leaf_b, test_state, async_backing_params);

prospective_parachain_->onActiveLeavesUpdate(network::ExViewRef{
(void)prospective_parachain_->onActiveLeavesUpdate(network::ExViewRef{
.new_head = {},
.lost = {},
});
Expand Down Expand Up @@ -1429,7 +1429,7 @@ TEST_F(ProspectiveParachainsTest, FragmentTree_correctlyUpdatesLeaves) {
};
// handle_leaf_activation_2(update2, leaf_c, test_state,
// async_backing_params);
prospective_parachain_->onActiveLeavesUpdate(network::ExViewRef{
(void)prospective_parachain_->onActiveLeavesUpdate(network::ExViewRef{
.new_head = {},
.lost = update2.lost,
});
Expand Down Expand Up @@ -1465,7 +1465,7 @@ TEST_F(ProspectiveParachainsTest, FragmentTree_correctlyUpdatesLeaves) {
.new_head = {},
.lost = {leaf_a.hash, leaf_b.hash, leaf_c.hash},
};
prospective_parachain_->onActiveLeavesUpdate(network::ExViewRef{
(void)prospective_parachain_->onActiveLeavesUpdate(network::ExViewRef{
.new_head = {},
.lost = update2.lost,
});
Expand Down
8 changes: 2 additions & 6 deletions test/core/runtime/wavm/wavm_runtime_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class WavmRuntimeTest : public RuntimeTestBase {
std::shared_ptr<kagome::runtime::wavm::IntrinsicModuleInstance>
intrinsic_module_instance = intrinsic_module->instantiate();
resolver_ = std::make_shared<kagome::runtime::wavm::IntrinsicResolverImpl>(
intrinsic_module_instance);
compartment, intrinsic_module_instance);

auto module_factory =
std::make_shared<kagome::runtime::wavm::ModuleFactoryImpl>(
Expand All @@ -53,13 +53,9 @@ class WavmRuntimeTest : public RuntimeTestBase {
std::nullopt,
hasher_);


auto instance_env_factory =
std::make_shared<kagome::runtime::wavm::InstanceEnvironmentFactory>(
trie_storage_,
serializer_,
host_api_factory_,
module_factory);
trie_storage_, serializer_, host_api_factory_, module_factory);

return module_factory;
}
Expand Down
Loading