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 a7f88b9
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 24 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
2 changes: 1 addition & 1 deletion LICENSE-3rdparty.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
root_name: datadog-alloc, builder, datadog-crashtracker, ddcommon, ddtelemetry, datadog-ddsketch, datadog-crashtracker-ffi, ddcommon-ffi, build_common, datadog-profiling, datadog-profiling-ffi, data-pipeline-ffi, data-pipeline, datadog-trace-normalization, datadog-trace-protobuf, datadog-trace-utils, ddtelemetry-ffi, symbolizer-ffi, datadog-profiling-replayer, datadog-dynamic-configuration, tools, datadog-ipc, datadog-ipc-macros, tarpc, tarpc-plugins, spawn_worker, cc_utils, datadog-remote-config, datadog-sidecar, datadog-sidecar-macros, datadog-sidecar-ffi, sidecar_mockgen, datadog-trace-obfuscation, test_spawn_from_lib, datadog-serverless-trace-mini-agent, datadog-trace-mini-agent, bin_tests
root_name: datadog-alloc, builder, build_common, datadog-crashtracker-ffi, datadog-crashtracker, ddcommon, ddtelemetry, datadog-ddsketch, ddcommon-ffi, datadog-profiling-ffi, data-pipeline-ffi, data-pipeline, datadog-trace-normalization, datadog-trace-protobuf, datadog-trace-utils, datadog-profiling, ddtelemetry-ffi, symbolizer-ffi, tools, datadog-profiling-replayer, datadog-ipc, datadog-ipc-macros, tarpc, tarpc-plugins, spawn_worker, cc_utils, datadog-sidecar, datadog-remote-config, datadog-dynamic-configuration, datadog-sidecar-macros, datadog-sidecar-ffi, sidecar_mockgen, datadog-trace-obfuscation, test_spawn_from_lib, datadog-serverless-trace-mini-agent, datadog-trace-mini-agent, bin_tests
third_party_libraries:
- package_name: addr2line
package_version: 0.21.0
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 a7f88b9

Please sign in to comment.