Skip to content

build: compile with C++20 #441

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 4 commits into from
Jul 17, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 5 additions & 4 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ build --action_env=PATH
build:clang --action_env=BAZEL_COMPILER=clang
build:clang --action_env=CC=clang
build:clang --action_env=CXX=clang++
build:clang --copt -Wno-pragma-once-outside-header --cxxopt -Wno-pragma-once-outside-header

# Common flags for Clang sanitizers.
build:clang-xsan --config=clang
Expand Down Expand Up @@ -80,10 +81,10 @@ build:zig-cc-linux-aarch64 --test_env=QEMU_LD_PREFIX=/usr/aarch64-linux-gnu/

build --enable_platform_specific_config

# Use C++17.
build:linux --cxxopt=-std=c++17
build:macos --cxxopt=-std=c++17
build:windows --cxxopt="/std:c++17"
# Use C++20.
build:linux --cxxopt=-std=c++20 --host_cxxopt=-std=c++20
build:macos --cxxopt=-std=c++20 --host_cxxopt=-std=c++20
build:windows --cxxopt="/std:c++20" --host_cxxopt="/std:c++20"

# Enable symlinks and runfiles on Windows (enabled by default on other platforms).
startup --windows_enable_symlinks
Expand Down
15 changes: 15 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
Checks: clang-*,
-clang-analyzer-core.CallAndMessage,
-clang-analyzer-optin.portability.UnixAPI,
-clang-analyzer-unix.Malloc,
-clang-diagnostic-pragma-once-outside-header,
-clang-diagnostic-builtin-macro-redefined,
cppcoreguidelines-pro-type-member-init,
cppcoreguidelines-pro-type-static-cast-downcast,
misc-*,
-misc-non-private-member-variables-in-classes,
-misc-use-anonymous-namespace,
-misc-const-correctness,
-misc-include-cleaner,
-misc-unused-parameters,
modernize-*,
-modernize-avoid-c-arrays,
-modernize-use-trailing-return-type,
-modernize-return-braced-init-list,
-modernize-use-default-member-init,
-modernize-type-traits,
-modernize-use-emplace,
llvm-include-order,
performance-*,
-performance-no-int-to-ptr,
-performance-avoid-endl,
portability-*,
readability-*,
-readability-convert-member-functions-to-static,
-readability-function-cognitive-complexity,
-readability-magic-numbers,
-readability-make-member-function-const,
-readability-simplify-boolean-expr,
-readability-identifier-length,
-readability-container-data-pointer,
-readability-redundant-casting,
-readability-avoid-return-with-void-value,

WarningsAsErrors: '*'
14 changes: 7 additions & 7 deletions .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
addlicense:
name: verify licenses

runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v2
Expand All @@ -63,7 +63,7 @@ jobs:
buildifier:
name: check format with buildifier

runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -101,29 +101,29 @@ jobs:
clang_format:
name: check format with clang-format

runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v2

- name: Install dependencies (Linux)
run: sudo apt update -y && sudo apt install -y clang-format-12
run: sudo apt update -y && sudo apt install -y clang-format-18

- name: Format (clang-format)
run: |
find . -name "*.h" -o -name "*.cc" -o -name "*.proto" | grep -v ".pb." | xargs -n1 clang-format-12 -i
find . -name "*.h" -o -name "*.cc" -o -name "*.proto" | grep -v ".pb." | xargs -n1 clang-format-18 -i
git diff --exit-code

clang_tidy:
name: check format with clang-tidy

runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v2

- name: Install dependencies (Linux)
run: sudo apt update -y && sudo apt install -y clang-tidy-12 lld-12 && sudo ln -sf /usr/bin/lld-12 /usr/bin/lld
run: sudo apt update -y && sudo apt install -y clang-tidy-18 lld-18 && sudo ln -sf /usr/bin/lld-18 /usr/bin/lld

- name: Bazel cache
uses: PiotrSikora/[email protected]
Expand Down
38 changes: 19 additions & 19 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
test_data:
name: build test data

runs-on: ubuntu-22.04
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -111,19 +111,19 @@ jobs:
include:
- name: 'NullVM on Linux/x86_64'
engine: 'null'
os: ubuntu-22.04
os: ubuntu-24.04
arch: x86_64
action: test
flags: --config=gcc
- name: 'NullVM on Linux/x86_64 with ASan'
engine: 'null'
os: ubuntu-22.04
os: ubuntu-24.04
arch: x86_64
action: test
flags: --config=clang-asan-strict --define=crypto=system
flags: --config=clang-asan --define=crypto=system
- name: 'NullVM on Linux/x86_64 with TSan'
engine: 'null'
os: ubuntu-22.04
os: ubuntu-24.04
arch: x86_64
action: test
flags: --config=clang-tsan
Expand All @@ -136,39 +136,39 @@ jobs:
- name: 'V8 on Linux/x86_64'
engine: 'v8'
repo: 'v8'
os: ubuntu-22.04
os: ubuntu-24.04
arch: x86_64
action: test
flags: --config=clang --define=crypto=system
cache: true
- name: 'V8 on Linux/x86_64 with ASan'
engine: 'v8'
repo: 'v8'
os: ubuntu-22.04
os: ubuntu-24.04
arch: x86_64
action: test
flags: --config=clang-asan
cache: true
- name: 'V8 on Linux/x86_64 with TSan'
engine: 'v8'
repo: 'v8'
os: ubuntu-22.04
os: ubuntu-24.04
arch: x86_64
action: test
flags: --config=clang-tsan
cache: true
- name: 'V8 on Linux/x86_64 with GCC'
engine: 'v8'
repo: 'v8'
os: ubuntu-22.04
os: ubuntu-24.04
arch: x86_64
action: test
flags: --config=gcc
cache: true
- name: 'V8 on Linux/aarch64'
engine: 'v8'
repo: 'v8'
os: ubuntu-22.04
os: ubuntu-24.04
arch: aarch64
action: test
targets: -//test/fuzz/...
Expand All @@ -185,7 +185,7 @@ jobs:
- name: 'WAMR interp on Linux/x86_64'
engine: 'wamr-interp'
repo: 'com_github_bytecodealliance_wasm_micro_runtime'
os: ubuntu-22.04
os: ubuntu-24.04
arch: x86_64
action: test
flags: --config=clang
Expand All @@ -198,11 +198,11 @@ jobs:
- name: 'WAMR jit on Linux/x86_64'
engine: 'wamr-jit'
repo: 'com_github_bytecodealliance_wasm_micro_runtime'
os: ubuntu-22.04
os: ubuntu-24.04
arch: x86_64
action: test
flags: --config=clang
deps: lld-12
deps: lld-18
cache: true
- name: 'WAMR jit on macOS/x86_64'
engine: 'wamr-jit'
Expand All @@ -214,7 +214,7 @@ jobs:
- name: 'WasmEdge on Linux/x86_64'
engine: 'wasmedge'
repo: 'com_github_wasmedge_wasmedge'
os: ubuntu-22.04
os: ubuntu-24.04
arch: x86_64
action: test
flags: --config=clang
Expand All @@ -227,29 +227,29 @@ jobs:
- name: 'Wasmtime on Linux/x86_64'
engine: 'wasmtime'
repo: 'com_github_bytecodealliance_wasmtime'
os: ubuntu-22.04
os: ubuntu-24.04
arch: x86_64
action: test
flags: --config=clang -c opt
- name: 'Wasmtime on Linux/x86_64 with ASan'
engine: 'wasmtime'
repo: 'com_github_bytecodealliance_wasmtime'
os: ubuntu-22.04
os: ubuntu-24.04
arch: x86_64
action: test
flags: --config=clang-asan-strict --define=crypto=system
flags: --config=clang-asan --define=crypto=system
- name: 'Wasmtime on Linux/aarch64'
engine: 'wasmtime'
repo: 'com_github_bytecodealliance_wasmtime'
os: ubuntu-22.04
os: ubuntu-24.04
arch: aarch64
action: build
flags: --config=zig-cc-linux-aarch64
deps: qemu-user-static libc6-arm64-cross
- name: 'Wasmtime on Linux/s390x'
engine: 'wasmtime'
repo: 'com_github_bytecodealliance_wasmtime'
os: ubuntu-22.04
os: ubuntu-24.04
arch: s390x
action: test
flags: --config=clang --test_timeout=1800
Expand Down
11 changes: 0 additions & 11 deletions bazel/external/bazel_clang_tidy.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# 1. Treat .h files as C++ headers.
# 2. Hardcode clang-tidy-12.

diff --git a/clang_tidy/clang_tidy.bzl b/clang_tidy/clang_tidy.bzl
index 3a5ed07..5db5c6c 100644
Expand All @@ -15,13 +14,3 @@ index 3a5ed07..5db5c6c 100644
# start args passed to the compiler
args.add("--")

diff --git a/clang_tidy/run_clang_tidy.sh b/clang_tidy/run_clang_tidy.sh
index 582bab1..b9ebb94 100755
--- a/clang_tidy/run_clang_tidy.sh
+++ b/clang_tidy/run_clang_tidy.sh
@@ -11,4 +11,4 @@ shift
touch $OUTPUT
truncate -s 0 $OUTPUT

-clang-tidy "$@"
+clang-tidy-12 "$@"
5 changes: 4 additions & 1 deletion bazel/external/v8.patch
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ diff --git a/bazel/defs.bzl b/bazel/defs.bzl
index e957c0fad3..063627b72b 100644
--- a/bazel/defs.bzl
+++ b/bazel/defs.bzl
@@ -131,6 +131,7 @@ def _default_args():
@@ -131,6 +131,10 @@ def _default_args():
"-Wno-redundant-move",
"-Wno-return-type",
"-Wno-stringop-overflow",
+ "-Wno-nonnull",
+ "-Wno-error=pessimizing-move",
+ "-Wno-error=dangling-reference",
+ "-Wno-error=dangling-pointer=",
# Use GNU dialect, because GCC doesn't allow using
# ##__VA_ARGS__ when in standards-conforming mode.
"-std=gnu++17",
Expand Down
3 changes: 3 additions & 0 deletions bazel/external/wasmedge.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ cmake(
"WASMEDGE_BUILD_TOOLS": "Off",
"WASMEDGE_FORCE_DISABLE_LTO": "On",
},
env = {
"CXXFLAGS": "-Wno-error=dangling-reference -Wno-error=maybe-uninitialized -Wno-error=array-bounds= -Wno-error=deprecated-declarations -std=c++20",
},
generate_args = ["-GNinja"],
lib_source = ":srcs",
out_static_libs = ["libwasmedge.a"],
Expand Down
14 changes: 6 additions & 8 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ def proxy_wasm_cpp_host_repositories():
maybe(
http_archive,
name = "proxy_wasm_cpp_sdk",
sha256 = "89792fc1abca331f29f99870476a04146de5e82ff903bdffca90e6729c1f2470",
strip_prefix = "proxy-wasm-cpp-sdk-95bb82ce45c41d9100fd1ec15d2ffc67f7f3ceee",
urls = ["https://github.com/proxy-wasm/proxy-wasm-cpp-sdk/archive/95bb82ce45c41d9100fd1ec15d2ffc67f7f3ceee.tar.gz"],
sha256 = "26c4c0f9f645de7e789dc92f113d7352ee54ac43bb93ae3a8a22945f1ce71590",
strip_prefix = "proxy-wasm-cpp-sdk-7465dee8b2953beebff99f6dc3720ad0c79bab99",
urls = ["https://github.com/proxy-wasm/proxy-wasm-cpp-sdk/archive/7465dee8b2953beebff99f6dc3720ad0c79bab99.tar.gz"],
)

# Compile DB dependencies.
Expand All @@ -149,11 +149,9 @@ def proxy_wasm_cpp_host_repositories():
maybe(
http_archive,
name = "com_google_googletest",
sha256 = "9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb",
strip_prefix = "googletest-release-1.10.0",
urls = ["https://github.com/google/googletest/archive/release-1.10.0.tar.gz"],
patches = ["@proxy_wasm_cpp_host//bazel/external:googletest.patch"],
patch_args = ["-p1"],
sha256 = "65fab701d9829d38cb77c14acdc431d2108bfdbf8979e40eb8ae567edf10b27c",
strip_prefix = "googletest-1.17.0",
urls = ["https://github.com/google/googletest/releases/download/v1.17.0/googletest-1.17.0.tar.gz"],
)

# NullVM dependencies.
Expand Down
1 change: 0 additions & 1 deletion src/null/null_plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <utility>
#include <vector>

#include "include/proxy-wasm/null_plugin.h"
#include "include/proxy-wasm/null_vm.h"
#include "include/proxy-wasm/wasm.h"

Expand Down
1 change: 1 addition & 0 deletions src/wasmedge/wasmedge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include "wasmedge/wasmedge.h"

#include <algorithm>
#include <array>
#include <cassert>
#include <cstring>
Expand Down
11 changes: 5 additions & 6 deletions test/utility.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@ std::string TestContext::global_log_;
std::vector<std::string> getWasmEngines() {
std::vector<std::string> engines = {
#if defined(PROXY_WASM_HOST_ENGINE_V8)
"v8",
"v8",
#endif
#if defined(PROXY_WASM_HOST_ENGINE_WAMR)
"wamr",
"wamr",
#endif
#if defined(PROXY_WASM_HOST_ENGINE_WASMEDGE)
"wasmedge",
"wasmedge",
#endif
#if defined(PROXY_WASM_HOST_ENGINE_WASMTIME)
"wasmtime",
"wasmtime",
#endif
""
};
""};
engines.pop_back();
return engines;
}
Expand Down
3 changes: 3 additions & 0 deletions test/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,7 @@ class TestVm : public testing::TestWithParam<std::string> {
std::string engine_;
};

// TODO: remove when #412 is fixed.
GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TestVm);

} // namespace proxy_wasm
Loading