From 970f1336382dd1c766461dd2db83d7159bb795a8 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Mon, 16 Dec 2024 22:10:24 +0100 Subject: [PATCH] build: build v8 with -fvisibility=hidden 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. On Linux the size reduction is around 8MB. --- tools/v8_gypfiles/v8.gyp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/v8_gypfiles/v8.gyp b/tools/v8_gypfiles/v8.gyp index 9acad07d966a35..8b1119617458ed 100644 --- a/tools/v8_gypfiles/v8.gyp +++ b/tools/v8_gypfiles/v8.gyp @@ -41,6 +41,10 @@ 'AdditionalOptions': ['/utf-8'] } }, + 'cflags': ['-fvisibility=hidden'], + 'xcode_settings': { + 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden + }, }, 'targets': [ {