Skip to content

Compile internal SQLite library with -ffunction-sections#295

Merged
SRombauts merged 1 commit intoSRombauts:masterfrom
smichaku:smichaku/sqlite-function-sections
Jan 6, 2021
Merged

Compile internal SQLite library with -ffunction-sections#295
SRombauts merged 1 commit intoSRombauts:masterfrom
smichaku:smichaku/sqlite-function-sections

Conversation

@smichaku
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown
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