2011-08-03 17:01:30 -07:00
|
|
|
{
|
2011-08-03 23:36:27 -07:00
|
|
|
'variables': {
|
2019-01-26 00:33:36 +05:30
|
|
|
'v8_use_siphash%': 0,
|
2017-06-30 19:08:32 -05:00
|
|
|
'v8_trace_maps%': 0,
|
2019-11-13 12:18:10 +01:00
|
|
|
'v8_enable_pointer_compression%': 0,
|
|
|
|
'v8_enable_31bit_smis_on_64bit_arch%': 0,
|
2016-03-22 21:05:54 -04:00
|
|
|
'node_no_browser_globals%': 'false',
|
2022-03-24 21:37:08 +08:00
|
|
|
'node_snapshot_main%': '',
|
2019-04-23 22:21:52 +08:00
|
|
|
'node_use_node_snapshot%': 'false',
|
2016-03-26 20:17:55 -04:00
|
|
|
'node_use_v8_platform%': 'true',
|
|
|
|
'node_use_bundled_v8%': 'true',
|
|
|
|
'node_shared%': 'false',
|
2016-06-29 16:03:18 -04:00
|
|
|
'force_dynamic_crt%': 0,
|
2020-08-13 17:12:44 +01:00
|
|
|
'ossfuzz' : 'false',
|
2016-03-26 20:17:55 -04:00
|
|
|
'node_module_version%': '',
|
2018-11-27 10:16:34 +09:00
|
|
|
'node_shared_brotli%': 'false',
|
2012-02-26 16:02:21 -07:00
|
|
|
'node_shared_zlib%': 'false',
|
2012-10-23 09:01:26 -04:00
|
|
|
'node_shared_http_parser%': 'false',
|
2016-03-18 09:25:17 +11:00
|
|
|
'node_shared_cares%': 'false',
|
2012-10-23 19:54:22 -04:00
|
|
|
'node_shared_libuv%': 'false',
|
2017-11-06 09:59:01 +01:00
|
|
|
'node_shared_nghttp2%': 'false',
|
2011-09-05 01:01:53 +02:00
|
|
|
'node_use_openssl%': 'true',
|
2012-06-20 13:31:49 -07:00
|
|
|
'node_shared_openssl%': 'false',
|
2014-03-27 00:30:49 +04:00
|
|
|
'node_v8_options%': '',
|
2022-11-22 16:28:19 +08:00
|
|
|
'node_enable_v8_vtunejit%': 'false',
|
2015-09-29 10:22:00 -04:00
|
|
|
'node_core_target_name%': 'node',
|
2019-04-08 10:48:09 -04:00
|
|
|
'node_lib_target_name%': 'libnode',
|
2017-12-04 16:07:53 -08:00
|
|
|
'node_intermediate_lib_type%': 'static_library',
|
2020-01-11 14:03:59 -08:00
|
|
|
'node_builtin_modules_path%': '',
|
2021-06-18 05:01:41 +08:00
|
|
|
# We list the deps/ files out instead of globbing them in js2c.py since we
|
|
|
|
# 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-05 01:01:53 +02:00
|
|
|
'library_files': [
|
2021-07-08 00:19:00 +08:00
|
|
|
'<@(node_library_files)',
|
2021-06-18 05:01:41 +08:00
|
|
|
],
|
|
|
|
'deps_files': [
|
2021-01-30 23:19:13 +01: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 08:36:48 +01:00
|
|
|
'deps/acorn/acorn/dist/acorn.js',
|
|
|
|
'deps/acorn/acorn-walk/dist/walk.js',
|
2022-08-23 22:41:29 -04:00
|
|
|
'<@(node_builtin_shareable_builtins)',
|
2011-09-05 01:01:53 +02:00
|
|
|
],
|
2019-04-18 22:09:28 +08:00
|
|
|
'node_mksnapshot_exec': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)node_mksnapshot<(EXECUTABLE_SUFFIX)',
|
2016-03-26 20:17:55 -04:00
|
|
|
'conditions': [
|
2020-03-03 15:02:02 -05: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-26 20:17:55 -04:00
|
|
|
[ 'node_shared=="true"', {
|
|
|
|
'node_target_type%': 'shared_library',
|
2017-12-04 16:07:53 -08:00
|
|
|
'conditions': [
|
|
|
|
['OS=="aix"', {
|
|
|
|
# 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-26 20:17:55 -04:00
|
|
|
}, {
|
|
|
|
'node_target_type%': 'executable',
|
|
|
|
}],
|
2016-04-18 16:10:20 +02:00
|
|
|
[ 'OS=="win" and '
|
|
|
|
'node_use_openssl=="true" and '
|
|
|
|
'node_shared_openssl=="false"', {
|
2018-10-19 12:09:00 -07:00
|
|
|
'use_openssl_def%': 1,
|
2016-04-18 16:10:20 +02:00
|
|
|
}, {
|
2018-10-19 12:09:00 -07:00
|
|
|
'use_openssl_def%': 0,
|
2016-04-18 16:10:20 +02:00
|
|
|
}],
|
2016-03-26 20:17:55 -04:00
|
|
|
],
|
2011-08-03 23:36:27 -07:00
|
|
|
},
|
|
|
|
|
2019-04-06 14:22:45 -04: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 14:22:45 -04:00
|
|
|
],
|
|
|
|
},
|
|
|
|
|
|
|
|
# Relevant only for x86.
|
|
|
|
# Refs: https://github.com/nodejs/node/pull/25852
|
|
|
|
# Refs: https://docs.microsoft.com/en-us/cpp/build/reference/safeseh-image-has-safe-exception-handlers
|
|
|
|
'msvs_settings': {
|
|
|
|
'VCLinkerTool': {
|
|
|
|
'ImageHasSafeExceptionHandlers': 'false',
|
|
|
|
},
|
|
|
|
},
|
2019-05-19 14:48:30 -04:00
|
|
|
|
|
|
|
'conditions': [
|
|
|
|
['OS=="aix"', {
|
|
|
|
'ldflags': [
|
|
|
|
'-Wl,-bnoerrmsg',
|
|
|
|
],
|
|
|
|
}],
|
2019-10-23 16:31:55 -05:00
|
|
|
['OS == "linux" and llvm_version != "0.0"', {
|
2019-06-14 16:03:48 -05:00
|
|
|
'libraries': ['-latomic'],
|
|
|
|
}],
|
2019-05-19 14:48:30 -04:00
|
|
|
],
|
2019-04-06 14:22:45 -04:00
|
|
|
},
|
|
|
|
|
2011-08-03 17:01:30 -07:00
|
|
|
'targets': [
|
2020-02-26 16:21:41 -08:00
|
|
|
{
|
|
|
|
'target_name': 'node_text_start',
|
|
|
|
'type': 'none',
|
|
|
|
'conditions': [
|
2020-07-12 05:52:46 +01:00
|
|
|
[ 'OS in "linux freebsd solaris" and '
|
2020-02-26 16:21:41 -08:00
|
|
|
'target_arch=="x64"', {
|
|
|
|
'type': 'static_library',
|
|
|
|
'sources': [
|
|
|
|
'src/large_pages/node_text_start.S'
|
|
|
|
]
|
|
|
|
}],
|
|
|
|
]
|
|
|
|
},
|
2011-08-03 17:01:30 -07:00
|
|
|
{
|
2015-09-29 10:22:00 -04:00
|
|
|
'target_name': '<(node_core_target_name)',
|
2017-12-04 16:07:53 -08:00
|
|
|
'type': 'executable',
|
2019-04-07 15:02:04 -04:00
|
|
|
|
|
|
|
'defines': [
|
2020-03-12 22:20:36 -04:00
|
|
|
'NODE_ARCH="<(target_arch)"',
|
|
|
|
'NODE_PLATFORM="<(OS)"',
|
2019-04-07 15:02:04 -04:00
|
|
|
'NODE_WANT_INTERNALS=1',
|
2017-12-04 16:07:53 -08:00
|
|
|
],
|
2019-04-07 15:02:04 -04:00
|
|
|
|
2018-03-07 12:25:26 -08:00
|
|
|
'includes': [
|
|
|
|
'node.gypi'
|
|
|
|
],
|
2019-04-07 15:02:04 -04:00
|
|
|
|
2017-12-04 16:07:53 -08:00
|
|
|
'include_dirs': [
|
|
|
|
'src',
|
2019-01-07 11:36:35 -08:00
|
|
|
'deps/v8/include'
|
2017-12-04 16:07:53 -08:00
|
|
|
],
|
2019-04-07 15:02:04 -04:00
|
|
|
|
|
|
|
'sources': [
|
|
|
|
'src/node_main.cc'
|
|
|
|
],
|
|
|
|
|
2019-09-04 17:56:51 -04:00
|
|
|
'dependencies': [
|
|
|
|
'deps/histogram/histogram.gyp:histogram',
|
|
|
|
'deps/uvwasi/uvwasi.gyp:uvwasi',
|
|
|
|
],
|
2018-09-03 22:00:09 -04:00
|
|
|
|
2019-02-03 15:51:20 -05:00
|
|
|
'msvs_settings': {
|
|
|
|
'VCLinkerTool': {
|
|
|
|
'GenerateMapFile': 'true', # /MAP
|
|
|
|
'MapExports': 'true', # /MAPINFO:EXPORTS
|
|
|
|
'RandomizedBaseAddress': 2, # enable ASLR
|
|
|
|
'DataExecutionPrevention': 2, # enable DEP
|
|
|
|
'AllowIsolation': 'true',
|
2022-07-02 18:38:11 +02: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 15:51:20 -05:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2018-09-03 22:00:09 -04: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-04 16:07:53 -08:00
|
|
|
'conditions': [
|
2020-04-06 14:17:57 +02:00
|
|
|
[ 'error_on_warn=="true"', {
|
|
|
|
'cflags': ['-Werror'],
|
2020-05-11 19:42:52 +01:00
|
|
|
'xcode_settings': {
|
|
|
|
'WARNING_CFLAGS': [ '-Werror' ],
|
|
|
|
},
|
2020-04-06 14:17:57 +02:00
|
|
|
}],
|
2017-12-04 16:07:53 -08:00
|
|
|
[ 'node_intermediate_lib_type=="static_library" and '
|
|
|
|
'node_shared=="true" and OS=="aix"', {
|
|
|
|
# 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-04 16:07:53 -08:00
|
|
|
}],
|
2019-02-03 15:51:20 -05:00
|
|
|
[ 'node_intermediate_lib_type=="static_library" and node_shared=="false"', {
|
2017-12-04 16:07:53 -08:00
|
|
|
'xcode_settings': {
|
|
|
|
'OTHER_LDFLAGS': [
|
2019-03-29 03:38:12 -04: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-04 16:07:53 -08:00
|
|
|
],
|
|
|
|
},
|
|
|
|
'msvs_settings': {
|
|
|
|
'VCLinkerTool': {
|
|
|
|
'AdditionalOptions': [
|
2019-04-08 10:48:09 -04:00
|
|
|
'/WHOLEARCHIVE:<(node_lib_target_name)<(STATIC_LIB_SUFFIX)',
|
2019-03-29 03:38:12 -04:00
|
|
|
'/WHOLEARCHIVE:<(STATIC_LIB_PREFIX)v8_base_without_compiler<(STATIC_LIB_SUFFIX)',
|
2017-12-04 16:07:53 -08:00
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'conditions': [
|
2022-09-21 18:02:40 +08:00
|
|
|
['OS != "aix" and OS != "mac" and OS != "ios"', {
|
2017-12-04 16:07:53 -08:00
|
|
|
'ldflags': [
|
2019-03-29 03:38:12 -04: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-04 16:07:53 -08:00
|
|
|
'-Wl,--no-whole-archive',
|
|
|
|
],
|
|
|
|
}],
|
2022-10-19 18:27:53 +01:00
|
|
|
[ 'OS=="win"', {
|
|
|
|
'sources': [ 'src/res/node.rc' ],
|
|
|
|
}],
|
2017-12-04 16:07:53 -08:00
|
|
|
],
|
|
|
|
}],
|
2018-02-02 10:06:33 -08: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 10:06:33 -08: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 10:06:33 -08:00
|
|
|
}],
|
2021-08-22 02:21:23 +08: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 03:38:12 -04:00
|
|
|
['OS=="win"', {
|
|
|
|
'libraries': [
|
|
|
|
'Dbghelp.lib',
|
|
|
|
'winmm.lib',
|
|
|
|
'Ws2_32.lib',
|
2018-09-05 10:06:59 -04:00
|
|
|
],
|
|
|
|
}],
|
2019-02-03 15:51:20 -05: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 15:02:04 -04:00
|
|
|
}],
|
2021-11-18 11:56:39 +08:00
|
|
|
['node_use_node_snapshot=="true"', {
|
2019-04-18 22:09:28 +08:00
|
|
|
'dependencies': [
|
|
|
|
'node_mksnapshot',
|
|
|
|
],
|
2022-03-24 21:37:08 +08: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 22:09:28 +08:00
|
|
|
],
|
2022-03-24 21:37:08 +08: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 22:09:28 +08:00
|
|
|
],
|
2022-03-24 21:37:08 +08:00
|
|
|
}],
|
2019-04-18 22:09:28 +08:00
|
|
|
],
|
2022-03-24 21:37:08 +08:00
|
|
|
}, {
|
2019-04-18 22:09:28 +08:00
|
|
|
'sources': [
|
|
|
|
'src/node_snapshot_stub.cc'
|
|
|
|
],
|
|
|
|
}],
|
2020-03-26 03:14:59 +00:00
|
|
|
[ 'OS in "linux freebsd" and '
|
2020-02-26 16:21:41 -08:00
|
|
|
'target_arch=="x64"', {
|
|
|
|
'dependencies': [ 'node_text_start' ],
|
|
|
|
'ldflags+': [
|
2020-03-03 15:02:02 -05:00
|
|
|
'<(obj_dir)/<(node_text_start_object_path)'
|
2020-02-26 16:21:41 -08:00
|
|
|
]
|
|
|
|
}],
|
2021-04-14 11:19:54 +02:00
|
|
|
|
|
|
|
['node_fipsinstall=="true"', {
|
|
|
|
'variables': {
|
|
|
|
'openssl-cli': '<(PRODUCT_DIR)/<(EXECUTABLE_PREFIX)openssl-cli<(EXECUTABLE_SUFFIX)',
|
|
|
|
'provider_name': 'libopenssl-fipsmodule',
|
2022-05-14 10:04:48 +02:00
|
|
|
'opensslconfig': './deps/openssl/nodejs-openssl.cnf',
|
2021-10-19 10:04:22 +02: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 10:04:48 +02:00
|
|
|
'fipsconfig': '<(PRODUCT_DIR)/obj.target/deps/openssl/fipsmodule.cnf',
|
2021-10-19 10:04:22 +02:00
|
|
|
'opensslconfig_internal': '<(PRODUCT_DIR)/obj.target/deps/openssl/openssl.cnf',
|
|
|
|
}],
|
|
|
|
],
|
2021-04-14 11:19:54 +02: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': [
|
|
|
|
'python', 'tools/copyfile.py',
|
|
|
|
'<(fipsmodule_internal)',
|
|
|
|
'<(fipsmodule)',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'action_name': 'copy_openssl_cnf_and_include_fips_cnf',
|
|
|
|
'inputs': [ '<(opensslconfig)', ],
|
|
|
|
'outputs': [ '<(opensslconfig_internal)', ],
|
|
|
|
'action': [
|
|
|
|
'python', 'tools/enable_fips_include.py',
|
|
|
|
'<(opensslconfig)',
|
|
|
|
'<(opensslconfig_internal)',
|
|
|
|
'<(fipsconfig)',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}, {
|
|
|
|
'variables': {
|
|
|
|
'opensslconfig_internal': '<(obj_dir)/deps/openssl/openssl.cnf',
|
2022-05-14 10:04:48 +02:00
|
|
|
'opensslconfig': './deps/openssl/nodejs-openssl.cnf',
|
2021-04-14 11:19:54 +02:00
|
|
|
},
|
|
|
|
'actions': [
|
|
|
|
{
|
|
|
|
'action_name': 'reset_openssl_cnf',
|
|
|
|
'inputs': [ '<(opensslconfig)', ],
|
|
|
|
'outputs': [ '<(opensslconfig_internal)', ],
|
|
|
|
'action': [
|
2022-11-14 16:36:22 +08:00
|
|
|
'<(python)', 'tools/copyfile.py',
|
2022-05-14 10:04:48 +02:00
|
|
|
'<(opensslconfig)',
|
|
|
|
'<(opensslconfig_internal)',
|
2021-04-14 11:19:54 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}],
|
2017-12-04 16:07:53 -08:00
|
|
|
],
|
2018-09-30 13:44:55 -04:00
|
|
|
}, # node_core_target_name
|
2017-12-04 16:07:53 -08:00
|
|
|
{
|
|
|
|
'target_name': '<(node_lib_target_name)',
|
|
|
|
'type': '<(node_intermediate_lib_type)',
|
2016-10-18 16:41:26 +02:00
|
|
|
'includes': [
|
2019-04-08 10:48:09 -04:00
|
|
|
'node.gypi',
|
2016-10-18 16:41:26 +02:00
|
|
|
],
|
|
|
|
|
2011-08-04 16:40:07 -07:00
|
|
|
'include_dirs': [
|
2011-08-08 12:11:48 -07:00
|
|
|
'src',
|
2017-11-06 09:59:01 +01:00
|
|
|
'<(SHARED_INTERMEDIATE_DIR)' # for node_natives.h
|
2011-08-04 16:40:07 -07:00
|
|
|
],
|
2019-09-04 17:56:51 -04:00
|
|
|
'dependencies': [
|
2021-08-13 01:49:27 -04:00
|
|
|
'deps/base64/base64.gyp:base64',
|
2021-07-14 23:20:27 +08:00
|
|
|
'deps/googletest/googletest.gyp:gtest_prod',
|
2019-09-04 17:56:51 -04:00
|
|
|
'deps/histogram/histogram.gyp:histogram',
|
|
|
|
'deps/uvwasi/uvwasi.gyp:uvwasi',
|
2022-11-30 11:05:17 -05:00
|
|
|
'deps/simdutf/simdutf.gyp:simdutf',
|
2019-09-04 17:56:51 -04:00
|
|
|
],
|
2011-08-04 16:40:07 -07:00
|
|
|
|
2011-08-03 17:01:30 -07:00
|
|
|
'sources': [
|
2019-03-22 10:23:51 +01:00
|
|
|
'src/api/async_resource.cc',
|
2019-01-17 03:00:55 +08:00
|
|
|
'src/api/callback.cc',
|
2020-10-11 15:13:19 +02:00
|
|
|
'src/api/embed_helpers.cc',
|
2019-01-17 03:00:55 +08:00
|
|
|
'src/api/encoding.cc',
|
|
|
|
'src/api/environment.cc',
|
|
|
|
'src/api/exceptions.cc',
|
|
|
|
'src/api/hooks.cc',
|
|
|
|
'src/api/utils.cc',
|
2017-11-14 13:34:52 +01:00
|
|
|
'src/async_wrap.cc',
|
2022-09-27 16:39:53 +08:00
|
|
|
'src/base_object.cc',
|
2011-08-08 12:11:48 -07:00
|
|
|
'src/cares_wrap.cc',
|
2022-08-25 01:59:55 +08:00
|
|
|
'src/cleanup_queue.cc',
|
2016-06-29 20:20:54 +02:00
|
|
|
'src/connect_wrap.cc',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/connection_wrap.cc',
|
2018-06-07 16:54:29 +02:00
|
|
|
'src/debug_utils.cc',
|
2017-01-18 12:34:33 +01:00
|
|
|
'src/env.cc',
|
|
|
|
'src/fs_event_wrap.cc',
|
2011-08-08 12:11:48 -07:00
|
|
|
'src/handle_wrap.cc',
|
2018-07-01 01:27:09 +02:00
|
|
|
'src/heap_utils.cc',
|
2020-02-27 13:14:38 -08:00
|
|
|
'src/histogram.cc',
|
2018-10-19 15:10:59 -04: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',
|
2015-02-23 23:09:44 +03:00
|
|
|
'src/js_stream.cc',
|
2020-03-29 20:11:56 +02:00
|
|
|
'src/json_utils.cc',
|
2020-05-12 15:17:42 -07:00
|
|
|
'src/js_udp_wrap.cc',
|
2017-06-05 19:44:56 -05:00
|
|
|
'src/module_wrap.cc',
|
2011-08-08 12:11:48 -07:00
|
|
|
'src/node.cc',
|
2017-03-20 14:55:26 -07:00
|
|
|
'src/node_api.cc',
|
2018-11-29 00:46:45 +08:00
|
|
|
'src/node_binding.cc',
|
2021-01-05 15:39:54 -08:00
|
|
|
'src/node_blob.cc',
|
2011-08-08 12:11:48 -07:00
|
|
|
'src/node_buffer.cc',
|
2022-08-05 02:32:06 +08:00
|
|
|
'src/node_builtins.cc',
|
2016-04-18 21:02:18 -07:00
|
|
|
'src/node_config.cc',
|
2011-08-08 12:11:48 -07:00
|
|
|
'src/node_constants.cc',
|
vm, core, module: re-do vm to fix known issues
As documented in #3042 and in [1], the existing vm implementation has
many problems. All of these are solved by @brianmcd's [contextify][2]
package. This commit uses contextify as a conceptual base and its code
core to overhaul the vm module and fix its many edge cases and caveats.
Functionally, this fixes #3042. In particular:
- A context is now indistinguishable from the object it is based on
(the "sandbox"). A context is simply a sandbox that has been marked
by the vm module, via `vm.createContext`, with special internal
information that allows scripts to be run inside of it.
- Consequently, items added to the context from anywhere are
immediately visible to all code that can access that context, both
inside and outside the virtual machine.
This commit also smooths over the API very slightly:
- Parameter defaults are now uniformly triggered via `undefined`, per
ES6 semantics and previous discussion at [3].
- Several undocumented and problematic features have been removed, e.g.
the conflation of `vm.Script` with `vm` itself, and the fact that
`Script` instances also had all static `vm` methods. The API is now
exactly as documented (although arguably the existence of the
`vm.Script` export is not yet documented, just the `Script` class
itself).
In terms of implementation, this replaces node_script.cc with
node_contextify.cc, which is derived originally from [4] (see [5]) but
has since undergone extensive modifications and iterations to expose
the most useful C++ API and use the coding conventions and utilities of
Node core.
The bindings exposed by `process.binding('contextify')`
(node_contextify.cc) replace those formerly exposed by
`process.binding('evals')` (node_script.cc). They are:
- ContextifyScript(code, [filename]), with methods:
- runInThisContext()
- runInContext(sandbox, [timeout])
- makeContext(sandbox)
From this, the vm.js file builds the entire documented vm module API.
node.js and module.js were modified to use this new native binding, or
the vm module itself where possible. This introduces an extra line or
two into the stack traces of module compilation (and thus into most
stack traces), explaining the changed tests.
The tests were also updated slightly, with all vm-related simple tests
consolidated as test/simple/test-vm-* (some of them were formerly
test/simple/test-script-*). At the same time they switched from
`common.debug` to `console.error` and were updated to use
`assert.throws` instead of rolling their own error-testing methods.
New tests were also added, of course, demonstrating the new
capabilities and fixes.
[1]: http://nodejs.org/docs/v0.10.16/api/vm.html#vm_caveats
[2]: https://github.com/brianmcd/contextify
[3]: https://github.com/joyent/node/issues/5323#issuecomment-20250726
[4]: https://github.com/kkoopa/contextify/blob/bf123f3ef960f0943d1e30bda02e3163a004e964/src/contextify.cc
[5]: https://gist.github.com/domenic/6068120
2013-07-27 00:34:12 -04:00
|
|
|
'src/node_contextify.cc',
|
2018-12-16 03:13:12 +08:00
|
|
|
'src/node_credentials.cc',
|
2019-08-27 17:14:27 -07:00
|
|
|
'src/node_dir.cc',
|
2018-12-16 01:32:39 +08:00
|
|
|
'src/node_env_var.cc',
|
2018-11-03 22:45:40 +08:00
|
|
|
'src/node_errors.cc',
|
2019-04-20 21:35:27 +08:00
|
|
|
'src/node_external_reference.cc',
|
2011-08-08 12:11:48 -07:00
|
|
|
'src/node_file.cc',
|
2019-09-17 14:17:08 +02:00
|
|
|
'src/node_http_parser.cc',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/node_http2.cc',
|
|
|
|
'src/node_i18n.cc',
|
2019-04-14 14:41:04 +08:00
|
|
|
'src/node_main_instance.cc',
|
2017-09-05 22:38:32 +02:00
|
|
|
'src/node_messaging.cc',
|
2018-12-02 04:16:09 +08:00
|
|
|
'src/node_metadata.cc',
|
2018-08-10 02:45:28 +02:00
|
|
|
'src/node_options.cc',
|
2011-08-08 12:11:48 -07:00
|
|
|
'src/node_os.cc',
|
2017-08-07 15:53:24 -07:00
|
|
|
'src/node_perf.cc',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/node_platform.cc',
|
2017-12-25 22:17:25 -02:00
|
|
|
'src/node_postmortem_metadata.cc',
|
2018-12-31 22:59:40 +08:00
|
|
|
'src/node_process_events.cc',
|
2019-01-09 00:00:33 +08:00
|
|
|
'src/node_process_methods.cc',
|
|
|
|
'src/node_process_object.cc',
|
2022-08-31 22:41:42 +08:00
|
|
|
'src/node_realm.cc',
|
2020-03-12 22:20:36 -04:00
|
|
|
'src/node_report.cc',
|
|
|
|
'src/node_report_module.cc',
|
|
|
|
'src/node_report_utils.cc',
|
2017-01-26 21:38:11 -08:00
|
|
|
'src/node_serdes.cc',
|
2022-05-03 00:46:31 +08:00
|
|
|
'src/node_shadow_realm.cc',
|
2021-01-29 00:04:22 +08:00
|
|
|
'src/node_snapshotable.cc',
|
2020-03-03 11:18:45 -08:00
|
|
|
'src/node_sockaddr.cc',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/node_stat_watcher.cc',
|
2018-12-19 20:33:20 +08:00
|
|
|
'src/node_symbols.cc',
|
2018-12-19 18:44:14 +08:00
|
|
|
'src/node_task_queue.cc',
|
2017-07-17 16:47:12 -07:00
|
|
|
'src/node_trace_events.cc',
|
2018-01-27 22:01:32 +01:00
|
|
|
'src/node_types.cc',
|
2016-05-31 11:52:19 -07:00
|
|
|
'src/node_url.cc',
|
2021-06-10 15:58:41 +08:00
|
|
|
'src/node_url_tables.cc',
|
2015-09-29 14:30:22 -05:00
|
|
|
'src/node_util.cc',
|
2013-10-28 14:57:47 +01:00
|
|
|
'src/node_v8.cc',
|
2019-09-04 17:56:51 -04:00
|
|
|
'src/node_wasi.cc',
|
2022-04-23 05:09:15 +02:00
|
|
|
'src/node_wasm_web_api.cc',
|
2012-10-08 21:24:08 +02:00
|
|
|
'src/node_watchdog.cc',
|
2017-09-01 17:03:41 +02:00
|
|
|
'src/node_worker.cc',
|
2011-09-06 16:13:05 -07:00
|
|
|
'src/node_zlib.cc',
|
2011-08-08 12:11:48 -07:00
|
|
|
'src/pipe_wrap.cc',
|
2017-01-18 12:34:33 +01:00
|
|
|
'src/process_wrap.cc',
|
2012-08-20 23:59:21 +02:00
|
|
|
'src/signal_wrap.cc',
|
2014-02-10 21:22:06 +01:00
|
|
|
'src/spawn_sync.cc',
|
stream_base: introduce StreamBase
StreamBase is an improved way to write C++ streams. The class itself is
for separting `StreamWrap` (with the methods like `.writeAsciiString`,
`.writeBuffer`, `.writev`, etc) from the `HandleWrap` class, making
possible to write abstract C++ streams that are not bound to any uv
socket.
The following methods are important part of the abstraction (which
mimics libuv's stream API):
* Events:
* `OnAlloc(size_t size, uv_buf_t*)`
* `OnRead(ssize_t nread, const uv_buf_t*, uv_handle_type pending)`
* `OnAfterWrite(WriteWrap*)`
* Wrappers:
* `DoShutdown(ShutdownWrap*)`
* `DoTryWrite(uv_buf_t** bufs, size_t* count)`
* `DoWrite(WriteWrap*, uv_buf_t*, size_t count, uv_stream_t* handle)`
* `Error()`
* `ClearError()`
The implementation should provide all of these methods, thus providing
the access to the underlying resource (be it uv handle, TLS socket, or
anything else).
A C++ stream may consume the input of another stream by replacing the
event callbacks and proxying the writes. This kind of API is actually
used now for the TLSWrap implementation, making it possible to wrap TLS
stream into another TLS stream. Thus legacy API calls are no longer
required in `_tls_wrap.js`.
PR-URL: https://github.com/iojs/io.js/pull/840
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-02-22 21:59:07 +03:00
|
|
|
'src/stream_base.cc',
|
2018-02-13 01:23:50 +01:00
|
|
|
'src/stream_pipe.cc',
|
2011-08-08 12:11:48 -07:00
|
|
|
'src/stream_wrap.cc',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/string_bytes.cc',
|
|
|
|
'src/string_decoder.cc',
|
2011-08-08 12:11:48 -07:00
|
|
|
'src/tcp_wrap.cc',
|
2018-05-13 17:42:22 +02:00
|
|
|
'src/timers.cc',
|
2020-07-03 07:42:45 -07:00
|
|
|
'src/timer_wrap.cc',
|
2017-01-18 12:34:33 +01:00
|
|
|
'src/tracing/agent.cc',
|
|
|
|
'src/tracing/node_trace_buffer.cc',
|
|
|
|
'src/tracing/node_trace_writer.cc',
|
|
|
|
'src/tracing/trace_event.cc',
|
2018-06-22 12:50:01 -07:00
|
|
|
'src/tracing/traced_value.cc',
|
2011-09-20 13:38:07 -07:00
|
|
|
'src/tty_wrap.cc',
|
2011-08-24 16:20:08 -07:00
|
|
|
'src/udp_wrap.cc',
|
2017-01-17 07:51:25 +01:00
|
|
|
'src/util.cc',
|
2013-07-16 23:08:25 +02:00
|
|
|
'src/uv.cc',
|
2011-08-15 17:35:48 +01:00
|
|
|
# headers to make for a more pleasant IDE experience
|
2017-08-25 12:45:00 -07:00
|
|
|
'src/aliased_buffer.h',
|
2020-04-10 19:42:37 -07:00
|
|
|
'src/aliased_struct.h',
|
|
|
|
'src/aliased_struct-inl.h',
|
2017-11-14 13:34:52 +01:00
|
|
|
'src/async_wrap.h',
|
|
|
|
'src/async_wrap-inl.h',
|
2017-11-14 13:34:52 +01:00
|
|
|
'src/base_object.h',
|
|
|
|
'src/base_object-inl.h',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/base64.h',
|
2020-08-25 15:31:11 -05:00
|
|
|
'src/base64-inl.h',
|
2020-05-06 23:36:10 +02:00
|
|
|
'src/callback_queue.h',
|
|
|
|
'src/callback_queue-inl.h',
|
2022-08-25 01:59:55 +08:00
|
|
|
'src/cleanup_queue.h',
|
|
|
|
'src/cleanup_queue-inl.h',
|
2016-06-29 20:20:54 +02:00
|
|
|
'src/connect_wrap.h',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/connection_wrap.h',
|
2018-05-27 16:37:30 +02:00
|
|
|
'src/debug_utils.h',
|
2020-01-21 18:30:20 +01:00
|
|
|
'src/debug_utils-inl.h',
|
2022-08-31 22:41:42 +08:00
|
|
|
'src/env_properties.h',
|
2013-08-11 00:26:11 +02:00
|
|
|
'src/env.h',
|
|
|
|
'src/env-inl.h',
|
2011-08-15 17:35:48 +01:00
|
|
|
'src/handle_wrap.h',
|
2019-01-07 11:36:35 -08:00
|
|
|
'src/histogram.h',
|
|
|
|
'src/histogram-inl.h',
|
2015-02-23 23:09:44 +03:00
|
|
|
'src/js_stream.h',
|
2020-03-29 20:11:56 +02:00
|
|
|
'src/json_utils.h',
|
2020-02-21 08:26:29 -08:00
|
|
|
'src/large_pages/node_large_page.cc',
|
2020-02-25 21:38:34 -05:00
|
|
|
'src/large_pages/node_large_page.h',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/memory_tracker.h',
|
|
|
|
'src/memory_tracker-inl.h',
|
2017-06-05 19:44:56 -05:00
|
|
|
'src/module_wrap.h',
|
2011-08-15 17:35:48 +01:00
|
|
|
'src/node.h',
|
2018-11-06 12:17:05 +01:00
|
|
|
'src/node_api.h',
|
|
|
|
'src/node_api_types.h',
|
2018-11-29 00:46:45 +08:00
|
|
|
'src/node_binding.h',
|
2021-01-05 15:39:54 -08:00
|
|
|
'src/node_blob.h',
|
2011-08-15 17:35:48 +01:00
|
|
|
'src/node_buffer.h',
|
2022-08-05 02:32:06 +08:00
|
|
|
'src/node_builtins.h',
|
2011-08-15 17:35:48 +01:00
|
|
|
'src/node_constants.h',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/node_context_data.h',
|
2017-12-09 10:32:34 -06:00
|
|
|
'src/node_contextify.h',
|
2019-08-27 17:14:27 -07:00
|
|
|
'src/node_dir.h',
|
2018-11-06 12:17:05 +01:00
|
|
|
'src/node_errors.h',
|
2022-10-06 20:41:16 +08:00
|
|
|
'src/node_exit_code.h',
|
2019-04-20 21:35:27 +08:00
|
|
|
'src/node_external_reference.h',
|
2017-12-14 10:49:55 -08:00
|
|
|
'src/node_file.h',
|
2019-11-18 14:49:56 +01:00
|
|
|
'src/node_file-inl.h',
|
2020-03-02 17:27:06 -08:00
|
|
|
'src/node_http_common.h',
|
|
|
|
'src/node_http_common-inl.h',
|
http2: introducing HTTP/2
At long last: The initial *experimental* implementation of HTTP/2.
This is an accumulation of the work that has been done in the nodejs/http2
repository, squashed down to a couple of commits. The original commit
history has been preserved in the nodejs/http2 repository.
This PR introduces the nghttp2 C library as a new dependency. This library
provides the majority of the HTTP/2 protocol implementation, with the rest
of the code here providing the mapping of the library into a usable JS API.
Within src, a handful of new node_http2_*.c and node_http2_*.h files are
introduced. These provide the internal mechanisms that interface with nghttp
and define the `process.binding('http2')` interface.
The JS API is defined within `internal/http2/*.js`.
There are two APIs provided: Core and Compat.
The Core API is HTTP/2 specific and is designed to be as minimal and as
efficient as possible.
The Compat API is intended to be as close to the existing HTTP/1 API as
possible, with some exceptions.
Tests, documentation and initial benchmarks are included.
The `http2` module is gated by a new `--expose-http2` command line flag.
When used, `require('http2')` will be exposed to users. Note that there
is an existing `http2` module on npm that would be impacted by the introduction
of this module, which is the main reason for gating this behind a flag.
When using `require('http2')` the first time, a process warning will be
emitted indicating that an experimental feature is being used.
To run the benchmarks, the `h2load` tool (part of the nghttp project) is
required: `./node benchmarks/http2/simple.js benchmarker=h2load`. Only
two benchmarks are currently available.
Additional configuration options to enable verbose debugging are provided:
```
$ ./configure --debug-http2 --debug-nghttp2
$ NODE_DEBUG=http2 ./node
```
The `--debug-http2` configuration option enables verbose debug statements
from the `src/node_http2_*` files. The `--debug-nghttp2` enables the nghttp
library's own verbose debug output. The `NODE_DEBUG=http2` enables JS-level
debug output.
The following illustrates as simple HTTP/2 server and client interaction:
(The HTTP/2 client and server support both plain text and TLS connections)
```jt client = http2.connect('http://localhost:80');
const req = client.request({ ':path': '/some/path' });
req.on('data', (chunk) => { /* do something with the data */ });
req.on('end', () => {
client.destroy();
});
// Plain text (non-TLS server)
const server = http2.createServer();
server.on('stream', (stream, requestHeaders) => {
stream.respond({ ':status': 200 });
stream.write('hello ');
stream.end('world');
});
server.listen(80);
```
```js
const http2 = require('http2');
const client = http2.connect('http://localhost');
```
Author: Anna Henningsen <anna@addaleax.net>
Author: Colin Ihrig <cjihrig@gmail.com>
Author: Daniel Bevenius <daniel.bevenius@gmail.com>
Author: James M Snell <jasnell@gmail.com>
Author: Jun Mukai
Author: Kelvin Jin
Author: Matteo Collina <matteo.collina@gmail.com>
Author: Robert Kowalski <rok@kowalski.gd>
Author: Santiago Gimeno <santiago.gimeno@gmail.com>
Author: Sebastiaan Deckers <sebdeckers83@gmail.com>
Author: Yosuke Furukawa <yosuke.furukawa@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/14239
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
2017-07-17 10:17:16 -07:00
|
|
|
'src/node_http2.h',
|
2017-08-25 12:45:00 -07:00
|
|
|
'src/node_http2_state.h',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/node_i18n.h',
|
2013-08-11 00:26:11 +02:00
|
|
|
'src/node_internals.h',
|
2019-04-14 14:41:04 +08:00
|
|
|
'src/node_main_instance.h',
|
2019-12-01 01:30:40 +01:00
|
|
|
'src/node_mem.h',
|
|
|
|
'src/node_mem-inl.h',
|
2017-09-05 22:38:32 +02:00
|
|
|
'src/node_messaging.h',
|
2018-12-02 04:16:09 +08:00
|
|
|
'src/node_metadata.h',
|
2016-06-18 01:39:05 +02:00
|
|
|
'src/node_mutex.h',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/node_object_wrap.h',
|
2018-08-10 02:45:28 +02:00
|
|
|
'src/node_options.h',
|
|
|
|
'src/node_options-inl.h',
|
2017-08-07 15:53:24 -07:00
|
|
|
'src/node_perf.h',
|
|
|
|
'src/node_perf_common.h',
|
2018-02-21 15:24:18 +01:00
|
|
|
'src/node_platform.h',
|
2018-12-31 23:18:08 +08:00
|
|
|
'src/node_process.h',
|
2021-05-21 21:18:44 +05:30
|
|
|
'src/node_process-inl.h',
|
2022-08-31 22:41:42 +08:00
|
|
|
'src/node_realm.h',
|
|
|
|
'src/node_realm-inl.h',
|
2020-03-12 22:20:36 -04:00
|
|
|
'src/node_report.h',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/node_revert.h',
|
2011-08-15 17:35:48 +01:00
|
|
|
'src/node_root_certs.h',
|
2022-05-03 00:46:31 +08:00
|
|
|
'src/node_shadow_realm.h',
|
2021-01-29 00:04:22 +08:00
|
|
|
'src/node_snapshotable.h',
|
2022-04-12 00:38:57 +08:00
|
|
|
'src/node_snapshot_builder.h',
|
2020-03-03 11:18:45 -08:00
|
|
|
'src/node_sockaddr.h',
|
|
|
|
'src/node_sockaddr-inl.h',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/node_stat_watcher.h',
|
2018-11-14 22:38:12 +08:00
|
|
|
'src/node_union_bytes.h',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/node_url.h',
|
2022-08-10 00:04:44 +08:00
|
|
|
'src/node_util.h',
|
2011-08-15 17:35:48 +01:00
|
|
|
'src/node_version.h',
|
2021-01-28 23:37:21 +08:00
|
|
|
'src/node_v8.h',
|
2019-01-17 02:34:43 +08:00
|
|
|
'src/node_v8_platform-inl.h',
|
2019-09-04 17:56:51 -04:00
|
|
|
'src/node_wasi.h',
|
2012-10-08 21:24:08 +02:00
|
|
|
'src/node_watchdog.h',
|
2017-09-01 17:03:41 +02:00
|
|
|
'src/node_worker.h',
|
2011-08-15 17:35:48 +01:00
|
|
|
'src/pipe_wrap.h',
|
2017-11-14 13:34:52 +01:00
|
|
|
'src/req_wrap.h',
|
|
|
|
'src/req_wrap-inl.h',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/spawn_sync.h',
|
stream_base: introduce StreamBase
StreamBase is an improved way to write C++ streams. The class itself is
for separting `StreamWrap` (with the methods like `.writeAsciiString`,
`.writeBuffer`, `.writev`, etc) from the `HandleWrap` class, making
possible to write abstract C++ streams that are not bound to any uv
socket.
The following methods are important part of the abstraction (which
mimics libuv's stream API):
* Events:
* `OnAlloc(size_t size, uv_buf_t*)`
* `OnRead(ssize_t nread, const uv_buf_t*, uv_handle_type pending)`
* `OnAfterWrite(WriteWrap*)`
* Wrappers:
* `DoShutdown(ShutdownWrap*)`
* `DoTryWrite(uv_buf_t** bufs, size_t* count)`
* `DoWrite(WriteWrap*, uv_buf_t*, size_t count, uv_stream_t* handle)`
* `Error()`
* `ClearError()`
The implementation should provide all of these methods, thus providing
the access to the underlying resource (be it uv handle, TLS socket, or
anything else).
A C++ stream may consume the input of another stream by replacing the
event callbacks and proxying the writes. This kind of API is actually
used now for the TLSWrap implementation, making it possible to wrap TLS
stream into another TLS stream. Thus legacy API calls are no longer
required in `_tls_wrap.js`.
PR-URL: https://github.com/iojs/io.js/pull/840
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-02-22 21:59:07 +03:00
|
|
|
'src/stream_base.h',
|
2015-02-25 20:43:14 +03:00
|
|
|
'src/stream_base-inl.h',
|
2018-02-13 01:23:50 +01:00
|
|
|
'src/stream_pipe.h',
|
2011-08-15 17:35:48 +01:00
|
|
|
'src/stream_wrap.h',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/string_bytes.h',
|
|
|
|
'src/string_decoder.h',
|
|
|
|
'src/string_decoder-inl.h',
|
|
|
|
'src/string_search.h',
|
|
|
|
'src/tcp_wrap.h',
|
2017-01-17 08:12:08 +01:00
|
|
|
'src/tracing/agent.h',
|
|
|
|
'src/tracing/node_trace_buffer.h',
|
|
|
|
'src/tracing/node_trace_writer.h',
|
2017-10-30 13:45:10 +01:00
|
|
|
'src/tracing/trace_event.h',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/tracing/trace_event_common.h',
|
2018-06-22 12:50:01 -07:00
|
|
|
'src/tracing/traced_value.h',
|
2020-07-03 07:42:45 -07:00
|
|
|
'src/timer_wrap.h',
|
2021-11-13 03:17:42 +05:30
|
|
|
'src/timer_wrap-inl.h',
|
2018-11-19 21:36:32 -05:00
|
|
|
'src/tty_wrap.h',
|
|
|
|
'src/udp_wrap.h',
|
2013-08-11 00:26:11 +02:00
|
|
|
'src/util.h',
|
|
|
|
'src/util-inl.h',
|
2018-11-19 21:36:32 -05:00
|
|
|
# Dependency headers
|
2015-04-03 10:13:43 +11:00
|
|
|
'deps/v8/include/v8.h',
|
2011-09-05 01:01:53 +02:00
|
|
|
# javascript files to make for an even more pleasant IDE experience
|
|
|
|
'<@(library_files)',
|
2021-06-18 05:01:41 +08:00
|
|
|
'<@(deps_files)',
|
2018-11-19 21:36:32 -05:00
|
|
|
# node.gyp is added by default, common.gypi is added for change detection
|
2011-10-28 12:10:24 +02:00
|
|
|
'common.gypi',
|
2011-08-04 16:40:07 -07:00
|
|
|
],
|
|
|
|
|
2017-11-06 10:30:29 +01:00
|
|
|
'variables': {
|
|
|
|
'openssl_system_ca_path%': '',
|
2020-06-03 12:56:58 +02:00
|
|
|
'openssl_default_cipher_list%': '',
|
2017-11-06 10:30:29 +01:00
|
|
|
},
|
|
|
|
|
2022-09-11 10:48:34 +02:00
|
|
|
'cflags': ['-Werror=unused-result'],
|
|
|
|
|
2011-08-04 16:40:07 -07:00
|
|
|
'defines': [
|
2015-01-08 13:05:51 +01:00
|
|
|
'NODE_ARCH="<(target_arch)"',
|
|
|
|
'NODE_PLATFORM="<(OS)"',
|
|
|
|
'NODE_WANT_INTERNALS=1',
|
2015-07-01 23:47:37 +02:00
|
|
|
# Warn when using deprecated V8 APIs.
|
|
|
|
'V8_DEPRECATION_WARNINGS=1',
|
2017-11-06 10:30:29 +01:00
|
|
|
'NODE_OPENSSL_SYSTEM_CERT_PATH="<(openssl_system_ca_path)"',
|
2011-08-03 17:01:30 -07:00
|
|
|
],
|
2018-09-03 22:00:09 -04: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-01 21:19:16 -07:00
|
|
|
'conditions': [
|
2020-06-03 12:56:58 +02:00
|
|
|
[ 'openssl_default_cipher_list!=""', {
|
|
|
|
'defines': [
|
|
|
|
'NODE_OPENSSL_DEFAULT_CIPHER_LIST="<(openssl_default_cipher_list)"'
|
|
|
|
]
|
|
|
|
}],
|
2020-04-06 14:17:57 +02:00
|
|
|
[ 'error_on_warn=="true"', {
|
|
|
|
'cflags': ['-Werror'],
|
2020-05-11 19:42:52 +01:00
|
|
|
'xcode_settings': {
|
|
|
|
'WARNING_CFLAGS': [ '-Werror' ],
|
|
|
|
},
|
2020-04-06 14:17:57 +02:00
|
|
|
}],
|
2020-01-11 14:03:59 -08:00
|
|
|
[ 'node_builtin_modules_path!=""', {
|
|
|
|
'defines': [ 'NODE_BUILTIN_MODULES_PATH="<(node_builtin_modules_path)"' ]
|
|
|
|
}],
|
2019-07-29 20:15:14 +02:00
|
|
|
[ 'node_shared=="true"', {
|
|
|
|
'sources': [
|
|
|
|
'src/node_snapshot_stub.cc',
|
|
|
|
]
|
|
|
|
}],
|
2017-11-01 21:19:16 -07:00
|
|
|
[ 'node_shared=="true" and node_module_version!="" and OS!="win"', {
|
|
|
|
'product_extension': '<(shlib_suffix)',
|
2018-02-02 10:06:33 -08:00
|
|
|
'xcode_settings': {
|
|
|
|
'LD_DYLIB_INSTALL_NAME':
|
|
|
|
'@rpath/lib<(node_core_target_name).<(shlib_suffix)'
|
|
|
|
},
|
2017-11-08 09:41:09 +01:00
|
|
|
}],
|
2021-11-18 11:56:39 +08:00
|
|
|
[ 'node_use_node_code_cache=="true"', {
|
|
|
|
'defines': [
|
|
|
|
'NODE_USE_NODE_CODE_CACHE=1',
|
|
|
|
],
|
|
|
|
}],
|
2017-12-04 16:07:53 -08:00
|
|
|
['node_shared=="true" and OS=="aix"', {
|
|
|
|
'product_name': 'node_base',
|
|
|
|
}],
|
2017-11-08 09:41:09 +01:00
|
|
|
[ 'v8_enable_inspector==1', {
|
2018-09-27 10:45:24 -04:00
|
|
|
'includes' : [ 'src/inspector/node_inspector.gypi' ],
|
2017-11-08 09:41:09 +01:00
|
|
|
}, {
|
|
|
|
'defines': [ 'HAVE_INSPECTOR=0' ]
|
|
|
|
}],
|
|
|
|
[ 'OS=="win"', {
|
2017-08-23 09:52:59 +02:00
|
|
|
'conditions': [
|
2017-12-04 16:07:53 -08:00
|
|
|
[ 'node_intermediate_lib_type!="static_library"', {
|
2017-08-23 09:52:59 +02:00
|
|
|
'sources': [
|
|
|
|
'src/res/node.rc',
|
|
|
|
],
|
|
|
|
}],
|
2017-11-08 09:41:09 +01:00
|
|
|
],
|
2019-04-08 19:41:52 +01: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-12 22:20:36 -04:00
|
|
|
'Ws2_32',
|
2019-04-08 19:41:52 +01:00
|
|
|
],
|
2017-11-08 09:41:09 +01:00
|
|
|
}],
|
|
|
|
[ 'node_use_openssl=="true"', {
|
|
|
|
'sources': [
|
2020-08-25 10:05:51 -07:00
|
|
|
'src/crypto/crypto_aes.cc',
|
2020-09-18 10:14:58 -07:00
|
|
|
'src/crypto/crypto_bio.cc',
|
2020-08-25 10:05:51 -07:00
|
|
|
'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',
|
2021-01-24 14:31:48 +01:00
|
|
|
'src/crypto/crypto_ec.cc',
|
2020-08-25 10:05:51 -07:00
|
|
|
'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',
|
2020-09-18 10:14:58 -07:00
|
|
|
'src/crypto/crypto_clienthello.cc',
|
2020-08-25 10:05:51 -07:00
|
|
|
'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',
|
2020-10-06 15:28:14 -07:00
|
|
|
'src/crypto/crypto_tls.cc',
|
2020-08-25 10:05:51 -07:00
|
|
|
'src/crypto/crypto_aes.cc',
|
2021-01-04 21:27:20 -08:00
|
|
|
'src/crypto/crypto_x509.cc',
|
2020-09-18 10:14:58 -07:00
|
|
|
'src/crypto/crypto_bio.h',
|
|
|
|
'src/crypto/crypto_clienthello-inl.h',
|
2020-08-25 10:05:51 -07:00
|
|
|
'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',
|
2020-10-06 15:28:14 -07:00
|
|
|
'src/crypto/crypto_tls.h',
|
2020-08-25 10:05:51 -07:00
|
|
|
'src/crypto/crypto_clienthello.h',
|
|
|
|
'src/crypto/crypto_context.h',
|
2021-03-18 06:47:03 +00:00
|
|
|
'src/crypto/crypto_ec.h',
|
2020-08-25 10:05:51 -07:00
|
|
|
'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',
|
2021-01-04 21:27:20 -08:00
|
|
|
'src/crypto/crypto_x509.h',
|
2017-11-08 09:41:09 +01:00
|
|
|
'src/node_crypto.cc',
|
2020-10-06 15:28:14 -07:00
|
|
|
'src/node_crypto.h'
|
2017-11-08 09:41:09 +01:00
|
|
|
],
|
|
|
|
}],
|
2020-07-12 05:52:46 +01:00
|
|
|
[ 'OS in "linux freebsd mac solaris" and '
|
2020-01-28 11:01:32 +01:00
|
|
|
'target_arch=="x64" and '
|
|
|
|
'node_target_type=="executable"', {
|
2018-03-23 12:16:48 -07:00
|
|
|
'defines': [ 'NODE_ENABLE_LARGE_CODE_PAGES=1' ],
|
|
|
|
}],
|
2016-04-18 16:10:20 +02:00
|
|
|
[ 'use_openssl_def==1', {
|
2018-09-30 13:44:55 -04: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 16:10:20 +02:00
|
|
|
'variables': {
|
|
|
|
'mkssldef_flags': [
|
|
|
|
# Categories to export.
|
|
|
|
'-CAES,BF,BIO,DES,DH,DSA,EC,ECDH,ECDSA,ENGINE,EVP,HMAC,MD4,MD5,'
|
2018-03-17 05:13:47 +01:00
|
|
|
'PSK,RC2,RC4,RSA,SHA,SHA0,SHA1,SHA256,SHA512,SOCK,STDIO,TLSEXT,'
|
2019-05-06 12:59:11 -07:00
|
|
|
'UI,FP_API,TLS1_METHOD,TLS1_1_METHOD,TLS1_2_METHOD,SCRYPT,OCSP,'
|
2019-02-07 19:20:25 +00:00
|
|
|
'NEXTPROTONEG,RMD160,CAST,DEPRECATEDIN_1_1_0,DEPRECATEDIN_1_2_0',
|
2016-04-18 16:10:20 +02:00
|
|
|
# Defines.
|
|
|
|
'-DWIN32',
|
|
|
|
# Symbols to filter from the export list.
|
|
|
|
'-X^DSO',
|
|
|
|
'-X^_',
|
|
|
|
'-X^private_',
|
2016-08-05 04:36:40 +02:00
|
|
|
# Base generated DEF on zlib.def
|
|
|
|
'-Bdeps/zlib/win32/zlib.def'
|
2016-04-18 16:10:20 +02:00
|
|
|
],
|
|
|
|
},
|
|
|
|
'conditions': [
|
2021-04-14 11:19:54 +02:00
|
|
|
['openssl_is_fips!=""', {
|
2016-04-18 16:10:20 +02:00
|
|
|
'variables': { 'mkssldef_flags': ['-DOPENSSL_FIPS'] },
|
|
|
|
}],
|
|
|
|
],
|
|
|
|
'actions': [
|
|
|
|
{
|
|
|
|
'action_name': 'mkssldef',
|
|
|
|
'inputs': [
|
2018-03-07 22:31:05 +09:00
|
|
|
'deps/openssl/openssl/util/libcrypto.num',
|
|
|
|
'deps/openssl/openssl/util/libssl.num',
|
2016-04-18 16:10:20 +02:00
|
|
|
],
|
|
|
|
'outputs': ['<(SHARED_INTERMEDIATE_DIR)/openssl.def'],
|
2018-09-30 13:44:55 -04:00
|
|
|
'process_outputs_as_sources': 1,
|
2016-04-18 16:10:20 +02:00
|
|
|
'action': [
|
2021-07-20 18:00:19 +08:00
|
|
|
'<(python)',
|
2016-04-18 16:10:20 +02:00
|
|
|
'tools/mkssldef.py',
|
|
|
|
'<@(mkssldef_flags)',
|
|
|
|
'-o',
|
|
|
|
'<@(_outputs)',
|
|
|
|
'<@(_inputs)',
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
}],
|
2022-10-27 14:25:55 +02:00
|
|
|
[ 'debug_nghttp2==1', {
|
|
|
|
'defines': [ 'NODE_DEBUG_NGHTTP2=1' ]
|
|
|
|
}],
|
2016-04-18 16:10:20 +02:00
|
|
|
],
|
2011-08-03 17:01:30 -07:00
|
|
|
'actions': [
|
|
|
|
{
|
|
|
|
'action_name': 'node_js2c',
|
2017-02-02 23:23:49 +01:00
|
|
|
'process_outputs_as_sources': 1,
|
2011-08-03 17:01:30 -07:00
|
|
|
'inputs': [
|
2019-01-14 18:43:16 -05:00
|
|
|
# Put the code first so it's a dependency and can be used for invocation.
|
|
|
|
'tools/js2c.py',
|
2011-08-03 17:01:30 -07:00
|
|
|
'<@(library_files)',
|
2021-06-18 05:01:41 +08:00
|
|
|
'<@(deps_files)',
|
2019-12-01 12:55:54 -08:00
|
|
|
'config.gypi'
|
2011-08-03 17:01:30 -07:00
|
|
|
],
|
|
|
|
'outputs': [
|
2017-02-02 23:23:49 +01:00
|
|
|
'<(SHARED_INTERMEDIATE_DIR)/node_javascript.cc',
|
2011-08-03 17:01:30 -07:00
|
|
|
],
|
2013-07-24 12:53:28 +02:00
|
|
|
'action': [
|
2021-07-20 18:00:19 +08:00
|
|
|
'<(python)',
|
2021-06-18 05:01:41 +08:00
|
|
|
'tools/js2c.py',
|
|
|
|
'--directory',
|
|
|
|
'lib',
|
|
|
|
'--target',
|
|
|
|
'<@(_outputs)',
|
|
|
|
'config.gypi',
|
|
|
|
'<@(deps_files)',
|
2013-07-24 12:53:28 +02:00
|
|
|
],
|
2011-08-03 17:01:30 -07:00
|
|
|
},
|
|
|
|
],
|
2018-09-30 13:44:55 -04:00
|
|
|
}, # node_lib_target_name
|
2020-08-13 17:12:44 +01:00
|
|
|
{ # fuzz_url
|
|
|
|
'target_name': 'fuzz_url',
|
|
|
|
'type': 'executable',
|
|
|
|
'dependencies': [
|
|
|
|
'<(node_lib_target_name)',
|
|
|
|
],
|
|
|
|
'includes': [
|
|
|
|
'node.gypi'
|
|
|
|
],
|
|
|
|
'include_dirs': [
|
|
|
|
'src',
|
|
|
|
],
|
|
|
|
'defines': [
|
|
|
|
'NODE_ARCH="<(target_arch)"',
|
|
|
|
'NODE_PLATFORM="<(OS)"',
|
|
|
|
'NODE_WANT_INTERNALS=1',
|
|
|
|
],
|
|
|
|
'sources': [
|
|
|
|
'src/node_snapshot_stub.cc',
|
|
|
|
'test/fuzzers/fuzz_url.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',
|
|
|
|
}],
|
|
|
|
],
|
|
|
|
}, # fuzz_url
|
2020-08-19 22:02:14 +01:00
|
|
|
{ # fuzz_env
|
|
|
|
'target_name': 'fuzz_env',
|
|
|
|
'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_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',
|
|
|
|
}],
|
|
|
|
],
|
|
|
|
}, # fuzz_env
|
2015-03-19 02:01:45 +01:00
|
|
|
{
|
|
|
|
'target_name': 'cctest',
|
|
|
|
'type': 'executable',
|
2016-10-18 16:41:26 +02:00
|
|
|
|
|
|
|
'dependencies': [
|
2018-02-05 14:57:13 +01:00
|
|
|
'<(node_lib_target_name)',
|
2021-08-13 01:49:27 -04:00
|
|
|
'deps/base64/base64.gyp:base64',
|
2021-07-14 23:20:27 +08:00
|
|
|
'deps/googletest/googletest.gyp:gtest',
|
|
|
|
'deps/googletest/googletest.gyp:gtest_main',
|
2019-01-07 11:36:35 -08:00
|
|
|
'deps/histogram/histogram.gyp:histogram',
|
2019-09-04 17:56:51 -04:00
|
|
|
'deps/uvwasi/uvwasi.gyp:uvwasi',
|
2023-01-10 12:25:19 +01:00
|
|
|
'deps/simdutf/simdutf.gyp:simdutf',
|
2016-10-18 16:41:26 +02:00
|
|
|
],
|
|
|
|
|
|
|
|
'includes': [
|
|
|
|
'node.gypi'
|
|
|
|
],
|
|
|
|
|
2015-03-19 02:01:45 +01:00
|
|
|
'include_dirs': [
|
|
|
|
'src',
|
2016-10-18 16:41:26 +02:00
|
|
|
'tools/msvs/genfiles',
|
2016-11-09 14:19:35 -08:00
|
|
|
'deps/v8/include',
|
2016-10-18 16:41:26 +02:00
|
|
|
'deps/cares/include',
|
|
|
|
'deps/uv/include',
|
2019-09-04 17:56:51 -04:00
|
|
|
'deps/uvwasi/include',
|
2019-04-14 17:24:22 -04:00
|
|
|
'test/cctest',
|
2016-10-18 16:41:26 +02:00
|
|
|
],
|
|
|
|
|
2020-03-12 22:20:36 -04:00
|
|
|
'defines': [
|
|
|
|
'NODE_ARCH="<(target_arch)"',
|
|
|
|
'NODE_PLATFORM="<(OS)"',
|
|
|
|
'NODE_WANT_INTERNALS=1',
|
|
|
|
],
|
2016-10-18 16:41:26 +02:00
|
|
|
|
2015-03-19 02:01:45 +01:00
|
|
|
'sources': [
|
2019-04-18 22:09:28 +08:00
|
|
|
'src/node_snapshot_stub.cc',
|
2017-08-25 12:45:00 -07:00
|
|
|
'test/cctest/node_test_fixture.cc',
|
2019-04-14 17:24:22 -04:00
|
|
|
'test/cctest/node_test_fixture.h',
|
2017-08-25 12:45:00 -07:00
|
|
|
'test/cctest/test_aliased_buffer.cc',
|
2017-04-05 17:05:55 +03:00
|
|
|
'test/cctest/test_base64.cc',
|
2019-09-29 01:29:07 +02:00
|
|
|
'test/cctest/test_base_object_ptr.cc',
|
2017-12-25 22:17:25 -02:00
|
|
|
'test/cctest/test_node_postmortem_metadata.cc',
|
2017-03-21 08:06:43 +01:00
|
|
|
'test/cctest/test_environment.cc',
|
2019-03-05 20:09:43 +01:00
|
|
|
'test/cctest/test_linked_binding.cc',
|
2021-06-08 21:53:07 +08:00
|
|
|
'test/cctest/test_node_api.cc',
|
2019-05-30 11:54:09 -04:00
|
|
|
'test/cctest/test_per_process.cc',
|
2018-04-12 22:01:11 +02:00
|
|
|
'test/cctest/test_platform.cc',
|
2022-08-25 01:02:26 +08:00
|
|
|
'test/cctest/test_report.cc',
|
2020-03-29 20:11:56 +02:00
|
|
|
'test/cctest/test_json_utils.cc',
|
2020-03-03 11:18:45 -08:00
|
|
|
'test/cctest/test_sockaddr.cc',
|
2018-06-22 12:50:01 -07:00
|
|
|
'test/cctest/test_traced_value.cc',
|
2016-10-18 16:41:26 +02:00
|
|
|
'test/cctest/test_util.cc',
|
2019-04-14 17:24:22 -04:00
|
|
|
'test/cctest/test_url.cc',
|
2016-10-18 16:41:26 +02:00
|
|
|
],
|
|
|
|
|
2016-02-07 08:47:14 -08:00
|
|
|
'conditions': [
|
2017-11-08 09:41:09 +01:00
|
|
|
[ 'node_use_openssl=="true"', {
|
2017-12-04 19:08:15 -02:00
|
|
|
'defines': [
|
|
|
|
'HAVE_OPENSSL=1',
|
|
|
|
],
|
2020-10-06 13:25:23 +02:00
|
|
|
'sources': [
|
2022-09-15 19:27:04 +02:00
|
|
|
'test/cctest/test_crypto_clienthello.cc',
|
2020-10-06 13:25:23 +02:00
|
|
|
'test/cctest/test_node_crypto.cc',
|
|
|
|
]
|
2017-08-15 09:17:02 +02:00
|
|
|
}],
|
2017-01-17 11:49:26 -08:00
|
|
|
['v8_enable_inspector==1', {
|
2016-02-07 08:47:14 -08:00
|
|
|
'sources': [
|
2016-11-09 14:19:35 -08:00
|
|
|
'test/cctest/test_inspector_socket.cc',
|
|
|
|
'test/cctest/test_inspector_socket_server.cc'
|
2016-07-06 23:16:35 +03:00
|
|
|
],
|
2017-11-08 09:41:09 +01:00
|
|
|
'defines': [
|
|
|
|
'HAVE_INSPECTOR=1',
|
|
|
|
],
|
|
|
|
}, {
|
2019-04-07 15:02:04 -04:00
|
|
|
'defines': [
|
|
|
|
'HAVE_INSPECTOR=0',
|
|
|
|
]
|
2016-03-26 20:17:55 -04:00
|
|
|
}],
|
2016-10-18 16:41:26 +02:00
|
|
|
['OS=="solaris"', {
|
|
|
|
'ldflags': [ '-I<(SHARED_INTERMEDIATE_DIR)' ]
|
|
|
|
}],
|
2018-07-24 13:44:09 -07:00
|
|
|
# Skip cctest while building shared lib node for Windows
|
|
|
|
[ 'OS=="win" and node_shared=="true"', {
|
|
|
|
'type': 'none',
|
|
|
|
}],
|
2018-09-29 16:43:39 -04:00
|
|
|
[ 'node_shared=="true"', {
|
|
|
|
'xcode_settings': {
|
|
|
|
'OTHER_LDFLAGS': [ '-Wl,-rpath,@loader_path', ],
|
|
|
|
},
|
|
|
|
}],
|
2019-03-29 03:38:12 -04:00
|
|
|
['OS=="win"', {
|
|
|
|
'libraries': [
|
|
|
|
'Dbghelp.lib',
|
|
|
|
'winmm.lib',
|
|
|
|
'Ws2_32.lib',
|
|
|
|
],
|
|
|
|
}],
|
2018-02-05 14:57:13 +01:00
|
|
|
],
|
2018-09-30 13:44:55 -04:00
|
|
|
}, # cctest
|
2019-03-29 03:38:12 -04:00
|
|
|
|
2020-02-27 18:54:13 -08:00
|
|
|
{
|
|
|
|
'target_name': 'embedtest',
|
|
|
|
'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/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',
|
|
|
|
],
|
|
|
|
}],
|
|
|
|
],
|
|
|
|
}, # embedtest
|
|
|
|
|
2019-09-02 15:51:29 -03: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'
|
|
|
|
],
|
|
|
|
}],
|
|
|
|
]
|
|
|
|
}, # overlapped-checker
|
2019-04-18 16:26:48 +08:00
|
|
|
{
|
|
|
|
'target_name': 'node_mksnapshot',
|
|
|
|
'type': 'executable',
|
|
|
|
|
|
|
|
'dependencies': [
|
|
|
|
'<(node_lib_target_name)',
|
|
|
|
'deps/histogram/histogram.gyp:histogram',
|
2019-09-04 17:56:51 -04:00
|
|
|
'deps/uvwasi/uvwasi.gyp:uvwasi',
|
2019-04-18 16:26:48 +08:00
|
|
|
],
|
|
|
|
|
|
|
|
'includes': [
|
|
|
|
'node.gypi'
|
|
|
|
],
|
|
|
|
|
|
|
|
'include_dirs': [
|
|
|
|
'src',
|
|
|
|
'tools/msvs/genfiles',
|
|
|
|
'deps/v8/include',
|
|
|
|
'deps/cares/include',
|
|
|
|
'deps/uv/include',
|
2019-09-04 17:56:51 -04:00
|
|
|
'deps/uvwasi/include',
|
2019-04-18 16:26:48 +08:00
|
|
|
],
|
|
|
|
|
|
|
|
'defines': [ 'NODE_WANT_INTERNALS=1' ],
|
|
|
|
|
|
|
|
'sources': [
|
2019-04-18 22:09:28 +08:00
|
|
|
'src/node_snapshot_stub.cc',
|
2019-04-18 16:26:48 +08:00
|
|
|
'tools/snapshot/node_mksnapshot.cc',
|
|
|
|
],
|
|
|
|
|
|
|
|
'conditions': [
|
2020-02-20 17:57:55 +08:00
|
|
|
[ 'node_use_openssl=="true"', {
|
|
|
|
'defines': [
|
|
|
|
'HAVE_OPENSSL=1',
|
|
|
|
],
|
|
|
|
}],
|
2021-11-18 11:56:39 +08:00
|
|
|
[ 'node_use_node_code_cache=="true"', {
|
|
|
|
'defines': [
|
|
|
|
'NODE_USE_NODE_CODE_CACHE=1',
|
|
|
|
],
|
|
|
|
}],
|
2020-02-20 17:57:55 +08:00
|
|
|
['v8_enable_inspector==1', {
|
|
|
|
'defines': [
|
|
|
|
'HAVE_INSPECTOR=1',
|
|
|
|
],
|
|
|
|
}],
|
2019-03-29 03:38:12 -04:00
|
|
|
['OS=="win"', {
|
|
|
|
'libraries': [
|
|
|
|
'Dbghelp.lib',
|
|
|
|
'winmm.lib',
|
|
|
|
'Ws2_32.lib',
|
2019-04-18 16:26:48 +08:00
|
|
|
],
|
|
|
|
}],
|
|
|
|
],
|
|
|
|
}, # node_mksnapshot
|
|
|
|
], # end targets
|
2015-09-29 10:22:00 -04:00
|
|
|
|
|
|
|
'conditions': [
|
2019-04-07 15:02:04 -04:00
|
|
|
['OS=="aix" and node_shared=="true"', {
|
2017-08-23 09:52:59 +02:00
|
|
|
'targets': [
|
|
|
|
{
|
2017-12-04 16:07:53 -08:00
|
|
|
'target_name': 'node_aix_shared',
|
|
|
|
'type': 'shared_library',
|
2017-08-23 09:52:59 +02:00
|
|
|
'product_name': '<(node_core_target_name)',
|
2019-04-07 15:02:04 -04:00
|
|
|
'ldflags': ['--shared'],
|
2017-12-04 16:07:53 -08:00
|
|
|
'product_extension': '<(shlib_suffix)',
|
|
|
|
'includes': [
|
|
|
|
'node.gypi'
|
|
|
|
],
|
2019-04-07 15:02:04 -04:00
|
|
|
'dependencies': ['<(node_lib_target_name)'],
|
2015-09-29 10:22:00 -04:00
|
|
|
'include_dirs': [
|
|
|
|
'src',
|
|
|
|
'deps/v8/include',
|
|
|
|
],
|
|
|
|
'sources': [
|
|
|
|
'<@(library_files)',
|
2021-06-18 05:01:41 +08:00
|
|
|
'<@(deps_files)',
|
2015-09-29 10:22:00 -04:00
|
|
|
'common.gypi',
|
|
|
|
],
|
2018-02-02 10:06:33 -08:00
|
|
|
'direct_dependent_settings': {
|
|
|
|
'ldflags': [ '-Wl,-brtl' ],
|
|
|
|
},
|
2015-09-29 10:22:00 -04:00
|
|
|
},
|
2017-12-04 16:07:53 -08:00
|
|
|
]
|
2015-09-29 10:22:00 -04: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 10:22:00 -04:00
|
|
|
], # end conditions block
|
2011-08-03 17:01:30 -07:00
|
|
|
}
|