Fix hotpatching when the bin target's crate name differs from the package name (#5719) (#5720)

(cherry picked from commit 4c51c12bc19d78983cb2992f319ebe996acb2893)

Signed-off-by: Nico Burns <nico@nicoburns.com>
This commit is contained in:
Nico Burns authored and GitHub committed 2026-07-29 16:55:16 -07:00
1 parent 3e43ffa6cf
commit fda083bb65
4 files changed
+18 -4

No files matched your search

+11 -1
View File
@@ -2581,6 +2581,16 @@ impl BuildRequest {
self.main_target.replace('-', "_")
}
/// The workspace package name of the tip crate (hyphens replaced with underscores).
///
/// This can differ from `tip_crate_name()` when the binary target is named differently
/// than its package (e.g. package `browser` with `[[bin]] name = "blitz"`). Use this for
/// workspace-graph lookups (which are keyed by package name) and `tip_crate_name()` for
/// rustc `--crate-name` keys like `{name}.bin`.
pub(crate) fn tip_package_name(&self) -> String {
self.package().name.replace('-', "_")
}
/// Stderr captured from the linker during the last build. Written by the linker
/// interception in `rustcwrapper` and read back to surface warnings/errors to the user.
fn link_err_file(&self) -> PathBuf {
@@ -3095,7 +3105,7 @@ impl BuildRequest {
})
.collect();
let tip = self.tip_crate_name();
let tip = self.tip_package_name();
let Some(tip_nid) = krates.workspace_members().find_map(|m| match m {
krates::Node::Krate { id, krate, .. } if krate.name.replace('-', "_") == tip => {
krates.nid_for_kid(id)