about summary refs log tree commit diff
path: root/src/comp
diff options
context:
space:
mode:
authorRafael Ávila de Espíndola <respindola@mozilla.com>2011-07-08 15:03:48 -0400
committerRafael Ávila de Espíndola <respindola@mozilla.com>2011-07-08 15:05:32 -0400
commit94f0e9d956ed3169848ee334df23ffa724001d80 (patch)
tree782602cb20b8ba7b42da6c132cbcb1db25422242 /src/comp
parent0864a22aceab14092cef9b8a99dedcfb16fe1548 (diff)
downloadrust-94f0e9d956ed3169848ee334df23ffa724001d80.tar.gz
rust-94f0e9d956ed3169848ee334df23ffa724001d80.zip
Add just enough logic to the driver so that we can link std statically.
Diffstat (limited to 'src/comp')
-rw-r--r--src/comp/driver/rustc.rs12
-rw-r--r--src/comp/metadata/creader.rs3
-rw-r--r--src/comp/middle/trans.rs3
3 files changed, 16 insertions, 2 deletions
diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs
index 697e6c509ca..823560b0082 100644
--- a/src/comp/driver/rustc.rs
+++ b/src/comp/driver/rustc.rs
@@ -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];
diff --git a/src/comp/metadata/creader.rs b/src/comp/metadata/creader.rs
index d9d48914c07..498b44fbfc3 100644
--- a/src/comp/metadata/creader.rs
+++ b/src/comp/metadata/creader.rs
@@ -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"); }
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 39921381886..bcdb31fb39d 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -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)]);