From 3b1bdd43a8e712a06ef3b0fc4459ed1cbb32a430 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 16 Dec 2024 22:10:24 +0100 Subject: [PATCH 1/2] 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. --- tools/v8_gypfiles/v8.gyp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp index 9acad07d966a35..907eec78dde224 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -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': [ { From 3ee4021dfa5426d1a37e1364e3460f2a3b50dfce Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Tue, 17 Dec 2024 16:57:01 +0100 Subject: [PATCH 2/2] fixup! build: build v8 with -fvisibility=hidden on macOS --- tools/v8_gypfiles/v8.gyp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp index 907eec78dde224..88c1297b9a09ec 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -41,14 +41,18 @@ '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. + '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': [