@@ -561,6 +561,13 @@ fn link_binary(sess: session::session,
561
561
obj_filename : str ,
562
562
out_filename : str ,
563
563
lm : link_meta ) {
564
+ let output = if sess. building_library ( ) {
565
+ let long_libname =
566
+ std:: os:: dylib_filename ( #fmt ( "%s-%s-%s" ,
567
+ lm. name , lm. extras_hash , lm. vers ) ) ;
568
+ fs:: connect ( fs:: dirname ( out_filename) , long_libname)
569
+ } else { out_filename } ;
570
+
564
571
// The default library location, we need this to find the runtime.
565
572
// The location of crates will be determined as needed.
566
573
let stage: str = "-L" + sess. filesearch ( ) . get_target_lib_path ( ) ;
@@ -570,9 +577,9 @@ fn link_binary(sess: session::session,
570
577
571
578
let gcc_args =
572
579
[ stage] + sess. get_targ_cfg ( ) . target_strs . gcc_args +
573
- [ "-o" , out_filename, obj_filename] ;
574
- let lib_cmd;
580
+ [ "-o" , output, obj_filename] ;
575
581
582
+ let lib_cmd;
576
583
let os = sess. get_targ_cfg ( ) . os ;
577
584
if os == session:: os_macos {
578
585
lib_cmd = "-dynamiclib" ;
@@ -620,24 +627,20 @@ fn link_binary(sess: session::session,
620
627
let used_libs = cstore:: get_used_libraries ( cstore) ;
621
628
for l: str in used_libs { gcc_args += [ "-l" + l] ; }
622
629
623
- let long_libname =
624
- std:: os:: dylib_filename ( #fmt ( "%s-%s-%s" ,
625
- lm. name , lm. extras_hash , lm. vers ) ) ;
626
-
627
630
if sess. building_library ( ) {
628
631
gcc_args += [ lib_cmd] ;
629
632
630
633
// On mac we need to tell the linker to let this library
631
634
// be rpathed
632
635
if sess. get_targ_cfg ( ) . os == session:: os_macos {
633
- gcc_args += [ "-Wl,-install_name,@rpath/" + long_libname] ;
636
+ gcc_args += [ "-Wl,-install_name,@rpath/"
637
+ + fs:: basename ( output) ] ;
634
638
}
635
639
} else {
636
640
// FIXME: why do we hardcode -lm?
637
641
gcc_args += [ "-lm" ] ;
638
642
}
639
643
640
-
641
644
// Always want the runtime linked in
642
645
gcc_args += [ "-lrustrt" ] ;
643
646
@@ -666,18 +669,13 @@ fn link_binary(sess: session::session,
666
669
667
670
// Clean up on Darwin
668
671
if sess. get_targ_cfg ( ) . os == session:: os_macos {
669
- run:: run_program ( "dsymutil" , [ out_filename ] ) ;
672
+ run:: run_program ( "dsymutil" , [ output ] ) ;
670
673
}
671
674
672
675
// Remove the temporary object file if we aren't saving temps
673
676
if !sess. get_opts ( ) . save_temps {
674
677
run:: run_program ( "rm" , [ obj_filename] ) ;
675
678
}
676
-
677
- if sess. building_library ( ) {
678
- let fullname = fs:: connect ( fs:: dirname ( out_filename) , long_libname) ;
679
- run:: run_program ( "mv" , [ out_filename, fullname] ) ;
680
- }
681
679
}
682
680
//
683
681
// Local Variables:
0 commit comments