Skip to content

Emit warning when search path not found in -L #143687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion compiler/rustc_session/src/search_paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,19 @@ impl SearchPath {
early_dcx.early_fatal("empty search path given via `-L`");
}

if !dir.exists() {
#[allow(rustc::untranslatable_diagnostic)] // FIXME: make this translatable
early_dcx.early_warn(format!("search path `{}` does not exist", dir.display()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we‘d better to explicitly inform users that this search path comes from the -L option.

}

Self::new(kind, dir)
}

pub fn from_sysroot_and_triple(sysroot: &Path, triple: &str) -> Self {
Self::new(PathKind::All, make_target_lib_path(sysroot, triple))
}

pub fn new(kind: PathKind, dir: PathBuf) -> Self {
fn new(kind: PathKind, dir: PathBuf) -> Self {
// Get the files within the directory.
let mut files = match std::fs::read_dir(&dir) {
Ok(files) => files
Expand Down
7 changes: 7 additions & 0 deletions tests/ui/link-native-libs/search-path-not-found.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//@ check-pass
//@ compile-flags: -L native=does-not-exist -Link-everything-statically

fn main() {}

//~? WARN search path `does-not-exist` does not exist
//~? WARN search path `ink-everything-statically` does not exist
4 changes: 4 additions & 0 deletions tests/ui/link-native-libs/search-path-not-found.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
warning: search path `does-not-exist` does not exist

warning: search path `ink-everything-statically` does not exist

Loading