Skip to content

Commit b6bf41b

Browse files
committed
build: build v8 with -fvisibility=hidden -fvisibility-inlines-hidden
1 parent 55cc372 commit b6bf41b

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

node.gyp

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

tools/v8_gypfiles/v8.gyp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,26 @@
4242
}
4343
},
4444
'conditions': [
45+
# Build with -fvisibility=hidden and -fvisibility-inlines-hidden to avoid
46+
# including unnecessary internal symbols, which may lead to run-time fixups.
47+
# This is not done on AIX where symbols are exported by tools/create_expfile.sh
48+
# see https://github.com/nodejs/node/pull/56290#issuecomment-2582703109
49+
['OS!="aix"', {
50+
'defines': [
51+
'BUILDING_V8_SHARED', # Make V8_EXPORT visible.
52+
]
53+
}],
4554
['OS=="mac"', {
46-
# Hide symbols that are not explicitly exported with V8_EXPORT.
47-
# TODO(joyeecheung): enable it on other platforms. Currently gcc times out
48-
# or run out of memory with -fvisibility=hidden on some machines in the CI.
4955
'xcode_settings': {
5056
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
57+
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' # -fvisibility-inlines-hidden
5158
},
52-
'defines': [
53-
'BUILDING_V8_SHARED', # Make V8_EXPORT visible.
59+
}, 'OS!="aix" and (OS!="win" or clang==1)', {
60+
'cflags': [
61+
'-fvisibility=hidden',
62+
'-fvisibility-inlines-hidden'
5463
],
55-
}],
64+
}], # MSVC hides the non-public symbols by default so no need to configure it.
5665
],
5766
},
5867
'targets': [

0 commit comments

Comments
 (0)