Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -1900,17 +1896,15 @@ 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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Non-blocking but a couple of lines above, there's also another guard that errors out on --shared for node_snapshot_main, which I think is also fixed by this PR and can be removed?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically yeah, but I haven't tested with node_snapshot_main. Will give it a shot.


# 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.
if options.without_node_code_cache or options.without_node_snapshot or options.node_builtin_modules_path or options.coverage:
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)
Expand Down
239 changes: 149 additions & 90 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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)',
],
},
Expand All @@ -695,15 +703,15 @@
['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',
],
}],
['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',
],
}],
Expand Down Expand Up @@ -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"', {
Expand Down Expand Up @@ -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',
],
Expand All @@ -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',
],
Expand Down Expand Up @@ -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' ],
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -1155,7 +1083,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': {
Expand Down Expand Up @@ -1200,6 +1128,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',
Expand Down Expand Up @@ -1692,7 +1751,7 @@
'type': 'executable',

'dependencies': [
'<(node_lib_target_name)',
'node_base',
],

'includes': [
Expand Down
Loading