From 552b553a44f48ed159c7a2cf43d077d6ca310d95 Mon Sep 17 00:00:00 2001 From: Nico Burns Date: Thu, 11 Dec 2025 02:36:56 +0000 Subject: [PATCH] Fix call to rustc-objcopy to strip binary on Linux (#5066) * Fix call to rustc-objcopy to strip binary on Linux Signed-off-by: Nico Burns * Print stdout and stderr if strip fails Signed-off-by: Nico Burns --------- Signed-off-by: Nico Burns --- packages/cli/src/build/request.rs | 8 ++++++++ packages/cli/src/workspace.rs | 5 +++++ 2 files changed, 13 insertions(+) diff --git a/packages/cli/src/build/request.rs b/packages/cli/src/build/request.rs index ef6ce21e2..9ae8c4f97 100644 --- a/packages/cli/src/build/request.rs +++ b/packages/cli/src/build/request.rs @@ -3979,10 +3979,18 @@ impl BuildRequest { }; if let Some(strip_arg) = strip_arg { let rustc_objcopy = self.workspace.rustc_objcopy(); + let dylib_path = self.workspace.rustc_objcopy_dylib_path(); let mut command = Command::new(rustc_objcopy); + command.env("LD_LIBRARY_PATH", &dylib_path); command.arg(strip_arg).arg(exe).arg(exe); let output = command.output().await?; if !output.status.success() { + if let Ok(stdout) = std::str::from_utf8(&output.stdout) { + tracing::error!("{}", stdout); + } + if let Ok(stderr) = std::str::from_utf8(&output.stderr) { + tracing::error!("{}", stderr); + } return Err(anyhow::anyhow!("Failed to strip binary")); } } diff --git a/packages/cli/src/workspace.rs b/packages/cli/src/workspace.rs index 31ec293d6..4a5fdf7dc 100644 --- a/packages/cli/src/workspace.rs +++ b/packages/cli/src/workspace.rs @@ -285,6 +285,11 @@ impl Workspace { .join("rust-objcopy") } + // ./rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib + pub fn rustc_objcopy_dylib_path(&self) -> PathBuf { + self.sysroot.join("lib") + } + /// Find the "main" package in the workspace. There might not be one! pub fn find_main_package(&self, package: Option) -> Result { if let Some(package) = package {