-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Disable V8/ICU whole-archive flag, improving file size #477
Conversation
44e9c06
to
1029dab
Compare
The title of the change suggests removing a patch, but that's not in the current draft. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to have some data in the commit message, e.g. what is the saving?
Please sync the title with the PR (e.g. remove a patch or fix the title), thanks.
Do we know why these were marked alwayslink in the first place? Removing alwayslink can break things e.g. if the code depends on startup-time initializers to populate global registries. However, I thought the Chrome project was adverse to startup-time initializers in the first place so it'd be slightly surprising to me if V8 relies on them. |
Was going to look into that a bit more before turning it into a non-draft PR – tcmalloc uses alwayslink and probably depends on it, I believe in V8's case it's be more about preventing linking issues with shared libraries (which we don't use). |
We do use shared libraries in debug builds FWIW. |
1029dab
to
b7fe084
Compare
Took a deep dive in V8's code base and this should be safe: Within its primary build system GN, V8 only uses Looking at the code itself, there are some instances where |
b7fe084
to
df8c353
Compare
Thanks Felix, nice write up. It looks like for workerd we link all the v8 object files directly into the workerd binary (including debug), but this is not the same for ew (which I think Kenton was alluding to when he wrote "We do use shared libraries in debug builds FWIW.") |
Thank you! |
This patches V8 to not use the alwayslink parameter (corresponding to the
--whole-archive
linker flag on Linux) for several V8 and ICU-related libraries. This reduces binary sizes by ~1MB on Linux and ~19MB on macOS for opt binaries. macOS sees a much larger improvement since bazel uses --ffunction-sections and section garbage collection by default for opt Linux binaries it while we do not yet use the equivalent -dead_strip linker flag on macOS.I will take a deeper look at V8's code base to confirm this is safe before converting to a non-draft PR.