Rollup merge of #138273 - petrochenkov:nonatroot, r=bjorn3
metadata: Ignore sysroot when doing the manual native lib search in rustc This is the opposite alternative to https://github.com/rust-lang/rust/pull/138170 and another way to make native library search consistent between rustc and linker. This way the directory list searched by rustc is still a prefix of the directory list considered by linker, but it's a shorter prefix than in #138170. We can include the sysroot directories into rustc's search again later if the issues with #138170 are resolved, it will be a backward compatible change. This may break some code doing weird things on unstable rustc, or tier 2-3 targets, like bundling `libunwind.a` or sanitizers into something. Note that this doesn't affect shipped `libc.a`, because it lives in `self-contained` directories in sysroot, and `self-contained` sysroot is already not included into the rustc's search. All libunwind and sanitizer libs should be moved to `self-contained` sysroot too eventually. With the consistent search directory list between rustc and linker we can make rustc own the native library search (at least for static libs) and use linker search only as a fallback (like in #123436). This will allow addressing issues like https://github.com/rust-lang/rust/pull/132394 once and for all on all targets. r? ``@bjorn3``
This commit is contained in:
commit
5ae93cf5b4
3 changed files with 46 additions and 47 deletions
|
@ -22,7 +22,9 @@ use rustc_fs_util::{fix_windows_verbatim_for_gcc, try_canonicalize};
|
|||
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
||||
use rustc_macros::LintDiagnostic;
|
||||
use rustc_metadata::fs::{METADATA_FILENAME, copy_to_stdout, emit_wrapper_file};
|
||||
use rustc_metadata::{find_native_static_library, walk_native_lib_search_dirs};
|
||||
use rustc_metadata::{
|
||||
NativeLibSearchFallback, find_native_static_library, walk_native_lib_search_dirs,
|
||||
};
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::lint::lint_level;
|
||||
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerFile;
|
||||
|
@ -2129,19 +2131,15 @@ fn add_library_search_dirs(
|
|||
return;
|
||||
}
|
||||
|
||||
walk_native_lib_search_dirs(
|
||||
sess,
|
||||
self_contained_components,
|
||||
apple_sdk_root,
|
||||
|dir, is_framework| {
|
||||
if is_framework {
|
||||
cmd.framework_path(dir);
|
||||
} else {
|
||||
cmd.include_path(&fix_windows_verbatim_for_gcc(dir));
|
||||
}
|
||||
ControlFlow::<()>::Continue(())
|
||||
},
|
||||
);
|
||||
let fallback = Some(NativeLibSearchFallback { self_contained_components, apple_sdk_root });
|
||||
walk_native_lib_search_dirs(sess, fallback, |dir, is_framework| {
|
||||
if is_framework {
|
||||
cmd.framework_path(dir);
|
||||
} else {
|
||||
cmd.include_path(&fix_windows_verbatim_for_gcc(dir));
|
||||
}
|
||||
ControlFlow::<()>::Continue(())
|
||||
});
|
||||
}
|
||||
|
||||
/// Add options making relocation sections in the produced ELF files read-only
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue