Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Aug 27, 2024
1 parent fa7734f commit cbaa24d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
6 changes: 3 additions & 3 deletions compiler/rustc_metadata/src/native_libs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub fn walk_native_lib_search_dirs<R>(
f(&search_path.dir, false)?;
}
for search_path in sess.target_filesearch(PathKind::Framework).cli_search_paths() {
// Contrary to the `-L` docs only framework-specific paths are considered here.
// Frameworks are looked up strictly in framework-specific paths.
if search_path.kind != PathKind::All {
f(&search_path.dir, true)?;
}
Expand All @@ -45,7 +45,7 @@ pub fn walk_native_lib_search_dirs<R>(
| LinkSelfContainedComponents::UNWIND
| LinkSelfContainedComponents::MINGW,
) {
f(&sess.target_filesearch(PathKind::Native).get_self_contained_lib_path(), false)?;
f(&sess.target_tlib_path.dir.join("self-contained"), false)?;
}

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

// Mac Catalyst uses the macOS SDK, but to link to iOS-specific frameworks
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rustc/src/command-line-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ KIND=PATH` where `KIND` may be one of:
directory.
- `native` — Only search for native libraries in this directory.
- `framework` — Only search for macOS frameworks in this directory.
- `all` — Search for all library kinds in this directory. This is the default
- `all` — Search for all library kinds in this directory, except frameworks. This is the default
if `KIND` is not specified.

<a id="option-l-link-lib"></a>
Expand Down
2 changes: 2 additions & 0 deletions tests/run-make/native-lib-alt-naming/native.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#[no_mangle]
pub extern "C" fn native_lib_alt_naming() {}
15 changes: 15 additions & 0 deletions tests/run-make/native-lib-alt-naming/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// On MSVC the alternative naming format for static libraries (`libfoo.a`) is accepted in addition
// to the default format (`foo.lib`).

//REMOVE@ only-msvc

use run_make_support::rustc;

fn main() {
// Prepare the native library.
rustc().input("native.rs").crate_type("staticlib").output("libnative.a").run();

// Try to link to it from both a rlib and a bin.
rustc().input("rust.rs").crate_type("rlib").arg("-lstatic=native").run();
rustc().input("rust.rs").crate_type("bin").arg("-lstatic=native").run();
}
1 change: 1 addition & 0 deletions tests/run-make/native-lib-alt-naming/rust.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub fn main() {}

0 comments on commit cbaa24d

Please sign in to comment.