File tree 2 files changed +17
-4
lines changed
compiler/rustc_codegen_ssa/src/back
tests/run-make/native-link-modifier-verbatim-linker
2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -585,7 +585,23 @@ impl<'a> Linker for GccLinker<'a> {
585
585
self . hint_static ( ) ;
586
586
let colon = if verbatim && self . is_gnu { ":" } else { "" } ;
587
587
if !whole_archive {
588
- self . link_or_cc_arg ( format ! ( "-l{colon}{name}" ) ) ;
588
+ if self . sess . target . is_like_osx && verbatim {
589
+ // The man page for ld64's `-l` option says:
590
+ // > This option tells the linker to search for libx.dylib or libx.a in the library
591
+ // > search path. If string x is of the form y.o, then that file is searched for in
592
+ // > the same places, but without prepending `lib' or appending `.a' or `.dylib' to
593
+ // > the filename.
594
+ //
595
+ // So if we're linking a verbatim file, then we need to do the lookup and pass it
596
+ // directly as a normal file parameter on the command line.
597
+ //
598
+ // NOTE: We _could_ add `&& name.ends_with(".o")`, but having more guaranteed
599
+ // consistent behaviour in `rustc` regardless of the file extension seems like the
600
+ // better solution.
601
+ self . link_or_cc_arg ( find_native_static_library ( name, verbatim, self . sess ) ) ;
602
+ } else {
603
+ self . link_or_cc_arg ( format ! ( "-l{colon}{name}" ) ) ;
604
+ }
589
605
} else if self . sess . target . is_like_osx {
590
606
// -force_load is the macOS equivalent of --whole-archive, but it
591
607
// involves passing the full path to the library to link.
Original file line number Diff line number Diff line change 3
3
// This test is the same as native-link-modifier-rustc, but without rlibs.
4
4
// See https://github.com/rust-lang/rust/issues/99425
5
5
6
- //@ ignore-apple
7
- // Reason: linking fails due to the unusual ".ext" staticlib name.
8
-
9
6
use run_make_support:: rustc;
10
7
11
8
fn main ( ) {
You can’t perform that action at this time.
0 commit comments