Skip to content

Commit 47d3875

Browse files
LeszekSwirskitargos
andcommitted
build: disable ICF for mksnapshot
Refs: https://chromium-review.googlesource.com/c/v8/v8/+/5447267 Co-authored-by: Michaël Zasso <[email protected]>
1 parent aa0873d commit 47d3875

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

node.gyp

+5
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,11 @@
13191319
'winmm.lib',
13201320
'Ws2_32.lib',
13211321
],
1322+
'msbuild_settings': {
1323+
'Link': {
1324+
'EnableCOMDATFolding': 'false', # /OPT:NOICF
1325+
},
1326+
},
13221327
}],
13231328
# Avoid excessive LTO
13241329
['enable_lto=="true"', {

tools/v8_gypfiles/v8.gyp

+7
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,13 @@
17001700
['enable_lto=="true"', {
17011701
'ldflags': [ '-fno-lto' ],
17021702
}],
1703+
['OS=="win"', {
1704+
'msbuild_settings': {
1705+
'Link': {
1706+
'EnableCOMDATFolding': 'false', # /OPT:NOICF
1707+
},
1708+
},
1709+
}],
17031710
],
17041711
}, # mksnapshot
17051712
{

unofficial.gni

+18-1
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,30 @@ template("node_gn_build") {
235235
if (node_use_node_snapshot) {
236236
if (current_toolchain == v8_snapshot_toolchain) {
237237
executable("node_mksnapshot") {
238-
configs += [ ":node_internal_config" ]
238+
configs += [ ":node_internal_config", ":disable_icf" ]
239239
sources = [
240240
"src/node_snapshot_stub.cc",
241241
"tools/snapshot/node_mksnapshot.cc",
242242
]
243243
deps = [ ":libnode" ]
244244
}
245+
246+
# This config disables a link time optimization "ICF", which may merge
247+
# different functions into one if the function signature and body of them are
248+
# identical.
249+
#
250+
# ICF breaks 1:1 mappings of the external references for V8 snapshot, so we
251+
# disable it while taking a V8 snapshot.
252+
config("disable_icf") {
253+
visibility = [ ":*" ] # Only targets in this file can depend on this.
254+
if (is_win) {
255+
ldflags = [ "/OPT:NOICF" ] # link.exe, but also lld-link.exe.
256+
} else if (is_apple && !use_lld) {
257+
ldflags = [ "-Wl,-no_deduplicate" ] # ld64.
258+
} else if (use_gold || use_lld) {
259+
ldflags = [ "-Wl,--icf=none" ]
260+
}
261+
}
245262
}
246263

247264
action("run_node_mksnapshot") {

0 commit comments

Comments
 (0)