Kontinuation opened a new pull request, #672:
URL: https://github.com/apache/sedona-db/pull/672
## Summary
Replace the C-based `dlopen`/`dlsym` dynamic PROJ loading
(`proj_dyn.c`/`proj_dyn.h`) with a pure Rust implementation using the
`libloading` crate. This eliminates the `cc` build dependency and ~250 lines of
C code while maintaining the same `ProjApi` struct-of-function-pointers
architecture used by all existing call sites.
## Changes
- **New**: `c/sedona-proj/src/dyn_load.rs` — Pure Rust dynamic symbol loader
with `load_fn!` macro and `load_proj_from_path()` function
- **Deleted**: `c/sedona-proj/build.rs`, `c/sedona-proj/src/proj_dyn.c`,
`c/sedona-proj/src/proj_dyn.h` — C-based loader and its build script
- **Modified**: `c/sedona-proj/src/proj.rs` — `ProjApi` struct now holds
`Option<Library>` to keep the shared library alive; `try_from_shared_library()`
calls the Rust loader; `Drop` relies on automatic `Library` drop instead of the
C `release` callback
- **Modified**: `c/sedona-proj/src/proj_dyn_bindgen.rs` — Removed `extern
"C" { proj_dyn_api_init }` block (no longer needed)
- **Modified**: `c/sedona-proj/Cargo.toml` — Replaced `cc` build-dependency
with `libloading` runtime dependency
- **Modified**: `Cargo.toml` — Added `libloading = "0.9"` to workspace
dependencies
## Approach
The `libloading` crate provides safe, cross-platform dynamic library loading
(`dlopen`/`LoadLibrary`). Each PROJ symbol is loaded via a `load_fn!` macro
that:
1. Loads the symbol as a raw `*const ()` pointer
2. Transmutes it to the expected function pointer type
3. Stores it in the existing `ProjApi` `#[repr(C)]` struct
The `Library` handle is stored as `_lib: Option<Library>` in the Rust
`ProjApi` wrapper — `Some` when loaded from a shared library, `None` when using
`proj-sys`. This ensures the library stays loaded for the lifetime of the
function pointers.
All 22 existing tests pass. No clippy warnings.
## Note
A similar PR for `sedona-gdal` will follow as a stacked PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]