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

Compile internal SQLite library with -ffunction-sections #295

Merged

Conversation

smichaku
Copy link

When building with SQLITECPP_INTERNAL_SQLITE=ON the SQLite amalgamation
source is used for generating the library. Using one big source file
means all the library code will be put in a single section. When
building statically linked executables the entire section will be
linked even if a small portion of the library is actually used.

This commit addresses this issue by setting the -ffunction-sections
compiler option when building the library. As each function is placed in
a section of its own the linker, when passed the --gc-sections, will
throw away unused sections (functions) and reduce the executable size.

When building with SQLITECPP_INTERNAL_SQLITE=ON the SQLite amalgamation
source is used for generating the library. Using one big source file
means all the library code will be put in a single section. When
building statically linked executables the entire section will be
linked even if a small portion of the library is actually used.

This commit addresses this issue by setting the -ffunction-sections
compiler option when building the library. As each function is placed in
a section of its own the linker, when passed the --gc-sections, will
throw away unused sections (functions) and reduce the executable size.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling 6f9075d on smichaku:smichaku/sqlite-function-sections into 4e3d36a on SRombauts:master.

@SRombauts SRombauts self-assigned this Jan 6, 2021
@SRombauts SRombauts merged commit 9b6c0cf into SRombauts:master Jan 6, 2021
@SRombauts
Copy link
Owner

Thanks a lot for providing this!
I am sorry that it took me so long to merge it, especially since I did review it early, but then it got out of my mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants