Skip to content

Commit 3b1bdd4

Browse files
committed
build: build v8 with -fvisibility=hidden on macOS
V8 should be built with -fvisibility=hidden, otherwise the resulting binary would contain unnecessary symbols. In particular, on macOS, this leads to 5000+ weak symbols resolved at runtime, leading to a startup regression. On macOS this also reduces the binary size about ~10MB. It's only enabled on macOS in this patch as gcc can time out or run out of memory on some machines in the CI with -fvisibility=hidden.
1 parent 938a581 commit 3b1bdd4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tools/v8_gypfiles/v8.gyp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@
4141
'AdditionalOptions': ['/utf-8']
4242
}
4343
},
44+
# Hide symbols that are not explicitly exported with V8_EXPORT.
45+
# TODO(joyeecheung): enable it on other platforms. Currently gcc times out
46+
# or run out of memory with -fvisibility=hidden on some machines in the CI.
47+
'xcode_settings': {
48+
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
49+
},
50+
'defines': [
51+
'BUILDING_V8_SHARED', # Make V8_EXPORT visible.
52+
],
4453
},
4554
'targets': [
4655
{

0 commit comments

Comments
 (0)