Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
.gitlab-ci.yml @DataDog/apm-common-components-core
.gitlab/benchmarks.yml @DataDog/apm-common-components-core
.gitlab/fuzz.yml @DataDog/chaos-platform
.gitmodules @DataDog/libdatadog
benchmark/ @DataDog/apm-common-components-core
bin_tests/ @DataDog/libdatadog-profiling
build-common/ @DataDog/apm-common-components-core
Expand Down Expand Up @@ -44,6 +45,7 @@ libdd-data-pipeline*/ @DataDog/libdatadog-apm
libdd-ddsketch*/ @DataDog/libdatadog-apm @DataDog/apm-common-components-core
libdd-dogstatsd-client @DataDog/apm-common-components-core
libdd-library-config*/ @DataDog/apm-sdk-capabilities
libdd-libunwind*/ @DataDog/libdatadog-profiling
libdd-log*/ @DataDog/apm-common-components-core
libdd-profiling*/ @DataDog/libdatadog-profiling
libdd-telemetry*/ @DataDog/apm-common-components-core
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
docker-images: true
swap-storage: true
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
submodules: recursive
- name: Install Rust
run: rustup install nightly-2026-02-08 && rustup default nightly-2026-02-08
- name: Install cargo-llvm-cov
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
submodules: recursive
- name: Run actionlint
uses: devops-actions/actionlint@c6744a34774e4e1c1df0ff66bdb07ec7ee480ca0 # 0.1.9
with:
Expand All @@ -22,6 +24,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
submodules: recursive
- name: Install nightly-2026-02-08 toolchain and rustfmt
run: rustup install nightly-2026-02-08 && rustup default nightly-2026-02-08 && rustup component add rustfmt
- name: Cache [rust]
Expand All @@ -41,6 +45,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
submodules: recursive
- name: Install ${{ matrix.rust_version }} toolchain and clippy
run: rustup install ${{ matrix.rust_version }} && rustup default ${{ matrix.rust_version }} && rustup component add clippy
- name: Cache [rust]
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/miri.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ jobs:
PROPTEST_CASES: 1
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
submodules: recursive
- name: Set up Rust
run: |
set -e
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ jobs:
swap-storage: true
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
submodules: recursive
- name: Install Rust ${{ matrix.rust_version }}
if: matrix.rust_version != ''
run: rustup install ${{ matrix.rust_version }} && rustup default ${{ matrix.rust_version }}
Expand Down Expand Up @@ -155,6 +157,8 @@ jobs:
steps:
- name: Checkout sources
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
submodules: recursive
- name: Setup output dir
shell: bash
run: |
Expand Down Expand Up @@ -297,6 +301,8 @@ jobs:
swap-storage: true
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
submodules: recursive
- name: Cache [rust]
uses: Swatinem/rust-cache@f13886b937689c021905a6b90929199931d60db1 # 2.8.1
with:
Expand All @@ -321,6 +327,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
with:
submodules: recursive
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # 3.10.0
with:
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "libdd-libunwind-sys/libunwind"]
path = libdd-libunwind-sys/libunwind
url = https://github.com/DataDog/libunwind.git
branch = kevin/v1.8.1-custom-2
9 changes: 9 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ members = [
"libdd-tinybytes",
"libdd-dogstatsd-client",
"libdd-log",
"libdd-log-ffi",
"libdd-log-ffi", "libdd-libunwind-sys",
]

# https://doc.rust-lang.org/cargo/reference/resolver.html
Expand Down
2 changes: 1 addition & 1 deletion LICENSE-3rdparty.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
root_name: builder, build_common, tools, libdd-alloc, libdd-crashtracker, libdd-common, libdd-telemetry, libdd-ddsketch, libdd-crashtracker-ffi, libdd-common-ffi, datadog-ffe, datadog-ffe-ffi, datadog-ipc, datadog-ipc-macros, libdd-tinybytes, tarpc, tarpc-plugins, spawn_worker, cc_utils, libdd-library-config, libdd-library-config-ffi, datadog-live-debugger, libdd-data-pipeline, libdd-dogstatsd-client, libdd-trace-protobuf, libdd-trace-stats, libdd-trace-utils, libdd-trace-normalization, libdd-log, datadog-live-debugger-ffi, libdd-profiling, libdd-profiling-protobuf, libdd-profiling-ffi, libdd-data-pipeline-ffi, libdd-ddsketch-ffi, libdd-log-ffi, libdd-telemetry-ffi, symbolizer-ffi, datadog-profiling-replayer, datadog-remote-config, datadog-sidecar, datadog-sidecar-macros, datadog-sidecar-ffi, libdd-trace-obfuscation, datadog-tracer-flare, sidecar_mockgen, test_spawn_from_lib
root_name: builder, build_common, tools, libdd-alloc, libdd-crashtracker, libdd-common, libdd-telemetry, libdd-ddsketch, libdd-crashtracker-ffi, libdd-common-ffi, datadog-ffe, datadog-ffe-ffi, datadog-ipc, datadog-ipc-macros, libdd-tinybytes, tarpc, tarpc-plugins, spawn_worker, cc_utils, libdd-library-config, libdd-library-config-ffi, datadog-live-debugger, libdd-data-pipeline, libdd-dogstatsd-client, libdd-trace-protobuf, libdd-trace-stats, libdd-trace-utils, libdd-trace-normalization, libdd-log, datadog-live-debugger-ffi, libdd-profiling, libdd-profiling-protobuf, libdd-profiling-ffi, libdd-data-pipeline-ffi, libdd-ddsketch-ffi, libdd-log-ffi, libdd-telemetry-ffi, symbolizer-ffi, datadog-profiling-replayer, datadog-remote-config, datadog-sidecar, datadog-sidecar-macros, datadog-sidecar-ffi, libdd-trace-obfuscation, datadog-tracer-flare, sidecar_mockgen, test_spawn_from_lib, bin_tests
third_party_libraries:
- package_name: addr2line
package_version: 0.24.2
Expand Down
19 changes: 19 additions & 0 deletions libdd-libunwind-sys/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "libdd-libunwind"
edition.workspace = true
version.workspace = true
rust-version.workspace = true
license.workspace = true
publish = false
links = "unwind" # Tells Cargo this crate links to libunwind (prevents multiple builds)

[lib]
crate-type = ["lib"]
bench = false

[dependencies]
paste = "1.0"
libc = "0.2"

[build-dependencies]
cc = "1.0"
137 changes: 137 additions & 0 deletions libdd-libunwind-sys/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
// Copyright 2025-Present Datadog, Inc. https://www.datadoghq.com/
// SPDX-License-Identifier: Apache-2.0

fn main() {
#[cfg(target_os = "linux")]
linux::main();
}

#[cfg(target_os = "linux")]
mod linux {
use std::env;
use std::path::PathBuf;

pub(crate) fn main() {
let out_dir = PathBuf::from(env::var("OUT_DIR").unwrap());
let build_dir = out_dir.join("libunwind_build");
let manifest_dir = std::env::var("CARGO_MANIFEST_DIR").unwrap();
let libunwind_dir = std::path::Path::new(&manifest_dir).join("libunwind");

if !libunwind_dir.join("src").exists() {
panic!(
"libunwind source not found at {}. \
Did you forget to run `git submodule update --init`?",
libunwind_dir.display()
);
}

// Check if libunwind submodule is initialized
if !libunwind_dir.exists() || std::fs::read_dir(&libunwind_dir).unwrap().next().is_none() {
panic!(
"libunwind submodule not initialized!\n\
Run: git submodule update --init --recursive\n\
\n\
For CI, ensure your workflow checks out submodules:\n\
- GitHub Actions: add 'submodules: recursive' to actions/checkout\n\
- GitLab CI: add 'GIT_SUBMODULE_STRATEGY: recursive'\n\
\n\
Directory checked: {}",
libunwind_dir.display()
);
}

std::fs::create_dir_all(&build_dir).unwrap();

let lib_file = build_dir.join("src/.libs/libunwind.a");

// Only build if library doesn't exist
if !lib_file.exists() {
eprintln!("Building libunwind from source...");

// Only run autoreconf if configure doesn't exist
let configure_script = libunwind_dir.join("configure");
if !configure_script.exists() {
eprintln!("Running autoreconf...");
let status = std::process::Command::new("sh")
.current_dir(&libunwind_dir)
.args(["-c", "autoreconf -i"])
.status()
.expect(
"Failed to run autoreconf. Install with: apt install autoconf automake libtool",
);

if !status.success() {
panic!("autoreconf failed with exit code: {:?}", status.code());
}
}

eprintln!("Configuring libunwind...");
let status = std::process::Command::new("sh")
.current_dir(&build_dir)
.args([
"-c",
&format!(
r"{}/configure CXXFLAGS=-fPIC\ -D_GLIBCXX_USE_CXX11_ABI=0\ -O3\ -g CFLAGS=-fPIC\ -O3\ -g --disable-shared --enable-static --disable-minidebuginfo --disable-zlibdebuginfo --disable-tests",
libunwind_dir.display()
)
])
.status()
.expect("Failed to run configure");

if !status.success() {
panic!(
"libunwind configure failed with exit code: {:?}",
status.code()
);
}

eprintln!("Building libunwind...");
let status = std::process::Command::new("sh")
.current_dir(&build_dir)
.args(["-c", "make -j$(nproc)"])
.status()
.expect("Failed to run make");

if !status.success() {
panic!("libunwind make failed with exit code: {:?}", status.code());
}

// Verify the library was actually created
if !lib_file.exists() {
panic!(
"libunwind.a was not created at expected location: {}",
lib_file.display()
);
}

eprintln!("libunwind built successfully at {}", lib_file.display());
} else {
eprintln!("Using cached libunwind build");
}

let lib_path = build_dir.join("src/.libs");
let include_path = build_dir.join("include");

#[cfg(target_arch = "x86_64")]
let arch = "x86_64";
#[cfg(target_arch = "aarch64")]
let arch = "aarch64";

// Link directives for this crate
println!("cargo:rustc-link-search=native={}", lib_path.display());
println!("cargo:rustc-link-lib=static=unwind");
println!("cargo:rustc-link-lib=static=unwind-{}", arch);

// Export paths to dependent crates via DEP_UNWIND_* environment variables
println!("cargo:include={}", include_path.display());
println!("cargo:lib={}", lib_path.display());
println!("cargo:libdir={}", lib_path.display());
println!("cargo:root={}", build_dir.display());

eprintln!("libunwind library ready at {}", lib_path.display());

println!("cargo:rerun-if-changed={}/src", libunwind_dir.display());
println!("cargo:rerun-if-changed={}/include", libunwind_dir.display());
println!("cargo:rerun-if-changed=build.rs");
}
}
1 change: 1 addition & 0 deletions libdd-libunwind-sys/libunwind
Submodule libunwind added at cc1d07
Loading
Loading