]> git.lizzy.rs Git - rust.git/commitdiff
Stop propagating link arguments across crates
authorAlex Crichton <alex@alexcrichton.com>
Thu, 31 Oct 2013 05:54:27 +0000 (22:54 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Sat, 2 Nov 2013 04:28:47 +0000 (21:28 -0700)
This is a fairly brittle modle that doesn't scale well across many crates. It's
unlikely that all of the downstream crates will have all of the original native
dependencies of all the upstream crates. In the case that FFI functions are
reachable, then it should be the responsibility of the downstream crate to link
against the correct library, or the upstream crate should prevent the functions
from being reachable.

src/librustc/back/link.rs
src/librustc/metadata/csearch.rs
src/librustc/metadata/decoder.rs
src/librustc/metadata/encoder.rs

index 1b9cb10f1dcfdcb1dcd0715cdce16ac5220bf505..815ec943c49621725a3d1422e79affd9823825d8 100644 (file)
@@ -16,7 +16,7 @@
 use lib::llvm::ModuleRef;
 use lib;
 use metadata::common::LinkMeta;
-use metadata::{encoder, csearch, cstore, filesearch};
+use metadata::{encoder, cstore, filesearch};
 use middle::trans::context::CrateContext;
 use middle::trans::common::gensym_name;
 use middle::ty;
@@ -1043,14 +1043,6 @@ fn unlib(config: @session::config, stem: ~str) -> ~str {
     let ula = cstore::get_used_link_args(cstore);
     for arg in ula.iter() { args.push(arg.to_owned()); }
 
-    // Add all the link args for external crates.
-    do cstore::iter_crate_data(cstore) |crate_num, _| {
-        let link_args = csearch::get_link_args_for_crate(cstore, crate_num);
-        for link_arg in link_args.move_iter() {
-            args.push(link_arg);
-        }
-    }
-
     // # Extern library linking
 
     // User-supplied library search paths (-L on the cammand line) These are
index 617051c217f506bc3dec9c7f5d8c9e443d5543c3..48fe21b334395312915dd373a48ab6b5530126a1 100644 (file)
@@ -261,13 +261,6 @@ pub fn get_item_visibility(cstore: @mut cstore::CStore,
     decoder::get_item_visibility(cdata, def_id.node)
 }
 
-pub fn get_link_args_for_crate(cstore: @mut cstore::CStore,
-                               crate_num: ast::CrateNum)
-                            -> ~[~str] {
-    let cdata = cstore::get_crate_data(cstore, crate_num);
-    decoder::get_link_args_for_crate(cdata)
-}
-
 pub fn each_impl(cstore: @mut cstore::CStore,
                  crate_num: ast::CrateNum,
                  callback: &fn(ast::DefId)) {
index aca41f5f4cbb9364ebc13c4def1041f57b11b875..56abaa27cce2c10fb4fa93f4f6a42eaa781666f5 100644 (file)
@@ -1456,16 +1456,6 @@ pub fn translate_def_id(cdata: Cmd, did: ast::DefId) -> ast::DefId {
     }
 }
 
-pub fn get_link_args_for_crate(cdata: Cmd) -> ~[~str] {
-    let link_args = reader::get_doc(reader::Doc(cdata.data), tag_link_args);
-    let mut result = ~[];
-    do reader::tagged_docs(link_args, tag_link_args_arg) |arg_doc| {
-        result.push(arg_doc.as_str());
-        true
-    };
-    result
-}
-
 pub fn each_impl(cdata: Cmd, callback: &fn(ast::DefId)) {
     let impls_doc = reader::get_doc(reader::Doc(cdata.data), tag_impls);
     let _ = do reader::tagged_docs(impls_doc, tag_impls_impl) |impl_doc| {
index 86c4ca0158f19c8d25a8f888acced425a8a698c8..1ad7e416342f5bd5eac81c960141d2d1d6ecc308 100644 (file)
@@ -75,7 +75,6 @@ struct Stats {
     attr_bytes: u64,
     dep_bytes: u64,
     lang_item_bytes: u64,
-    link_args_bytes: u64,
     impl_bytes: u64,
     misc_bytes: u64,
     item_bytes: u64,
@@ -1610,19 +1609,6 @@ fn encode_lang_items(ecx: &EncodeContext, ebml_w: &mut writer::Encoder) {
     ebml_w.end_tag();   // tag_lang_items
 }
 
-fn encode_link_args(ecx: &EncodeContext, ebml_w: &mut writer::Encoder) {
-    ebml_w.start_tag(tag_link_args);
-
-    let link_args = cstore::get_used_link_args(ecx.cstore);
-    for link_arg in link_args.iter() {
-        ebml_w.start_tag(tag_link_args_arg);
-        ebml_w.writer.write(link_arg.as_bytes());
-        ebml_w.end_tag();
-    }
-
-    ebml_w.end_tag();
-}
-
 struct ImplVisitor<'self> {
     ecx: &'self EncodeContext<'self>,
     ebml_w: &'self mut writer::Encoder,
@@ -1740,7 +1726,6 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
         attr_bytes: 0,
         dep_bytes: 0,
         lang_item_bytes: 0,
-        link_args_bytes: 0,
         impl_bytes: 0,
         misc_bytes: 0,
         item_bytes: 0,
@@ -1797,11 +1782,6 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
     encode_lang_items(&ecx, &mut ebml_w);
     ecx.stats.lang_item_bytes = wr.tell() - i;
 
-    // Encode the link args.
-    i = wr.tell();
-    encode_link_args(&ecx, &mut ebml_w);
-    ecx.stats.link_args_bytes = wr.tell() - i;
-
     // Encode the def IDs of impls, for coherence checking.
     i = wr.tell();
     encode_impls(&ecx, crate, &mut ebml_w);
@@ -1838,7 +1818,6 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
         println!(" attribute bytes: {}", ecx.stats.attr_bytes);
         println!("       dep bytes: {}", ecx.stats.dep_bytes);
         println!(" lang item bytes: {}", ecx.stats.lang_item_bytes);
-        println!(" link args bytes: {}", ecx.stats.link_args_bytes);
         println!("      impl bytes: {}", ecx.stats.impl_bytes);
         println!("      misc bytes: {}", ecx.stats.misc_bytes);
         println!("      item bytes: {}", ecx.stats.item_bytes);