Skip to content

Commit 1769597

Browse files
joyeecheungaduh95
authored andcommitted
build: build v8 with -fvisibility=hidden -fvisibility-inlines-hidden
PR-URL: #56290 Reviewed-By: Richard Lau <richard.lau@ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent b66f0f7 commit 1769597

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

node.gyp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,19 @@
488488
['clang==0 and OS!="win"', {
489489
'cflags': [ '-Wno-restrict', ],
490490
}],
491+
# TODO(joyeecheung): investigate if it breaks addons.
492+
# ['OS=="mac"', {
493+
# 'xcode_settings': {
494+
# 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
495+
# 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' # -fvisibility-inlines-hidden
496+
# },
497+
# }],
498+
# ['OS!="win" or clang==1', {
499+
# 'cflags': [
500+
# '-fvisibility=hidden',
501+
# '-fvisibility-inlines-hidden'
502+
# ],
503+
# }],
491504
# Pointer authentication for ARM64.
492505
['target_arch=="arm64"', {
493506
'target_conditions': [

tools/v8_gypfiles/v8.gyp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,31 @@
4646
}
4747
},
4848
'conditions': [
49-
['OS=="mac"', {
50-
# Hide symbols that are not explicitly exported with V8_EXPORT.
51-
# TODO(joyeecheung): enable it on other platforms. Currently gcc times out
52-
# or run out of memory with -fvisibility=hidden on some machines in the CI.
53-
'xcode_settings': {
54-
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
55-
},
49+
# Build with -fvisibility=hidden and -fvisibility-inlines-hidden to avoid
50+
# including unnecessary internal symbols, which may lead to run-time fixups.
51+
# This is not done on AIX where symbols are exported by tools/create_expfile.sh
52+
# see https://github.com/nodejs/node/pull/56290#issuecomment-2582703109
53+
['OS!="aix"', {
5654
'defines': [
5755
'BUILDING_V8_SHARED', # Make V8_EXPORT visible.
58-
],
56+
]
5957
}],
6058
['node_shared=="true"', {
6159
'defines': [
6260
'V8_TLS_USED_IN_LIBRARY', # Enable V8_TLS_LIBRARY_MODE.
6361
],
6462
}],
63+
['OS=="mac"', {
64+
'xcode_settings': {
65+
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
66+
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' # -fvisibility-inlines-hidden
67+
},
68+
}, 'OS!="aix" and (OS!="win" or clang==1)', {
69+
'cflags': [
70+
'-fvisibility=hidden',
71+
'-fvisibility-inlines-hidden'
72+
],
73+
}], # MSVC hides the non-public symbols by default so no need to configure it.
6574
],
6675
},
6776
'targets': [

0 commit comments

Comments
 (0)