Skip to content

Commit 497e4ef

Browse files
leonm1mpwarres
andauthored
build: compile with C++20 (#441)
* build using c++20 std=c++20 is used by both v8 and Envoy. Switching to use it is necessary to build with more recent versions of v8, and will also reduce overall build surprises when importing proxy-wasm-cpp-host into Envoy. Signed-off-by: Michael Warres <[email protected]> * change --config=clang-asan-strict to --config=clang-asan Signed-off-by: Michael Warres <[email protected]> * chore: support clang-18 and ubuntu-24.04 These changes make Proxy-Wasm build cleanly with clang-18 and pass clang-tidy-18 checks. Signed-off-by: Matt Leon <[email protected]> * chore: ignore c++20 + clang-18 + gcc-14 findings Signed-off-by: Matt Leon <[email protected]> --------- Signed-off-by: Michael Warres <[email protected]> Signed-off-by: Matt Leon <[email protected]> Co-authored-by: Michael Warres <[email protected]>
1 parent ad8303f commit 497e4ef

File tree

12 files changed

+68
-57
lines changed

12 files changed

+68
-57
lines changed

.bazelrc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ build --action_env=PATH
1010
build:clang --action_env=BAZEL_COMPILER=clang
1111
build:clang --action_env=CC=clang
1212
build:clang --action_env=CXX=clang++
13+
build:clang --copt -Wno-pragma-once-outside-header --cxxopt -Wno-pragma-once-outside-header
1314

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

8182
build --enable_platform_specific_config
8283

83-
# Use C++17.
84-
build:linux --cxxopt=-std=c++17
85-
build:macos --cxxopt=-std=c++17
86-
build:windows --cxxopt="/std:c++17"
84+
# Use C++20.
85+
build:linux --cxxopt=-std=c++20 --host_cxxopt=-std=c++20
86+
build:macos --cxxopt=-std=c++20 --host_cxxopt=-std=c++20
87+
build:windows --cxxopt="/std:c++20" --host_cxxopt="/std:c++20"
8788

8889
# Enable symlinks and runfiles on Windows (enabled by default on other platforms).
8990
startup --windows_enable_symlinks

.clang-tidy

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,38 @@
11
Checks: clang-*,
2+
-clang-analyzer-core.CallAndMessage,
23
-clang-analyzer-optin.portability.UnixAPI,
34
-clang-analyzer-unix.Malloc,
45
-clang-diagnostic-pragma-once-outside-header,
6+
-clang-diagnostic-builtin-macro-redefined,
57
cppcoreguidelines-pro-type-member-init,
68
cppcoreguidelines-pro-type-static-cast-downcast,
79
misc-*,
810
-misc-non-private-member-variables-in-classes,
11+
-misc-use-anonymous-namespace,
12+
-misc-const-correctness,
13+
-misc-include-cleaner,
14+
-misc-unused-parameters,
915
modernize-*,
1016
-modernize-avoid-c-arrays,
1117
-modernize-use-trailing-return-type,
18+
-modernize-return-braced-init-list,
19+
-modernize-use-default-member-init,
20+
-modernize-type-traits,
21+
-modernize-use-emplace,
1222
llvm-include-order,
1323
performance-*,
1424
-performance-no-int-to-ptr,
25+
-performance-avoid-endl,
1526
portability-*,
1627
readability-*,
1728
-readability-convert-member-functions-to-static,
1829
-readability-function-cognitive-complexity,
1930
-readability-magic-numbers,
2031
-readability-make-member-function-const,
2132
-readability-simplify-boolean-expr,
33+
-readability-identifier-length,
34+
-readability-container-data-pointer,
35+
-readability-redundant-casting,
36+
-readability-avoid-return-with-void-value,
2237

2338
WarningsAsErrors: '*'

.github/workflows/format.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
addlicense:
4444
name: verify licenses
4545

46-
runs-on: ubuntu-22.04
46+
runs-on: ubuntu-24.04
4747

4848
steps:
4949
- uses: actions/checkout@v2
@@ -63,7 +63,7 @@ jobs:
6363
buildifier:
6464
name: check format with buildifier
6565

66-
runs-on: ubuntu-22.04
66+
runs-on: ubuntu-24.04
6767

6868
steps:
6969
- uses: actions/checkout@v2
@@ -101,29 +101,29 @@ jobs:
101101
clang_format:
102102
name: check format with clang-format
103103

104-
runs-on: ubuntu-22.04
104+
runs-on: ubuntu-24.04
105105

106106
steps:
107107
- uses: actions/checkout@v2
108108

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

112112
- name: Format (clang-format)
113113
run: |
114-
find . -name "*.h" -o -name "*.cc" -o -name "*.proto" | grep -v ".pb." | xargs -n1 clang-format-12 -i
114+
find . -name "*.h" -o -name "*.cc" -o -name "*.proto" | grep -v ".pb." | xargs -n1 clang-format-18 -i
115115
git diff --exit-code
116116
117117
clang_tidy:
118118
name: check format with clang-tidy
119119

120-
runs-on: ubuntu-22.04
120+
runs-on: ubuntu-24.04
121121

122122
steps:
123123
- uses: actions/checkout@v2
124124

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

128128
- name: Bazel cache
129129
uses: PiotrSikora/[email protected]

.github/workflows/test.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
test_data:
4444
name: build test data
4545

46-
runs-on: ubuntu-22.04
46+
runs-on: ubuntu-24.04
4747

4848
steps:
4949
- uses: actions/checkout@v2
@@ -111,19 +111,19 @@ jobs:
111111
include:
112112
- name: 'NullVM on Linux/x86_64'
113113
engine: 'null'
114-
os: ubuntu-22.04
114+
os: ubuntu-24.04
115115
arch: x86_64
116116
action: test
117117
flags: --config=gcc
118118
- name: 'NullVM on Linux/x86_64 with ASan'
119119
engine: 'null'
120-
os: ubuntu-22.04
120+
os: ubuntu-24.04
121121
arch: x86_64
122122
action: test
123-
flags: --config=clang-asan-strict --define=crypto=system
123+
flags: --config=clang-asan --define=crypto=system
124124
- name: 'NullVM on Linux/x86_64 with TSan'
125125
engine: 'null'
126-
os: ubuntu-22.04
126+
os: ubuntu-24.04
127127
arch: x86_64
128128
action: test
129129
flags: --config=clang-tsan
@@ -136,39 +136,39 @@ jobs:
136136
- name: 'V8 on Linux/x86_64'
137137
engine: 'v8'
138138
repo: 'v8'
139-
os: ubuntu-22.04
139+
os: ubuntu-24.04
140140
arch: x86_64
141141
action: test
142142
flags: --config=clang --define=crypto=system
143143
cache: true
144144
- name: 'V8 on Linux/x86_64 with ASan'
145145
engine: 'v8'
146146
repo: 'v8'
147-
os: ubuntu-22.04
147+
os: ubuntu-24.04
148148
arch: x86_64
149149
action: test
150150
flags: --config=clang-asan
151151
cache: true
152152
- name: 'V8 on Linux/x86_64 with TSan'
153153
engine: 'v8'
154154
repo: 'v8'
155-
os: ubuntu-22.04
155+
os: ubuntu-24.04
156156
arch: x86_64
157157
action: test
158158
flags: --config=clang-tsan
159159
cache: true
160160
- name: 'V8 on Linux/x86_64 with GCC'
161161
engine: 'v8'
162162
repo: 'v8'
163-
os: ubuntu-22.04
163+
os: ubuntu-24.04
164164
arch: x86_64
165165
action: test
166166
flags: --config=gcc
167167
cache: true
168168
- name: 'V8 on Linux/aarch64'
169169
engine: 'v8'
170170
repo: 'v8'
171-
os: ubuntu-22.04
171+
os: ubuntu-24.04
172172
arch: aarch64
173173
action: test
174174
targets: -//test/fuzz/...
@@ -185,7 +185,7 @@ jobs:
185185
- name: 'WAMR interp on Linux/x86_64'
186186
engine: 'wamr-interp'
187187
repo: 'com_github_bytecodealliance_wasm_micro_runtime'
188-
os: ubuntu-22.04
188+
os: ubuntu-24.04
189189
arch: x86_64
190190
action: test
191191
flags: --config=clang
@@ -198,11 +198,11 @@ jobs:
198198
- name: 'WAMR jit on Linux/x86_64'
199199
engine: 'wamr-jit'
200200
repo: 'com_github_bytecodealliance_wasm_micro_runtime'
201-
os: ubuntu-22.04
201+
os: ubuntu-24.04
202202
arch: x86_64
203203
action: test
204204
flags: --config=clang
205-
deps: lld-12
205+
deps: lld-18
206206
cache: true
207207
- name: 'WAMR jit on macOS/x86_64'
208208
engine: 'wamr-jit'
@@ -214,7 +214,7 @@ jobs:
214214
- name: 'WasmEdge on Linux/x86_64'
215215
engine: 'wasmedge'
216216
repo: 'com_github_wasmedge_wasmedge'
217-
os: ubuntu-22.04
217+
os: ubuntu-24.04
218218
arch: x86_64
219219
action: test
220220
flags: --config=clang
@@ -227,29 +227,29 @@ jobs:
227227
- name: 'Wasmtime on Linux/x86_64'
228228
engine: 'wasmtime'
229229
repo: 'com_github_bytecodealliance_wasmtime'
230-
os: ubuntu-22.04
230+
os: ubuntu-24.04
231231
arch: x86_64
232232
action: test
233233
flags: --config=clang -c opt
234234
- name: 'Wasmtime on Linux/x86_64 with ASan'
235235
engine: 'wasmtime'
236236
repo: 'com_github_bytecodealliance_wasmtime'
237-
os: ubuntu-22.04
237+
os: ubuntu-24.04
238238
arch: x86_64
239239
action: test
240-
flags: --config=clang-asan-strict --define=crypto=system
240+
flags: --config=clang-asan --define=crypto=system
241241
- name: 'Wasmtime on Linux/aarch64'
242242
engine: 'wasmtime'
243243
repo: 'com_github_bytecodealliance_wasmtime'
244-
os: ubuntu-22.04
244+
os: ubuntu-24.04
245245
arch: aarch64
246246
action: build
247247
flags: --config=zig-cc-linux-aarch64
248248
deps: qemu-user-static libc6-arm64-cross
249249
- name: 'Wasmtime on Linux/s390x'
250250
engine: 'wasmtime'
251251
repo: 'com_github_bytecodealliance_wasmtime'
252-
os: ubuntu-22.04
252+
os: ubuntu-24.04
253253
arch: s390x
254254
action: test
255255
flags: --config=clang --test_timeout=1800

bazel/external/bazel_clang_tidy.patch

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# 1. Treat .h files as C++ headers.
2-
# 2. Hardcode clang-tidy-12.
32

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

18-
diff --git a/clang_tidy/run_clang_tidy.sh b/clang_tidy/run_clang_tidy.sh
19-
index 582bab1..b9ebb94 100755
20-
--- a/clang_tidy/run_clang_tidy.sh
21-
+++ b/clang_tidy/run_clang_tidy.sh
22-
@@ -11,4 +11,4 @@ shift
23-
touch $OUTPUT
24-
truncate -s 0 $OUTPUT
25-
26-
-clang-tidy "$@"
27-
+clang-tidy-12 "$@"

bazel/external/v8.patch

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,14 @@ diff --git a/bazel/defs.bzl b/bazel/defs.bzl
2020
index e957c0fad3..063627b72b 100644
2121
--- a/bazel/defs.bzl
2222
+++ b/bazel/defs.bzl
23-
@@ -131,6 +131,7 @@ def _default_args():
23+
@@ -131,6 +131,10 @@ def _default_args():
2424
"-Wno-redundant-move",
2525
"-Wno-return-type",
2626
"-Wno-stringop-overflow",
2727
+ "-Wno-nonnull",
28+
+ "-Wno-error=pessimizing-move",
29+
+ "-Wno-error=dangling-reference",
30+
+ "-Wno-error=dangling-pointer=",
2831
# Use GNU dialect, because GCC doesn't allow using
2932
# ##__VA_ARGS__ when in standards-conforming mode.
3033
"-std=gnu++17",

bazel/external/wasmedge.BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ cmake(
1818
"WASMEDGE_BUILD_TOOLS": "Off",
1919
"WASMEDGE_FORCE_DISABLE_LTO": "On",
2020
},
21+
env = {
22+
"CXXFLAGS": "-Wno-error=dangling-reference -Wno-error=maybe-uninitialized -Wno-error=array-bounds= -Wno-error=deprecated-declarations -std=c++20",
23+
},
2124
generate_args = ["-GNinja"],
2225
lib_source = ":srcs",
2326
out_static_libs = ["libwasmedge.a"],

bazel/repositories.bzl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,9 @@ def proxy_wasm_cpp_host_repositories():
130130
maybe(
131131
http_archive,
132132
name = "proxy_wasm_cpp_sdk",
133-
sha256 = "89792fc1abca331f29f99870476a04146de5e82ff903bdffca90e6729c1f2470",
134-
strip_prefix = "proxy-wasm-cpp-sdk-95bb82ce45c41d9100fd1ec15d2ffc67f7f3ceee",
135-
urls = ["https://github.com/proxy-wasm/proxy-wasm-cpp-sdk/archive/95bb82ce45c41d9100fd1ec15d2ffc67f7f3ceee.tar.gz"],
133+
sha256 = "26c4c0f9f645de7e789dc92f113d7352ee54ac43bb93ae3a8a22945f1ce71590",
134+
strip_prefix = "proxy-wasm-cpp-sdk-7465dee8b2953beebff99f6dc3720ad0c79bab99",
135+
urls = ["https://github.com/proxy-wasm/proxy-wasm-cpp-sdk/archive/7465dee8b2953beebff99f6dc3720ad0c79bab99.tar.gz"],
136136
)
137137

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

159157
# NullVM dependencies.

src/null/null_plugin.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <utility>
2727
#include <vector>
2828

29-
#include "include/proxy-wasm/null_plugin.h"
3029
#include "include/proxy-wasm/null_vm.h"
3130
#include "include/proxy-wasm/wasm.h"
3231

src/wasmedge/wasmedge.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "wasmedge/wasmedge.h"
2121

22+
#include <algorithm>
2223
#include <array>
2324
#include <cassert>
2425
#include <cstring>

0 commit comments

Comments
 (0)