Skip to content

Commit d94ca0d

Browse files
LeszekSwirskivictorgomes
authored andcommitted
Disable ICF for node_mksnapshot (nodejs#176)
1 parent 4eda4f9 commit d94ca0d

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

249266
action("run_node_mksnapshot") {

0 commit comments

Comments
 (0)