Skip to content

Commit

Permalink
build: disable ICF for mksnapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
2 people authored and nodejs-github-bot committed Apr 27, 2024
1 parent edae8d9 commit 582acb6
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
16 changes: 16 additions & 0 deletions node.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -1272,6 +1272,7 @@
'deps/ada/ada.gyp:ada',
'deps/simdjson/simdjson.gyp:simdjson',
'deps/simdutf/simdutf.gyp:simdutf',
'disable_icf',
],

'includes': [
Expand Down Expand Up @@ -1326,6 +1327,21 @@
}],
],
}, # node_mksnapshot
{
'target_name': 'disable_icf',
'type': 'none',
'direct_dependent_settings': {
'conditions': [
['OS=="win"', {
'msvs_settings': {
'VCLinkerTool': {
'EnableCOMDATFolding': '0', # /OPT:NOICF
},
},
}],
],
},
}, # disable_icf
], # end targets

'conditions': [
Expand Down
16 changes: 16 additions & 0 deletions tools/v8_gypfiles/v8.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -1687,6 +1687,7 @@
'v8_turboshaft',
'v8_pch',
'v8_abseil',
'disable_icf',
# "build/win:default_exe_manifest",
],
'sources': [
Expand All @@ -1702,6 +1703,21 @@
}],
],
}, # mksnapshot
{
'target_name': 'disable_icf',
'type': 'none',
'direct_dependent_settings': {
'conditions': [
['is_win', {
'msvs_settings': {
'VCLinkerTool': {
'EnableCOMDATFolding': '0', # /OPT:NOICF
},
},
}],
],
},
}, # disable_icf
{
'target_name': 'torque',
'type': 'executable',
Expand Down
19 changes: 18 additions & 1 deletion unofficial.gni
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,30 @@ template("node_gn_build") {
if (node_use_node_snapshot) {
if (current_toolchain == v8_snapshot_toolchain) {
executable("node_mksnapshot") {
configs += [ ":node_internal_config" ]
configs += [ ":node_internal_config", ":disable_icf" ]
sources = [
"src/node_snapshot_stub.cc",
"tools/snapshot/node_mksnapshot.cc",
]
deps = [ ":libnode" ]
}

# This config disables a link time optimization "ICF", which may merge
# different functions into one if the function signature and body of them are
# identical.
#
# ICF breaks 1:1 mappings of the external references for V8 snapshot, so we
# disable it while taking a V8 snapshot.
config("disable_icf") {
visibility = [ ":*" ] # Only targets in this file can depend on this.
if (is_win) {
ldflags = [ "/OPT:NOICF" ] # link.exe, but also lld-link.exe.
} else if (is_apple && !use_lld) {
ldflags = [ "-Wl,-no_deduplicate" ] # ld64.
} else if (use_gold || use_lld) {
ldflags = [ "-Wl,--icf=none" ]
}
}
}

action("run_node_mksnapshot") {
Expand Down

0 comments on commit 582acb6

Please sign in to comment.