Skip to content

Commit 22a78a7

Browse files
jesecrichardlau
authored andcommittedSep 10, 2021
build: preserves symbols during LTO with macOS linker
man ld -export_dynamic: ``` Preserves all global symbols in main executables during LTO. Without this option, Link Time Optimization is allowed to inline and remove global functions. This option is used when a main executable may load a plug-in which requires certain symbols from the main executable. ``` Bug: vercel/pkg#1155 Signed-off-by: Jesse Chan <jc@linux.com> PR-URL: #39839 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 97f3072 commit 22a78a7

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
 

‎node.gyp

+13
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,19 @@
236236
'OTHER_LDFLAGS': [ '-Wl,-rpath,@loader_path', ],
237237
},
238238
}],
239+
[ 'enable_lto=="true"', {
240+
'xcode_settings': {
241+
'OTHER_LDFLAGS': [
242+
# man ld -export_dynamic:
243+
# Preserves all global symbols in main executables during LTO.
244+
# Without this option, Link Time Optimization is allowed to
245+
# inline and remove global functions. This option is used when
246+
# a main executable may load a plug-in which requires certain
247+
# symbols from the main executable.
248+
'-Wl,-export_dynamic',
249+
],
250+
},
251+
}],
239252
['OS=="win"', {
240253
'libraries': [
241254
'Dbghelp.lib',

0 commit comments

Comments
 (0)
Please sign in to comment.