Skip to content

Commit df6345a

Browse files
committed
generate output dll name based on target os
1 parent 0a7b730 commit df6345a

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

src/librustc/back/link.rs

+19-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use lib::llvm::{ModuleRef, mk_pass_manager, mk_target_data, True, False,
2626
use metadata::filesearch;
2727
use syntax::ast_map::{path, path_mod, path_name};
2828
use io::{Writer, WriterUtil};
29+
use os::consts::{macos, freebsd, linux, win32};
2930

3031
enum output_type {
3132
output_type_none,
@@ -631,6 +632,21 @@ fn mangle_internal_name_by_seq(ccx: @crate_ctxt, flav: ~str) -> ~str {
631632
return fmt!("%s_%u", flav, (ccx.names)(flav).repr);
632633
}
633634

635+
636+
fn output_dll_filename(os: session::os, lm: &link_meta) -> ~str {
637+
let libname = fmt!("%s-%s-%s", lm.name, lm.extras_hash, lm.vers);
638+
match os {
639+
session::os_macos =>
640+
macos::dll_prefix() + libname + macos::dll_suffix(),
641+
session::os_freebsd =>
642+
freebsd::dll_prefix() + libname + macos::dll_suffix(),
643+
session::os_linux =>
644+
freebsd::dll_prefix() + libname + macos::dll_suffix(),
645+
session::os_win32 =>
646+
win32::dll_prefix() + libname + win32::dll_suffix(),
647+
}
648+
}
649+
634650
// If the user wants an exe generated we need to invoke
635651
// cc to link the object file with some libs
636652
fn link_binary(sess: Session,
@@ -648,10 +664,9 @@ fn link_binary(sess: Session,
648664
}
649665

650666
let output = if sess.building_library {
651-
let long_libname =
652-
os::dll_filename(fmt!("%s-%s-%s",
653-
lm.name, lm.extras_hash, lm.vers));
654-
debug!("link_meta.name: %s", lm.name);
667+
let long_libname = output_dll_filename(sess.targ_cfg.os, &lm);
668+
669+
debug!("link_meta.name: %s", lm.name);
655670
debug!("long_libname: %s", long_libname);
656671
debug!("out_filename: %s", out_filename.to_str());
657672
debug!("dirname(out_filename): %s", out_filename.dir_path().to_str());

0 commit comments

Comments
 (0)