summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_codegen_ssa/src/back/rpath.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /compiler/rustc_codegen_ssa/src/back/rpath.rs
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/back/rpath.rs')
-rw-r--r--compiler/rustc_codegen_ssa/src/back/rpath.rs14
1 files changed, 6 insertions, 8 deletions
diff --git a/compiler/rustc_codegen_ssa/src/back/rpath.rs b/compiler/rustc_codegen_ssa/src/back/rpath.rs
index ebf04e7a3..603462286 100644
--- a/compiler/rustc_codegen_ssa/src/back/rpath.rs
+++ b/compiler/rustc_codegen_ssa/src/back/rpath.rs
@@ -1,8 +1,7 @@
use pathdiff::diff_paths;
use rustc_data_structures::fx::FxHashSet;
-use std::env;
+use rustc_fs_util::try_canonicalize;
use std::ffi::OsString;
-use std::fs;
use std::path::{Path, PathBuf};
pub struct RPathConfig<'a> {
@@ -82,12 +81,11 @@ fn get_rpath_relative_to_output(config: &mut RPathConfig<'_>, lib: &Path) -> OsS
// Mac doesn't appear to support $ORIGIN
let prefix = if config.is_like_osx { "@loader_path" } else { "$ORIGIN" };
- let cwd = env::current_dir().unwrap();
- let mut lib = fs::canonicalize(&cwd.join(lib)).unwrap_or_else(|_| cwd.join(lib));
- lib.pop(); // strip filename
- let mut output = cwd.join(&config.out_filename);
- output.pop(); // strip filename
- let output = fs::canonicalize(&output).unwrap_or(output);
+ // Strip filenames
+ let lib = lib.parent().unwrap();
+ let output = config.out_filename.parent().unwrap();
+ let lib = try_canonicalize(lib).unwrap();
+ let output = try_canonicalize(output).unwrap();
let relative = path_relative_from(&lib, &output)
.unwrap_or_else(|| panic!("couldn't create relative path from {output:?} to {lib:?}"));