mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
build: build codecache and snapshot with libnode
Signed-off-by: Chengzhong Wu <cwu631@bloomberg.net> PR-URL: https://github.com/nodejs/node/pull/63626 Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Gürgün Dayıoğlu <hey@gurgun.day>
This commit is contained in:
1 parent
60dab8d2e3
commit
3d35dd86fc
2 files changed
+152
-103
No files matched your search
+3
-9
@@ -1818,7 +1818,7 @@ def configure_node_lib_files(o):
|
||||
o['variables']['node_library_files'] = SearchFiles('lib', 'js')
|
||||
|
||||
def configure_node_cctest_sources(o):
|
||||
o['variables']['node_cctest_sources'] = [ 'src/node_snapshot_stub.cc' ] + \
|
||||
o['variables']['node_cctest_sources'] = [] + \
|
||||
SearchFiles('test/cctest', 'cc') + \
|
||||
SearchFiles('test/cctest', 'h')
|
||||
|
||||
@@ -1886,10 +1886,6 @@ def configure_node(o):
|
||||
o['variables']['arm_fpu'] = options.arm_fpu or 'neon'
|
||||
|
||||
if options.node_snapshot_main is not None:
|
||||
if options.shared:
|
||||
# This should be possible to fix, but we will need to refactor the
|
||||
# libnode target to avoid building it twice.
|
||||
error('--node-snapshot-main is incompatible with --shared')
|
||||
if options.without_node_snapshot:
|
||||
error('--node-snapshot-main is incompatible with ' +
|
||||
'--without-node-snapshot')
|
||||
@@ -1900,8 +1896,7 @@ def configure_node(o):
|
||||
if options.without_node_snapshot or options.node_builtin_modules_path:
|
||||
o['variables']['node_use_node_snapshot'] = 'false'
|
||||
else:
|
||||
o['variables']['node_use_node_snapshot'] = b(
|
||||
not cross_compiling and not options.shared)
|
||||
o['variables']['node_use_node_snapshot'] = b(not cross_compiling)
|
||||
|
||||
# Do not use code cache when Node.js is built for collecting coverage of itself, this allows more
|
||||
# precise coverage for the JS built-ins.
|
||||
@@ -1909,8 +1904,7 @@ def configure_node(o):
|
||||
o['variables']['node_use_node_code_cache'] = 'false'
|
||||
else:
|
||||
# TODO(refack): fix this when implementing embedded code-cache when cross-compiling.
|
||||
o['variables']['node_use_node_code_cache'] = b(
|
||||
not cross_compiling and not options.shared)
|
||||
o['variables']['node_use_node_code_cache'] = b(not cross_compiling)
|
||||
|
||||
if options.write_snapshot_as_array_literals is not None:
|
||||
o['variables']['node_write_snapshot_as_array_literals'] = b(options.write_snapshot_as_array_literals)
|
||||
|
||||
@@ -6,9 +6,15 @@
|
||||
'v8_enable_31bit_smis_on_64bit_arch%': 0,
|
||||
'force_dynamic_crt%': 0,
|
||||
'node_builtin_modules_path%': '',
|
||||
# `node` executable target name.
|
||||
'node_core_target_name%': 'node',
|
||||
'node_enable_v8_vtunejit%': 'false',
|
||||
# Derived flag from `node_shared`.
|
||||
# On most platforms, this is `static_library` if `node_shared` is false and `shared_library` if `node_shared` is true.
|
||||
# AIX needs to generate static library first and then link to shared library `node_aix_shared`.
|
||||
# TODO(legendecas): move this to depend on target `node_base` in AIX build .
|
||||
'node_intermediate_lib_type%': 'static_library',
|
||||
# `libnode` target name, can be a `static_library` or `shared_library` based on `node_shared`.
|
||||
# NOTE: Gyp will prefix this with `lib` if this name does not start with `lib`.
|
||||
'node_lib_target_name%': 'libnode',
|
||||
'node_module_version%': '',
|
||||
'node_no_browser_globals%': 'false',
|
||||
@@ -41,6 +47,7 @@
|
||||
'node_use_sqlite%': 'true',
|
||||
'node_use_ffi%': 'false',
|
||||
'node_use_v8_platform%': 'true',
|
||||
'node_enable_v8_vtunejit%': 'false',
|
||||
'node_v8_options%': '',
|
||||
'node_write_snapshot_as_string_literals': 'true',
|
||||
'ossfuzz' : 'false',
|
||||
@@ -670,16 +677,17 @@
|
||||
}],
|
||||
],
|
||||
}],
|
||||
[ 'node_intermediate_lib_type=="static_library" and node_shared=="false"', {
|
||||
[ 'node_shared=="false"', {
|
||||
# Keep this whole-archive section in sync with the `node_lib` target below.
|
||||
'xcode_settings': {
|
||||
'OTHER_LDFLAGS': [
|
||||
'-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)<(node_core_target_name)<(STATIC_LIB_SUFFIX)',
|
||||
'-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)node_base<(STATIC_LIB_SUFFIX)',
|
||||
],
|
||||
},
|
||||
'msvs_settings': {
|
||||
'VCLinkerTool': {
|
||||
'AdditionalOptions': [
|
||||
'/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/<(node_lib_target_name)<(STATIC_LIB_SUFFIX)',
|
||||
'/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/<(STATIC_LIB_PREFIX)node_base<(STATIC_LIB_SUFFIX)',
|
||||
'/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/<(STATIC_LIB_PREFIX)v8_base_without_compiler<(STATIC_LIB_SUFFIX)',
|
||||
],
|
||||
},
|
||||
@@ -695,7 +703,7 @@
|
||||
['node_use_bundled_v8=="true" and OS != "aix" and OS != "os400" and OS != "mac" and OS != "ios"', {
|
||||
'ldflags': [
|
||||
'-Wl,--whole-archive',
|
||||
'<(obj_dir)/<(STATIC_LIB_PREFIX)<(node_core_target_name)<(STATIC_LIB_SUFFIX)',
|
||||
'<(obj_dir)/<(STATIC_LIB_PREFIX)node_base<(STATIC_LIB_SUFFIX)',
|
||||
'<(obj_dir)/tools/v8_gypfiles/<(STATIC_LIB_PREFIX)v8_base_without_compiler<(STATIC_LIB_SUFFIX)',
|
||||
'-Wl,--no-whole-archive',
|
||||
],
|
||||
@@ -703,7 +711,7 @@
|
||||
['node_use_bundled_v8!="true" and OS != "aix" and OS != "os400" and OS != "mac" and OS != "ios"', {
|
||||
'ldflags': [
|
||||
'-Wl,--whole-archive',
|
||||
'<(obj_dir)/<(STATIC_LIB_PREFIX)<(node_core_target_name)<(STATIC_LIB_SUFFIX)',
|
||||
'<(obj_dir)/<(STATIC_LIB_PREFIX)node_base<(STATIC_LIB_SUFFIX)',
|
||||
'-Wl,--no-whole-archive',
|
||||
],
|
||||
}],
|
||||
@@ -771,55 +779,6 @@
|
||||
'LinkIncremental': 2, # enable incremental linking
|
||||
},
|
||||
},
|
||||
}],
|
||||
['node_use_node_snapshot=="true"', {
|
||||
'dependencies': [
|
||||
'node_mksnapshot',
|
||||
],
|
||||
'conditions': [
|
||||
['node_snapshot_main!=""', {
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'node_mksnapshot',
|
||||
'process_outputs_as_sources': 1,
|
||||
'inputs': [
|
||||
'<(node_mksnapshot_exec)',
|
||||
'<(node_snapshot_main)',
|
||||
],
|
||||
'outputs': [
|
||||
'<(SHARED_INTERMEDIATE_DIR)/node_snapshot.cc',
|
||||
],
|
||||
'action': [
|
||||
'<(node_mksnapshot_exec)',
|
||||
'--build-snapshot',
|
||||
'<(node_snapshot_main)',
|
||||
'<@(_outputs)',
|
||||
],
|
||||
},
|
||||
],
|
||||
}, {
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'node_mksnapshot',
|
||||
'process_outputs_as_sources': 1,
|
||||
'inputs': [
|
||||
'<(node_mksnapshot_exec)',
|
||||
],
|
||||
'outputs': [
|
||||
'<(SHARED_INTERMEDIATE_DIR)/node_snapshot.cc',
|
||||
],
|
||||
'action': [
|
||||
'<@(_inputs)',
|
||||
'<@(_outputs)',
|
||||
],
|
||||
},
|
||||
],
|
||||
}],
|
||||
],
|
||||
}, {
|
||||
'sources': [
|
||||
'src/node_snapshot_stub.cc'
|
||||
],
|
||||
}],
|
||||
[ 'OS in "linux freebsd openharmony" and '
|
||||
'target_arch=="x64"', {
|
||||
@@ -913,8 +872,8 @@
|
||||
],
|
||||
}, # node_core_target_name
|
||||
{
|
||||
'target_name': '<(node_lib_target_name)',
|
||||
'type': '<(node_intermediate_lib_type)',
|
||||
'target_name': 'node_base',
|
||||
'type': 'static_library',
|
||||
'includes': [
|
||||
'node.gypi',
|
||||
],
|
||||
@@ -933,9 +892,6 @@
|
||||
# Dependency headers
|
||||
'deps/v8/include/v8.h',
|
||||
'deps/postject/postject-api.h',
|
||||
# javascript files to make for an even more pleasant IDE experience
|
||||
'<@(library_files)',
|
||||
'<@(deps_files)',
|
||||
# node.gyp is added by default, common.gypi is added for change detection
|
||||
'common.gypi',
|
||||
],
|
||||
@@ -979,17 +935,6 @@
|
||||
}],
|
||||
[ 'node_builtin_modules_path!=""', {
|
||||
'defines': [ 'NODE_BUILTIN_MODULES_PATH="<(node_builtin_modules_path)"' ],
|
||||
# When loading builtins from disk, JS source files do not need to
|
||||
# trigger rebuilds since the binary reads them at runtime.
|
||||
'sources!': [
|
||||
'<@(library_files)',
|
||||
'<@(deps_files)',
|
||||
],
|
||||
}],
|
||||
[ 'node_shared=="true"', {
|
||||
'sources': [
|
||||
'src/node_snapshot_stub.cc',
|
||||
]
|
||||
}],
|
||||
[ 'node_use_bundled_v8!="false"', {
|
||||
'dependencies': [ 'tools/v8_gypfiles/abseil.gyp:abseil' ],
|
||||
@@ -1026,29 +971,12 @@
|
||||
}],
|
||||
],
|
||||
}],
|
||||
[ 'node_shared=="true" and node_module_version!="" and OS!="win"', {
|
||||
'product_extension': '<(shlib_suffix)',
|
||||
'xcode_settings': {
|
||||
'LD_DYLIB_INSTALL_NAME':
|
||||
'@rpath/lib<(node_core_target_name).<(shlib_suffix)'
|
||||
},
|
||||
}],
|
||||
['node_shared=="true" and OS in "aix os400"', {
|
||||
'product_name': 'node_base',
|
||||
}],
|
||||
[ 'v8_enable_inspector==1', {
|
||||
'includes' : [ 'src/inspector/node_inspector.gypi' ],
|
||||
}, {
|
||||
'defines': [ 'HAVE_INSPECTOR=0' ]
|
||||
}],
|
||||
[ 'OS=="win"', {
|
||||
'conditions': [
|
||||
[ 'node_intermediate_lib_type!="static_library"', {
|
||||
'sources': [
|
||||
'src/res/node.rc',
|
||||
],
|
||||
}],
|
||||
],
|
||||
'libraries': [
|
||||
'Dbghelp',
|
||||
'Psapi',
|
||||
@@ -1138,7 +1066,7 @@
|
||||
[ 'debug_nghttp2==1', {
|
||||
'defines': [ 'NODE_DEBUG_NGHTTP2=1' ]
|
||||
}],
|
||||
# Thin LTO for node sources (scoped to libnode, not global)
|
||||
# Thin LTO for node sources (scoped to node_base, not global)
|
||||
['node_with_ltcg=="true"', {
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
@@ -1183,6 +1111,137 @@
|
||||
],
|
||||
},
|
||||
],
|
||||
}, # node_base
|
||||
{
|
||||
'target_name': '<(node_lib_target_name)',
|
||||
'type': '<(node_intermediate_lib_type)',
|
||||
'includes': [
|
||||
'node.gypi',
|
||||
],
|
||||
|
||||
'include_dirs': [
|
||||
'src',
|
||||
'deps/v8/include',
|
||||
'deps/uv/include',
|
||||
],
|
||||
|
||||
'dependencies': [
|
||||
'node_base',
|
||||
],
|
||||
|
||||
'defines': [
|
||||
'NODE_ARCH="<(target_arch)"',
|
||||
'NODE_PLATFORM="<(OS)"',
|
||||
'NODE_WANT_INTERNALS=1',
|
||||
],
|
||||
|
||||
'sources': [
|
||||
# javascript files to make for an even more pleasant IDE experience
|
||||
'<@(library_files)',
|
||||
'<@(deps_files)',
|
||||
],
|
||||
|
||||
'conditions': [
|
||||
[ 'node_builtin_modules_path!=""', {
|
||||
# When loading builtins from disk, JS source files do not need to
|
||||
# trigger rebuilds since the binary reads them at runtime.
|
||||
'sources!': [
|
||||
'<@(library_files)',
|
||||
'<@(deps_files)',
|
||||
],
|
||||
}],
|
||||
['node_use_node_snapshot=="true"', {
|
||||
'dependencies': [
|
||||
'node_mksnapshot',
|
||||
],
|
||||
'conditions': [
|
||||
['node_snapshot_main!=""', {
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'node_mksnapshot',
|
||||
'process_outputs_as_sources': 1,
|
||||
'inputs': [
|
||||
'<(node_mksnapshot_exec)',
|
||||
'<(node_snapshot_main)',
|
||||
],
|
||||
'outputs': [
|
||||
'<(SHARED_INTERMEDIATE_DIR)/node_snapshot.cc',
|
||||
],
|
||||
'action': [
|
||||
'<(node_mksnapshot_exec)',
|
||||
'--build-snapshot',
|
||||
'<(node_snapshot_main)',
|
||||
'<@(_outputs)',
|
||||
],
|
||||
},
|
||||
],
|
||||
}, {
|
||||
'actions': [
|
||||
{
|
||||
'action_name': 'node_mksnapshot',
|
||||
'process_outputs_as_sources': 1,
|
||||
'inputs': [
|
||||
'<(node_mksnapshot_exec)',
|
||||
],
|
||||
'outputs': [
|
||||
'<(SHARED_INTERMEDIATE_DIR)/node_snapshot.cc',
|
||||
],
|
||||
'action': [
|
||||
'<@(_inputs)',
|
||||
'<@(_outputs)',
|
||||
],
|
||||
},
|
||||
],
|
||||
}],
|
||||
],
|
||||
}, {
|
||||
'sources': [
|
||||
'src/node_snapshot_stub.cc'
|
||||
],
|
||||
}],
|
||||
[ 'node_shared=="true"', {
|
||||
# Keep this whole-archive section in sync with the `node_exe` target above.
|
||||
'xcode_settings': {
|
||||
'OTHER_LDFLAGS': [
|
||||
'-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)node_base<(STATIC_LIB_SUFFIX)',
|
||||
],
|
||||
},
|
||||
'msvs_settings': {
|
||||
'VCLinkerTool': {
|
||||
'AdditionalOptions': [
|
||||
'/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/<(STATIC_LIB_PREFIX)node_base<(STATIC_LIB_SUFFIX)',
|
||||
'/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/<(STATIC_LIB_PREFIX)v8_base_without_compiler<(STATIC_LIB_SUFFIX)',
|
||||
],
|
||||
},
|
||||
},
|
||||
'conditions': [
|
||||
['node_use_bundled_v8=="true"', {
|
||||
'xcode_settings': {
|
||||
'OTHER_LDFLAGS': [
|
||||
'-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)v8_base_without_compiler<(STATIC_LIB_SUFFIX)',
|
||||
],
|
||||
},
|
||||
}],
|
||||
# gyp automatically applies `--whole-archive` to static dependencies of `shared_library` targets.
|
||||
# No need to add the flags again here.
|
||||
],
|
||||
}],
|
||||
[ 'node_shared=="true" and node_module_version!="" and OS!="win"', {
|
||||
'product_extension': '<(shlib_suffix)',
|
||||
'xcode_settings': {
|
||||
'LD_DYLIB_INSTALL_NAME':
|
||||
'@rpath/lib<(node_core_target_name).<(shlib_suffix)'
|
||||
},
|
||||
}],
|
||||
['node_shared=="true" and OS in "aix os400"', {
|
||||
'product_name': 'node_base',
|
||||
}],
|
||||
[ 'node_shared=="true" and OS=="win"', {
|
||||
'sources': [
|
||||
'src/res/node.rc',
|
||||
],
|
||||
}],
|
||||
],
|
||||
}, # node_lib_target_name
|
||||
{ # fuzz_env
|
||||
'target_name': 'fuzz_env',
|
||||
@@ -1209,7 +1268,6 @@
|
||||
'NODE_WANT_INTERNALS=1',
|
||||
],
|
||||
'sources': [
|
||||
'src/node_snapshot_stub.cc',
|
||||
'test/fuzzers/fuzz_env.cc',
|
||||
],
|
||||
'conditions': [
|
||||
@@ -1254,7 +1312,6 @@
|
||||
'NODE_WANT_INTERNALS=1',
|
||||
],
|
||||
'sources': [
|
||||
'src/node_snapshot_stub.cc',
|
||||
'test/fuzzers/fuzz_ClientHelloParser.cc',
|
||||
],
|
||||
'conditions': [
|
||||
@@ -1303,7 +1360,6 @@
|
||||
'NODE_WANT_INTERNALS=1',
|
||||
],
|
||||
'sources': [
|
||||
'src/node_snapshot_stub.cc',
|
||||
'test/fuzzers/fuzz_strings.cc',
|
||||
],
|
||||
'conditions': [
|
||||
@@ -1485,7 +1541,6 @@
|
||||
],
|
||||
|
||||
'sources': [
|
||||
'src/node_snapshot_stub.cc',
|
||||
'test/embedding/embedtest.cc',
|
||||
],
|
||||
|
||||
@@ -1675,7 +1730,7 @@
|
||||
'type': 'executable',
|
||||
|
||||
'dependencies': [
|
||||
'<(node_lib_target_name)',
|
||||
'node_base',
|
||||
],
|
||||
|
||||
'includes': [
|
||||
|
||||
Reference in new issue
Block a user