From bfbed0afd531a05f2fb10f3106eca6d380366cb9 Mon Sep 17 00:00:00 2001 From: Chengzhong Wu Date: Tue, 23 Jul 2024 09:56:44 +0100 Subject: [PATCH] build: fix conflict gyp configs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gyp generated build files can be built in either Release/Debug mode. - make: single directory, two configurations by cli: `make -C out BUILDTYPE=Release` and `make -C out BUILDTYPE=Debug`. - msbuild: single directory, two configurations by cli: `msbuild node.sln /p:Configuration=Release` and `msbuild node.sln /p:Configuration=Debug`. - ninja: two directories in `out/`, build with `ninja -C out/Release` or `ninja -C out/Debug`. Variables that changes with either Release or Debug configuration should be defined in a configuration level, instead of the root level. This fixes generating invalid build files. Additionally, `v8_gypfiles/toolchain.gypi` duplicates defines in `v8_gypfiles/features.gypi`. Remove the duplications in `toolchains.gypi` PR-URL: https://github.com/nodejs/node/pull/53605 Fixes: https://github.com/nodejs/node/issues/53446 Reviewed-By: Michaƫl Zasso Reviewed-By: James M Snell --- configure.py | 20 +++++++++++++++----- tools/v8_gypfiles/features.gypi | 1 - tools/v8_gypfiles/toolchain.gypi | 6 ------ 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/configure.py b/configure.py index 379fb5bb06c413..909f99e5b001bd 100755 --- a/configure.py +++ b/configure.py @@ -1306,6 +1306,9 @@ def host_arch_win(): return matchup.get(arch, 'ia32') +def set_configuration_variable(configs, name, release=None, debug=None): + configs['Release'][name] = release + configs['Debug'][name] = debug def configure_arm(o): if options.arm_float_abi: @@ -1620,7 +1623,9 @@ def configure_library(lib, output, pkgname=None): output['libraries'] += pkg_libs.split() -def configure_v8(o): +def configure_v8(o, configs): + set_configuration_variable(configs, 'v8_enable_v8_checks', release=1, debug=0) + o['variables']['v8_enable_webassembly'] = 0 if options.v8_lite_mode else 1 o['variables']['v8_enable_javascript_promise_hooks'] = 1 o['variables']['v8_enable_lite_mode'] = 1 if options.v8_lite_mode else 0 @@ -1638,7 +1643,6 @@ def configure_v8(o): o['variables']['v8_enable_31bit_smis_on_64bit_arch'] = 1 if options.enable_pointer_compression else 0 o['variables']['v8_enable_shared_ro_heap'] = 0 if options.enable_pointer_compression or options.disable_shared_ro_heap else 1 o['variables']['v8_enable_extensible_ro_snapshot'] = 0 - o['variables']['v8_enable_v8_checks'] = 1 if options.debug else 0 o['variables']['v8_trace_maps'] = 1 if options.trace_maps else 0 o['variables']['node_use_v8_platform'] = b(not options.without_v8_platform) o['variables']['node_use_bundled_v8'] = b(not options.without_bundled_v8) @@ -2154,6 +2158,10 @@ def make_bin_override(): 'defines': [], 'cflags': [], } +configurations = { + 'Release': { 'variables': {} }, + 'Debug': { 'variables': {} }, +} # Print a warning when the compiler is too old. check_compiler(output) @@ -2181,7 +2189,7 @@ def make_bin_override(): configure_library('ngtcp2', output, pkgname='libngtcp2') configure_library('sqlite', output, pkgname='sqlite3') configure_library('uvwasi', output, pkgname='libuvwasi') -configure_v8(output) +configure_v8(output, configurations) configure_openssl(output) configure_intl(output) configure_static(output) @@ -2204,7 +2212,6 @@ def make_bin_override(): # move everything else to target_defaults variables = output['variables'] del output['variables'] -variables['is_debug'] = B(options.debug) # make_global_settings should be a root level element too if 'make_global_settings' in output: @@ -2213,6 +2220,9 @@ def make_bin_override(): else: make_global_settings = False +# Add configurations to target defaults +output['configurations'] = configurations + output = { 'variables': variables, 'target_defaults': output, @@ -2223,7 +2233,7 @@ def make_bin_override(): print_verbose(output) write('config.gypi', do_not_edit + - pprint.pformat(output, indent=2, width=1024) + '\n') + pprint.pformat(output, indent=2, width=128) + '\n') write('config.status', '#!/bin/sh\nset -x\nexec ./configure ' + ' '.join([shlex.quote(arg) for arg in original_argv]) + '\n') diff --git a/tools/v8_gypfiles/features.gypi b/tools/v8_gypfiles/features.gypi index db9bda604bc176..6e21dac6d70ede 100644 --- a/tools/v8_gypfiles/features.gypi +++ b/tools/v8_gypfiles/features.gypi @@ -88,7 +88,6 @@ 'v8_enable_private_mapping_fork_optimization': 0, }], ], - 'is_debug%': 0, # Variables from BUILD.gn diff --git a/tools/v8_gypfiles/toolchain.gypi b/tools/v8_gypfiles/toolchain.gypi index 98e738d0a81c53..9d1b0987167fc6 100644 --- a/tools/v8_gypfiles/toolchain.gypi +++ b/tools/v8_gypfiles/toolchain.gypi @@ -711,13 +711,7 @@ 'configurations': { 'Debug': { 'defines': [ - 'ENABLE_DISASSEMBLER', - 'V8_ENABLE_CHECKS', - 'OBJECT_PRINT', 'DEBUG', - 'V8_TRACE_MAPS', - 'V8_ENABLE_ALLOCATION_TIMEOUT', - 'V8_ENABLE_FORCE_SLOW_PATH', ], 'conditions': [ ['OS=="linux" and v8_enable_backtrace==1', {