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
34 changes: 6 additions & 28 deletions builder/src/arch/apple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0

use std::ffi::OsStr;
use std::os::unix::process::ExitStatusExt;
use std::process::Command;

use crate::utils::wait_for_success;
Expand All @@ -13,34 +12,13 @@ pub const PROF_DYNAMIC_LIB: &str = "libdatadog_profiling.dylib";
pub const PROF_STATIC_LIB: &str = "libdatadog_profiling.a";
pub const PROF_DYNAMIC_LIB_FFI: &str = "libdatadog_profiling_ffi.dylib";
pub const PROF_STATIC_LIB_FFI: &str = "libdatadog_profiling_ffi.a";
pub const REMOVE_RPATH: bool = true;
pub const BUILD_CRASHTRACKER: bool = true;
pub const RUSTFLAGS: [&str; 2] = ["-C", "relocation-model=pic"];

pub fn fix_rpath(lib_path: &str) {
if REMOVE_RPATH {
let lib_name = lib_path.split('/').next_back().unwrap();

let exit_status = Command::new("install_name_tool")
.arg("-id")
.arg("@rpath/".to_string() + lib_name)
.arg(lib_path)
.status()
.expect("Failed to fix rpath using install_name_tool");
match exit_status.code() {
Some(0) => {}
Some(rc) => panic!("Failed to fix rpath using install_name_tool: return code {rc}"),
None => match exit_status.signal() {
Some(sig) => {
panic!("Failed to fix rpath using install_name_tool: killed by signal {sig}")
}
None => panic!(
"Failed to fix rpath using install_name_tool: exit status {exit_status:?}"
),
},
}
}
}
pub const RUSTFLAGS: [&str; 4] = [
"-C",
"relocation-model=pic",
"-C",
"link-arg=-Wl,-install_name,@rpath/libdatadog_profiling.dylib",
];

pub fn strip_libraries(lib_path: &str) {
// objcopy is not available in macos image. Investigate llvm-objcopy
Expand Down
13 changes: 0 additions & 13 deletions builder/src/arch/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub const PROF_DYNAMIC_LIB: &str = "libdatadog_profiling.so";
pub const PROF_STATIC_LIB: &str = "libdatadog_profiling.a";
pub const PROF_DYNAMIC_LIB_FFI: &str = "libdatadog_profiling_ffi.so";
pub const PROF_STATIC_LIB_FFI: &str = "libdatadog_profiling_ffi.a";
pub const REMOVE_RPATH: bool = false;
pub const BUILD_CRASHTRACKER: bool = true;
pub const RUSTFLAGS: [&str; 4] = [
"-C",
Expand All @@ -20,18 +19,6 @@ pub const RUSTFLAGS: [&str; 4] = [
"link-arg=-Wl,-soname,libdatadog_profiling.so",
];

pub fn fix_rpath(lib_path: &str) {
if REMOVE_RPATH {
let patchelf = Command::new("patchelf")
.arg("--remove-rpath")
.arg(lib_path)
.spawn()
.expect("failed to spawn patchelf");

wait_for_success(patchelf, "patchelf");
}
}

pub fn strip_libraries(lib_path: &str) {
let rm_section = Command::new("objcopy")
.arg("--remove-section")
Expand Down
11 changes: 0 additions & 11 deletions builder/src/arch/musl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pub const PROF_DYNAMIC_LIB: &str = "libdatadog_profiling.so";
pub const PROF_STATIC_LIB: &str = "libdatadog_profiling.a";
pub const PROF_DYNAMIC_LIB_FFI: &str = "libdatadog_profiling_ffi.so";
pub const PROF_STATIC_LIB_FFI: &str = "libdatadog_profiling_ffi.a";
pub const REMOVE_RPATH: bool = false;
pub const BUILD_CRASHTRACKER: bool = true;
pub const RUSTFLAGS: [&str; 4] = [
"-C",
Expand All @@ -20,16 +19,6 @@ pub const RUSTFLAGS: [&str; 4] = [
"link-arg=-Wl,-soname,libdatadog_profiling.so",
];

pub fn fix_rpath(lib_path: &str) {
if REMOVE_RPATH {
Command::new("patchelf")
.arg("--remove-rpath")
.arg(lib_path)
.spawn()
.expect("failed to remove rpath");
}
}

pub fn strip_libraries(lib_path: &str) {
let rm_section = Command::new("objcopy")
.arg("--remove-section")
Expand Down
2 changes: 0 additions & 2 deletions builder/src/arch/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pub const PROF_PDB: &str = "datadog_profiling.pdb";
pub const PROF_DYNAMIC_LIB_FFI: &str = "datadog_profiling_ffi.dll";
pub const PROF_STATIC_LIB_FFI: &str = "datadog_profiling_ffi.lib";
pub const PROF_PDB_FFI: &str = "datadog_profiling_ffi.pdb";
pub const REMOVE_RPATH: bool = false;
pub const BUILD_CRASHTRACKER: bool = false;
pub const RUSTFLAGS: [&str; 4] = [
"-C",
Expand All @@ -21,7 +20,6 @@ pub const RUSTFLAGS: [&str; 4] = [
"target-feature=+crt-static",
];

pub fn fix_rpath(_lib_path: &str) {}
pub fn strip_libraries(_lib_path: &str) {}

pub fn add_additional_files(lib_path: &str, target_path: &OsStr) {
Expand Down
1 change: 0 additions & 1 deletion builder/src/bin/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ pub fn main() {
let res = builder.build();
match res {
Ok(_) => {
builder.sanitize_libraries();
// Note: tar creation is handled by CI, not by this binary
}
Err(err) => panic!("{}", format!("Building failed: {err}")),
Expand Down
13 changes: 0 additions & 13 deletions builder/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,6 @@ impl Builder {
.expect("Failed to create include directory");
}

// TODO: maybe do this in module's build.rs
pub fn sanitize_libraries(&self) {
let datadog_lib_dir = Path::new(self.source_lib.as_ref());

let libs = fs::read_dir(datadog_lib_dir).unwrap();
for lib in libs.flatten() {
let name = lib.file_name().into_string().unwrap();
if name.ends_with(".so") {
arch::fix_rpath(lib.path().to_str().unwrap());
}
}
}

pub fn add_cmake(&self) {
let libs = arch::NATIVE_LIBS.to_owned();
let cmake_dir: PathBuf = [&self.target_dir, "cmake"].iter().collect();
Expand Down
Loading