Skip to content

feat: add static linking support and improve download reliability#28

Merged
wudidapaopao merged 1 commit into
chdb-io:mainfrom
ION28:main
May 3, 2026
Merged

feat: add static linking support and improve download reliability#28
wudidapaopao merged 1 commit into
chdb-io:mainfrom
ION28:main

Conversation

@ION28

@ION28 ION28 commented Apr 15, 2026

Copy link
Copy Markdown
Contributor

This is a fix for #27 - Closes #27

Proposed benefit: Static linking significantly increases the final binary size but removes all runtime shared library requirements for chDB to support more portable applications.

Change summary:

  • Introduce 'static' feature flag to Cargo.toml
  • Update build.rs to fetch and link static libchdb archives
  • Increase download timeout to 600s and stream to disk to prevent OOM
  • Link stdc++ when static feature is enabled

I have tested this successfully bundling into my application without supplying the features as well as supplying --features = static and confirmed the resulting ldd output shows the binary appearing (dynamic resolve) vs not appearing (statically linked).

How to test:

Dynamic (Default/current behavior):

cargo build
ldd target/debug/libyour_project.so  # Should show dependency on libchdb.so

Static:

cargo build --features static
ldd target/debug/libyour_project.so  # Should NOT show libchdb.so as a dependency

- Introduce 'static' feature flag to Cargo.toml
- Update build.rs to fetch and link static libchdb archives
- Increase download timeout to 600s and stream to disk to prevent OOM
- Link stdc++ when static feature is enabled
@CLAassistant

CLAassistant commented Apr 15, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@ION28

ION28 commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

The project should feel free to use the code provided in this PR if desired even though I will not be signing the current CLA. Really appreciate this library!

@wudidapaopao

Copy link
Copy Markdown
Contributor

Hi @ION28, CLA has been updated, feel free to check it out.

@wudidapaopao wudidapaopao merged commit 6c1c098 into chdb-io:main May 3, 2026
2 checks passed
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.

Support for Static Linking of chdb-rust when embedded into other applications

3 participants