Skip to content

Commit 86c44d5

Browse files
joyeecheungjuanarbol
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 c55bebc commit 86c44d5

2 files changed

Lines changed: 33 additions & 6 deletions

File tree

node.gyp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,19 @@
483483
['clang==0 and OS!="win"', {
484484
'cflags': [ '-Wno-restrict', ],
485485
}],
486+
# TODO(joyeecheung): investigate if it breaks addons.
487+
# ['OS=="mac"', {
488+
# 'xcode_settings': {
489+
# 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
490+
# 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' # -fvisibility-inlines-hidden
491+
# },
492+
# }],
493+
# ['OS!="win" or clang==1', {
494+
# 'cflags': [
495+
# '-fvisibility=hidden',
496+
# '-fvisibility-inlines-hidden'
497+
# ],
498+
# }],
486499
# Pointer authentication for ARM64.
487500
['target_arch=="arm64"', {
488501
'target_conditions': [

tools/v8_gypfiles/v8.gyp

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,31 @@
4646
}
4747
},
4848
'conditions': [
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"', {
54+
'defines': [
55+
'BUILDING_V8_SHARED', # Make V8_EXPORT visible.
56+
]
57+
}],
58+
['node_shared=="true"', {
59+
'defines': [
60+
'V8_TLS_USED_IN_LIBRARY', # Enable V8_TLS_LIBRARY_MODE.
61+
],
62+
}],
4963
['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.
5364
'xcode_settings': {
5465
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
66+
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' # -fvisibility-inlines-hidden
5567
},
56-
'defines': [
57-
'BUILDING_V8_SHARED', # Make V8_EXPORT visible.
68+
}, 'OS!="aix" and (OS!="win" or clang==1)', {
69+
'cflags': [
70+
'-fvisibility=hidden',
71+
'-fvisibility-inlines-hidden'
5872
],
59-
}],
73+
}], # MSVC hides the non-public symbols by default so no need to configure it.
6074
],
6175
},
6276
'targets': [

0 commit comments

Comments
 (0)