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 <nico@nicoburns.com>

* Print stdout and stderr if strip fails

Signed-off-by: Nico Burns <nico@nicoburns.com>

---------

Signed-off-by: Nico Burns <nico@nicoburns.com>
This commit is contained in:
Nico Burns authored and GitHub committed 2025-12-11 02:36:56 +00:00
1 parent 05b2dd400c
commit 552b553a44
2 files changed
+13

No files matched your search

+8
View File
@@ -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"));
}
}
+5
View File
@@ -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<String>) -> Result<NodeId> {
if let Some(package) = package {