Skip to content

Commit 8d14333

Browse files
LeszekSwirskivictorgomes
authored andcommitted
Disable ICF for node_mksnapshot (nodejs#176)
1 parent 923ef91 commit 8d14333

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

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)