Skip to content

Commit cbbd077

Browse files
authored
[build] Add SONAME at link time instead of using patchelf (#1258)
Add SONAME at link time instead of using patchelf Fix format
1 parent f900e79 commit cbbd077

File tree

5 files changed

+12
-29
lines changed

5 files changed

+12
-29
lines changed

builder/src/arch/apple.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,4 @@ pub fn strip_libraries(lib_path: &str) {
5252
strip.wait().expect("Failed to strip library");
5353
}
5454

55-
pub fn fix_soname(_lib_path: &str) {}
56-
5755
pub fn add_additional_files(_lib_path: &str, _target_path: &OsStr) {}

builder/src/arch/linux.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ pub const PROF_DYNAMIC_LIB_FFI: &str = "libdatadog_profiling_ffi.so";
1212
pub const PROF_STATIC_LIB_FFI: &str = "libdatadog_profiling_ffi.a";
1313
pub const REMOVE_RPATH: bool = false;
1414
pub const BUILD_CRASHTRACKER: bool = true;
15-
pub const RUSTFLAGS: [&str; 2] = ["-C", "relocation-model=pic"];
15+
pub const RUSTFLAGS: [&str; 4] = [
16+
"-C",
17+
"relocation-model=pic",
18+
"-C",
19+
"link-arg=-Wl,-soname,libdatadog_profiling.so",
20+
];
1621

1722
pub fn fix_rpath(lib_path: &str) {
1823
if REMOVE_RPATH {
@@ -62,15 +67,4 @@ pub fn strip_libraries(lib_path: &str) {
6267
debug.wait().expect("Failed to set debuglink");
6368
}
6469

65-
pub fn fix_soname(lib_path: &str) {
66-
let mut patch_soname = Command::new("patchelf")
67-
.arg("--set-soname")
68-
.arg(PROF_DYNAMIC_LIB)
69-
.arg(lib_path.to_owned() + "/" + PROF_DYNAMIC_LIB)
70-
.spawn()
71-
.expect("failed to span patchelf");
72-
73-
patch_soname.wait().expect("failed to change the soname");
74-
}
75-
7670
pub fn add_additional_files(_lib_path: &str, _target_path: &OsStr) {}

builder/src/arch/musl.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,12 @@ pub const PROF_DYNAMIC_LIB_FFI: &str = "libdatadog_profiling_ffi.so";
1212
pub const PROF_STATIC_LIB_FFI: &str = "libdatadog_profiling_ffi.a";
1313
pub const REMOVE_RPATH: bool = false;
1414
pub const BUILD_CRASHTRACKER: bool = true;
15-
pub const RUSTFLAGS: [&str; 2] = ["-C", "relocation-model=pic"];
15+
pub const RUSTFLAGS: [&str; 4] = [
16+
"-C",
17+
"relocation-model=pic",
18+
"-C",
19+
"link-arg=-Wl,-soname,libdatadog_profiling.so",
20+
];
1621

1722
pub fn fix_rpath(lib_path: &str) {
1823
if REMOVE_RPATH {
@@ -60,15 +65,4 @@ pub fn strip_libraries(lib_path: &str) {
6065
debug.wait().expect("Failed to set debuglink");
6166
}
6267

63-
pub fn fix_soname(lib_path: &str) {
64-
let mut patch_soname = Command::new("patchelf")
65-
.arg("--set-soname")
66-
.arg(PROF_DYNAMIC_LIB)
67-
.arg(lib_path.to_owned() + "/" + PROF_DYNAMIC_LIB)
68-
.spawn()
69-
.expect("failed to spawn patchelf");
70-
71-
patch_soname.wait().expect("failed to change the soname");
72-
}
73-
7468
pub fn add_additional_files(_lib_path: &str, _target_path: &OsStr) {}

builder/src/arch/windows.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ pub const RUSTFLAGS: [&str; 4] = [
2323

2424
pub fn fix_rpath(_lib_path: &str) {}
2525
pub fn strip_libraries(_lib_path: &str) {}
26-
pub fn fix_soname(_lib_path: &str) {}
2726

2827
pub fn add_additional_files(lib_path: &str, target_path: &OsStr) {
2928
let from_pdb: PathBuf = [lib_path, PROF_PDB_FFI].iter().collect();

builder/src/profiling.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,6 @@ impl Profiling {
109109

110110
arch::add_additional_files(&self.source_lib, lib_dir.as_os_str());
111111

112-
arch::fix_soname(&self.target_lib);
113-
114112
// Generate debug information
115113
arch::strip_libraries(&self.target_lib);
116114
Ok(())

0 commit comments

Comments
 (0)