Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: prevent C++ linker from overwriting executable #22027

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,12 @@
# the executable and rename it back to node.exe later
'product_name': '<(node_core_target_name)-win',
}],
[ 'OS!="win"', {
# On Unix builds, the build may replace the executable while it is
# running. To avoid this, we provide a different PRODUCT_NAME for
# the executable and rename it back to node later
'product_name': '<(node_core_target_name)-unix',
}],
],
},
{
Expand Down Expand Up @@ -900,15 +906,15 @@
]
},
{
# When using shared lib to build executable in Windows, in order to avoid
# filename collision, the executable name is node-win.exe. Need to rename
# it back to node.exe
'target_name': 'rename_node_bin_win',
'target_name': 'rename_node_bin',
'type': 'none',
'dependencies': [
'<(node_core_target_name)',
],
'conditions': [
# When using shared lib to build executable in Windows, in order to
# avoid filename collision, the executable name is node-win.exe. Need
# to rename it back to node.exe
[ 'OS=="win" and node_intermediate_lib_type=="shared_library"', {
'actions': [
{
Expand All @@ -925,6 +931,25 @@
},
],
} ],
# When building executable on Unix operating systems, in order to
# avoid overwriting the executable while it it running, build it with
Copy link
Member

Choose a reason for hiding this comment

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

typo: is

# a different name and then rename it back to node.
[ 'OS!="win"', {
'actions': [
{
'action_name': 'rename_node_bin_unix',
'inputs': [
'<(PRODUCT_DIR)/<(node_core_target_name)-unix'
],
'outputs': [
'<(PRODUCT_DIR)/<(node_core_target_name)',
],
'action': [
'mv', '<@(_inputs)', '<@(_outputs)',
],
},
],
} ],
]
},
{
Expand All @@ -933,7 +958,7 @@

'dependencies': [
'<(node_lib_target_name)',
'rename_node_bin_win',
'rename_node_bin',
'deps/gtest/gtest.gyp:gtest',
'node_js2c#host',
'node_dtrace_header',
Expand Down