Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Add -fvisibility-inlines-hidden #1976

Merged
merged 1 commit into from
Apr 9, 2024

Conversation

fhanau
Copy link
Collaborator

@fhanau fhanau commented Apr 5, 2024

Mark C++ inline methods as hidden, causing them to not be exported when creating shared libraries.

This significantly reduces binary sizes and possibly link times on Linux, where shared linkage is used for everything except the workerd binary (build folder size shrinks 7011MB => 6954 MB based on CI statistics). There is a smaller binary size improvement for macOS, where shared linkage is not enabled by default.
I want to also enable actual hidden visibility (i.e. -fvisibility=hidden) for V8, but that likely requires significant patching as it is only supported in the V8 GN build so far.
See https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#index-fvisibility-inlines-hidden for background information.

@fhanau fhanau force-pushed the felix/visibility-inlines-hidden branch from 8150aad to 6f47928 Compare April 7, 2024 22:16
Mark C++ inline methods as hidden, causing them to not be exported when
creating shared libraries.

This significantly reduces binary sizes and possibly link times on Linux,
where shared linkage is used for everything except the workerd binary.
There is a smaller binary size improvement for macOS, where shared
linkage is not enabled by default.
See https://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Dialect-Options.html#index-fvisibility-inlines-hidden
for background information.
@fhanau fhanau force-pushed the felix/visibility-inlines-hidden branch from 6f47928 to c92ae9d Compare April 8, 2024 19:06
@fhanau fhanau marked this pull request as ready for review April 8, 2024 20:27
@fhanau fhanau requested review from a team as code owners April 8, 2024 20:27
Copy link
Contributor

@hoodmane hoodmane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds reasonable to me.

@fhanau fhanau merged commit 7204518 into main Apr 9, 2024
10 checks passed
@fhanau fhanau deleted the felix/visibility-inlines-hidden branch April 9, 2024 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants