Skip to content
Closed
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
31 changes: 26 additions & 5 deletions libdd-libunwind-sys/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mod linux {

const LIBUNWIND_REPO: &str = "https://github.com/DataDog/libunwind.git";
const LIBUNWIND_BRANCH: &str = "kevin/v1.8.1-custom-2";
const AUTOTOOLS_INSTALL_HINT: &str = "Install autotools:\n Debian/Ubuntu: apt install autoconf automake libtool\n Alpine: apk add autoconf automake libtool m4";

/// Try initializing the libunwind git submodule from the repo root.
/// Only works when running inside a git repository.
Expand Down Expand Up @@ -103,17 +104,37 @@ mod linux {
if !lib_file.exists() {
eprintln!("Building libunwind from source...");

// Only run autoreconf if configure doesn't exist
// Only run autotools bootstrap if configure doesn't exist.
let configure_script = libunwind_dir.join("configure");
if !configure_script.exists() {
// Some source snapshots do not include generated autotools files.
// Ensure macro dir exists before running autoreconf
std::fs::create_dir_all(libunwind_dir.join("m4"))
.expect("Failed to create libunwind/m4 directory");

eprintln!("Running libtoolize...");
let status = std::process::Command::new("sh")
.current_dir(&libunwind_dir)
.args(["-c", "libtoolize --copy --force"])
.status()
.expect(&format!(
"Failed to run libtoolize.\n{}",
AUTOTOOLS_INSTALL_HINT
));

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

eprintln!("Running autoreconf...");
let status = std::process::Command::new("sh")
.current_dir(&libunwind_dir)
.args(["-c", "autoreconf -i"])
.args(["-c", "autoreconf -fi"])
.status()
.expect(
"Failed to run autoreconf. Install with: apt install autoconf automake libtool",
);
.expect(&format!(
"Failed to run autoreconf.\n{}",
AUTOTOOLS_INSTALL_HINT
));

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