From 6f8984c89a0e85a056d773484b3dcf97f30f1a21 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Thu, 5 Nov 2026 15:32:49 +0100 Subject: [PATCH] build: fix GCC warnings when building V8 with gnu++20 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This silences the following warning from GCC: - deps/v8/src/base/flags.h: call to non-constexpr function `std::__atomic_base::operator unsigned char() const` in the defaulted `constexpr Flags::operator==` when instantiated with `std::atomic` storage [-Winvalid-constexpr] - deps/v8/include/v8-wasm.h: call to non-constexpr function `std::unique_ptr::get() const` in `constexpr OwnedBuffer::as_span()` [-Winvalid-constexpr] - deps/v8/src/execution/simulator.h: ‘nodebug’ attribute directive ignored [-Wattributes] Also move -fvisibility-inlines-hidden from cflags to cflags_cc in tools/v8_gypfiles/v8.gyp to fix the following warning. cc1: warning: command-line option '-fvisibility-inlines-hidden' is valid for C++/ObjC++ but not for C Signed-off-by: Joyee Cheung --- node.gyp | 3 +++ tools/v8_gypfiles/toolchain.gypi | 7 +++++++ tools/v8_gypfiles/v8.gyp | 2 ++ 3 files changed, 12 insertions(+) diff --git a/node.gyp b/node.gyp index 714609b03e66..eddac01f1e13 100644 --- a/node.gyp +++ b/node.gyp @@ -558,6 +558,9 @@ 'conditions': [ ['clang==0 and OS!="win"', { 'cflags': [ '-Wno-restrict', ], + 'cflags_cc': [ + '-Wno-invalid-constexpr', + ], }], # TODO(joyeecheung): investigate if it breaks addons. # ['OS=="mac"', { diff --git a/tools/v8_gypfiles/toolchain.gypi b/tools/v8_gypfiles/toolchain.gypi index 058580f2ab42..645f19ca5c9f 100644 --- a/tools/v8_gypfiles/toolchain.gypi +++ b/tools/v8_gypfiles/toolchain.gypi @@ -122,6 +122,13 @@ # On by default in Clang and V8 requires it at least for arm64. '-flax-vector-conversions', ], + 'cflags_cc': [ + # TODO(joyeecheung): this may be removed after we switch to C++23 + '-Wno-invalid-constexpr', + # V8 uses the clang-only nodebug attribute in + # src/execution/simulator.h, which GCC ignores with a warning. + '-Wno-attributes', + ], }], ['clang==1 or OS!="win"', { 'cflags_cc': [ diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp index 71b6772bc345..d7143a86acb4 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -77,6 +77,8 @@ }, '(OS!="aix" and OS!="os400") and (OS!="win" or clang==1)', { 'cflags': [ '-fvisibility=hidden', + ], + 'cflags_cc': [ '-fvisibility-inlines-hidden' ], }], # MSVC hides the non-public symbols by default so no need to configure it.