Skip to content

Commit 349d171

Browse files
committed
build: enable -fvisibility to improve startup speeds
Signed-off-by: avivkeller <me@aviv.sh>
1 parent 18eaa73 commit 349d171

6 files changed

Lines changed: 56 additions & 20 deletions

File tree

‎deps/ada/ada.gyp‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,21 @@
1919
'dependencies': [
2020
'../../tools/v8_gypfiles/v8.gyp:simdutf',
2121
],
22-
'sources': [ '<@(ada_sources)' ]
22+
'sources': [ '<@(ada_sources)' ],
23+
'conditions': [
24+
# See the same setting in node.gyp.
25+
['node_shared=="false" and OS=="mac"', {
26+
'xcode_settings': {
27+
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
28+
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' # -fvisibility-inlines-hidden
29+
},
30+
}, 'node_shared=="false" and (OS!="aix" and OS!="os400") and (OS!="win" or clang==1)', {
31+
'cflags': [
32+
'-fvisibility=hidden',
33+
'-fvisibility-inlines-hidden'
34+
],
35+
}], # MSVC hides the non-public symbols by default so no need to configure it.
36+
],
2337
},
2438
]
2539
}

‎node.gyp‎

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -538,19 +538,21 @@
538538
['clang==0 and OS!="win"', {
539539
'cflags': [ '-Wno-restrict', ],
540540
}],
541-
# TODO(joyeecheung): investigate if it breaks addons.
542-
# ['OS=="mac"', {
543-
# 'xcode_settings': {
544-
# 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
545-
# 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' # -fvisibility-inlines-hidden
546-
# },
547-
# }],
548-
# ['OS!="win" or clang==1', {
549-
# 'cflags': [
550-
# '-fvisibility=hidden',
551-
# '-fvisibility-inlines-hidden'
552-
# ],
553-
# }],
541+
# Build with -fvisibility=hidden and -fvisibility-inlines-hidden to avoid
542+
# including unnecessary internal symbols, which may lead to run-time fixups.
543+
# This is not done on AIX where symbols are exported by tools/create_expfile.sh
544+
# see https://github.com/nodejs/node/pull/56290#issuecomment-2582703109
545+
['node_shared=="false" and OS=="mac"', {
546+
'xcode_settings': {
547+
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
548+
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' # -fvisibility-inlines-hidden
549+
},
550+
}, 'node_shared=="false" and (OS!="aix" and OS!="os400") and (OS!="win" or clang==1)', {
551+
'cflags': [
552+
'-fvisibility=hidden',
553+
'-fvisibility-inlines-hidden'
554+
],
555+
}], # MSVC hides the non-public symbols by default so no need to configure it.
554556
# Pointer authentication for ARM64.
555557
['target_arch=="arm64"', {
556558
'target_conditions': [

‎src/node.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1240,8 +1240,7 @@ NODE_EXTERN v8::Local<v8::Value> WinapiErrnoException(
12401240
const char* path = nullptr);
12411241
#endif
12421242

1243-
const char* signo_string(int errorno);
1244-
1243+
NODE_EXTERN const char* signo_string(int errorno);
12451244

12461245
typedef void (*addon_register_func)(
12471246
v8::Local<v8::Object> exports,

‎tools/icu/icu-generic.gyp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@
5858
[ 'OS == "mac" or OS == "ios"', {
5959
'xcode_settings': {'GCC_ENABLE_CPP_RTTI': 'YES' },
6060
}],
61+
# See the same setting in node.gyp.
62+
['node_shared=="false" and OS=="mac"', {
63+
'xcode_settings': {
64+
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
65+
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' # -fvisibility-inlines-hidden
66+
},
67+
}, 'node_shared=="false" and (OS!="aix" and OS!="os400") and (OS!="win" or clang==1)', {
68+
'cflags': [
69+
'-fvisibility=hidden',
70+
'-fvisibility-inlines-hidden'
71+
],
72+
}], # MSVC hides the non-public symbols by default so no need to configure it.
6173
[ 'OS == "win"', {
6274
'msvs_settings': {
6375
'VCCLCompilerTool': {'RuntimeTypeInfo': 'true'},

‎tools/v8_gypfiles/abseil.gyp‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,18 @@
377377
'<(ABSEIL_ROOT)/absl/time/internal/cctz/src/time_zone_name_win.cc',
378378
],
379379
}],
380+
# See the same setting in node.gyp.
381+
['node_shared=="false" and OS=="mac"', {
382+
'xcode_settings': {
383+
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
384+
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES' # -fvisibility-inlines-hidden
385+
},
386+
}, 'node_shared=="false" and (OS!="aix" and OS!="os400") and (OS!="win" or clang==1)', {
387+
'cflags': [
388+
'-fvisibility=hidden',
389+
'-fvisibility-inlines-hidden'
390+
],
391+
}], # MSVC hides the non-public symbols by default so no need to configure it.
380392
],
381393
}, # abseil
382394
]

‎tools/v8_gypfiles/v8.gyp‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@
5252
}
5353
},
5454
'conditions': [
55-
# Build with -fvisibility=hidden and -fvisibility-inlines-hidden to avoid
56-
# including unnecessary internal symbols, which may lead to run-time fixups.
57-
# This is not done on AIX where symbols are exported by tools/create_expfile.sh
58-
# see https://github.com/nodejs/node/pull/56290#issuecomment-2582703109
55+
# See the same setting in node.gyp
5956
['OS!="aix" and OS!="os400"', {
6057
'defines': [
6158
'BUILDING_V8_SHARED', # Make V8_EXPORT visible.

0 commit comments

Comments
 (0)