From 644e5e222f58f92dc8adc2b765fb7742350ca40a Mon Sep 17 00:00:00 2001 From: Michael Warres Date: Sun, 18 Aug 2024 21:46:36 +0000 Subject: [PATCH 1/9] Compile with C++20 Signed-off-by: Michael Warres --- .bazelrc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.bazelrc b/.bazelrc index ab9a27f8..b05ba07b 100644 --- a/.bazelrc +++ b/.bazelrc @@ -80,10 +80,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 +build:macos --cxxopt=-std=c++20 +build:windows --cxxopt="/std:c++20" # Enable symlinks and runfiles on Windows (enabled by default on other platforms). startup --windows_enable_symlinks From fdb5e9373f98146d497423f45aed5d1908131e06 Mon Sep 17 00:00:00 2001 From: Michael Warres Date: Sun, 18 Aug 2024 22:17:10 +0000 Subject: [PATCH 2/9] Update googletest to v1.15.2 Signed-off-by: Michael Warres --- bazel/external/googletest.patch | 13 ------------- bazel/repositories.bzl | 8 +++----- 2 files changed, 3 insertions(+), 18 deletions(-) delete mode 100644 bazel/external/googletest.patch diff --git a/bazel/external/googletest.patch b/bazel/external/googletest.patch deleted file mode 100644 index 502ef58b..00000000 --- a/bazel/external/googletest.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/BUILD.bazel b/BUILD.bazel -index 8099642a85..3598661079 100644 ---- a/BUILD.bazel -+++ b/BUILD.bazel -@@ -40,7 +40,7 @@ exports_files(["LICENSE"]) - - config_setting( - name = "windows", -- constraint_values = ["@bazel_tools//platforms:windows"], -+ constraint_values = ["@platforms//os:windows"], - ) - - config_setting( diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 79e2fd59..d708483f 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -139,11 +139,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 = "7b42b4d6ed48810c5362c265a17faebe90dc2373c885e5216439d37927f02926", + strip_prefix = "googletest-1.15.2", + urls = ["https://github.com/google/googletest/archive/refs/tags/v1.15.2.tar.gz"], ) # NullVM dependencies. From aab161168fc82282d124b00bafe6c6955f9ff08f Mon Sep 17 00:00:00 2001 From: Michael Warres Date: Mon, 19 Aug 2024 01:45:48 +0000 Subject: [PATCH 3/9] Patch proxy-wasm-cpp-sdk to work around g++ -std=c++20 compilation issue Signed-off-by: Michael Warres --- bazel/external/proxy_wasm_cpp_sdk.patch | 33 +++++++++++++++++++++++++ bazel/repositories.bzl | 2 ++ 2 files changed, 35 insertions(+) create mode 100644 bazel/external/proxy_wasm_cpp_sdk.patch diff --git a/bazel/external/proxy_wasm_cpp_sdk.patch b/bazel/external/proxy_wasm_cpp_sdk.patch new file mode 100644 index 00000000..c9ef490c --- /dev/null +++ b/bazel/external/proxy_wasm_cpp_sdk.patch @@ -0,0 +1,33 @@ +# Address g++ -std=c++20 variadic template compilation issue: +# https://github.com/proxy-wasm/proxy-wasm-cpp-host/pull/411#issuecomment-2295429152 + +diff --git a/proxy_wasm_api.h b/proxy_wasm_api.h +index 166b49c..263d2b9 100644 +--- a/proxy_wasm_api.h ++++ b/proxy_wasm_api.h +@@ -1207,7 +1207,7 @@ struct SimpleHistogram { + template struct Counter : public MetricBase { + static Counter *New(std::string_view name, MetricTagDescriptor... fieldnames); + +- Counter(std::string_view name, MetricTagDescriptor... descriptors) ++ Counter(std::string_view name, MetricTagDescriptor... descriptors) + : Counter(std::string(name), std::vector({toMetricTag(descriptors)...})) { + } + +@@ -1256,7 +1256,7 @@ inline Counter *Counter::New(std::string_view name, + template struct Gauge : public MetricBase { + static Gauge *New(std::string_view name, MetricTagDescriptor... fieldnames); + +- Gauge(std::string_view name, MetricTagDescriptor... descriptors) ++ Gauge(std::string_view name, MetricTagDescriptor... descriptors) + : Gauge(std::string(name), std::vector({toMetricTag(descriptors)...})) {} + + SimpleGauge resolve(Tags... f) { +@@ -1302,6 +1302,6 @@ inline Gauge *Gauge::New(std::string_view name, + template struct Histogram : public MetricBase { + static Histogram *New(std::string_view name, MetricTagDescriptor... fieldnames); + +- Histogram(std::string_view name, MetricTagDescriptor... descriptors) ++ Histogram(std::string_view name, MetricTagDescriptor... descriptors) + : Histogram(std::string(name), + std::vector({toMetricTag(descriptors)...})) {} diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index d708483f..373c25d0 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -132,6 +132,8 @@ def proxy_wasm_cpp_host_repositories(): sha256 = "89792fc1abca331f29f99870476a04146de5e82ff903bdffca90e6729c1f2470", strip_prefix = "proxy-wasm-cpp-sdk-95bb82ce45c41d9100fd1ec15d2ffc67f7f3ceee", urls = ["https://github.com/proxy-wasm/proxy-wasm-cpp-sdk/archive/95bb82ce45c41d9100fd1ec15d2ffc67f7f3ceee.tar.gz"], + patches = ["@proxy_wasm_cpp_host//bazel/external:proxy_wasm_cpp_sdk.patch"], + patch_args = ["-p1"], ) # Test dependencies. From 749ebf8b77d3ccf239fa8ed0bdf49b6e57c91508 Mon Sep 17 00:00:00 2001 From: Michael Warres Date: Mon, 19 Aug 2024 02:48:26 +0000 Subject: [PATCH 4/9] Add temporary workaround for #412 Signed-off-by: Michael Warres --- test/utility.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/utility.h b/test/utility.h index 27b3b049..be60d321 100644 --- a/test/utility.h +++ b/test/utility.h @@ -197,4 +197,7 @@ class TestVm : public testing::TestWithParam { std::string engine_; }; +// TODO: remove when #412 is fixed. +GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TestVm); + } // namespace proxy_wasm From fc7a80b87e777cf0e7451d52619d1825e5cf3e28 Mon Sep 17 00:00:00 2001 From: Michael Warres Date: Mon, 19 Aug 2024 15:56:11 +0000 Subject: [PATCH 5/9] Add -fno-sanitize=unsigned-integer-overflow to clang asan options Signed-off-by: Michael Warres --- .bazelrc | 1 + 1 file changed, 1 insertion(+) diff --git a/.bazelrc b/.bazelrc index b05ba07b..c21135e4 100644 --- a/.bazelrc +++ b/.bazelrc @@ -28,6 +28,7 @@ build:clang-asan --copt -DADDRESS_SANITIZER=1 build:clang-asan --copt -DUNDEFINED_SANITIZER=1 build:clang-asan --copt -fsanitize=address,undefined build:clang-asan --copt -fsanitize-address-use-after-scope +build:clang-asan --copt -fno-sanitize=unsigned-integer-overflow build:clang-asan --linkopt -fsanitize=address,undefined build:clang-asan --linkopt -fsanitize-address-use-after-scope build:clang-asan --test_env=ASAN_OPTIONS=check_initialization_order=1:detect_stack_use_after_return=1:strict_init_order=1:strict_string_checks=1 From c2f810279e5914edb249ba90aef1fab9d8863a5f Mon Sep 17 00:00:00 2001 From: Michael Warres Date: Mon, 19 Aug 2024 15:59:37 +0000 Subject: [PATCH 6/9] Disable clang-tidy clang-diagnostic-builtin-macro-redefined check Signed-off-by: Michael Warres --- .clang-tidy | 1 + 1 file changed, 1 insertion(+) diff --git a/.clang-tidy b/.clang-tidy index ceab9ad4..ea657db5 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -19,5 +19,6 @@ Checks: clang-*, -readability-magic-numbers, -readability-make-member-function-const, -readability-simplify-boolean-expr, + -clang-diagnostic-builtin-macro-redefined, WarningsAsErrors: '*' From d7d6af73bd16cf6abf7383f7b1382b06c89f923d Mon Sep 17 00:00:00 2001 From: Michael Warres Date: Mon, 19 Aug 2024 16:17:50 +0000 Subject: [PATCH 7/9] Change asan config for NullVM and Wasmtime from clang-asan-strict to clang-asan Signed-off-by: Michael Warres --- .bazelrc | 1 - .github/workflows/test.yml | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index c21135e4..b05ba07b 100644 --- a/.bazelrc +++ b/.bazelrc @@ -28,7 +28,6 @@ build:clang-asan --copt -DADDRESS_SANITIZER=1 build:clang-asan --copt -DUNDEFINED_SANITIZER=1 build:clang-asan --copt -fsanitize=address,undefined build:clang-asan --copt -fsanitize-address-use-after-scope -build:clang-asan --copt -fno-sanitize=unsigned-integer-overflow build:clang-asan --linkopt -fsanitize=address,undefined build:clang-asan --linkopt -fsanitize-address-use-after-scope build:clang-asan --test_env=ASAN_OPTIONS=check_initialization_order=1:detect_stack_use_after_return=1:strict_init_order=1:strict_string_checks=1 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 66ec91bf..548c099a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -118,7 +118,7 @@ jobs: os: ubuntu-22.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 @@ -235,7 +235,7 @@ jobs: os: ubuntu-22.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' From 93358c2017b01f621224af68b080d97bbf8ab241 Mon Sep 17 00:00:00 2001 From: Michael Warres Date: Mon, 19 Aug 2024 18:31:29 +0000 Subject: [PATCH 8/9] Additionally specify --host_cxxopt=-std=c++20 This isn't strictly necessary in this PR for CI to pass, however I encountered a need for it in child PR #409, and seemed more appropriate to add here. Signed-off-by: Michael Warres --- .bazelrc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index b05ba07b..6e130159 100644 --- a/.bazelrc +++ b/.bazelrc @@ -81,9 +81,9 @@ build:zig-cc-linux-aarch64 --test_env=QEMU_LD_PREFIX=/usr/aarch64-linux-gnu/ build --enable_platform_specific_config # Use C++20. -build:linux --cxxopt=-std=c++20 -build:macos --cxxopt=-std=c++20 -build:windows --cxxopt="/std: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 From 6257b588e0a5b0c513c00526c691e95b23879d1f Mon Sep 17 00:00:00 2001 From: Michael Warres Date: Mon, 19 Aug 2024 22:13:40 +0000 Subject: [PATCH 9/9] Update runner used by clang-format and clang-tidy, and don't pin to clang-tidy-12 Signed-off-by: Michael Warres --- .github/workflows/format.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index de71b24c..3aa8cf89 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -41,7 +41,7 @@ jobs: addlicense: name: verify licenses - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 @@ -61,7 +61,7 @@ jobs: buildifier: name: check format with buildifier - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v2 @@ -99,29 +99,29 @@ jobs: clang_format: name: check format with clang-format - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.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 - 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 -i git diff --exit-code clang_tidy: name: check format with clang-tidy - runs-on: ubuntu-20.04 + runs-on: ubuntu-22.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 lld - name: Bazel cache uses: PiotrSikora/cache@v2.1.7-with-skip-cache