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.

PR-URL: #56275
Fixes: nodejs/performance#180
Reviewed-By: Juan José Arboleda <[email protected]>
Reviewed-By: Daniel Lemire <[email protected]>
Reviewed-By: Rafael Gonzaga <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Chengzhong Wu <[email protected]>
Reviewed-By: Marco Ippolito <[email protected]>
  • Loading branch information
joyeecheung authored Dec 19, 2024
1 parent 60bd4fd commit 7560778
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tools/v8_gypfiles/v8.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@
'AdditionalOptions': ['/utf-8']
}
},
'conditions': [
['OS=="mac"', {
# 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 7560778

Please sign in to comment.