From d95b0e39128854a05563cabfd597ef3450d8003e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Zasso?= Date: Thu, 14 Mar 2024 11:11:43 +0100 Subject: [PATCH] build: speed up compilation of some V8 files This introduces a special target to compile some of the 'v8_initializers' files with "-O1" instead of "-O3" to avoid huge compilation times with GCC versions <13. Closes: https://github.com/nodejs/node/issues/52068 --- tools/v8_gypfiles/v8.gyp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp index 53b6f565810cdd..a6154890083fa0 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -253,12 +253,32 @@ '<(V8_ROOT)/src/init/setup-isolate-full.cc', ], }, # v8_init + { + # This target is used to work around a GCC issue that causes the + # compilation to take several minutes when using -O2 or -O3. + # This is fixed in GCC 13. + 'target_name': 'v8_initializers_slow', + 'type': 'static_library', + 'toolsets': ['host', 'target'], + 'dependencies': [ + 'run_torque', + ], + 'cflags!': ['-O3'], + 'cflags': ['-O1'], + 'sources': [ + '<(SHARED_INTERMEDIATE_DIR)/torque-generated/src/builtins/js-to-wasm-tq-csa.h', + '<(SHARED_INTERMEDIATE_DIR)/torque-generated/src/builtins/js-to-wasm-tq-csa.cc', + '<(SHARED_INTERMEDIATE_DIR)/torque-generated/src/builtins/wasm-to-js-tq-csa.h', + '<(SHARED_INTERMEDIATE_DIR)/torque-generated/src/builtins/wasm-to-js-tq-csa.cc', + ], + }, # v8_initializers_slow { 'target_name': 'v8_initializers', 'type': 'static_library', 'toolsets': ['host', 'target'], 'dependencies': [ 'torque_generated_initializers', + 'v8_initializers_slow', 'v8_base_without_compiler', 'v8_shared_internal_headers', 'v8_pch', @@ -267,6 +287,13 @@ '<(SHARED_INTERMEDIATE_DIR)', '<(generate_bytecode_output_root)', ], + # Compiled by v8_initializers_slow target. + 'sources!': [ + '<(SHARED_INTERMEDIATE_DIR)/torque-generated/src/builtins/js-to-wasm-tq-csa.h', + '<(SHARED_INTERMEDIATE_DIR)/torque-generated/src/builtins/js-to-wasm-tq-csa.cc', + '<(SHARED_INTERMEDIATE_DIR)/torque-generated/src/builtins/wasm-to-js-tq-csa.h', + '<(SHARED_INTERMEDIATE_DIR)/torque-generated/src/builtins/wasm-to-js-tq-csa.cc', + ], 'sources': [ '