Skip to content

Commit

Permalink
build: build v8 with -fvisibility=hidden on macOS
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joyeecheung committed Dec 17, 2024
1 parent 938a581 commit 3b1bdd4
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/v8_gypfiles/v8.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@
'AdditionalOptions': ['/utf-8']
}
},
# Hide symbols that are not explicitly exported with V8_EXPORT.
# TODO(joyeecheung): enable it on other platforms. Currently gcc times out
# or run out of memory with -fvisibility=hidden on some machines in the CI.
'xcode_settings': {
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
},
'defines': [
'BUILDING_V8_SHARED', # Make V8_EXPORT visible.
],
},
'targets': [
{
Expand Down

0 comments on commit 3b1bdd4

Please sign in to comment.