Skip to content

Commit 496b031

Browse files
LeszekSwirskipthier
authored andcommitted
Disable ICF for node_mksnapshot (#176)
1 parent c910884 commit 496b031

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

unofficial.gni

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

248265
action("run_node_mksnapshot") {

0 commit comments

Comments
 (0)