Skip to content

Commit 06e5dad

Browse files
committed
Produce proper suffix to shared libraries
Issue rust-lang#744
1 parent 17c651b commit 06e5dad

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/comp/back/link.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -510,9 +510,7 @@ fn link_binary(sess: session::session,
510510
let prog: str = "gcc";
511511
// The invocations of gcc share some flags across platforms
512512

513-
let gcc_args =
514-
[stage, "-m32", "-o", saved_out_filename,
515-
saved_out_filename + ".o"];
513+
let gcc_args = [stage, "-m32", saved_out_filename + ".o"];
516514
let lib_cmd;
517515

518516
let os = sess.get_targ_cfg().os;
@@ -565,13 +563,24 @@ fn link_binary(sess: session::session,
565563
if sess.get_opts().library {
566564
gcc_args += [lib_cmd];
567565

566+
let library_name = saved_out_filename +
567+
alt sess.get_targ_cfg().os {
568+
session::os_macos. { ".dylib" }
569+
session::os_win32. { ".dll" }
570+
_ { ".so" }
571+
};
572+
573+
gcc_args += ["-o", library_name];
574+
568575
// On mac we need to tell the linker to let this library
569576
// be rpathed
570577
if sess.get_targ_cfg().os == session::os_macos {
571578
gcc_args += ["-Wl,-install_name,@rpath/"
572579
+ fs::basename(saved_out_filename)];
573580
}
574581
} else {
582+
gcc_args += ["-o", saved_out_filename];
583+
575584
// FIXME: why do we hardcode -lm?
576585
gcc_args += ["-lm"];
577586
}

0 commit comments

Comments
 (0)