mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-28 23:53:55 +00:00
Add just enough logic to the driver so that we can link std statically.
This commit is contained in:
parent
0864a22ace
commit
94f0e9d956
@ -436,6 +436,10 @@ fn main(vec[str] args) {
|
||||
metadata::creader::list_file_metadata(ifile, std::io::stdout());
|
||||
ret;
|
||||
}
|
||||
|
||||
auto stop_after_codegen = sopts.output_type != link::output_type_exe ||
|
||||
(sopts.static && sopts.library);
|
||||
|
||||
alt (output_file) {
|
||||
case (none) {
|
||||
let vec[str] parts = str::split(ifile, '.' as u8);
|
||||
@ -460,7 +464,7 @@ fn main(vec[str] args) {
|
||||
|
||||
saved_out_filename = ofile;
|
||||
auto temp_filename;
|
||||
if (sopts.output_type == link::output_type_exe && !sopts.static) {
|
||||
if (!stop_after_codegen) {
|
||||
temp_filename = ofile + ".o";
|
||||
} else {
|
||||
temp_filename = ofile;
|
||||
@ -473,7 +477,7 @@ fn main(vec[str] args) {
|
||||
// gcc to link the object file with some libs
|
||||
//
|
||||
// TODO: Factor this out of main.
|
||||
if (sopts.output_type != link::output_type_exe || sopts.static) {
|
||||
if (stop_after_codegen) {
|
||||
ret;
|
||||
}
|
||||
|
||||
@ -521,6 +525,10 @@ fn main(vec[str] args) {
|
||||
|
||||
auto cstore = sess.get_cstore();
|
||||
for (str cratepath in cstore::get_used_crate_files(cstore)) {
|
||||
if (str::ends_with(cratepath, ".rlib")) {
|
||||
gcc_args += [cratepath];
|
||||
cont;
|
||||
}
|
||||
auto dir = fs::dirname(cratepath);
|
||||
if (dir != "") {
|
||||
gcc_args += ["-L" + dir];
|
||||
|
@ -124,6 +124,9 @@ fn metadata_matches(&vec[u8] crate_data,
|
||||
|
||||
fn default_native_lib_naming(session::session sess) ->
|
||||
rec(str prefix, str suffix) {
|
||||
if (sess.get_opts().static) {
|
||||
ret rec(prefix="lib", suffix=".rlib");
|
||||
}
|
||||
alt (sess.get_targ_cfg().os) {
|
||||
case (session::os_win32) { ret rec(prefix="", suffix=".dll"); }
|
||||
case (session::os_macos) { ret rec(prefix="lib", suffix=".dylib"); }
|
||||
|
@ -9263,6 +9263,9 @@ fn create_module_map(&@crate_ctxt ccx) -> ValueRef {
|
||||
auto maptype = T_array(elttype, ccx.module_data.size() + 1u);
|
||||
auto map =
|
||||
llvm::LLVMAddGlobal(ccx.llmod, maptype, str::buf("_rust_mod_map"));
|
||||
llvm::LLVMSetLinkage(map,
|
||||
lib::llvm::LLVMInternalLinkage as
|
||||
llvm::Linkage);
|
||||
let ValueRef[] elts = ~[];
|
||||
for each (@tup(str, ValueRef) item in ccx.module_data.items()) {
|
||||
auto elt = C_struct(~[p2i(C_cstr(ccx, item._0)), p2i(item._1)]);
|
||||
|
Loading…
Reference in New Issue
Block a user