# libdatadog-libunwind
Rust bindings for libunwind, targeting Linux on x86_64 and aarch64.
libunwind is **vendored** directly in this repository under `libdd-libunwind-sys/libunwind/`.
Vendoring is intentional: it eliminates the runtime dependency on an external source and protects
against supply chain attacks.
## Crates
| `libdd-libunwind-sys` | Low-level FFI bindings and build logic |
## Bindings
The FFI bindings in `libdd-libunwind-sys/src/` are **hand-written** (not generated by `bindgen`).
Each supported architecture has its own module:
- `libunwind_x86_64.rs` — bindings for x86_64
- `libunwind_aarch64.rs` — bindings for aarch64
The bindings expose a subset of the libunwind API:
`unw_init_local2`, `unw_step`, `unw_get_reg`, `unw_get_proc_name`, and `unw_backtrace2`.
When adding or updating bindings, edit the appropriate architecture file directly.
## Build
### Prerequisites
The build script compiles libunwind from source and requires the following tools on the host:
| `make` | Drives the build | `apt install make` |
| `gcc` or `clang` | C/C++ compiler for libunwind | `apt install gcc` |
Install all at once:
```sh
apt install make gcc
```
### Building
```sh
cargo build
```
### Supported targets
| `x86_64-unknown-linux-gnu` | Supported |
| `aarch64-unknown-linux-gnu` | Supported |
All other targets produce an empty crate (the build script and bindings are gated on `target_os = "linux"`).
## How to publish
1. **Bump the version** in `Cargo.toml` and merge the change to `main`.
2. **Tag the release commit** on `main`:
```sh
git checkout main && git pull
git tag v<version> git push origin v<version>
```
3. **Wait for CI** — the tag push triggers a pipeline that runs all four
build+test configurations (CentOS and Alpine, x86\_64 and aarch64).
4. **Trigger the publish job** — once all test jobs are green, a manual
`publish_crate` job appears in the pipeline. Click ▶ to publish to
crates.io.
The publish job validates that the tag version matches `Cargo.toml`, that
the tagged commit is on `main`, and does a `--dry-run` before the real
publish. If the version is already on crates.io the job exits cleanly
without error.