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

build: Compile with C++20 #411

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
8 changes: 4 additions & 4 deletions .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -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 --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
1 change: 1 addition & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ Checks: clang-*,
-readability-magic-numbers,
-readability-make-member-function-const,
-readability-simplify-boolean-expr,
-clang-diagnostic-builtin-macro-redefined,

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

runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2
Expand All @@ -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
Expand Down Expand Up @@ -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/[email protected]
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down
13 changes: 0 additions & 13 deletions bazel/external/googletest.patch

This file was deleted.

33 changes: 33 additions & 0 deletions bazel/external/proxy_wasm_cpp_sdk.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Address g++ -std=c++20 variadic template compilation issue:
Copy link
Member

@PiotrSikora PiotrSikora Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be fixed directly in the C++ SDK (which we also control) and bumped here instead.

# 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 <typename... Tags> struct Counter : public MetricBase {
static Counter<Tags...> *New(std::string_view name, MetricTagDescriptor<Tags>... fieldnames);

- Counter<Tags...>(std::string_view name, MetricTagDescriptor<Tags>... descriptors)
+ Counter(std::string_view name, MetricTagDescriptor<Tags>... descriptors)
: Counter<Tags...>(std::string(name), std::vector<MetricTag>({toMetricTag(descriptors)...})) {
}

@@ -1256,7 +1256,7 @@ inline Counter<Tags...> *Counter<Tags...>::New(std::string_view name,
template <typename... Tags> struct Gauge : public MetricBase {
static Gauge<Tags...> *New(std::string_view name, MetricTagDescriptor<Tags>... fieldnames);

- Gauge<Tags...>(std::string_view name, MetricTagDescriptor<Tags>... descriptors)
+ Gauge(std::string_view name, MetricTagDescriptor<Tags>... descriptors)
: Gauge<Tags...>(std::string(name), std::vector<MetricTag>({toMetricTag(descriptors)...})) {}

SimpleGauge resolve(Tags... f) {
@@ -1302,6 +1302,6 @@ inline Gauge<Tags...> *Gauge<Tags...>::New(std::string_view name,
template <typename... Tags> struct Histogram : public MetricBase {
static Histogram<Tags...> *New(std::string_view name, MetricTagDescriptor<Tags>... fieldnames);

- Histogram<Tags...>(std::string_view name, MetricTagDescriptor<Tags>... descriptors)
+ Histogram(std::string_view name, MetricTagDescriptor<Tags>... descriptors)
: Histogram<Tags...>(std::string(name),
std::vector<MetricTag>({toMetricTag(descriptors)...})) {}
10 changes: 5 additions & 5 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -133,18 +133,18 @@ 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.

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.
Expand Down
3 changes: 3 additions & 0 deletions test/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,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