Skip to content

Commit cbaa24d

Browse files
committed
WIP
1 parent fa7734f commit cbaa24d

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

compiler/rustc_metadata/src/native_libs.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn walk_native_lib_search_dirs<R>(
3232
f(&search_path.dir, false)?;
3333
}
3434
for search_path in sess.target_filesearch(PathKind::Framework).cli_search_paths() {
35-
// Contrary to the `-L` docs only framework-specific paths are considered here.
35+
// Frameworks are looked up strictly in framework-specific paths.
3636
if search_path.kind != PathKind::All {
3737
f(&search_path.dir, true)?;
3838
}
@@ -45,7 +45,7 @@ pub fn walk_native_lib_search_dirs<R>(
4545
| LinkSelfContainedComponents::UNWIND
4646
| LinkSelfContainedComponents::MINGW,
4747
) {
48-
f(&sess.target_filesearch(PathKind::Native).get_self_contained_lib_path(), false)?;
48+
f(&sess.target_tlib_path.dir.join("self-contained"), false)?;
4949
}
5050

5151
// Toolchains for some targets may ship `libunwind.a`, but place it into the main sysroot
@@ -59,7 +59,7 @@ pub fn walk_native_lib_search_dirs<R>(
5959
|| sess.target.os == "fuchsia"
6060
|| sess.target.is_like_osx && !sess.opts.unstable_opts.sanitizer.is_empty()
6161
{
62-
f(&sess.target_filesearch(PathKind::Native).get_lib_path(), false)?;
62+
f(&sess.target_tlib_path.dir, false)?;
6363
}
6464

6565
// Mac Catalyst uses the macOS SDK, but to link to iOS-specific frameworks

src/doc/rustc/src/command-line-arguments.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ KIND=PATH` where `KIND` may be one of:
4747
directory.
4848
- `native` — Only search for native libraries in this directory.
4949
- `framework` — Only search for macOS frameworks in this directory.
50-
- `all` — Search for all library kinds in this directory. This is the default
50+
- `all` — Search for all library kinds in this directory, except frameworks. This is the default
5151
if `KIND` is not specified.
5252

5353
<a id="option-l-link-lib"></a>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#[no_mangle]
2+
pub extern "C" fn native_lib_alt_naming() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// On MSVC the alternative naming format for static libraries (`libfoo.a`) is accepted in addition
2+
// to the default format (`foo.lib`).
3+
4+
//REMOVE@ only-msvc
5+
6+
use run_make_support::rustc;
7+
8+
fn main() {
9+
// Prepare the native library.
10+
rustc().input("native.rs").crate_type("staticlib").output("libnative.a").run();
11+
12+
// Try to link to it from both a rlib and a bin.
13+
rustc().input("rust.rs").crate_type("rlib").arg("-lstatic=native").run();
14+
rustc().input("rust.rs").crate_type("bin").arg("-lstatic=native").run();
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pub fn main() {}

0 commit comments

Comments
 (0)