From 756077867b4901377c11abd5840e040f9e0d135e Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Thu, 19 Dec 2024 04:24:51 +0100 Subject: [PATCH] build: build v8 with -fvisibility=hidden on macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: https://github.com/nodejs/node/pull/56275 Fixes: https://github.com/nodejs/performance/issues/180 Reviewed-By: Juan José Arboleda Reviewed-By: Daniel Lemire Reviewed-By: Rafael Gonzaga Reviewed-By: Yagiz Nizipli Reviewed-By: Geoffrey Booth Reviewed-By: Luigi Pinca Reviewed-By: Michaël Zasso Reviewed-By: Matteo Collina Reviewed-By: Chengzhong Wu Reviewed-By: Marco Ippolito --- tools/v8_gypfiles/v8.gyp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp index 9acad07d966a35..88c1297b9a09ec 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -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': [ {