From 95fa56446a0c58134b9b9f7407951f7460adebac Mon Sep 17 00:00:00 2001 From: Igor Sheludko Date: Thu, 25 Apr 2024 17:57:58 +0200 Subject: [PATCH] Add node_enable_deprecated_declarations_warnings GN flag (#181) * Add node_enable_deprecated_declarations_warnings GN flag Warnings about using deprecated declarations were disabled by default which made it hard to ensure that Node doesn't use V8's deprecated Apis. The flag allows enabling deprecated warnings and suppresses (hopefully) known issues with using deprecated functionality in c-api. The flag is off by default which preserves the existing behavior. Drive-by: fix deps/openssl/unofficial.gni by exposing the required OpenSSL compatibility level (OPENSSL_API_COMPAT) via public_configs. --- deps/openssl/unofficial.gni | 2 +- unofficial.gni | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/deps/openssl/unofficial.gni b/deps/openssl/unofficial.gni index 6cc699c900d1ff..73003df1ace368 100644 --- a/deps/openssl/unofficial.gni +++ b/deps/openssl/unofficial.gni @@ -16,6 +16,7 @@ template("openssl_gn_build") { "openssl/crypto/include", "openssl/include", ] + defines = [ "OPENSSL_API_COMPAT=0x10100001L" ] } config("openssl_internal_config") { @@ -26,7 +27,6 @@ template("openssl_gn_build") { defines = [ "MODULESDIR=\"deps/openssl/lib/openssl-modules\"", - "OPENSSL_API_COMPAT=0x10100001L", "STATIC_LEGACY", ] + gypi_values.openssl_default_defines_all if (is_win) { diff --git a/unofficial.gni b/unofficial.gni index 3ff9815357dd36..0317487b242a73 100644 --- a/unofficial.gni +++ b/unofficial.gni @@ -6,6 +6,12 @@ import("node.gni") import("$node_v8_path/gni/snapshot_toolchain.gni") import("$node_v8_path/gni/v8.gni") +declare_args() { + # Enable warnings about usages of deprecated declarations and suppress + # known issues with c-ares. + node_enable_deprecated_declarations_warnings = false +} + # The actual configurations are put inside a template in unofficial.gni to # prevent accidental edits from contributors. template("node_gn_build") { @@ -33,7 +39,7 @@ template("node_gn_build") { defines += [ "HAVE_INSPECTOR=0" ] } if (node_use_node_code_cache) { - defines += [ "NODE_USE_NODE_CODE_CACHE=1"] + defines += [ "NODE_USE_NODE_CODE_CACHE=1" ] } if (v8_enable_i18n_support) { defines += [ "NODE_HAVE_I18N_SUPPORT=1" ] @@ -64,7 +70,6 @@ template("node_gn_build") { libs = [] cflags = [ "-Wno-microsoft-include" ] cflags_cc = [ - "-Wno-deprecated-declarations", "-Wno-extra-semi", "-Wno-implicit-fallthrough", "-Wno-macro-redefined", @@ -82,6 +87,10 @@ template("node_gn_build") { "-Wno-unused-function", ] + if (!node_enable_deprecated_declarations_warnings) { + cflags_cc += [ "-Wno-deprecated-declarations" ] + } + if (current_cpu == "x86") { node_arch = "ia32" } else { @@ -100,6 +109,11 @@ template("node_gn_build") { "NODE_REPORT" ] + if (node_enable_deprecated_declarations_warnings) { + # Refs: https://github.com/nodejs/node/issues/52464 + defines += [ "CARES_NO_DEPRECATED=1" ] + } + if (is_win) { defines += [ "NOMINMAX",