about summary refs log tree commit diff
path: root/compiler/rustc_codegen_ssa/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-06-05 18:40:07 +0000
committerbors <bors@rust-lang.org>2024-06-05 18:40:07 +0000
commit7ebd2bdbf6d798e6e711a0100981b0ff029abf5f (patch)
tree88186c3530c163795b396dd63e3293f3d7307456 /compiler/rustc_codegen_ssa/src
parentc1dba09f263cbff6170f130aa418e28bdf22bd96 (diff)
parentdd2e1a3b34f1ebc54f5f3507d7642b2e886d9662 (diff)
downloadrust-7ebd2bdbf6d798e6e711a0100981b0ff029abf5f.tar.gz
rust-7ebd2bdbf6d798e6e711a0100981b0ff029abf5f.zip
Auto merge of #126037 - matthiaskrgr:rollup-7pz1nhr, r=matthiaskrgr
Rollup of 10 pull requests

Successful merges:

 - #124746 (`rustc --explain E0582` additional example)
 - #125407 (Detect when user is trying to create a lending `Iterator` and give a custom explanation)
 - #125505 (Add intra-doc-links to rustc_middle crate-level docs.)
 - #125792 (Don't drop `Unsize` candidate in intercrate mode)
 - #125819 (Various `HirTyLowerer` cleanups)
 - #125861 (rustc_codegen_ssa: fix `get_rpath_relative_to_output` panic when lib only contains file name)
 - #125911 (delete bootstrap build before switching to bumped rustc)
 - #125921 (coverage: Carve out hole spans in a separate early pass)
 - #125940 (std::unix::fs::get_path: using fcntl codepath for netbsd instead.)
 - #126022 (set `has_unconstrained_ty_var` when generalizing aliases in bivariant contexts)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/rpath.rs5
-rw-r--r--compiler/rustc_codegen_ssa/src/back/rpath/tests.rs16
2 files changed, 21 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/rpath.rs b/compiler/rustc_codegen_ssa/src/back/rpath.rs
index 3114f1c38ae..f499bbcf853 100644
--- a/compiler/rustc_codegen_ssa/src/back/rpath.rs
+++ b/compiler/rustc_codegen_ssa/src/back/rpath.rs
@@ -85,6 +85,11 @@ fn get_rpath_relative_to_output(config: &RPathConfig<'_>, lib: &Path) -> OsStrin
     // Strip filenames
     let lib = lib.parent().unwrap();
     let output = config.out_filename.parent().unwrap();
+
+    // If output or lib is empty, just assume it locates in current path
+    let lib = if lib == Path::new("") { Path::new(".") } else { lib };
+    let output = if output == Path::new("") { Path::new(".") } else { output };
+
     let lib = try_canonicalize(lib).unwrap();
     let output = try_canonicalize(output).unwrap();
     let relative = path_relative_from(&lib, &output)
diff --git a/compiler/rustc_codegen_ssa/src/back/rpath/tests.rs b/compiler/rustc_codegen_ssa/src/back/rpath/tests.rs
index ac2e54072c4..0de90a1036e 100644
--- a/compiler/rustc_codegen_ssa/src/back/rpath/tests.rs
+++ b/compiler/rustc_codegen_ssa/src/back/rpath/tests.rs
@@ -58,6 +58,22 @@ fn test_rpath_relative() {
 }
 
 #[test]
+fn test_rpath_relative_issue_119571() {
+    let config = &mut RPathConfig {
+        libs: &[],
+        out_filename: PathBuf::from("rustc"),
+        has_rpath: true,
+        is_like_osx: false,
+        linker_is_gnu: true,
+    };
+    // Should not panic when out_filename only contains filename.
+    // Issue 119571
+    let _ = get_rpath_relative_to_output(config, Path::new("lib/libstd.so"));
+    // Should not panic when lib only contains filename.
+    let _ = get_rpath_relative_to_output(config, Path::new("libstd.so"));
+}
+
+#[test]
 fn test_xlinker() {
     let args = rpaths_to_flags(vec!["a/normal/path".into(), "a,comma,path".into()]);