Skip to content

Commit

Permalink
Fix bugs
Browse files Browse the repository at this point in the history
* Add call to wait on spawning commands to ensure all pending modifications to the filesystem have finished.
* Fix header directory assembling the tar file.
* Avoid telemetry header inclusion when telemetry feature is not
  selected.
* Fix clippy suggestions.
* Run clippy through all workspace so the builder crate is included.
* Fix merge conflicts.
  • Loading branch information
hoolioh committed Aug 28, 2024
1 parent 9710602 commit 2c438dd
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
run: rustup install ${{ matrix.rust_version }} && rustup default ${{ matrix.rust_version }} && rustup component add clippy
- name: Run clippy on ${{ matrix.platform }} ${{ matrix.rust_version }}
shell: bash
run: cargo clippy --all-targets --all-features -- -D warnings "$([ ${{ matrix.rust_version }} = 1.71.1 ] && echo -Aunknown-lints)"
run: cargo clippy --workspace --all-targets --all-features -- -D warnings "$([ ${{ matrix.rust_version }} = 1.71.1 ] && echo -Aunknown-lints)"
licensecheck:
runs-on: ubuntu-latest
name: "Presence of licence headers"
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ members = [
"data-pipeline",
"data-pipeline-ffi",
"ddsketch",
"tinybytes",
]

default-members = [
Expand Down
6 changes: 4 additions & 2 deletions builder/build/arch/apple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ pub fn fix_rpath(lib_path: &str) {

pub fn strip_libraries(lib_path: &str) {
// objcopy is not available in macos image. Investigate llvm-objcopy
Command::new("strip")
let mut strip = Command::new("strip")
.arg("-S")
.arg(lib_path.to_owned() + "/libdatadog_profiling.dylib")
.spawn()
.expect("failed to strip the library");
.expect("Failed to spawn strip");

strip.wait().expect("Failed to strip library");
}
24 changes: 16 additions & 8 deletions builder/build/arch/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,37 @@ pub fn fix_rpath(lib_path: &str) {
}

pub fn strip_libraries(lib_path: &str) {
Command::new("objcopy")
let mut rm_section = Command::new("objcopy")
.arg("--remove-section")
.arg(".llvmbc")
.arg(lib_path.to_owned() + "/libdatadog_profiling.a")
.spawn()
.expect("failed to remove llvm section");
.expect("failed to spawn objcopy");

Command::new("objcopy")
rm_section.wait().expect("Failed to remove llvmbc section");

let mut create_debug = Command::new("objcopy")
.arg("--only-keep-debug")
.arg(lib_path.to_owned() + "/libdatadog_profiling.so")
.arg(lib_path.to_owned() + "/libdatadog_profiling.debug")
.spawn()
.expect("failed to create debug file");
.expect("Failed to spawn objcopy");

create_debug.wait().expect("Failed to extract debug info");

Command::new("strip")
let mut strip = Command::new("strip")
.arg("-S")
.arg(lib_path.to_owned() + "/libdatadog_profiling.so")
.spawn()
.expect("failed to strip the library");
.expect("Failed to spawn strip");

Command::new("objcopy")
strip.wait().expect("Failed to strip library");

let mut debug = Command::new("objcopy")
.arg("--add-gnu-debuglink=".to_string() + lib_path + "/libdatadog_profiling.debug")
.arg(lib_path.to_owned() + "/libdatadog_profiling.so")
.spawn()
.expect("failed to create debug file");
.expect("Failed to spawn objcopy");

debug.wait().expect("Failed to set debuglink");
}
24 changes: 16 additions & 8 deletions builder/build/arch/musl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,37 @@ pub fn fix_rpath(lib_path: &str) {
}

pub fn strip_libraries(lib_path: &str) {
Command::new("objcopy")
let mut rm_section = Command::new("objcopy")
.arg("--remove-section")
.arg(".llvmbc")
.arg(lib_path.to_owned() + "/libdatadog_profiling.a")
.spawn()
.expect("failed to remove llvm section");
.expect("failed to spawn objcopy");

Command::new("objcopy")
rm_section.wait().expect("Failed to remove llvmbc section");

let mut create_debug = Command::new("objcopy")
.arg("--only-keep-debug")
.arg(lib_path.to_owned() + "/libdatadog_profiling.so")
.arg(lib_path.to_owned() + "/libdatadog_profiling.debug")
.spawn()
.expect("failed to create debug file");
.expect("Failed to spawn objcopy");

create_debug.wait().expect("Failed to extract debug info");

Command::new("strip")
let mut strip = Command::new("strip")
.arg("-s")
.arg(lib_path.to_owned() + "/libdatadog_profiling.so")
.spawn()
.expect("failed to strip the library");
.expect("Failed to spawn strip");

Command::new("objcopy")
strip.wait().expect("Failed to strip library");

let mut debug = Command::new("objcopy")
.arg("--add-gnu-debuglink=".to_string() + lib_path + "/libdatadog_profiling.debug")
.arg(lib_path.to_owned() + "/libdatadog_profiling.so")
.spawn()
.expect("failed to create debug file");
.expect("Failed to spawn objcopy");

debug.wait().expect("Failed to set debuglink");
}
5 changes: 3 additions & 2 deletions builder/build/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,10 @@ impl Builder {
let mut ar = tar::Builder::new(artifact);
ar.append_dir_all("lib", self.target_lib.as_ref())?;
ar.append_dir("bin", self.target_bin.as_ref())?;
ar.append_dir_all("include", self.target_include.as_ref())?;
ar.append_dir_all("include/datadog", self.target_include.as_ref())?;

Ok(ar.finish().expect("Failed to write the tarfile"))
ar.finish().expect("Failed to write the tarfile");
Ok(())
}
}

Expand Down
7 changes: 5 additions & 2 deletions builder/build/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ pub struct Profiling {

impl Profiling {
fn add_headers(&self) -> Result<()> {
// Telemetry is reexported through profiling by default.
let headers: [&str; 2] = ["profiling.h", "telemetry.h"];
// Allowing unused_mut due to the methods mutating the vector are behind a feature flag.
#[allow(unused_mut)]
let mut headers = vec!["profiling.h"];
#[cfg(feature = "telemetry")]
headers.push("telemetry.h");

let mut origin_path: PathBuf = [&self.source_include, "dummy.h"].iter().collect();
let mut target_path: PathBuf = [&self.target_include, "dummy.h"].iter().collect();
Expand Down

0 comments on commit 2c438dd

Please sign in to comment.