From 6cd8f4502883803a4e73eb36c7107838fd363ff0 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 16 Nov 2026 22:37:36 +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 PR-URL: https://github.com/nodejs/node/pull/67279 Reviewed-By: James M Snell Reviewed-By: Luigi Pinca Reviewed-By: Chengzhong Wu Reviewed-By: Stewart X Addison Reviewed-By: Gürgün Dayıoğlu --- 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 a462a9e9f2e..00e43b52052 100644 --- a/node.gyp +++ b/node.gyp @@ -561,6 +561,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 058580f2ab4..645f19ca5c9 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 a3166cae562..b2cd6824779 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -75,6 +75,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.