Skip to content

feat: rocksdb linkage of existing static rocksdb library is missing stdc++#1607

Merged
Mirko-von-Leipzig merged 4 commits intonextfrom
bernhard-rocksdb-cxx-linkage-fix
Jan 29, 2026
Merged

feat: rocksdb linkage of existing static rocksdb library is missing stdc++#1607
Mirko-von-Leipzig merged 4 commits intonextfrom
bernhard-rocksdb-cxx-linkage-fix

Conversation

@drahnr
Copy link
Contributor

@drahnr drahnr commented Jan 28, 2026

Problem

rocksdb-rust has an issue supplying stdc++ (for linux, differs for platforms) to rustc at linktime. This implies missing C++ standard library features which in turn causes missing symbols when linking an existing rocksdb.a.

It doesn't show for me

Currently we do recompile both locally and in CI rocksdb with the cache (~1GB) and time (~50s) for each of those runs.
If you want to avoid this, the following has worked in the past and shaves off both:

  1. compile once without the env vars in step 4

  2. find the rocksdb.a in your target dir

  3. copy the rocksdb.a

  4. # assumes linux and home
    export TMP_ARTIFACT="$(fd -i -H --max-results=1 --extension a '.*rocksdb.*' target)"
    cp -v "${TMP_ARTIFACT}" "${HOME}/.local/lib/"
    export ROCKSDB_COMPILE=true
    export ROCKSDB_STATIC
    export ROCKSDB_LIB_DIR=${HOME}/.local/lib/
    make build
  5. the output should show librocksdb-sys(build) for less than 100ms instead of 50seconds

Why do we need this change?

Upstream's last release (10th of August '25) has a bug, it's already fixed in master, but there is no release including that, the relevant PR already landed:
rust-rocksdb/rust-rocksdb#1029

tl;dr - this is a stopgap solution to allow us to save both time and space in CI, as well as locally

Next steps

Separate steps of building our code and rocksdb - the latter should provide a statically linked rocksdb.a in most (all?) CI steps.


Approach

Possible paths

  1. use a .cargo/config.toml entry - while it works it will become an issue once trying to link musl or custom toolchain paths since it doesn't support CXXSTD env var - we also cannot simply gate for specific targets iiuc
  2. implement a build.rs for each binary to add the correct linkage flags - it's opt-in and doesn't break any other paths

Choosing the latter, it's more code, but it's both opt-in and very deliberate.

@drahnr drahnr requested a review from sergerad January 28, 2026 14:47
@drahnr drahnr added the no changelog This PR does not require an entry in the `CHANGELOG.md` file label Jan 28, 2026
Copy link
Collaborator

@Mirko-von-Leipzig Mirko-von-Leipzig left a comment

Choose a reason for hiding this comment

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

I think this is good. I just need to give it more time to percolate..

Also gees this sucks as an upstream bug :D

@Mirko-von-Leipzig
Copy link
Collaborator

Mirko-von-Leipzig commented Jan 29, 2026

Merging now, will update again after cache has been written. Ah nvm I believe the next step is required to actually CI/cache the rocks DB static lib?

@Mirko-von-Leipzig Mirko-von-Leipzig merged commit 8927fe2 into next Jan 29, 2026
7 checks passed
@Mirko-von-Leipzig Mirko-von-Leipzig deleted the bernhard-rocksdb-cxx-linkage-fix branch January 29, 2026 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no changelog This PR does not require an entry in the `CHANGELOG.md` file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants