From a9cc80dd347cf1107e43be24e4b3bcb3e29a55ca Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 5 Oct 2026 15:54:12 +0200 Subject: [PATCH] deps: V8: cherry-pick 00508c374a45 Original commit message: Add V8_HAS_WARNING for portable warning checks GCC does not provide the function-like __has_warning macro. Invoking it in a compound preprocessor condition causes a preprocessing error even when __clang__ is false. Add V8_HAS_WARNING to v8config.h, following existing feature-detection helpers. Use it for warning guards in base/macros.h. Compilers without __has_warning now use the fallback value of zero. Change-Id: I41d10799fd6f73a8bacbd3648aa0bb792d6b80cd Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/8385383 Reviewed-by: Igor Sheludko Commit-Queue: Igor Sheludko Reviewed-by: Maksim Ivanov Cr-Commit-Position: refs/heads/main@{#109976} Refs: https://github.com/v8/v8/commit/00508c374a45e53e20e48cb103d512befed8cc43 Signed-off-by: Joyee Cheung PR-URL: https://github.com/nodejs/node/pull/66537 Reviewed-By: Richard Lau Reviewed-By: Chengzhong Wu Reviewed-By: Filip Skokan Reviewed-By: Yagiz Nizipli --- common.gypi | 2 +- deps/v8/include/v8config.h | 7 +++++++ deps/v8/src/base/macros.h | 10 ++++------ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/common.gypi b/common.gypi index 73695cac679..5586cbce856 100644 --- a/common.gypi +++ b/common.gypi @@ -44,7 +44,7 @@ # Reset this number to 0 on major V8 upgrades. # Increment by one for each non-official patch applied to deps/v8. - 'v8_embedder_string': '-node.7', + 'v8_embedder_string': '-node.8', ##### V8 defaults for Node.js ##### diff --git a/deps/v8/include/v8config.h b/deps/v8/include/v8config.h index b36169f1f77..b7aeeade6b8 100644 --- a/deps/v8/include/v8config.h +++ b/deps/v8/include/v8config.h @@ -354,6 +354,7 @@ path. Add it with -I to the command line // V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported // V8_HAS_DECLSPEC_SELECTANY - __declspec(selectany) supported // V8_HAS___FORCEINLINE - __forceinline supported +// V8_HAS_WARNING(WARNING) - whether WARNING is supported // // Note that testing for compilers and/or features must be done using #if // not #ifdef. For example, to test for Intel C++ Compiler, use: @@ -367,6 +368,12 @@ path. Add it with -I to the command line #define V8_HAS_CPP_ATTRIBUTE(FEATURE) 0 #endif +#if defined(__has_warning) +#define V8_HAS_WARNING(WARNING) __has_warning(WARNING) +#else +#define V8_HAS_WARNING(WARNING) 0 +#endif + #if defined(__clang__) #if defined(__GNUC__) // Clang in gcc mode. diff --git a/deps/v8/src/base/macros.h b/deps/v8/src/base/macros.h index c2c24e8229a..5b1619f9ef0 100644 --- a/deps/v8/src/base/macros.h +++ b/deps/v8/src/base/macros.h @@ -668,8 +668,7 @@ static_assert(V8_ENABLE_SIMD128); #endif // defined(__clang__) // Disable/enable -Wlifetime-safety warnings in code. -#if defined(__clang__) && defined(__has_warning) && \ - __has_warning("-Wlifetime-safety") +#if V8_HAS_WARNING("-Wlifetime-safety") #define START_IGNORE_LIFETIME_SAFETY_WARNINGS() \ _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Wlifetime-safety\"") @@ -677,11 +676,10 @@ static_assert(V8_ENABLE_SIMD128); #else #define START_IGNORE_LIFETIME_SAFETY_WARNINGS() #define END_IGNORE_LIFETIME_SAFETY_WARNINGS() -#endif // defined(__clang__) +#endif // V8_HAS_WARNING("-Wlifetime-safety") // Disable/enable -Wreturn-stack-address warnings in code. -#if defined(__clang__) && defined(__has_warning) && \ - __has_warning("-Wreturn-stack-address") +#if V8_HAS_WARNING("-Wreturn-stack-address") #define START_IGNORE_RETURN_STACK_ADDRESS_WARNINGS() \ _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Wreturn-stack-address\"") @@ -690,6 +688,6 @@ static_assert(V8_ENABLE_SIMD128); #else #define START_IGNORE_RETURN_STACK_ADDRESS_WARNINGS() #define END_IGNORE_RETURN_STACK_ADDRESS_WARNINGS() -#endif // defined(__clang__) +#endif // V8_HAS_WARNING("-Wreturn-stack-address") #endif // V8_BASE_MACROS_H_