2011-08-04 00:01:30 +00:00
|
|
|
{
|
2011-08-04 06:36:27 +00:00
|
|
|
'variables': {
|
2019-01-25 19:03:36 +00:00
|
|
|
'v8_use_siphash%': 0,
|
2017-07-01 00:08:32 +00:00
|
|
|
'v8_trace_maps%': 0,
|
2019-11-13 11:18:10 +00:00
|
|
|
'v8_enable_pointer_compression%': 0,
|
|
|
|
'v8_enable_31bit_smis_on_64bit_arch%': 0,
|
2016-03-23 01:05:54 +00:00
|
|
|
'node_no_browser_globals%': 'false',
|
2022-03-24 13:37:08 +00:00
|
|
|
'node_snapshot_main%': '',
|
2019-04-23 14:21:52 +00:00
|
|
|
'node_use_node_snapshot%': 'false',
|
2016-03-27 00:17:55 +00:00
|
|
|
'node_use_v8_platform%': 'true',
|
|
|
|
'node_use_bundled_v8%': 'true',
|
|
|
|
'node_shared%': 'false',
|
2023-08-24 16:02:26 +00:00
|
|
|
'node_write_snapshot_as_string_literals': 'true',
|
2016-06-29 20:03:18 +00:00
|
|
|
'force_dynamic_crt%': 0,
|
2020-08-13 16:12:44 +00:00
|
|
|
'ossfuzz' : 'false',
|
2016-03-27 00:17:55 +00:00
|
|
|
'node_module_version%': '',
|
2024-08-02 10:37:36 +00:00
|
|
|
'node_use_amaro%': 'true',
|
2018-11-27 01:16:34 +00:00
|
|
|
'node_shared_brotli%': 'false',
|
2012-02-26 23:02:21 +00:00
|
|
|
'node_shared_zlib%': 'false',
|
2012-10-23 13:01:26 +00:00
|
|
|
'node_shared_http_parser%': 'false',
|
2016-03-17 22:25:17 +00:00
|
|
|
'node_shared_cares%': 'false',
|
2012-10-23 23:54:22 +00:00
|
|
|
'node_shared_libuv%': 'false',
|
2024-06-22 23:15:42 +00:00
|
|
|
'node_shared_sqlite%': 'false',
|
2020-11-25 06:49:21 +00:00
|
|
|
'node_shared_uvwasi%': 'false',
|
2017-11-06 08:59:01 +00:00
|
|
|
'node_shared_nghttp2%': 'false',
|
2011-09-04 23:01:53 +00:00
|
|
|
'node_use_openssl%': 'true',
|
2012-06-20 20:31:49 +00:00
|
|
|
'node_shared_openssl%': 'false',
|
2014-03-26 20:30:49 +00:00
|
|
|
'node_v8_options%': '',
|
2022-11-22 08:28:19 +00:00
|
|
|
'node_enable_v8_vtunejit%': 'false',
|
2015-09-29 14:22:00 +00:00
|
|
|
'node_core_target_name%': 'node',
|
2019-04-08 14:48:09 +00:00
|
|
|
'node_lib_target_name%': 'libnode',
|
2017-12-05 00:07:53 +00:00
|
|
|
'node_intermediate_lib_type%': 'static_library',
|
2020-01-11 22:03:59 +00:00
|
|
|
'node_builtin_modules_path%': '',
|
2023-06-24 15:36:14 +00:00
|
|
|
'linked_module_files': [
|
|
|
|
],
|
2023-03-07 16:46:04 +00:00
|
|
|
# We list the deps/ files out instead of globbing them in js2c.cc since we
|
2021-06-17 21:01:41 +00:00
|
|
|
# only include a subset of all the files under these directories.
|
|
|
|
# The lengths of their file names combined should not exceed the
|
|
|
|
# Windows command length limit or there would be an error.
|
|
|
|
# See https://docs.microsoft.com/en-us/troubleshoot/windows-client/shell-experience/command-line-string-limitation
|
2011-09-04 23:01:53 +00:00
|
|
|
'library_files': [
|
2021-07-07 16:19:00 +00:00
|
|
|
'<@(node_library_files)',
|
2023-06-24 15:36:14 +00:00
|
|
|
'<@(linked_module_files)',
|
2021-06-17 21:01:41 +00:00
|
|
|
],
|
|
|
|
'deps_files': [
|
2021-01-30 22:19:13 +00:00
|
|
|
'deps/v8/tools/splaytree.mjs',
|
|
|
|
'deps/v8/tools/codemap.mjs',
|
|
|
|
'deps/v8/tools/consarray.mjs',
|
|
|
|
'deps/v8/tools/csvparser.mjs',
|
|
|
|
'deps/v8/tools/profile.mjs',
|
|
|
|
'deps/v8/tools/profile_view.mjs',
|
|
|
|
'deps/v8/tools/logreader.mjs',
|
|
|
|
'deps/v8/tools/arguments.mjs',
|
|
|
|
'deps/v8/tools/tickprocessor.mjs',
|
|
|
|
'deps/v8/tools/sourcemap.mjs',
|
|
|
|
'deps/v8/tools/tickprocessor-driver.mjs',
|
2019-01-31 07:36:48 +00:00
|
|
|
'deps/acorn/acorn/dist/acorn.js',
|
|
|
|
'deps/acorn/acorn-walk/dist/walk.js',
|
2023-04-08 21:16:13 +00:00
|
|
|
'deps/minimatch/index.js',
|
2022-08-24 02:41:29 +00:00
|
|
|
'<@(node_builtin_shareable_builtins)',
|
2011-09-04 23:01:53 +00:00
|
|
|
],
|
2023-03-04 11:59:55 +00:00
|
|
|
'node_sources': [
|
|
|
|
'src/api/async_resource.cc',
|
|
|
|
'src/api/callback.cc',
|
|
|
|
'src/api/embed_helpers.cc',
|
|
|
|
'src/api/encoding.cc',
|
|
|
|
'src/api/environment.cc',
|
|
|
|
'src/api/exceptions.cc',
|
|
|
|
'src/api/hooks.cc',
|
|
|
|
'src/api/utils.cc',
|
2024-08-02 19:44:20 +00:00
|
|
|
'src/async_context_frame.cc',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/async_wrap.cc',
|
|
|
|
'src/base_object.cc',
|
|
|
|
'src/cares_wrap.cc',
|
|
|
|
'src/cleanup_queue.cc',
|
module: implement NODE_COMPILE_CACHE for automatic on-disk code caching
This patch implements automatic on-disk code caching that can be enabled
via an environment variable NODE_COMPILE_CACHE.
When set, whenever Node.js compiles a CommonJS or a ECMAScript Module,
it will use on-disk [V8 code cache][] persisted in the specified
directory to speed up the compilation. This may slow down the first
load of a module graph, but subsequent loads of the same module graph
may get a significant speedup if the contents of the modules do not
change. Locally, this speeds up loading of
test/fixtures/snapshot/typescript.js from ~130ms to ~80ms.
To clean up the generated code cache, simply remove the directory.
It will be recreated the next time the same directory is used for
`NODE_COMPILE_CACHE`.
Compilation cache generated by one version of Node.js may not be used
by a different version of Node.js. Cache generated by different versions
of Node.js will be stored separately if the same directory is used
to persist the cache, so they can co-exist.
Caveat: currently when using this with V8 JavaScript code coverage, the
coverage being collected by V8 may be less precise in functions that are
deserialized from the code cache. It's recommended to turn this off when
running tests to generate precise coverage.
Implementation details:
There is one cache file per module on disk. The directory layout
is:
- Compile cache directory (from NODE_COMPILE_CACHE)
- 8b23c8fe: CRC32 hash of CachedDataVersionTag + NODE_VERESION
- 2ea3424d:
- 10860e5a: CRC32 hash of filename + module type
- 431e9adc: ...
- ...
Inside the cache file, there is a header followed by the actual
cache content:
```
[uint32_t] code size
[uint32_t] code hash
[uint32_t] cache size
[uint32_t] cache hash
... compile cache content ...
```
When reading the cache file, we'll also check if the code size
and code hash match the code that the module loader is loading
and whether the cache size and cache hash match the file content
read. If they don't match, or if V8 rejects the cache passed,
we'll ignore the mismatch cache, and regenerate the cache after
compilation succeeds and rewrite it to disk.
PR-URL: https://github.com/nodejs/node/pull/52535
Refs: https://github.com/nodejs/node/issues/47472
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
2024-02-29 01:09:16 +00:00
|
|
|
'src/compile_cache.cc',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/connect_wrap.cc',
|
|
|
|
'src/connection_wrap.cc',
|
|
|
|
'src/dataqueue/queue.cc',
|
|
|
|
'src/debug_utils.cc',
|
2024-02-17 17:09:24 +00:00
|
|
|
'src/embedded_data.cc',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/encoding_binding.cc',
|
|
|
|
'src/env.cc',
|
|
|
|
'src/fs_event_wrap.cc',
|
|
|
|
'src/handle_wrap.cc',
|
|
|
|
'src/heap_utils.cc',
|
|
|
|
'src/histogram.cc',
|
2024-03-02 22:11:30 +00:00
|
|
|
'src/internal_only_v8.cc',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/js_native_api.h',
|
|
|
|
'src/js_native_api_types.h',
|
|
|
|
'src/js_native_api_v8.cc',
|
|
|
|
'src/js_native_api_v8.h',
|
|
|
|
'src/js_native_api_v8_internals.h',
|
|
|
|
'src/js_stream.cc',
|
|
|
|
'src/json_utils.cc',
|
|
|
|
'src/js_udp_wrap.cc',
|
2023-04-09 18:31:15 +00:00
|
|
|
'src/json_parser.h',
|
|
|
|
'src/json_parser.cc',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/module_wrap.cc',
|
|
|
|
'src/node.cc',
|
|
|
|
'src/node_api.cc',
|
|
|
|
'src/node_binding.cc',
|
|
|
|
'src/node_blob.cc',
|
|
|
|
'src/node_buffer.cc',
|
|
|
|
'src/node_builtins.cc',
|
|
|
|
'src/node_config.cc',
|
|
|
|
'src/node_constants.cc',
|
|
|
|
'src/node_contextify.cc',
|
|
|
|
'src/node_credentials.cc',
|
2024-08-13 12:37:02 +00:00
|
|
|
'src/node_debug.cc',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/node_dir.cc',
|
2023-08-17 14:08:05 +00:00
|
|
|
'src/node_dotenv.cc',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/node_env_var.cc',
|
|
|
|
'src/node_errors.cc',
|
|
|
|
'src/node_external_reference.cc',
|
|
|
|
'src/node_file.cc',
|
|
|
|
'src/node_http_parser.cc',
|
|
|
|
'src/node_http2.cc',
|
|
|
|
'src/node_i18n.cc',
|
|
|
|
'src/node_main_instance.cc',
|
|
|
|
'src/node_messaging.cc',
|
|
|
|
'src/node_metadata.cc',
|
2023-10-25 21:51:27 +00:00
|
|
|
'src/node_modules.cc',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/node_options.cc',
|
|
|
|
'src/node_os.cc',
|
|
|
|
'src/node_perf.cc',
|
|
|
|
'src/node_platform.cc',
|
|
|
|
'src/node_postmortem_metadata.cc',
|
|
|
|
'src/node_process_events.cc',
|
|
|
|
'src/node_process_methods.cc',
|
|
|
|
'src/node_process_object.cc',
|
|
|
|
'src/node_realm.cc',
|
|
|
|
'src/node_report.cc',
|
|
|
|
'src/node_report_module.cc',
|
|
|
|
'src/node_report_utils.cc',
|
|
|
|
'src/node_sea.cc',
|
|
|
|
'src/node_serdes.cc',
|
|
|
|
'src/node_shadow_realm.cc',
|
|
|
|
'src/node_snapshotable.cc',
|
|
|
|
'src/node_sockaddr.cc',
|
2024-07-09 20:33:38 +00:00
|
|
|
'src/node_sqlite.cc',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/node_stat_watcher.cc',
|
|
|
|
'src/node_symbols.cc',
|
|
|
|
'src/node_task_queue.cc',
|
2024-05-02 19:54:02 +00:00
|
|
|
'src/node_task_runner.cc',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/node_trace_events.cc',
|
|
|
|
'src/node_types.cc',
|
|
|
|
'src/node_url.cc',
|
|
|
|
'src/node_util.cc',
|
|
|
|
'src/node_v8.cc',
|
|
|
|
'src/node_wasi.cc',
|
|
|
|
'src/node_wasm_web_api.cc',
|
|
|
|
'src/node_watchdog.cc',
|
2023-09-15 14:32:14 +00:00
|
|
|
'src/node_webstorage.cc',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/node_worker.cc',
|
|
|
|
'src/node_zlib.cc',
|
2023-12-30 13:46:27 +00:00
|
|
|
'src/path.cc',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/permission/child_process_permission.cc',
|
|
|
|
'src/permission/fs_permission.cc',
|
2023-05-07 16:22:32 +00:00
|
|
|
'src/permission/inspector_permission.cc',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/permission/permission.cc',
|
2024-06-01 13:13:12 +00:00
|
|
|
'src/permission/wasi_permission.cc',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/permission/worker_permission.cc',
|
|
|
|
'src/pipe_wrap.cc',
|
|
|
|
'src/process_wrap.cc',
|
|
|
|
'src/signal_wrap.cc',
|
|
|
|
'src/spawn_sync.cc',
|
|
|
|
'src/stream_base.cc',
|
|
|
|
'src/stream_pipe.cc',
|
|
|
|
'src/stream_wrap.cc',
|
|
|
|
'src/string_bytes.cc',
|
|
|
|
'src/string_decoder.cc',
|
|
|
|
'src/tcp_wrap.cc',
|
|
|
|
'src/timers.cc',
|
|
|
|
'src/timer_wrap.cc',
|
|
|
|
'src/tracing/agent.cc',
|
|
|
|
'src/tracing/node_trace_buffer.cc',
|
|
|
|
'src/tracing/node_trace_writer.cc',
|
|
|
|
'src/tracing/trace_event.cc',
|
|
|
|
'src/tracing/traced_value.cc',
|
|
|
|
'src/tty_wrap.cc',
|
|
|
|
'src/udp_wrap.cc',
|
|
|
|
'src/util.cc',
|
|
|
|
'src/uv.cc',
|
|
|
|
# headers to make for a more pleasant IDE experience
|
|
|
|
'src/aliased_buffer.h',
|
|
|
|
'src/aliased_buffer-inl.h',
|
|
|
|
'src/aliased_struct.h',
|
|
|
|
'src/aliased_struct-inl.h',
|
2024-08-02 19:44:20 +00:00
|
|
|
'src/async_context_frame.h',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/async_wrap.h',
|
|
|
|
'src/async_wrap-inl.h',
|
|
|
|
'src/base_object.h',
|
|
|
|
'src/base_object-inl.h',
|
|
|
|
'src/base_object_types.h',
|
2023-05-09 07:45:20 +00:00
|
|
|
'src/blob_serializer_deserializer.h',
|
|
|
|
'src/blob_serializer_deserializer-inl.h',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/callback_queue.h',
|
|
|
|
'src/callback_queue-inl.h',
|
|
|
|
'src/cleanup_queue.h',
|
|
|
|
'src/cleanup_queue-inl.h',
|
module: implement NODE_COMPILE_CACHE for automatic on-disk code caching
This patch implements automatic on-disk code caching that can be enabled
via an environment variable NODE_COMPILE_CACHE.
When set, whenever Node.js compiles a CommonJS or a ECMAScript Module,
it will use on-disk [V8 code cache][] persisted in the specified
directory to speed up the compilation. This may slow down the first
load of a module graph, but subsequent loads of the same module graph
may get a significant speedup if the contents of the modules do not
change. Locally, this speeds up loading of
test/fixtures/snapshot/typescript.js from ~130ms to ~80ms.
To clean up the generated code cache, simply remove the directory.
It will be recreated the next time the same directory is used for
`NODE_COMPILE_CACHE`.
Compilation cache generated by one version of Node.js may not be used
by a different version of Node.js. Cache generated by different versions
of Node.js will be stored separately if the same directory is used
to persist the cache, so they can co-exist.
Caveat: currently when using this with V8 JavaScript code coverage, the
coverage being collected by V8 may be less precise in functions that are
deserialized from the code cache. It's recommended to turn this off when
running tests to generate precise coverage.
Implementation details:
There is one cache file per module on disk. The directory layout
is:
- Compile cache directory (from NODE_COMPILE_CACHE)
- 8b23c8fe: CRC32 hash of CachedDataVersionTag + NODE_VERESION
- 2ea3424d:
- 10860e5a: CRC32 hash of filename + module type
- 431e9adc: ...
- ...
Inside the cache file, there is a header followed by the actual
cache content:
```
[uint32_t] code size
[uint32_t] code hash
[uint32_t] cache size
[uint32_t] cache hash
... compile cache content ...
```
When reading the cache file, we'll also check if the code size
and code hash match the code that the module loader is loading
and whether the cache size and cache hash match the file content
read. If they don't match, or if V8 rejects the cache passed,
we'll ignore the mismatch cache, and regenerate the cache after
compilation succeeds and rewrite it to disk.
PR-URL: https://github.com/nodejs/node/pull/52535
Refs: https://github.com/nodejs/node/issues/47472
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
2024-02-29 01:09:16 +00:00
|
|
|
'src/compile_cache.h',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/connect_wrap.h',
|
|
|
|
'src/connection_wrap.h',
|
2023-12-02 17:15:24 +00:00
|
|
|
'src/cppgc_helpers.h',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/dataqueue/queue.h',
|
|
|
|
'src/debug_utils.h',
|
|
|
|
'src/debug_utils-inl.h',
|
2024-04-29 11:06:04 +00:00
|
|
|
'src/embedded_data.h',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/encoding_binding.h',
|
|
|
|
'src/env_properties.h',
|
|
|
|
'src/env.h',
|
|
|
|
'src/env-inl.h',
|
|
|
|
'src/handle_wrap.h',
|
|
|
|
'src/histogram.h',
|
|
|
|
'src/histogram-inl.h',
|
|
|
|
'src/js_stream.h',
|
|
|
|
'src/json_utils.h',
|
|
|
|
'src/large_pages/node_large_page.cc',
|
|
|
|
'src/large_pages/node_large_page.h',
|
|
|
|
'src/memory_tracker.h',
|
|
|
|
'src/memory_tracker-inl.h',
|
|
|
|
'src/module_wrap.h',
|
|
|
|
'src/node.h',
|
|
|
|
'src/node_api.h',
|
|
|
|
'src/node_api_types.h',
|
|
|
|
'src/node_binding.h',
|
|
|
|
'src/node_blob.h',
|
|
|
|
'src/node_buffer.h',
|
|
|
|
'src/node_builtins.h',
|
|
|
|
'src/node_constants.h',
|
|
|
|
'src/node_context_data.h',
|
|
|
|
'src/node_contextify.h',
|
2024-08-13 12:37:02 +00:00
|
|
|
'src/node_debug.h',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/node_dir.h',
|
2023-08-17 14:08:05 +00:00
|
|
|
'src/node_dotenv.h',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/node_errors.h',
|
|
|
|
'src/node_exit_code.h',
|
|
|
|
'src/node_external_reference.h',
|
|
|
|
'src/node_file.h',
|
|
|
|
'src/node_file-inl.h',
|
|
|
|
'src/node_http_common.h',
|
|
|
|
'src/node_http_common-inl.h',
|
|
|
|
'src/node_http2.h',
|
|
|
|
'src/node_http2_state.h',
|
|
|
|
'src/node_i18n.h',
|
|
|
|
'src/node_internals.h',
|
|
|
|
'src/node_main_instance.h',
|
|
|
|
'src/node_mem.h',
|
|
|
|
'src/node_mem-inl.h',
|
|
|
|
'src/node_messaging.h',
|
|
|
|
'src/node_metadata.h',
|
|
|
|
'src/node_mutex.h',
|
2023-10-25 21:51:27 +00:00
|
|
|
'src/node_modules.h',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/node_object_wrap.h',
|
|
|
|
'src/node_options.h',
|
|
|
|
'src/node_options-inl.h',
|
|
|
|
'src/node_perf.h',
|
|
|
|
'src/node_perf_common.h',
|
|
|
|
'src/node_platform.h',
|
|
|
|
'src/node_process.h',
|
|
|
|
'src/node_process-inl.h',
|
|
|
|
'src/node_realm.h',
|
|
|
|
'src/node_realm-inl.h',
|
|
|
|
'src/node_report.h',
|
|
|
|
'src/node_revert.h',
|
|
|
|
'src/node_root_certs.h',
|
|
|
|
'src/node_sea.h',
|
|
|
|
'src/node_shadow_realm.h',
|
|
|
|
'src/node_snapshotable.h',
|
|
|
|
'src/node_snapshot_builder.h',
|
|
|
|
'src/node_sockaddr.h',
|
|
|
|
'src/node_sockaddr-inl.h',
|
2024-07-09 20:33:38 +00:00
|
|
|
'src/node_sqlite.h',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/node_stat_watcher.h',
|
|
|
|
'src/node_union_bytes.h',
|
|
|
|
'src/node_url.h',
|
|
|
|
'src/node_version.h',
|
|
|
|
'src/node_v8.h',
|
|
|
|
'src/node_v8_platform-inl.h',
|
|
|
|
'src/node_wasi.h',
|
|
|
|
'src/node_watchdog.h',
|
2023-09-15 14:32:14 +00:00
|
|
|
'src/node_webstorage.h',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/node_worker.h',
|
2023-12-30 13:46:27 +00:00
|
|
|
'src/path.h',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/permission/child_process_permission.h',
|
|
|
|
'src/permission/fs_permission.h',
|
2023-05-07 16:22:32 +00:00
|
|
|
'src/permission/inspector_permission.h',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/permission/permission.h',
|
2024-06-01 13:13:12 +00:00
|
|
|
'src/permission/wasi_permission.h',
|
2023-03-04 11:59:55 +00:00
|
|
|
'src/permission/worker_permission.h',
|
|
|
|
'src/pipe_wrap.h',
|
|
|
|
'src/req_wrap.h',
|
|
|
|
'src/req_wrap-inl.h',
|
|
|
|
'src/spawn_sync.h',
|
|
|
|
'src/stream_base.h',
|
|
|
|
'src/stream_base-inl.h',
|
|
|
|
'src/stream_pipe.h',
|
|
|
|
'src/stream_wrap.h',
|
|
|
|
'src/string_bytes.h',
|
|
|
|
'src/string_decoder.h',
|
|
|
|
'src/string_decoder-inl.h',
|
|
|
|
'src/tcp_wrap.h',
|
|
|
|
'src/timers.h',
|
|
|
|
'src/tracing/agent.h',
|
|
|
|
'src/tracing/node_trace_buffer.h',
|
|
|
|
'src/tracing/node_trace_writer.h',
|
|
|
|
'src/tracing/trace_event.h',
|
|
|
|
'src/tracing/trace_event_common.h',
|
|
|
|
'src/tracing/traced_value.h',
|
|
|
|
'src/timer_wrap.h',
|
|
|
|
'src/timer_wrap-inl.h',
|
|
|
|
'src/tty_wrap.h',
|
|
|
|
'src/udp_wrap.h',
|
|
|
|
'src/util.h',
|
|
|
|
'src/util-inl.h',
|
|
|
|
],
|
|
|
|
'node_crypto_sources': [
|
|
|
|
'src/crypto/crypto_aes.cc',
|
|
|
|
'src/crypto/crypto_bio.cc',
|
|
|
|
'src/crypto/crypto_common.cc',
|
|
|
|
'src/crypto/crypto_dsa.cc',
|
|
|
|
'src/crypto/crypto_hkdf.cc',
|
|
|
|
'src/crypto/crypto_pbkdf2.cc',
|
|
|
|
'src/crypto/crypto_sig.cc',
|
|
|
|
'src/crypto/crypto_timing.cc',
|
|
|
|
'src/crypto/crypto_cipher.cc',
|
|
|
|
'src/crypto/crypto_context.cc',
|
|
|
|
'src/crypto/crypto_ec.cc',
|
|
|
|
'src/crypto/crypto_hmac.cc',
|
|
|
|
'src/crypto/crypto_random.cc',
|
|
|
|
'src/crypto/crypto_rsa.cc',
|
|
|
|
'src/crypto/crypto_spkac.cc',
|
|
|
|
'src/crypto/crypto_util.cc',
|
|
|
|
'src/crypto/crypto_clienthello.cc',
|
|
|
|
'src/crypto/crypto_dh.cc',
|
|
|
|
'src/crypto/crypto_hash.cc',
|
|
|
|
'src/crypto/crypto_keys.cc',
|
|
|
|
'src/crypto/crypto_keygen.cc',
|
|
|
|
'src/crypto/crypto_scrypt.cc',
|
|
|
|
'src/crypto/crypto_tls.cc',
|
|
|
|
'src/crypto/crypto_x509.cc',
|
|
|
|
'src/crypto/crypto_bio.h',
|
|
|
|
'src/crypto/crypto_clienthello-inl.h',
|
|
|
|
'src/crypto/crypto_dh.h',
|
|
|
|
'src/crypto/crypto_hmac.h',
|
|
|
|
'src/crypto/crypto_rsa.h',
|
|
|
|
'src/crypto/crypto_spkac.h',
|
|
|
|
'src/crypto/crypto_util.h',
|
|
|
|
'src/crypto/crypto_cipher.h',
|
|
|
|
'src/crypto/crypto_common.h',
|
|
|
|
'src/crypto/crypto_dsa.h',
|
|
|
|
'src/crypto/crypto_hash.h',
|
|
|
|
'src/crypto/crypto_keys.h',
|
|
|
|
'src/crypto/crypto_keygen.h',
|
|
|
|
'src/crypto/crypto_scrypt.h',
|
|
|
|
'src/crypto/crypto_tls.h',
|
|
|
|
'src/crypto/crypto_clienthello.h',
|
|
|
|
'src/crypto/crypto_context.h',
|
|
|
|
'src/crypto/crypto_ec.h',
|
|
|
|
'src/crypto/crypto_hkdf.h',
|
|
|
|
'src/crypto/crypto_pbkdf2.h',
|
|
|
|
'src/crypto/crypto_sig.h',
|
|
|
|
'src/crypto/crypto_random.h',
|
|
|
|
'src/crypto/crypto_timing.h',
|
|
|
|
'src/crypto/crypto_x509.h',
|
|
|
|
'src/node_crypto.cc',
|
|
|
|
'src/node_crypto.h',
|
|
|
|
],
|
2023-03-26 22:05:44 +00:00
|
|
|
'node_quic_sources': [
|
2023-05-08 23:14:20 +00:00
|
|
|
'src/quic/application.cc',
|
2023-03-30 02:13:48 +00:00
|
|
|
'src/quic/bindingdata.cc',
|
2023-03-26 22:05:44 +00:00
|
|
|
'src/quic/cid.cc',
|
|
|
|
'src/quic/data.cc',
|
2023-05-08 23:14:20 +00:00
|
|
|
'src/quic/endpoint.cc',
|
2023-12-27 22:03:38 +00:00
|
|
|
'src/quic/http3.cc',
|
2023-03-30 02:13:48 +00:00
|
|
|
'src/quic/logstream.cc',
|
2023-04-01 00:58:57 +00:00
|
|
|
'src/quic/packet.cc',
|
2023-03-26 22:05:44 +00:00
|
|
|
'src/quic/preferredaddress.cc',
|
2023-05-08 23:14:20 +00:00
|
|
|
'src/quic/session.cc',
|
2023-03-28 06:19:27 +00:00
|
|
|
'src/quic/sessionticket.cc',
|
2023-05-08 23:14:20 +00:00
|
|
|
'src/quic/streams.cc',
|
2023-04-01 00:58:57 +00:00
|
|
|
'src/quic/tlscontext.cc',
|
2023-03-28 06:19:27 +00:00
|
|
|
'src/quic/tokens.cc',
|
2023-03-30 02:13:48 +00:00
|
|
|
'src/quic/transportparams.cc',
|
2023-05-08 23:14:20 +00:00
|
|
|
'src/quic/application.h',
|
2023-03-30 02:13:48 +00:00
|
|
|
'src/quic/bindingdata.h',
|
2023-03-26 22:05:44 +00:00
|
|
|
'src/quic/cid.h',
|
|
|
|
'src/quic/data.h',
|
2023-05-08 23:14:20 +00:00
|
|
|
'src/quic/endpoint.h',
|
2023-12-27 22:03:38 +00:00
|
|
|
'src/quic/http3.h',
|
2023-03-30 02:13:48 +00:00
|
|
|
'src/quic/logstream.h',
|
2023-04-01 00:58:57 +00:00
|
|
|
'src/quic/packet.h',
|
2023-03-26 22:05:44 +00:00
|
|
|
'src/quic/preferredaddress.h',
|
2023-05-08 23:14:20 +00:00
|
|
|
'src/quic/session.h',
|
2023-03-28 06:19:27 +00:00
|
|
|
'src/quic/sessionticket.h',
|
2023-05-08 23:14:20 +00:00
|
|
|
'src/quic/streams.h',
|
2023-04-01 00:58:57 +00:00
|
|
|
'src/quic/tlscontext.h',
|
2023-03-28 06:19:27 +00:00
|
|
|
'src/quic/tokens.h',
|
2023-03-30 02:13:48 +00:00
|
|
|
'src/quic/transportparams.h',
|
2023-12-09 21:27:50 +00:00
|
|
|
'src/quic/quic.cc',
|
2023-03-26 22:05:44 +00:00
|
|
|
],
|
2023-09-08 11:26:00 +00:00
|
|
|
'node_cctest_sources': [
|
|
|
|
'src/node_snapshot_stub.cc',
|
|
|
|
'test/cctest/node_test_fixture.cc',
|
|
|
|
'test/cctest/node_test_fixture.h',
|
|
|
|
'test/cctest/test_aliased_buffer.cc',
|
|
|
|
'test/cctest/test_base64.cc',
|
|
|
|
'test/cctest/test_base_object_ptr.cc',
|
|
|
|
'test/cctest/test_cppgc.cc',
|
|
|
|
'test/cctest/test_node_postmortem_metadata.cc',
|
2024-05-02 19:54:02 +00:00
|
|
|
'test/cctest/test_node_task_runner.cc',
|
2023-09-08 11:26:00 +00:00
|
|
|
'test/cctest/test_environment.cc',
|
|
|
|
'test/cctest/test_linked_binding.cc',
|
|
|
|
'test/cctest/test_node_api.cc',
|
2024-03-21 14:36:40 +00:00
|
|
|
'test/cctest/test_path.cc',
|
2023-09-08 11:26:00 +00:00
|
|
|
'test/cctest/test_per_process.cc',
|
|
|
|
'test/cctest/test_platform.cc',
|
|
|
|
'test/cctest/test_report.cc',
|
|
|
|
'test/cctest/test_json_utils.cc',
|
|
|
|
'test/cctest/test_sockaddr.cc',
|
|
|
|
'test/cctest/test_traced_value.cc',
|
|
|
|
'test/cctest/test_util.cc',
|
|
|
|
'test/cctest/test_dataqueue.cc',
|
|
|
|
],
|
|
|
|
'node_cctest_openssl_sources': [
|
|
|
|
'test/cctest/test_crypto_clienthello.cc',
|
|
|
|
'test/cctest/test_node_crypto.cc',
|
|
|
|
'test/cctest/test_node_crypto_env.cc',
|
|
|
|
'test/cctest/test_quic_cid.cc',
|
2023-12-31 00:45:40 +00:00
|
|
|
'test/cctest/test_quic_error.cc',
|
2023-09-08 11:26:00 +00:00
|
|
|
'test/cctest/test_quic_tokens.cc',
|
|
|
|
],
|
|
|
|
'node_cctest_inspector_sources': [
|
|
|
|
'test/cctest/test_inspector_socket.cc',
|
|
|
|
'test/cctest/test_inspector_socket_server.cc',
|
|
|
|
],
|
2019-04-18 14:09:28 +00:00
|
|
|
'node_mksnapshot_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)node_mksnapshot<(EXECUTABLE_SUFFIX)',
|
2023-03-07 16:46:04 +00:00
|
|
|
'node_js2c_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)node_js2c<(EXECUTABLE_SUFFIX)',
|
2016-03-27 00:17:55 +00:00
|
|
|
'conditions': [
|
2020-03-03 20:02:02 +00:00
|
|
|
['GENERATOR == "ninja"', {
|
|
|
|
'node_text_start_object_path': 'src/large_pages/node_text_start.node_text_start.o'
|
|
|
|
}, {
|
|
|
|
'node_text_start_object_path': 'node_text_start/src/large_pages/node_text_start.o'
|
|
|
|
}],
|
2016-03-27 00:17:55 +00:00
|
|
|
[ 'node_shared=="true"', {
|
|
|
|
'node_target_type%': 'shared_library',
|
2017-12-05 00:07:53 +00:00
|
|
|
'conditions': [
|
2023-02-22 04:18:56 +00:00
|
|
|
['OS in "aix os400"', {
|
2017-12-05 00:07:53 +00:00
|
|
|
# For AIX, always generate static library first,
|
|
|
|
# It needs an extra step to generate exp and
|
|
|
|
# then use both static lib and exp to create
|
|
|
|
# shared lib.
|
|
|
|
'node_intermediate_lib_type': 'static_library',
|
|
|
|
}, {
|
|
|
|
'node_intermediate_lib_type': 'shared_library',
|
|
|
|
}],
|
|
|
|
],
|
2016-03-27 00:17:55 +00:00
|
|
|
}, {
|
|
|
|
'node_target_type%': 'executable',
|
|
|
|
}],
|
2016-04-18 14:10:20 +00:00
|
|
|
[ 'OS=="win" and '
|
|
|
|
'node_use_openssl=="true" and '
|
|
|
|
'node_shared_openssl=="false"', {
|
2018-10-19 19:09:00 +00:00
|
|
|
'use_openssl_def%': 1,
|
2016-04-18 14:10:20 +00:00
|
|
|
}, {
|
2018-10-19 19:09:00 +00:00
|
|
|
'use_openssl_def%': 0,
|
2016-04-18 14:10:20 +00:00
|
|
|
}],
|
2016-03-27 00:17:55 +00:00
|
|
|
],
|
2011-08-04 06:36:27 +00:00
|
|
|
},
|
|
|
|
|
2019-04-06 18:22:45 +00:00
|
|
|
'target_defaults': {
|
|
|
|
# Putting these explicitly here so not to depend on `common.gypi`.
|
|
|
|
# `common.gypi` need to be more general because it is used to build userland native addons.
|
|
|
|
# Refs: https://github.com/nodejs/node-gyp/issues/1118
|
|
|
|
'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ],
|
|
|
|
'xcode_settings': {
|
|
|
|
'WARNING_CFLAGS': [
|
|
|
|
'-Wall',
|
|
|
|
'-Wendif-labels',
|
|
|
|
'-W',
|
|
|
|
'-Wno-unused-parameter',
|
|
|
|
'-Werror=undefined-inline',
|
2023-01-13 01:41:46 +00:00
|
|
|
'-Werror=extra-semi',
|
2019-04-06 18:22:45 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
|
2019-05-19 18:48:30 +00:00
|
|
|
'conditions': [
|
2024-09-04 07:14:16 +00:00
|
|
|
['clang==0 and OS!="win"', {
|
|
|
|
'cflags': [ '-Wno-restrict', ],
|
|
|
|
}],
|
2024-04-24 06:30:02 +00:00
|
|
|
# Pointer authentication for ARM64.
|
2023-12-27 06:19:24 +00:00
|
|
|
['target_arch=="arm64"', {
|
2024-04-24 06:30:02 +00:00
|
|
|
'target_conditions': [
|
|
|
|
['_toolset=="host"', {
|
|
|
|
'conditions': [
|
|
|
|
['host_arch=="arm64"', {
|
|
|
|
'cflags': ['-mbranch-protection=standard'],
|
|
|
|
}],
|
|
|
|
],
|
|
|
|
}],
|
|
|
|
['_toolset=="target"', {
|
|
|
|
'cflags': ['-mbranch-protection=standard'],
|
|
|
|
}],
|
|
|
|
],
|
2023-12-27 06:19:24 +00:00
|
|
|
}],
|
2023-02-22 04:18:56 +00:00
|
|
|
['OS in "aix os400"', {
|
2019-05-19 18:48:30 +00:00
|
|
|
'ldflags': [
|
|
|
|
'-Wl,-bnoerrmsg',
|
|
|
|
],
|
|
|
|
}],
|
2024-05-07 11:55:58 +00:00
|
|
|
['OS=="linux" and clang==1', {
|
2019-06-14 21:03:48 +00:00
|
|
|
'libraries': ['-latomic'],
|
|
|
|
}],
|
2019-05-19 18:48:30 +00:00
|
|
|
],
|
2019-04-06 18:22:45 +00:00
|
|
|
},
|
|
|
|
|
2011-08-04 00:01:30 +00:00
|
|
|
'targets': [
|
2020-02-27 00:21:41 +00:00
|
|
|
{
|
|
|
|
'target_name': 'node_text_start',
|
|
|
|
'type': 'none',
|
|
|
|
'conditions': [
|
2020-07-12 04:52:46 +00:00
|
|
|
[ 'OS in "linux freebsd solaris" and '
|
2020-02-27 00:21:41 +00:00
|
|
|
'target_arch=="x64"', {
|
|
|
|
'type': 'static_library',
|
|
|
|
'sources': [
|
|
|
|
'src/large_pages/node_text_start.S'
|
|
|
|
]
|
|
|
|
}],
|
|
|
|
]
|
|
|
|
},
|
2011-08-04 00:01:30 +00:00
|
|
|
{
|
2015-09-29 14:22:00 +00:00
|
|
|
'target_name': '<(node_core_target_name)',
|
2017-12-05 00:07:53 +00:00
|
|
|
'type': 'executable',
|
2019-04-07 19:02:04 +00:00
|
|
|
|
|
|
|
'defines': [
|
2020-03-13 02:20:36 +00:00
|
|
|
'NODE_ARCH="<(target_arch)"',
|
|
|
|
'NODE_PLATFORM="<(OS)"',
|
2019-04-07 19:02:04 +00:00
|
|
|
'NODE_WANT_INTERNALS=1',
|
2017-12-05 00:07:53 +00:00
|
|
|
],
|
2019-04-07 19:02:04 +00:00
|
|
|
|
2018-03-07 20:25:26 +00:00
|
|
|
'includes': [
|
|
|
|
'node.gypi'
|
|
|
|
],
|
2019-04-07 19:02:04 +00:00
|
|
|
|
2017-12-05 00:07:53 +00:00
|
|
|
'include_dirs': [
|
|
|
|
'src',
|
2023-02-18 02:49:18 +00:00
|
|
|
'deps/v8/include',
|
|
|
|
'deps/postject'
|
2017-12-05 00:07:53 +00:00
|
|
|
],
|
2019-04-07 19:02:04 +00:00
|
|
|
|
|
|
|
'sources': [
|
|
|
|
'src/node_main.cc'
|
|
|
|
],
|
|
|
|
|
2019-09-04 21:56:51 +00:00
|
|
|
'dependencies': [
|
|
|
|
'deps/histogram/histogram.gyp:histogram',
|
|
|
|
],
|
2018-09-04 02:00:09 +00:00
|
|
|
|
2019-02-03 20:51:20 +00:00
|
|
|
'msvs_settings': {
|
|
|
|
'VCLinkerTool': {
|
|
|
|
'GenerateMapFile': 'true', # /MAP
|
|
|
|
'MapExports': 'true', # /MAPINFO:EXPORTS
|
|
|
|
'RandomizedBaseAddress': 2, # enable ASLR
|
|
|
|
'DataExecutionPrevention': 2, # enable DEP
|
|
|
|
'AllowIsolation': 'true',
|
2022-07-02 16:38:11 +00:00
|
|
|
# By default, the MSVC linker only reserves 1 MiB of stack memory for
|
|
|
|
# each thread, whereas other platforms typically allow much larger
|
|
|
|
# stack memory sections. We raise the limit to make it more consistent
|
|
|
|
# across platforms and to support the few use cases that require large
|
|
|
|
# amounts of stack memory, without having to modify the node binary.
|
|
|
|
'StackReserveSize': 0x800000,
|
2019-02-03 20:51:20 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2018-09-04 02:00:09 +00:00
|
|
|
# - "C4244: conversion from 'type1' to 'type2', possible loss of data"
|
|
|
|
# Ususaly safe. Disable for `dep`, enable for `src`
|
|
|
|
'msvs_disabled_warnings!': [4244],
|
|
|
|
|
2017-12-05 00:07:53 +00:00
|
|
|
'conditions': [
|
2020-04-06 12:17:57 +00:00
|
|
|
[ 'error_on_warn=="true"', {
|
|
|
|
'cflags': ['-Werror'],
|
2020-05-11 18:42:52 +00:00
|
|
|
'xcode_settings': {
|
|
|
|
'WARNING_CFLAGS': [ '-Werror' ],
|
|
|
|
},
|
2020-04-06 12:17:57 +00:00
|
|
|
}],
|
2017-12-05 00:07:53 +00:00
|
|
|
[ 'node_intermediate_lib_type=="static_library" and '
|
2023-02-22 04:18:56 +00:00
|
|
|
'node_shared=="true" and OS in "aix os400"', {
|
2017-12-05 00:07:53 +00:00
|
|
|
# For AIX, shared lib is linked by static lib and .exp. In the
|
|
|
|
# case here, the executable needs to link to shared lib.
|
|
|
|
# Therefore, use 'node_aix_shared' target to generate the
|
|
|
|
# shared lib and then executable.
|
|
|
|
'dependencies': [ 'node_aix_shared' ],
|
|
|
|
}, {
|
|
|
|
'dependencies': [ '<(node_lib_target_name)' ],
|
build: fix various shared library build issues
Node.js unofficially supports a shared library variant where the
main node executable is a thin wrapper around node.dll/libnode.so.
The key benefit of this is to support embedding Node.js in other
applications.
Since Node.js 12 there have been a number of issues preventing the
shared library build from working correctly, primarily on Windows:
* A number of functions used executables such as `mksnapshot` are
not exported from `libnode.dll` using a `NODE_EXTERN` attribute
* A dependency on the `Winmm` system library is missing
* Incorrect defines on executable targets leads to `node.exe`
claiming to export a number of functions that are actually in
`libnode.dll`
* Because `node.exe` attempts to export symbols, `node.lib` gets
generated causing native extensions to try to link against
`node.exe` not `libnode.dll`.
* Similarly, because `node.dll` was renamed to `libnode.dll`,
native extensions don't know to look for `libnode.lib` rather
than `node.lib`.
* On macOS an RPATH is added to find `libnode.dylib` relative to
`node` in the same folder. This works fine from the
`out/Release` folder but not from an installed prefix, where
`node` will be in `bin/` and `libnode.dylib` will be in `lib/`.
* Similarly on Linux, no RPATH is added so LD_LIBRARY_PATH needs
setting correctly for `bin/node` to find `lib/libnode.so`.
For the `libnode.lib` vs `node.lib` issue there are two possible
options:
1. Ensure `node.lib` from `node.exe` does not get generated, and
instead copy `libnode.lib` to `node.lib`. This means addons
compiled when referencing the correct `node.lib` file will
correctly depend on `libnode.dll`. The down side is that
native addons compiled with stock Node.js will still try to
resolve symbols against node.exe rather than libnode.dll.
2. After building `libnode.dll`, dump the exports using `dumpbin`,
and process this to generate a `node.def` file to be linked into
`node.exe` with the `/DEF:node.def` flag. The export entries
in `node.def` will all read
```
my_symbol=libnode.my_symbol
```
so that `node.exe` will redirect all exported symbols back to
`libnode.dll`. This has the benefit that addons compiled with
stock Node.js will load correctly into `node.exe` from a shared
library build, but means that every embedding executable also
needs to perform this same trick.
I went with the first option as it is the cleaner of the two
solutions in my opinion. Projects wishing to generate a shared
library variant of Node.js can now, for example,
```
.\vcbuild dll package vs
```
to generate a full node installation including `libnode.dll`,
`Release\node.lib`, and all the necessary headers. Native addons
can then be built against the shared library build easily by
specifying the correct `nodedir` option.
For example
```
>npx node-gyp configure --nodedir
C:\Users\User\node\Release\node-v18.0.0-win-x64
...
>npx node-gyp build
...
>dumpbin /dependents build\Release\binding.node
Microsoft (R) COFF/PE Dumper Version 14.29.30136.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file build\Release\binding.node
File Type: DLL
Image has the following dependencies:
KERNEL32.dll
libnode.dll
VCRUNTIME140.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
...
```
PR-URL: https://github.com/nodejs/node/pull/41850
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2022-02-04 10:12:57 +00:00
|
|
|
'conditions': [
|
|
|
|
['OS=="win" and node_shared=="true"', {
|
|
|
|
'dependencies': ['generate_node_def'],
|
|
|
|
'msvs_settings': {
|
|
|
|
'VCLinkerTool': {
|
|
|
|
'ModuleDefinitionFile': '<(PRODUCT_DIR)/<(node_core_target_name).def',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}],
|
|
|
|
],
|
2017-12-05 00:07:53 +00:00
|
|
|
}],
|
2019-02-03 20:51:20 +00:00
|
|
|
[ 'node_intermediate_lib_type=="static_library" and node_shared=="false"', {
|
2017-12-05 00:07:53 +00:00
|
|
|
'xcode_settings': {
|
|
|
|
'OTHER_LDFLAGS': [
|
2019-03-29 07:38:12 +00:00
|
|
|
'-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)<(node_core_target_name)<(STATIC_LIB_SUFFIX)',
|
|
|
|
'-Wl,-force_load,<(PRODUCT_DIR)/<(STATIC_LIB_PREFIX)v8_base_without_compiler<(STATIC_LIB_SUFFIX)',
|
2017-12-05 00:07:53 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
'msvs_settings': {
|
|
|
|
'VCLinkerTool': {
|
|
|
|
'AdditionalOptions': [
|
2024-05-13 19:05:05 +00:00
|
|
|
'/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/<(node_lib_target_name)<(STATIC_LIB_SUFFIX)',
|
|
|
|
'/WHOLEARCHIVE:<(PRODUCT_DIR)/lib/<(STATIC_LIB_PREFIX)v8_base_without_compiler<(STATIC_LIB_SUFFIX)',
|
2017-12-05 00:07:53 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'conditions': [
|
2023-02-22 04:18:56 +00:00
|
|
|
['OS != "aix" and OS != "os400" and OS != "mac" and OS != "ios"', {
|
2017-12-05 00:07:53 +00:00
|
|
|
'ldflags': [
|
2019-03-29 07:38:12 +00:00
|
|
|
'-Wl,--whole-archive',
|
|
|
|
'<(obj_dir)/<(STATIC_LIB_PREFIX)<(node_core_target_name)<(STATIC_LIB_SUFFIX)',
|
|
|
|
'<(obj_dir)/tools/v8_gypfiles/<(STATIC_LIB_PREFIX)v8_base_without_compiler<(STATIC_LIB_SUFFIX)',
|
2017-12-05 00:07:53 +00:00
|
|
|
'-Wl,--no-whole-archive',
|
|
|
|
],
|
|
|
|
}],
|
2022-10-19 17:27:53 +00:00
|
|
|
[ 'OS=="win"', {
|
|
|
|
'sources': [ 'src/res/node.rc' ],
|
|
|
|
}],
|
2017-12-05 00:07:53 +00:00
|
|
|
],
|
|
|
|
}],
|
2018-02-02 18:06:33 +00:00
|
|
|
[ 'node_shared=="true"', {
|
|
|
|
'xcode_settings': {
|
build: fix various shared library build issues
Node.js unofficially supports a shared library variant where the
main node executable is a thin wrapper around node.dll/libnode.so.
The key benefit of this is to support embedding Node.js in other
applications.
Since Node.js 12 there have been a number of issues preventing the
shared library build from working correctly, primarily on Windows:
* A number of functions used executables such as `mksnapshot` are
not exported from `libnode.dll` using a `NODE_EXTERN` attribute
* A dependency on the `Winmm` system library is missing
* Incorrect defines on executable targets leads to `node.exe`
claiming to export a number of functions that are actually in
`libnode.dll`
* Because `node.exe` attempts to export symbols, `node.lib` gets
generated causing native extensions to try to link against
`node.exe` not `libnode.dll`.
* Similarly, because `node.dll` was renamed to `libnode.dll`,
native extensions don't know to look for `libnode.lib` rather
than `node.lib`.
* On macOS an RPATH is added to find `libnode.dylib` relative to
`node` in the same folder. This works fine from the
`out/Release` folder but not from an installed prefix, where
`node` will be in `bin/` and `libnode.dylib` will be in `lib/`.
* Similarly on Linux, no RPATH is added so LD_LIBRARY_PATH needs
setting correctly for `bin/node` to find `lib/libnode.so`.
For the `libnode.lib` vs `node.lib` issue there are two possible
options:
1. Ensure `node.lib` from `node.exe` does not get generated, and
instead copy `libnode.lib` to `node.lib`. This means addons
compiled when referencing the correct `node.lib` file will
correctly depend on `libnode.dll`. The down side is that
native addons compiled with stock Node.js will still try to
resolve symbols against node.exe rather than libnode.dll.
2. After building `libnode.dll`, dump the exports using `dumpbin`,
and process this to generate a `node.def` file to be linked into
`node.exe` with the `/DEF:node.def` flag. The export entries
in `node.def` will all read
```
my_symbol=libnode.my_symbol
```
so that `node.exe` will redirect all exported symbols back to
`libnode.dll`. This has the benefit that addons compiled with
stock Node.js will load correctly into `node.exe` from a shared
library build, but means that every embedding executable also
needs to perform this same trick.
I went with the first option as it is the cleaner of the two
solutions in my opinion. Projects wishing to generate a shared
library variant of Node.js can now, for example,
```
.\vcbuild dll package vs
```
to generate a full node installation including `libnode.dll`,
`Release\node.lib`, and all the necessary headers. Native addons
can then be built against the shared library build easily by
specifying the correct `nodedir` option.
For example
```
>npx node-gyp configure --nodedir
C:\Users\User\node\Release\node-v18.0.0-win-x64
...
>npx node-gyp build
...
>dumpbin /dependents build\Release\binding.node
Microsoft (R) COFF/PE Dumper Version 14.29.30136.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file build\Release\binding.node
File Type: DLL
Image has the following dependencies:
KERNEL32.dll
libnode.dll
VCRUNTIME140.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
...
```
PR-URL: https://github.com/nodejs/node/pull/41850
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2022-02-04 10:12:57 +00:00
|
|
|
'OTHER_LDFLAGS': [ '-Wl,-rpath,@loader_path', '-Wl,-rpath,@loader_path/../lib'],
|
2018-02-02 18:06:33 +00:00
|
|
|
},
|
build: fix various shared library build issues
Node.js unofficially supports a shared library variant where the
main node executable is a thin wrapper around node.dll/libnode.so.
The key benefit of this is to support embedding Node.js in other
applications.
Since Node.js 12 there have been a number of issues preventing the
shared library build from working correctly, primarily on Windows:
* A number of functions used executables such as `mksnapshot` are
not exported from `libnode.dll` using a `NODE_EXTERN` attribute
* A dependency on the `Winmm` system library is missing
* Incorrect defines on executable targets leads to `node.exe`
claiming to export a number of functions that are actually in
`libnode.dll`
* Because `node.exe` attempts to export symbols, `node.lib` gets
generated causing native extensions to try to link against
`node.exe` not `libnode.dll`.
* Similarly, because `node.dll` was renamed to `libnode.dll`,
native extensions don't know to look for `libnode.lib` rather
than `node.lib`.
* On macOS an RPATH is added to find `libnode.dylib` relative to
`node` in the same folder. This works fine from the
`out/Release` folder but not from an installed prefix, where
`node` will be in `bin/` and `libnode.dylib` will be in `lib/`.
* Similarly on Linux, no RPATH is added so LD_LIBRARY_PATH needs
setting correctly for `bin/node` to find `lib/libnode.so`.
For the `libnode.lib` vs `node.lib` issue there are two possible
options:
1. Ensure `node.lib` from `node.exe` does not get generated, and
instead copy `libnode.lib` to `node.lib`. This means addons
compiled when referencing the correct `node.lib` file will
correctly depend on `libnode.dll`. The down side is that
native addons compiled with stock Node.js will still try to
resolve symbols against node.exe rather than libnode.dll.
2. After building `libnode.dll`, dump the exports using `dumpbin`,
and process this to generate a `node.def` file to be linked into
`node.exe` with the `/DEF:node.def` flag. The export entries
in `node.def` will all read
```
my_symbol=libnode.my_symbol
```
so that `node.exe` will redirect all exported symbols back to
`libnode.dll`. This has the benefit that addons compiled with
stock Node.js will load correctly into `node.exe` from a shared
library build, but means that every embedding executable also
needs to perform this same trick.
I went with the first option as it is the cleaner of the two
solutions in my opinion. Projects wishing to generate a shared
library variant of Node.js can now, for example,
```
.\vcbuild dll package vs
```
to generate a full node installation including `libnode.dll`,
`Release\node.lib`, and all the necessary headers. Native addons
can then be built against the shared library build easily by
specifying the correct `nodedir` option.
For example
```
>npx node-gyp configure --nodedir
C:\Users\User\node\Release\node-v18.0.0-win-x64
...
>npx node-gyp build
...
>dumpbin /dependents build\Release\binding.node
Microsoft (R) COFF/PE Dumper Version 14.29.30136.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file build\Release\binding.node
File Type: DLL
Image has the following dependencies:
KERNEL32.dll
libnode.dll
VCRUNTIME140.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
...
```
PR-URL: https://github.com/nodejs/node/pull/41850
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2022-02-04 10:12:57 +00:00
|
|
|
'conditions': [
|
|
|
|
['OS=="linux"', {
|
|
|
|
'ldflags': [
|
|
|
|
'-Wl,-rpath,\\$$ORIGIN/../lib'
|
|
|
|
],
|
|
|
|
}],
|
|
|
|
],
|
2018-02-02 18:06:33 +00:00
|
|
|
}],
|
2021-08-21 18:21:23 +00:00
|
|
|
[ 'enable_lto=="true"', {
|
|
|
|
'xcode_settings': {
|
|
|
|
'OTHER_LDFLAGS': [
|
|
|
|
# man ld -export_dynamic:
|
|
|
|
# Preserves all global symbols in main executables during LTO.
|
|
|
|
# Without this option, Link Time Optimization is allowed to
|
|
|
|
# inline and remove global functions. This option is used when
|
|
|
|
# a main executable may load a plug-in which requires certain
|
|
|
|
# symbols from the main executable.
|
|
|
|
'-Wl,-export_dynamic',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
}],
|
2019-03-29 07:38:12 +00:00
|
|
|
['OS=="win"', {
|
|
|
|
'libraries': [
|
|
|
|
'Dbghelp.lib',
|
|
|
|
'winmm.lib',
|
|
|
|
'Ws2_32.lib',
|
2018-09-05 14:06:59 +00:00
|
|
|
],
|
|
|
|
}],
|
2019-02-03 20:51:20 +00:00
|
|
|
['node_with_ltcg=="true"', {
|
|
|
|
'msvs_settings': {
|
|
|
|
'VCCLCompilerTool': {
|
|
|
|
'WholeProgramOptimization': 'true' # /GL, whole program optimization, needed for LTCG
|
|
|
|
},
|
|
|
|
'VCLibrarianTool': {
|
|
|
|
'AdditionalOptions': [
|
|
|
|
'/LTCG:INCREMENTAL', # link time code generation
|
|
|
|
],
|
|
|
|
},
|
|
|
|
'VCLinkerTool': {
|
|
|
|
'OptimizeReferences': 2, # /OPT:REF
|
|
|
|
'EnableCOMDATFolding': 2, # /OPT:ICF
|
|
|
|
'LinkIncremental': 1, # disable incremental linking
|
|
|
|
'AdditionalOptions': [
|
|
|
|
'/LTCG:INCREMENTAL', # incremental link-time code generation
|
|
|
|
],
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
'msvs_settings': {
|
|
|
|
'VCCLCompilerTool': {
|
|
|
|
'WholeProgramOptimization': 'false'
|
|
|
|
},
|
|
|
|
'VCLinkerTool': {
|
|
|
|
'LinkIncremental': 2 # enable incremental linking
|
|
|
|
},
|
|
|
|
},
|
2019-04-07 19:02:04 +00:00
|
|
|
}],
|
2021-11-18 03:56:39 +00:00
|
|
|
['node_use_node_snapshot=="true"', {
|
2019-04-18 14:09:28 +00:00
|
|
|
'dependencies': [
|
|
|
|
'node_mksnapshot',
|
|
|
|
],
|
2022-03-24 13:37:08 +00:00
|
|
|
'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)',
|
|
|
|
],
|
|
|
|
},
|
2019-04-18 14:09:28 +00:00
|
|
|
],
|
2022-03-24 13:37:08 +00:00
|
|
|
}, {
|
|
|
|
'actions': [
|
|
|
|
{
|
|
|
|
'action_name': 'node_mksnapshot',
|
|
|
|
'process_outputs_as_sources': 1,
|
|
|
|
'inputs': [
|
|
|
|
'<(node_mksnapshot_exec)',
|
|
|
|
],
|
|
|
|
'outputs': [
|
|
|
|
'<(SHARED_INTERMEDIATE_DIR)/node_snapshot.cc',
|
|
|
|
],
|
|
|
|
'action': [
|
|
|
|
'<@(_inputs)',
|
|
|
|
'<@(_outputs)',
|
|
|
|
],
|
|
|
|
},
|
2019-04-18 14:09:28 +00:00
|
|
|
],
|
2022-03-24 13:37:08 +00:00
|
|
|
}],
|
2019-04-18 14:09:28 +00:00
|
|
|
],
|
2022-03-24 13:37:08 +00:00
|
|
|
}, {
|
2019-04-18 14:09:28 +00:00
|
|
|
'sources': [
|
|
|
|
'src/node_snapshot_stub.cc'
|
|
|
|
],
|
|
|
|
}],
|
2020-03-26 03:14:59 +00:00
|
|
|
[ 'OS in "linux freebsd" and '
|
2020-02-27 00:21:41 +00:00
|
|
|
'target_arch=="x64"', {
|
|
|
|
'dependencies': [ 'node_text_start' ],
|
|
|
|
'ldflags+': [
|
2020-03-03 20:02:02 +00:00
|
|
|
'<(obj_dir)/<(node_text_start_object_path)'
|
2020-02-27 00:21:41 +00:00
|
|
|
]
|
|
|
|
}],
|
2021-04-14 09:19:54 +00:00
|
|
|
|
|
|
|
['node_fipsinstall=="true"', {
|
|
|
|
'variables': {
|
|
|
|
'openssl-cli': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)openssl-cli<(EXECUTABLE_SUFFIX)',
|
|
|
|
'provider_name': 'libopenssl-fipsmodule',
|
2022-05-14 08:04:48 +00:00
|
|
|
'opensslconfig': './deps/openssl/nodejs-openssl.cnf',
|
2021-10-19 08:04:22 +00:00
|
|
|
'conditions': [
|
|
|
|
['GENERATOR == "ninja"', {
|
|
|
|
'fipsmodule_internal': '<(PRODUCT_DIR)/lib/<(provider_name).so',
|
|
|
|
'fipsmodule': '<(PRODUCT_DIR)/obj/lib/openssl-modules/fips.so',
|
|
|
|
'fipsconfig': '<(PRODUCT_DIR)/obj/lib/fipsmodule.cnf',
|
|
|
|
'opensslconfig_internal': '<(PRODUCT_DIR)/obj/lib/openssl.cnf',
|
|
|
|
}, {
|
|
|
|
'fipsmodule_internal': '<(PRODUCT_DIR)/obj.target/deps/openssl/<(provider_name).so',
|
|
|
|
'fipsmodule': '<(PRODUCT_DIR)/obj.target/deps/openssl/lib/openssl-modules/fips.so',
|
2022-05-14 08:04:48 +00:00
|
|
|
'fipsconfig': '<(PRODUCT_DIR)/obj.target/deps/openssl/fipsmodule.cnf',
|
2021-10-19 08:04:22 +00:00
|
|
|
'opensslconfig_internal': '<(PRODUCT_DIR)/obj.target/deps/openssl/openssl.cnf',
|
|
|
|
}],
|
|
|
|
],
|
2021-04-14 09:19:54 +00:00
|
|
|
},
|
|
|
|
'actions': [
|
|
|
|
{
|
|
|
|
'action_name': 'fipsinstall',
|
|
|
|
'process_outputs_as_sources': 1,
|
|
|
|
'inputs': [
|
|
|
|
'<(fipsmodule_internal)',
|
|
|
|
],
|
|
|
|
'outputs': [
|
|
|
|
'<(fipsconfig)',
|
|
|
|
],
|
|
|
|
'action': [
|
|
|
|
'<(openssl-cli)', 'fipsinstall',
|
|
|
|
'-provider_name', '<(provider_name)',
|
|
|
|
'-module', '<(fipsmodule_internal)',
|
|
|
|
'-out', '<(fipsconfig)',
|
|
|
|
#'-quiet',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'action_name': 'copy_fips_module',
|
|
|
|
'inputs': [
|
|
|
|
'<(fipsmodule_internal)',
|
|
|
|
],
|
|
|
|
'outputs': [
|
|
|
|
'<(fipsmodule)',
|
|
|
|
],
|
|
|
|
'action': [
|
2023-10-25 02:43:37 +00:00
|
|
|
'<(python)', 'tools/copyfile.py',
|
2021-04-14 09:19:54 +00:00
|
|
|
'<(fipsmodule_internal)',
|
|
|
|
'<(fipsmodule)',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'action_name': 'copy_openssl_cnf_and_include_fips_cnf',
|
|
|
|
'inputs': [ '<(opensslconfig)', ],
|
|
|
|
'outputs': [ '<(opensslconfig_internal)', ],
|
|
|
|
'action': [
|
2023-10-25 02:43:37 +00:00
|
|
|
'<(python)', 'tools/enable_fips_include.py',
|
2021-04-14 09:19:54 +00:00
|
|
|
'<(opensslconfig)',
|
|
|
|
'<(opensslconfig_internal)',
|
|
|
|
'<(fipsconfig)',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}, {
|
|
|
|
'variables': {
|
|
|
|
'opensslconfig_internal': '<(obj_dir)/deps/openssl/openssl.cnf',
|
2022-05-14 08:04:48 +00:00
|
|
|
'opensslconfig': './deps/openssl/nodejs-openssl.cnf',
|
2021-04-14 09:19:54 +00:00
|
|
|
},
|
|
|
|
'actions': [
|
|
|
|
{
|
|
|
|
'action_name': 'reset_openssl_cnf',
|
|
|
|
'inputs': [ '<(opensslconfig)', ],
|
|
|
|
'outputs': [ '<(opensslconfig_internal)', ],
|
|
|
|
'action': [
|
2022-11-14 08:36:22 +00:00
|
|
|
'<(python)', 'tools/copyfile.py',
|
2022-05-14 08:04:48 +00:00
|
|
|
'<(opensslconfig)',
|
|
|
|
'<(opensslconfig_internal)',
|
2021-04-14 09:19:54 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}],
|
2017-12-05 00:07:53 +00:00
|
|
|
],
|
2018-09-30 17:44:55 +00:00
|
|
|
}, # node_core_target_name
|
2017-12-05 00:07:53 +00:00
|
|
|
{
|
|
|
|
'target_name': '<(node_lib_target_name)',
|
|
|
|
'type': '<(node_intermediate_lib_type)',
|
2016-10-18 14:41:26 +00:00
|
|
|
'includes': [
|
2019-04-08 14:48:09 +00:00
|
|
|
'node.gypi',
|
2016-10-18 14:41:26 +00:00
|
|
|
],
|
|
|
|
|
2011-08-04 23:40:07 +00:00
|
|
|
'include_dirs': [
|
2011-08-08 19:11:48 +00:00
|
|
|
'src',
|
2023-02-18 02:49:18 +00:00
|
|
|
'deps/postject',
|
2017-11-06 08:59:01 +00:00
|
|
|
'<(SHARED_INTERMEDIATE_DIR)' # for node_natives.h
|
2011-08-04 23:40:07 +00:00
|
|
|
],
|
2019-09-04 21:56:51 +00:00
|
|
|
'dependencies': [
|
2021-07-14 15:20:27 +00:00
|
|
|
'deps/googletest/googletest.gyp:gtest_prod',
|
2019-09-04 21:56:51 +00:00
|
|
|
'deps/histogram/histogram.gyp:histogram',
|
2023-10-21 21:44:41 +00:00
|
|
|
'deps/simdjson/simdjson.gyp:simdjson',
|
2022-11-30 16:05:17 +00:00
|
|
|
'deps/simdutf/simdutf.gyp:simdutf',
|
2023-01-27 20:49:13 +00:00
|
|
|
'deps/ada/ada.gyp:ada',
|
2024-06-18 23:46:54 +00:00
|
|
|
'deps/nbytes/nbytes.gyp:nbytes',
|
2023-03-07 16:46:04 +00:00
|
|
|
'node_js2c#host',
|
2019-09-04 21:56:51 +00:00
|
|
|
],
|
2011-08-04 23:40:07 +00:00
|
|
|
|
2011-08-04 00:01:30 +00:00
|
|
|
'sources': [
|
2023-03-04 11:59:55 +00:00
|
|
|
'<@(node_sources)',
|
2018-11-20 02:36:32 +00:00
|
|
|
# Dependency headers
|
2015-04-02 23:13:43 +00:00
|
|
|
'deps/v8/include/v8.h',
|
2023-03-02 16:10:19 +00:00
|
|
|
'deps/postject/postject-api.h',
|
2011-09-04 23:01:53 +00:00
|
|
|
# javascript files to make for an even more pleasant IDE experience
|
|
|
|
'<@(library_files)',
|
2021-06-17 21:01:41 +00:00
|
|
|
'<@(deps_files)',
|
2018-11-20 02:36:32 +00:00
|
|
|
# node.gyp is added by default, common.gypi is added for change detection
|
2011-10-28 10:10:24 +00:00
|
|
|
'common.gypi',
|
2011-08-04 23:40:07 +00:00
|
|
|
],
|
|
|
|
|
2017-11-06 09:30:29 +00:00
|
|
|
'variables': {
|
|
|
|
'openssl_system_ca_path%': '',
|
2020-06-03 10:56:58 +00:00
|
|
|
'openssl_default_cipher_list%': '',
|
2017-11-06 09:30:29 +00:00
|
|
|
},
|
|
|
|
|
2022-09-11 08:48:34 +00:00
|
|
|
'cflags': ['-Werror=unused-result'],
|
|
|
|
|
2011-08-04 23:40:07 +00:00
|
|
|
'defines': [
|
2015-01-08 12:05:51 +00:00
|
|
|
'NODE_ARCH="<(target_arch)"',
|
|
|
|
'NODE_PLATFORM="<(OS)"',
|
|
|
|
'NODE_WANT_INTERNALS=1',
|
2015-07-01 21:47:37 +00:00
|
|
|
# Warn when using deprecated V8 APIs.
|
|
|
|
'V8_DEPRECATION_WARNINGS=1',
|
2017-11-06 09:30:29 +00:00
|
|
|
'NODE_OPENSSL_SYSTEM_CERT_PATH="<(openssl_system_ca_path)"',
|
2024-11-18 00:57:04 +00:00
|
|
|
"SQLITE_ENABLE_SESSION"
|
2011-08-04 00:01:30 +00:00
|
|
|
],
|
2018-09-04 02:00:09 +00:00
|
|
|
|
|
|
|
# - "C4244: conversion from 'type1' to 'type2', possible loss of data"
|
|
|
|
# Ususaly safe. Disable for `dep`, enable for `src`
|
|
|
|
'msvs_disabled_warnings!': [4244],
|
|
|
|
|
2017-11-02 04:19:16 +00:00
|
|
|
'conditions': [
|
2020-06-03 10:56:58 +00:00
|
|
|
[ 'openssl_default_cipher_list!=""', {
|
|
|
|
'defines': [
|
|
|
|
'NODE_OPENSSL_DEFAULT_CIPHER_LIST="<(openssl_default_cipher_list)"'
|
|
|
|
]
|
|
|
|
}],
|
2020-04-06 12:17:57 +00:00
|
|
|
[ 'error_on_warn=="true"', {
|
|
|
|
'cflags': ['-Werror'],
|
2020-05-11 18:42:52 +00:00
|
|
|
'xcode_settings': {
|
|
|
|
'WARNING_CFLAGS': [ '-Werror' ],
|
|
|
|
},
|
2020-04-06 12:17:57 +00:00
|
|
|
}],
|
2020-01-11 22:03:59 +00:00
|
|
|
[ 'node_builtin_modules_path!=""', {
|
|
|
|
'defines': [ 'NODE_BUILTIN_MODULES_PATH="<(node_builtin_modules_path)"' ]
|
|
|
|
}],
|
2019-07-29 18:15:14 +00:00
|
|
|
[ 'node_shared=="true"', {
|
|
|
|
'sources': [
|
|
|
|
'src/node_snapshot_stub.cc',
|
|
|
|
]
|
|
|
|
}],
|
2017-11-02 04:19:16 +00:00
|
|
|
[ 'node_shared=="true" and node_module_version!="" and OS!="win"', {
|
|
|
|
'product_extension': '<(shlib_suffix)',
|
2018-02-02 18:06:33 +00:00
|
|
|
'xcode_settings': {
|
|
|
|
'LD_DYLIB_INSTALL_NAME':
|
|
|
|
'@rpath/lib<(node_core_target_name).<(shlib_suffix)'
|
|
|
|
},
|
2017-11-08 08:41:09 +00:00
|
|
|
}],
|
2021-11-18 03:56:39 +00:00
|
|
|
[ 'node_use_node_code_cache=="true"', {
|
|
|
|
'defines': [
|
|
|
|
'NODE_USE_NODE_CODE_CACHE=1',
|
|
|
|
],
|
|
|
|
}],
|
2023-02-22 04:18:56 +00:00
|
|
|
['node_shared=="true" and OS in "aix os400"', {
|
2017-12-05 00:07:53 +00:00
|
|
|
'product_name': 'node_base',
|
|
|
|
}],
|
2017-11-08 08:41:09 +00:00
|
|
|
[ 'v8_enable_inspector==1', {
|
2018-09-27 14:45:24 +00:00
|
|
|
'includes' : [ 'src/inspector/node_inspector.gypi' ],
|
2017-11-08 08:41:09 +00:00
|
|
|
}, {
|
|
|
|
'defines': [ 'HAVE_INSPECTOR=0' ]
|
|
|
|
}],
|
|
|
|
[ 'OS=="win"', {
|
2017-08-23 07:52:59 +00:00
|
|
|
'conditions': [
|
2017-12-05 00:07:53 +00:00
|
|
|
[ 'node_intermediate_lib_type!="static_library"', {
|
2017-08-23 07:52:59 +00:00
|
|
|
'sources': [
|
|
|
|
'src/res/node.rc',
|
|
|
|
],
|
|
|
|
}],
|
2017-11-08 08:41:09 +00:00
|
|
|
],
|
2019-04-08 18:41:52 +00:00
|
|
|
'libraries': [
|
|
|
|
'Dbghelp',
|
|
|
|
'Psapi',
|
build: fix various shared library build issues
Node.js unofficially supports a shared library variant where the
main node executable is a thin wrapper around node.dll/libnode.so.
The key benefit of this is to support embedding Node.js in other
applications.
Since Node.js 12 there have been a number of issues preventing the
shared library build from working correctly, primarily on Windows:
* A number of functions used executables such as `mksnapshot` are
not exported from `libnode.dll` using a `NODE_EXTERN` attribute
* A dependency on the `Winmm` system library is missing
* Incorrect defines on executable targets leads to `node.exe`
claiming to export a number of functions that are actually in
`libnode.dll`
* Because `node.exe` attempts to export symbols, `node.lib` gets
generated causing native extensions to try to link against
`node.exe` not `libnode.dll`.
* Similarly, because `node.dll` was renamed to `libnode.dll`,
native extensions don't know to look for `libnode.lib` rather
than `node.lib`.
* On macOS an RPATH is added to find `libnode.dylib` relative to
`node` in the same folder. This works fine from the
`out/Release` folder but not from an installed prefix, where
`node` will be in `bin/` and `libnode.dylib` will be in `lib/`.
* Similarly on Linux, no RPATH is added so LD_LIBRARY_PATH needs
setting correctly for `bin/node` to find `lib/libnode.so`.
For the `libnode.lib` vs `node.lib` issue there are two possible
options:
1. Ensure `node.lib` from `node.exe` does not get generated, and
instead copy `libnode.lib` to `node.lib`. This means addons
compiled when referencing the correct `node.lib` file will
correctly depend on `libnode.dll`. The down side is that
native addons compiled with stock Node.js will still try to
resolve symbols against node.exe rather than libnode.dll.
2. After building `libnode.dll`, dump the exports using `dumpbin`,
and process this to generate a `node.def` file to be linked into
`node.exe` with the `/DEF:node.def` flag. The export entries
in `node.def` will all read
```
my_symbol=libnode.my_symbol
```
so that `node.exe` will redirect all exported symbols back to
`libnode.dll`. This has the benefit that addons compiled with
stock Node.js will load correctly into `node.exe` from a shared
library build, but means that every embedding executable also
needs to perform this same trick.
I went with the first option as it is the cleaner of the two
solutions in my opinion. Projects wishing to generate a shared
library variant of Node.js can now, for example,
```
.\vcbuild dll package vs
```
to generate a full node installation including `libnode.dll`,
`Release\node.lib`, and all the necessary headers. Native addons
can then be built against the shared library build easily by
specifying the correct `nodedir` option.
For example
```
>npx node-gyp configure --nodedir
C:\Users\User\node\Release\node-v18.0.0-win-x64
...
>npx node-gyp build
...
>dumpbin /dependents build\Release\binding.node
Microsoft (R) COFF/PE Dumper Version 14.29.30136.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file build\Release\binding.node
File Type: DLL
Image has the following dependencies:
KERNEL32.dll
libnode.dll
VCRUNTIME140.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
...
```
PR-URL: https://github.com/nodejs/node/pull/41850
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2022-02-04 10:12:57 +00:00
|
|
|
'Winmm',
|
2020-03-13 02:20:36 +00:00
|
|
|
'Ws2_32',
|
2019-04-08 18:41:52 +00:00
|
|
|
],
|
2017-11-08 08:41:09 +00:00
|
|
|
}],
|
|
|
|
[ 'node_use_openssl=="true"', {
|
|
|
|
'sources': [
|
2023-03-04 11:59:55 +00:00
|
|
|
'<@(node_crypto_sources)',
|
2023-03-26 22:05:44 +00:00
|
|
|
'<@(node_quic_sources)',
|
2017-11-08 08:41:09 +00:00
|
|
|
],
|
2024-07-09 20:36:07 +00:00
|
|
|
'dependencies': [
|
|
|
|
'deps/ncrypto/ncrypto.gyp:ncrypto',
|
|
|
|
],
|
2017-11-08 08:41:09 +00:00
|
|
|
}],
|
2020-07-12 04:52:46 +00:00
|
|
|
[ 'OS in "linux freebsd mac solaris" and '
|
2020-01-28 10:01:32 +00:00
|
|
|
'target_arch=="x64" and '
|
|
|
|
'node_target_type=="executable"', {
|
2018-03-23 19:16:48 +00:00
|
|
|
'defines': [ 'NODE_ENABLE_LARGE_CODE_PAGES=1' ],
|
|
|
|
}],
|
2016-04-18 14:10:20 +00:00
|
|
|
[ 'use_openssl_def==1', {
|
2018-09-30 17:44:55 +00:00
|
|
|
# TODO(bnoordhuis) Make all platforms export the same list of symbols.
|
|
|
|
# Teach mkssldef.py to generate linker maps that UNIX linkers understand.
|
2016-04-18 14:10:20 +00:00
|
|
|
'variables': {
|
|
|
|
'mkssldef_flags': [
|
|
|
|
# Categories to export.
|
|
|
|
'-CAES,BF,BIO,DES,DH,DSA,EC,ECDH,ECDSA,ENGINE,EVP,HMAC,MD4,MD5,'
|
2018-03-17 04:13:47 +00:00
|
|
|
'PSK,RC2,RC4,RSA,SHA,SHA0,SHA1,SHA256,SHA512,SOCK,STDIO,TLSEXT,'
|
2019-05-06 19:59:11 +00:00
|
|
|
'UI,FP_API,TLS1_METHOD,TLS1_1_METHOD,TLS1_2_METHOD,SCRYPT,OCSP,'
|
2023-01-31 07:19:01 +00:00
|
|
|
'NEXTPROTONEG,RMD160,CAST,DEPRECATEDIN_1_1_0,DEPRECATEDIN_1_2_0,'
|
|
|
|
'DEPRECATEDIN_3_0',
|
2016-04-18 14:10:20 +00:00
|
|
|
# Defines.
|
|
|
|
'-DWIN32',
|
|
|
|
# Symbols to filter from the export list.
|
|
|
|
'-X^DSO',
|
|
|
|
'-X^_',
|
|
|
|
'-X^private_',
|
2016-08-05 02:36:40 +00:00
|
|
|
# Base generated DEF on zlib.def
|
|
|
|
'-Bdeps/zlib/win32/zlib.def'
|
2016-04-18 14:10:20 +00:00
|
|
|
],
|
|
|
|
},
|
|
|
|
'conditions': [
|
2021-04-14 09:19:54 +00:00
|
|
|
['openssl_is_fips!=""', {
|
2016-04-18 14:10:20 +00:00
|
|
|
'variables': { 'mkssldef_flags': ['-DOPENSSL_FIPS'] },
|
|
|
|
}],
|
|
|
|
],
|
|
|
|
'actions': [
|
|
|
|
{
|
|
|
|
'action_name': 'mkssldef',
|
|
|
|
'inputs': [
|
2018-03-07 13:31:05 +00:00
|
|
|
'deps/openssl/openssl/util/libcrypto.num',
|
|
|
|
'deps/openssl/openssl/util/libssl.num',
|
2016-04-18 14:10:20 +00:00
|
|
|
],
|
|
|
|
'outputs': ['<(SHARED_INTERMEDIATE_DIR)/openssl.def'],
|
2018-09-30 17:44:55 +00:00
|
|
|
'process_outputs_as_sources': 1,
|
2016-04-18 14:10:20 +00:00
|
|
|
'action': [
|
2021-07-20 10:00:19 +00:00
|
|
|
'<(python)',
|
2016-04-18 14:10:20 +00:00
|
|
|
'tools/mkssldef.py',
|
|
|
|
'<@(mkssldef_flags)',
|
|
|
|
'-o',
|
|
|
|
'<@(_outputs)',
|
|
|
|
'<@(_inputs)',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}],
|
2022-10-27 12:25:55 +00:00
|
|
|
[ 'debug_nghttp2==1', {
|
|
|
|
'defines': [ 'NODE_DEBUG_NGHTTP2=1' ]
|
|
|
|
}],
|
2016-04-18 14:10:20 +00:00
|
|
|
],
|
2011-08-04 00:01:30 +00:00
|
|
|
'actions': [
|
|
|
|
{
|
|
|
|
'action_name': 'node_js2c',
|
2017-02-02 22:23:49 +00:00
|
|
|
'process_outputs_as_sources': 1,
|
2011-08-04 00:01:30 +00:00
|
|
|
'inputs': [
|
2023-03-07 16:46:04 +00:00
|
|
|
'<(node_js2c_exec)',
|
2011-08-04 00:01:30 +00:00
|
|
|
'<@(library_files)',
|
2021-06-17 21:01:41 +00:00
|
|
|
'<@(deps_files)',
|
2019-12-01 20:55:54 +00:00
|
|
|
'config.gypi'
|
2011-08-04 00:01:30 +00:00
|
|
|
],
|
|
|
|
'outputs': [
|
2017-02-02 22:23:49 +00:00
|
|
|
'<(SHARED_INTERMEDIATE_DIR)/node_javascript.cc',
|
2011-08-04 00:01:30 +00:00
|
|
|
],
|
2013-07-24 10:53:28 +00:00
|
|
|
'action': [
|
2023-03-07 16:46:04 +00:00
|
|
|
'<(node_js2c_exec)',
|
2021-06-17 21:01:41 +00:00
|
|
|
'<@(_outputs)',
|
2023-03-07 16:46:04 +00:00
|
|
|
'lib',
|
2021-06-17 21:01:41 +00:00
|
|
|
'config.gypi',
|
|
|
|
'<@(deps_files)',
|
2023-06-24 15:36:14 +00:00
|
|
|
'<@(linked_module_files)',
|
2013-07-24 10:53:28 +00:00
|
|
|
],
|
2011-08-04 00:01:30 +00:00
|
|
|
},
|
|
|
|
],
|
2018-09-30 17:44:55 +00:00
|
|
|
}, # node_lib_target_name
|
2020-08-19 21:02:14 +00:00
|
|
|
{ # fuzz_env
|
|
|
|
'target_name': 'fuzz_env',
|
|
|
|
'type': 'executable',
|
|
|
|
'dependencies': [
|
|
|
|
'<(node_lib_target_name)',
|
|
|
|
'deps/histogram/histogram.gyp:histogram',
|
|
|
|
],
|
2020-11-25 06:49:21 +00:00
|
|
|
|
2020-08-19 21:02:14 +00:00
|
|
|
'includes': [
|
|
|
|
'node.gypi'
|
|
|
|
],
|
|
|
|
'include_dirs': [
|
|
|
|
'src',
|
|
|
|
'tools/msvs/genfiles',
|
|
|
|
'deps/v8/include',
|
|
|
|
'deps/cares/include',
|
|
|
|
'deps/uv/include',
|
|
|
|
'test/cctest',
|
|
|
|
],
|
2020-11-25 06:49:21 +00:00
|
|
|
|
2020-08-19 21:02:14 +00:00
|
|
|
'defines': [
|
|
|
|
'NODE_ARCH="<(target_arch)"',
|
|
|
|
'NODE_PLATFORM="<(OS)"',
|
|
|
|
'NODE_WANT_INTERNALS=1',
|
|
|
|
],
|
|
|
|
'sources': [
|
|
|
|
'src/node_snapshot_stub.cc',
|
|
|
|
'test/fuzzers/fuzz_env.cc',
|
|
|
|
],
|
|
|
|
'conditions': [
|
|
|
|
['OS=="linux"', {
|
|
|
|
'ldflags': [ '-fsanitize=fuzzer' ]
|
|
|
|
}],
|
|
|
|
# Ensure that ossfuzz flag has been set and that we are on Linux
|
|
|
|
[ 'OS!="linux" or ossfuzz!="true"', {
|
|
|
|
'type': 'none',
|
|
|
|
}],
|
2023-04-06 00:24:58 +00:00
|
|
|
# Avoid excessive LTO
|
|
|
|
['enable_lto=="true"', {
|
|
|
|
'ldflags': [ '-fno-lto' ],
|
|
|
|
}],
|
2020-08-19 21:02:14 +00:00
|
|
|
],
|
|
|
|
}, # fuzz_env
|
2024-05-12 17:28:44 +00:00
|
|
|
{ # fuzz_ClientHelloParser.cc
|
|
|
|
'target_name': 'fuzz_ClientHelloParser',
|
|
|
|
'type': 'executable',
|
|
|
|
'dependencies': [
|
|
|
|
'<(node_lib_target_name)',
|
|
|
|
'deps/histogram/histogram.gyp:histogram',
|
|
|
|
'deps/uvwasi/uvwasi.gyp:uvwasi',
|
|
|
|
],
|
|
|
|
'includes': [
|
|
|
|
'node.gypi'
|
|
|
|
],
|
|
|
|
'include_dirs': [
|
|
|
|
'src',
|
|
|
|
'tools/msvs/genfiles',
|
|
|
|
'deps/v8/include',
|
|
|
|
'deps/cares/include',
|
|
|
|
'deps/uv/include',
|
|
|
|
'deps/uvwasi/include',
|
|
|
|
'test/cctest',
|
|
|
|
],
|
|
|
|
'defines': [
|
|
|
|
'NODE_ARCH="<(target_arch)"',
|
|
|
|
'NODE_PLATFORM="<(OS)"',
|
|
|
|
'NODE_WANT_INTERNALS=1',
|
|
|
|
],
|
|
|
|
'sources': [
|
|
|
|
'src/node_snapshot_stub.cc',
|
|
|
|
'test/fuzzers/fuzz_ClientHelloParser.cc',
|
|
|
|
],
|
|
|
|
'conditions': [
|
|
|
|
['OS=="linux"', {
|
|
|
|
'ldflags': [ '-fsanitize=fuzzer' ]
|
|
|
|
}],
|
|
|
|
# Ensure that ossfuzz flag has been set and that we are on Linux
|
|
|
|
[ 'OS!="linux" or ossfuzz!="true"', {
|
|
|
|
'type': 'none',
|
|
|
|
}],
|
|
|
|
# Avoid excessive LTO
|
|
|
|
['enable_lto=="true"', {
|
|
|
|
'ldflags': [ '-fno-lto' ],
|
|
|
|
}],
|
|
|
|
],
|
|
|
|
}, # fuzz_ClientHelloParser.cc
|
2023-12-11 15:17:28 +00:00
|
|
|
{ # fuzz_strings
|
|
|
|
'target_name': 'fuzz_strings',
|
|
|
|
'type': 'executable',
|
|
|
|
'dependencies': [
|
|
|
|
'<(node_lib_target_name)',
|
|
|
|
'deps/googletest/googletest.gyp:gtest_prod',
|
|
|
|
'deps/histogram/histogram.gyp:histogram',
|
|
|
|
'deps/uvwasi/uvwasi.gyp:uvwasi',
|
|
|
|
'deps/ada/ada.gyp:ada',
|
2024-06-18 23:46:54 +00:00
|
|
|
'deps/nbytes/nbytes.gyp:nbytes',
|
2023-12-11 15:17:28 +00:00
|
|
|
],
|
|
|
|
'includes': [
|
|
|
|
'node.gypi'
|
|
|
|
],
|
|
|
|
'include_dirs': [
|
|
|
|
'src',
|
|
|
|
'tools/msvs/genfiles',
|
|
|
|
'deps/v8/include',
|
|
|
|
'deps/cares/include',
|
|
|
|
'deps/uv/include',
|
|
|
|
'deps/uvwasi/include',
|
|
|
|
'test/cctest',
|
|
|
|
],
|
|
|
|
'defines': [
|
|
|
|
'NODE_ARCH="<(target_arch)"',
|
|
|
|
'NODE_PLATFORM="<(OS)"',
|
|
|
|
'NODE_WANT_INTERNALS=1',
|
|
|
|
],
|
|
|
|
'sources': [
|
|
|
|
'src/node_snapshot_stub.cc',
|
|
|
|
'test/fuzzers/fuzz_strings.cc',
|
|
|
|
],
|
|
|
|
'conditions': [
|
|
|
|
['OS=="linux"', {
|
|
|
|
'ldflags': [ '-fsanitize=fuzzer' ]
|
|
|
|
}],
|
|
|
|
# Ensure that ossfuzz flag has been set and that we are on Linux
|
|
|
|
[ 'OS!="linux" or ossfuzz!="true"', {
|
|
|
|
'type': 'none',
|
|
|
|
}],
|
|
|
|
# Avoid excessive LTO
|
|
|
|
['enable_lto=="true"', {
|
|
|
|
'ldflags': [ '-fno-lto' ],
|
|
|
|
}],
|
|
|
|
],
|
|
|
|
}, # fuzz_strings
|
2015-03-19 01:01:45 +00:00
|
|
|
{
|
|
|
|
'target_name': 'cctest',
|
|
|
|
'type': 'executable',
|
2016-10-18 14:41:26 +00:00
|
|
|
|
|
|
|
'dependencies': [
|
2018-02-05 13:57:13 +00:00
|
|
|
'<(node_lib_target_name)',
|
2021-07-14 15:20:27 +00:00
|
|
|
'deps/googletest/googletest.gyp:gtest',
|
|
|
|
'deps/googletest/googletest.gyp:gtest_main',
|
2019-01-07 19:36:35 +00:00
|
|
|
'deps/histogram/histogram.gyp:histogram',
|
2023-10-21 21:44:41 +00:00
|
|
|
'deps/simdjson/simdjson.gyp:simdjson',
|
2023-01-10 11:25:19 +00:00
|
|
|
'deps/simdutf/simdutf.gyp:simdutf',
|
2023-01-27 20:49:13 +00:00
|
|
|
'deps/ada/ada.gyp:ada',
|
2024-06-18 23:46:54 +00:00
|
|
|
'deps/nbytes/nbytes.gyp:nbytes',
|
2016-10-18 14:41:26 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
'includes': [
|
|
|
|
'node.gypi'
|
|
|
|
],
|
|
|
|
|
2015-03-19 01:01:45 +00:00
|
|
|
'include_dirs': [
|
|
|
|
'src',
|
2016-10-18 14:41:26 +00:00
|
|
|
'tools/msvs/genfiles',
|
2016-11-09 22:19:35 +00:00
|
|
|
'deps/v8/include',
|
2016-10-18 14:41:26 +00:00
|
|
|
'deps/cares/include',
|
|
|
|
'deps/uv/include',
|
2019-04-14 21:24:22 +00:00
|
|
|
'test/cctest',
|
2016-10-18 14:41:26 +00:00
|
|
|
],
|
|
|
|
|
2020-03-13 02:20:36 +00:00
|
|
|
'defines': [
|
|
|
|
'NODE_ARCH="<(target_arch)"',
|
|
|
|
'NODE_PLATFORM="<(OS)"',
|
|
|
|
'NODE_WANT_INTERNALS=1',
|
|
|
|
],
|
2016-10-18 14:41:26 +00:00
|
|
|
|
2023-09-08 11:26:00 +00:00
|
|
|
'sources': [ '<@(node_cctest_sources)' ],
|
2016-10-18 14:41:26 +00:00
|
|
|
|
2016-02-07 16:47:14 +00:00
|
|
|
'conditions': [
|
2017-11-08 08:41:09 +00:00
|
|
|
[ 'node_use_openssl=="true"', {
|
2017-12-04 21:08:15 +00:00
|
|
|
'defines': [
|
|
|
|
'HAVE_OPENSSL=1',
|
|
|
|
],
|
2024-07-09 20:36:07 +00:00
|
|
|
'dependencies': [
|
|
|
|
'deps/ncrypto/ncrypto.gyp:ncrypto',
|
|
|
|
],
|
2023-09-08 11:26:00 +00:00
|
|
|
'sources': [ '<@(node_cctest_openssl_sources)' ],
|
2017-08-15 07:17:02 +00:00
|
|
|
}],
|
2017-01-17 19:49:26 +00:00
|
|
|
['v8_enable_inspector==1', {
|
2017-11-08 08:41:09 +00:00
|
|
|
'defines': [
|
|
|
|
'HAVE_INSPECTOR=1',
|
|
|
|
],
|
2023-09-08 11:26:00 +00:00
|
|
|
'sources': [ '<@(node_cctest_inspector_sources)' ],
|
2017-11-08 08:41:09 +00:00
|
|
|
}, {
|
2019-04-07 19:02:04 +00:00
|
|
|
'defines': [
|
|
|
|
'HAVE_INSPECTOR=0',
|
|
|
|
]
|
2016-03-27 00:17:55 +00:00
|
|
|
}],
|
2016-10-18 14:41:26 +00:00
|
|
|
['OS=="solaris"', {
|
|
|
|
'ldflags': [ '-I<(SHARED_INTERMEDIATE_DIR)' ]
|
|
|
|
}],
|
2018-07-24 20:44:09 +00:00
|
|
|
# Skip cctest while building shared lib node for Windows
|
|
|
|
[ 'OS=="win" and node_shared=="true"', {
|
|
|
|
'type': 'none',
|
|
|
|
}],
|
2018-09-29 20:43:39 +00:00
|
|
|
[ 'node_shared=="true"', {
|
|
|
|
'xcode_settings': {
|
|
|
|
'OTHER_LDFLAGS': [ '-Wl,-rpath,@loader_path', ],
|
|
|
|
},
|
|
|
|
}],
|
2019-03-29 07:38:12 +00:00
|
|
|
['OS=="win"', {
|
|
|
|
'libraries': [
|
|
|
|
'Dbghelp.lib',
|
|
|
|
'winmm.lib',
|
|
|
|
'Ws2_32.lib',
|
|
|
|
],
|
|
|
|
}],
|
2023-04-06 00:24:58 +00:00
|
|
|
# Avoid excessive LTO
|
|
|
|
['enable_lto=="true"', {
|
|
|
|
'ldflags': [ '-fno-lto' ],
|
|
|
|
}],
|
2018-02-05 13:57:13 +00:00
|
|
|
],
|
2018-09-30 17:44:55 +00:00
|
|
|
}, # cctest
|
2019-03-29 07:38:12 +00:00
|
|
|
|
2020-02-28 02:54:13 +00:00
|
|
|
{
|
|
|
|
'target_name': 'embedtest',
|
|
|
|
'type': 'executable',
|
|
|
|
|
|
|
|
'dependencies': [
|
|
|
|
'<(node_lib_target_name)',
|
|
|
|
'deps/histogram/histogram.gyp:histogram',
|
2023-01-27 20:49:13 +00:00
|
|
|
'deps/ada/ada.gyp:ada',
|
2024-06-18 23:46:54 +00:00
|
|
|
'deps/nbytes/nbytes.gyp:nbytes',
|
2020-02-28 02:54:13 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
'includes': [
|
|
|
|
'node.gypi'
|
|
|
|
],
|
|
|
|
|
|
|
|
'include_dirs': [
|
|
|
|
'src',
|
2024-05-23 18:33:40 +00:00
|
|
|
'tools',
|
2020-02-28 02:54:13 +00:00
|
|
|
'tools/msvs/genfiles',
|
|
|
|
'deps/v8/include',
|
|
|
|
'deps/cares/include',
|
|
|
|
'deps/uv/include',
|
|
|
|
'test/embedding',
|
|
|
|
],
|
|
|
|
|
|
|
|
'sources': [
|
|
|
|
'src/node_snapshot_stub.cc',
|
|
|
|
'test/embedding/embedtest.cc',
|
|
|
|
],
|
|
|
|
|
|
|
|
'conditions': [
|
|
|
|
['OS=="solaris"', {
|
|
|
|
'ldflags': [ '-I<(SHARED_INTERMEDIATE_DIR)' ]
|
|
|
|
}],
|
|
|
|
# Skip cctest while building shared lib node for Windows
|
|
|
|
[ 'OS=="win" and node_shared=="true"', {
|
|
|
|
'type': 'none',
|
|
|
|
}],
|
|
|
|
[ 'node_shared=="true"', {
|
|
|
|
'xcode_settings': {
|
|
|
|
'OTHER_LDFLAGS': [ '-Wl,-rpath,@loader_path', ],
|
|
|
|
},
|
|
|
|
}],
|
|
|
|
['OS=="win"', {
|
|
|
|
'libraries': [
|
|
|
|
'Dbghelp.lib',
|
|
|
|
'winmm.lib',
|
|
|
|
'Ws2_32.lib',
|
|
|
|
],
|
|
|
|
}],
|
2023-04-06 00:24:58 +00:00
|
|
|
# Avoid excessive LTO
|
|
|
|
['enable_lto=="true"', {
|
|
|
|
'ldflags': [ '-fno-lto' ],
|
|
|
|
}],
|
2020-02-28 02:54:13 +00:00
|
|
|
],
|
|
|
|
}, # embedtest
|
|
|
|
|
2019-09-02 18:51:29 +00:00
|
|
|
{
|
|
|
|
'target_name': 'overlapped-checker',
|
|
|
|
'type': 'executable',
|
|
|
|
|
|
|
|
'conditions': [
|
|
|
|
['OS=="win"', {
|
|
|
|
'sources': [
|
|
|
|
'test/overlapped-checker/main_win.c'
|
|
|
|
],
|
|
|
|
}],
|
|
|
|
['OS!="win"', {
|
|
|
|
'sources': [
|
|
|
|
'test/overlapped-checker/main_unix.c'
|
|
|
|
],
|
|
|
|
}],
|
2023-04-06 00:24:58 +00:00
|
|
|
# Avoid excessive LTO
|
|
|
|
['enable_lto=="true"', {
|
|
|
|
'ldflags': [ '-fno-lto' ],
|
|
|
|
}],
|
2019-09-02 18:51:29 +00:00
|
|
|
]
|
|
|
|
}, # overlapped-checker
|
2023-03-04 17:59:32 +00:00
|
|
|
{
|
|
|
|
'target_name': 'node_js2c',
|
|
|
|
'type': 'executable',
|
2023-03-07 16:46:04 +00:00
|
|
|
'toolsets': ['host'],
|
2023-03-04 17:59:32 +00:00
|
|
|
'dependencies': [
|
2023-03-07 16:46:04 +00:00
|
|
|
'deps/simdutf/simdutf.gyp:simdutf#host',
|
2023-03-04 17:59:32 +00:00
|
|
|
],
|
|
|
|
'include_dirs': [
|
2024-02-17 17:09:24 +00:00
|
|
|
'tools',
|
|
|
|
'src',
|
2023-03-04 17:59:32 +00:00
|
|
|
],
|
|
|
|
'sources': [
|
|
|
|
'tools/js2c.cc',
|
2024-02-17 17:09:24 +00:00
|
|
|
'tools/executable_wrapper.h',
|
|
|
|
'src/embedded_data.h',
|
|
|
|
'src/embedded_data.cc',
|
2023-03-04 17:59:32 +00:00
|
|
|
],
|
|
|
|
'conditions': [
|
|
|
|
[ 'node_shared_libuv=="false"', {
|
2023-03-07 16:46:04 +00:00
|
|
|
'dependencies': [ 'deps/uv/uv.gyp:libuv#host' ],
|
2023-03-04 17:59:32 +00:00
|
|
|
}],
|
tools: speedup compilation of js2c output
Incremental compilation of Node.js is slow. Currently on a powerful
Linux machine, it takes about 9 seconds and 830 MB of memory to compile
`gen/node_javascript.cc` with g++. This is the longest step when
recompiling a small change to a Javascript file.
`gen/node_javascript.cc` contains a lot of large binary literals of our
Javascript source code. It is well-known that embedding large binary
literals as C/C++ arrays is slow. One workaround is to include the data
as string literals instead. This is particularly nice for the Javascript
included via js2c, which look better as string literals anyway.
Add a build flag `NODE_JS2C_USE_STRING_LITERALS` to js2c. When this flag
is set, we emit string literals instead of array literals, i.e.:
```c++
// old: static const uint8_t X[] = { ... };
static const uint8_t *X = R"JS2C1b732aee(...)JS2C1b732aee";
// old: static const uint16_t Y[] = { ... };
static const uint16_t *Y = uR"JS2C1b732aee(...)JS2C1b732aee";
```
This requires some modest refactoring in order to deal with the flag
being on or off, but the new code itself is actually shorter.
I only enabled the new flag on Linux/macOS, since those are systems that
I have available for testing. On my Linux system with gcc, it speeds up
compilation by 5.5s (9.0s -> 3.5s). On my Mac system with clang, it
speeds up compilation by 2.2s (3.7s -> 1.5s). (I don't think this flag
will work with MSVC, but it'd probably speed up clang on windows.)
The long-term goal here is probably to allow this to occur incrementally
per Javascript file & in parallel, to avoid recompiling all of
`gen/node_javascript.cc`. Unfortunately the necessary gyp incantations
seem impossible (or at least, far beyond me). Anyway, a 60% speedup is a
nice enough win.
Refs: https://github.com/nodejs/node/issues/47984
PR-URL: https://github.com/nodejs/node/pull/48160
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
2023-06-24 15:52:29 +00:00
|
|
|
[ 'OS in "linux mac"', {
|
|
|
|
'defines': ['NODE_JS2C_USE_STRING_LITERALS'],
|
|
|
|
}],
|
2023-03-04 17:59:32 +00:00
|
|
|
[ 'debug_node=="true"', {
|
|
|
|
'cflags!': [ '-O3' ],
|
|
|
|
'cflags': [ '-g', '-O0' ],
|
|
|
|
'defines': [ 'DEBUG' ],
|
|
|
|
'xcode_settings': {
|
|
|
|
'OTHER_CFLAGS': [
|
|
|
|
'-g', '-O0'
|
|
|
|
],
|
|
|
|
},
|
|
|
|
}],
|
|
|
|
]
|
|
|
|
},
|
2019-04-18 08:26:48 +00:00
|
|
|
{
|
|
|
|
'target_name': 'node_mksnapshot',
|
|
|
|
'type': 'executable',
|
|
|
|
|
|
|
|
'dependencies': [
|
|
|
|
'<(node_lib_target_name)',
|
|
|
|
'deps/histogram/histogram.gyp:histogram',
|
2023-01-27 20:49:13 +00:00
|
|
|
'deps/ada/ada.gyp:ada',
|
2024-06-18 23:46:54 +00:00
|
|
|
'deps/nbytes/nbytes.gyp:nbytes',
|
2024-02-16 03:45:37 +00:00
|
|
|
'deps/simdjson/simdjson.gyp:simdjson',
|
|
|
|
'deps/simdutf/simdutf.gyp:simdutf',
|
2019-04-18 08:26:48 +00:00
|
|
|
],
|
|
|
|
|
|
|
|
'includes': [
|
|
|
|
'node.gypi'
|
|
|
|
],
|
|
|
|
|
|
|
|
'include_dirs': [
|
|
|
|
'src',
|
|
|
|
'tools/msvs/genfiles',
|
|
|
|
'deps/v8/include',
|
|
|
|
'deps/cares/include',
|
|
|
|
'deps/uv/include',
|
|
|
|
],
|
|
|
|
|
|
|
|
'defines': [ 'NODE_WANT_INTERNALS=1' ],
|
|
|
|
|
|
|
|
'sources': [
|
2019-04-18 14:09:28 +00:00
|
|
|
'src/node_snapshot_stub.cc',
|
2019-04-18 08:26:48 +00:00
|
|
|
'tools/snapshot/node_mksnapshot.cc',
|
|
|
|
],
|
|
|
|
|
2024-04-12 13:29:09 +00:00
|
|
|
'msvs_settings': {
|
|
|
|
'VCLinkerTool': {
|
|
|
|
'EnableCOMDATFolding': '1', # /OPT:NOICF
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2019-04-18 08:26:48 +00:00
|
|
|
'conditions': [
|
2023-08-24 16:02:26 +00:00
|
|
|
['node_write_snapshot_as_array_literals=="true"', {
|
|
|
|
'defines': [ 'NODE_MKSNAPSHOT_USE_ARRAY_LITERALS=1' ],
|
2023-08-14 12:53:02 +00:00
|
|
|
}],
|
2020-02-20 09:57:55 +00:00
|
|
|
[ 'node_use_openssl=="true"', {
|
2024-07-09 20:36:07 +00:00
|
|
|
'dependencies': [
|
|
|
|
'deps/ncrypto/ncrypto.gyp:ncrypto',
|
|
|
|
],
|
2020-02-20 09:57:55 +00:00
|
|
|
'defines': [
|
|
|
|
'HAVE_OPENSSL=1',
|
|
|
|
],
|
|
|
|
}],
|
2021-11-18 03:56:39 +00:00
|
|
|
[ 'node_use_node_code_cache=="true"', {
|
|
|
|
'defines': [
|
|
|
|
'NODE_USE_NODE_CODE_CACHE=1',
|
|
|
|
],
|
|
|
|
}],
|
2020-02-20 09:57:55 +00:00
|
|
|
['v8_enable_inspector==1', {
|
|
|
|
'defines': [
|
|
|
|
'HAVE_INSPECTOR=1',
|
|
|
|
],
|
|
|
|
}],
|
2019-03-29 07:38:12 +00:00
|
|
|
['OS=="win"', {
|
|
|
|
'libraries': [
|
|
|
|
'Dbghelp.lib',
|
|
|
|
'winmm.lib',
|
|
|
|
'Ws2_32.lib',
|
2019-04-18 08:26:48 +00:00
|
|
|
],
|
|
|
|
}],
|
2023-04-06 00:24:58 +00:00
|
|
|
# Avoid excessive LTO
|
|
|
|
['enable_lto=="true"', {
|
|
|
|
'ldflags': [ '-fno-lto' ],
|
|
|
|
}],
|
2019-04-18 08:26:48 +00:00
|
|
|
],
|
|
|
|
}, # node_mksnapshot
|
|
|
|
], # end targets
|
2015-09-29 14:22:00 +00:00
|
|
|
|
|
|
|
'conditions': [
|
2023-02-22 04:18:56 +00:00
|
|
|
['OS in "aix os400" and node_shared=="true"', {
|
2017-08-23 07:52:59 +00:00
|
|
|
'targets': [
|
|
|
|
{
|
2017-12-05 00:07:53 +00:00
|
|
|
'target_name': 'node_aix_shared',
|
|
|
|
'type': 'shared_library',
|
2017-08-23 07:52:59 +00:00
|
|
|
'product_name': '<(node_core_target_name)',
|
2019-04-07 19:02:04 +00:00
|
|
|
'ldflags': ['--shared'],
|
2017-12-05 00:07:53 +00:00
|
|
|
'product_extension': '<(shlib_suffix)',
|
|
|
|
'includes': [
|
|
|
|
'node.gypi'
|
|
|
|
],
|
2019-04-07 19:02:04 +00:00
|
|
|
'dependencies': ['<(node_lib_target_name)'],
|
2015-09-29 14:22:00 +00:00
|
|
|
'include_dirs': [
|
|
|
|
'src',
|
|
|
|
'deps/v8/include',
|
|
|
|
],
|
|
|
|
'sources': [
|
|
|
|
'<@(library_files)',
|
2021-06-17 21:01:41 +00:00
|
|
|
'<@(deps_files)',
|
2015-09-29 14:22:00 +00:00
|
|
|
'common.gypi',
|
|
|
|
],
|
2018-02-02 18:06:33 +00:00
|
|
|
'direct_dependent_settings': {
|
|
|
|
'ldflags': [ '-Wl,-brtl' ],
|
|
|
|
},
|
2015-09-29 14:22:00 +00:00
|
|
|
},
|
2017-12-05 00:07:53 +00:00
|
|
|
]
|
2015-09-29 14:22:00 +00:00
|
|
|
}], # end aix section
|
build: fix various shared library build issues
Node.js unofficially supports a shared library variant where the
main node executable is a thin wrapper around node.dll/libnode.so.
The key benefit of this is to support embedding Node.js in other
applications.
Since Node.js 12 there have been a number of issues preventing the
shared library build from working correctly, primarily on Windows:
* A number of functions used executables such as `mksnapshot` are
not exported from `libnode.dll` using a `NODE_EXTERN` attribute
* A dependency on the `Winmm` system library is missing
* Incorrect defines on executable targets leads to `node.exe`
claiming to export a number of functions that are actually in
`libnode.dll`
* Because `node.exe` attempts to export symbols, `node.lib` gets
generated causing native extensions to try to link against
`node.exe` not `libnode.dll`.
* Similarly, because `node.dll` was renamed to `libnode.dll`,
native extensions don't know to look for `libnode.lib` rather
than `node.lib`.
* On macOS an RPATH is added to find `libnode.dylib` relative to
`node` in the same folder. This works fine from the
`out/Release` folder but not from an installed prefix, where
`node` will be in `bin/` and `libnode.dylib` will be in `lib/`.
* Similarly on Linux, no RPATH is added so LD_LIBRARY_PATH needs
setting correctly for `bin/node` to find `lib/libnode.so`.
For the `libnode.lib` vs `node.lib` issue there are two possible
options:
1. Ensure `node.lib` from `node.exe` does not get generated, and
instead copy `libnode.lib` to `node.lib`. This means addons
compiled when referencing the correct `node.lib` file will
correctly depend on `libnode.dll`. The down side is that
native addons compiled with stock Node.js will still try to
resolve symbols against node.exe rather than libnode.dll.
2. After building `libnode.dll`, dump the exports using `dumpbin`,
and process this to generate a `node.def` file to be linked into
`node.exe` with the `/DEF:node.def` flag. The export entries
in `node.def` will all read
```
my_symbol=libnode.my_symbol
```
so that `node.exe` will redirect all exported symbols back to
`libnode.dll`. This has the benefit that addons compiled with
stock Node.js will load correctly into `node.exe` from a shared
library build, but means that every embedding executable also
needs to perform this same trick.
I went with the first option as it is the cleaner of the two
solutions in my opinion. Projects wishing to generate a shared
library variant of Node.js can now, for example,
```
.\vcbuild dll package vs
```
to generate a full node installation including `libnode.dll`,
`Release\node.lib`, and all the necessary headers. Native addons
can then be built against the shared library build easily by
specifying the correct `nodedir` option.
For example
```
>npx node-gyp configure --nodedir
C:\Users\User\node\Release\node-v18.0.0-win-x64
...
>npx node-gyp build
...
>dumpbin /dependents build\Release\binding.node
Microsoft (R) COFF/PE Dumper Version 14.29.30136.0
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file build\Release\binding.node
File Type: DLL
Image has the following dependencies:
KERNEL32.dll
libnode.dll
VCRUNTIME140.dll
api-ms-win-crt-string-l1-1-0.dll
api-ms-win-crt-stdio-l1-1-0.dll
api-ms-win-crt-runtime-l1-1-0.dll
...
```
PR-URL: https://github.com/nodejs/node/pull/41850
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2022-02-04 10:12:57 +00:00
|
|
|
['OS=="win" and node_shared=="true"', {
|
|
|
|
'targets': [
|
|
|
|
{
|
|
|
|
'target_name': 'gen_node_def',
|
|
|
|
'type': 'executable',
|
|
|
|
'sources': [
|
|
|
|
'tools/gen_node_def.cc'
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'target_name': 'generate_node_def',
|
|
|
|
'dependencies': [
|
|
|
|
'gen_node_def',
|
|
|
|
'<(node_lib_target_name)',
|
|
|
|
],
|
|
|
|
'type': 'none',
|
|
|
|
'actions': [
|
|
|
|
{
|
|
|
|
'action_name': 'generate_node_def_action',
|
|
|
|
'inputs': [
|
|
|
|
'<(PRODUCT_DIR)/<(node_lib_target_name).dll'
|
|
|
|
],
|
|
|
|
'outputs': [
|
|
|
|
'<(PRODUCT_DIR)/<(node_core_target_name).def',
|
|
|
|
],
|
|
|
|
'action': [
|
|
|
|
'<(PRODUCT_DIR)/gen_node_def.exe',
|
|
|
|
'<@(_inputs)',
|
|
|
|
'<@(_outputs)',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}], # end win section
|
2015-09-29 14:22:00 +00:00
|
|
|
], # end conditions block
|
2011-08-04 00:01:30 +00:00
|
|
|
}
|