Skip to content

feat: add columnar-dbc Rust crates linking dbc statically - #548

Draft
zeroshade wants to merge 4 commits into
feat/capifrom
feat/rust-crates
Draft

zeroshade wants to merge 4 commits into
feat/capifrom
feat/rust-crates

Conversation

@zeroshade

@zeroshade zeroshade commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

rust/: columnar-dbc (safe API), columnar-dbc-sys (bindgen 0.73.2 bindings generated from libdbc.h, committed) and five columnar-dbc-sys-<platform> crates, each bundling a prebuilt libdbc.a. Supported targets: x86_64/aarch64 Linux (glibc), x86_64/aarch64 macOS, x86_64-pc-windows-msvc and x86_64-pc-windows-gnu. Other targets fail at build time.

MSVC: a Go c-archive registers its runtime entry in .ctors, which only the MinGW CRT runs. Under MSVC the first dbc call blocked forever. The Windows platform crate registers _rt0_amd64_windows_lib in .CRT$XCU for target_env = "msvc". A local cargo xwin link map shows the pointer in the CRT's XCA..XCZ initializer table. CI in the top PR of the stack runs the tests.

Stacked on #547.

Linking a system or custom libdbc

Modeled on zstd-sys. The default bundled feature keeps the per-platform crates. Otherwise the source is chosen in this order:

  1. DBC_SYS_LIB_DIR=<dir>: a custom directory.
  2. The pkg-config feature, or DBC_SYS_USE_PKG_CONFIG set: pkg-config module dbc.
  3. bundled.

With default-features = false, features = ["pkg-config"], the platform crates aren't downloaded at all. Env overrides win even when bundled is on: the platform crate is never extern crated, so its archive isn't linked.

Linking is static by default; DBC_DYNAMIC (pkg-config-rs's own convention) links libdbc.so. pkg-config-rs refuses static links for archives under /usr, so build.rs emits the link directives itself rather than using .statik(true).

The MSVC Go runtime initializer moved from the Windows platform crate into -sys. It's applied to any static x86_64 MSVC link, and static MSVC links on other architectures fail with a clear error.

…http

tiny_http 0.12 unwraps peer_addr() on accept; on Windows it fails with WSAENOTCONN when the client has already closed the connection, killing the worker and failing the next request with EOF.
…LIB_DIR

Keep bundled platform crates as the default, with custom-directory and pkg-config overrides selecting static or opt-in dynamic linking. Move the MSVC Go initializer into the sys crate and reject non-x86_64 static MSVC links.

pkg-config 0.3.34 parse_libs defaults the non-macOS/non-Windows system root to /usr, and is_static_available requires an archive path outside every system root. Thus statik(true) alone emits an unqualified link for /usr/lib/<triplet>/libdbc.a, allowing the shared library to win. Probe without Cargo link metadata and explicitly emit static=dbc, leaving private system libraries dynamic.

This branch was successfully deployed

1 active deployment
snapshot — 55aebb17 Deployed Oct 30, 2026 by zeroshade via snapshot #1097
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.

1 participant