diff --git a/builder/src/arch/apple.rs b/builder/src/arch/apple.rs index 63bd18a7dc..c40d17c67b 100644 --- a/builder/src/arch/apple.rs +++ b/builder/src/arch/apple.rs @@ -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; @@ -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 diff --git a/builder/src/arch/linux.rs b/builder/src/arch/linux.rs index f6e0eb7db7..65fa738355 100644 --- a/builder/src/arch/linux.rs +++ b/builder/src/arch/linux.rs @@ -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", @@ -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") diff --git a/builder/src/arch/musl.rs b/builder/src/arch/musl.rs index 794d13b47f..684b0c1f3b 100644 --- a/builder/src/arch/musl.rs +++ b/builder/src/arch/musl.rs @@ -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", @@ -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") diff --git a/builder/src/arch/windows.rs b/builder/src/arch/windows.rs index de50397d79..1d9313817f 100644 --- a/builder/src/arch/windows.rs +++ b/builder/src/arch/windows.rs @@ -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", @@ -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) { diff --git a/builder/src/bin/release.rs b/builder/src/bin/release.rs index e4244287a5..dc0d972cf6 100644 --- a/builder/src/bin/release.rs +++ b/builder/src/bin/release.rs @@ -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}")), diff --git a/builder/src/builder.rs b/builder/src/builder.rs index 3363d18437..5e691e2280 100644 --- a/builder/src/builder.rs +++ b/builder/src/builder.rs @@ -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();