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