Skip to content

Commit 2b9c774

Browse files
committed
Stop propagating link arguments across crates
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.
1 parent c15038d commit 2b9c774

File tree

4 files changed

+1
-47
lines changed

4 files changed

+1
-47
lines changed

src/librustc/back/link.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use lib::llvm::llvm;
1616
use lib::llvm::ModuleRef;
1717
use lib;
1818
use metadata::common::LinkMeta;
19-
use metadata::{encoder, csearch, cstore, filesearch};
19+
use metadata::{encoder, cstore, filesearch};
2020
use middle::trans::context::CrateContext;
2121
use middle::trans::common::gensym_name;
2222
use middle::ty;
@@ -1043,14 +1043,6 @@ pub fn link_args(sess: Session,
10431043
let ula = cstore::get_used_link_args(cstore);
10441044
for arg in ula.iter() { args.push(arg.to_owned()); }
10451045

1046-
// Add all the link args for external crates.
1047-
do cstore::iter_crate_data(cstore) |crate_num, _| {
1048-
let link_args = csearch::get_link_args_for_crate(cstore, crate_num);
1049-
for link_arg in link_args.move_iter() {
1050-
args.push(link_arg);
1051-
}
1052-
}
1053-
10541046
// # Extern library linking
10551047

10561048
// User-supplied library search paths (-L on the cammand line) These are

src/librustc/metadata/csearch.rs

-7
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,6 @@ pub fn get_item_visibility(cstore: @mut cstore::CStore,
261261
decoder::get_item_visibility(cdata, def_id.node)
262262
}
263263

264-
pub fn get_link_args_for_crate(cstore: @mut cstore::CStore,
265-
crate_num: ast::CrateNum)
266-
-> ~[~str] {
267-
let cdata = cstore::get_crate_data(cstore, crate_num);
268-
decoder::get_link_args_for_crate(cdata)
269-
}
270-
271264
pub fn each_impl(cstore: @mut cstore::CStore,
272265
crate_num: ast::CrateNum,
273266
callback: &fn(ast::DefId)) {

src/librustc/metadata/decoder.rs

-10
Original file line numberDiff line numberDiff line change
@@ -1456,16 +1456,6 @@ pub fn translate_def_id(cdata: Cmd, did: ast::DefId) -> ast::DefId {
14561456
}
14571457
}
14581458

1459-
pub fn get_link_args_for_crate(cdata: Cmd) -> ~[~str] {
1460-
let link_args = reader::get_doc(reader::Doc(cdata.data), tag_link_args);
1461-
let mut result = ~[];
1462-
do reader::tagged_docs(link_args, tag_link_args_arg) |arg_doc| {
1463-
result.push(arg_doc.as_str());
1464-
true
1465-
};
1466-
result
1467-
}
1468-
14691459
pub fn each_impl(cdata: Cmd, callback: &fn(ast::DefId)) {
14701460
let impls_doc = reader::get_doc(reader::Doc(cdata.data), tag_impls);
14711461
let _ = do reader::tagged_docs(impls_doc, tag_impls_impl) |impl_doc| {

src/librustc/metadata/encoder.rs

-21
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ struct Stats {
7575
attr_bytes: u64,
7676
dep_bytes: u64,
7777
lang_item_bytes: u64,
78-
link_args_bytes: u64,
7978
impl_bytes: u64,
8079
misc_bytes: u64,
8180
item_bytes: u64,
@@ -1610,19 +1609,6 @@ fn encode_lang_items(ecx: &EncodeContext, ebml_w: &mut writer::Encoder) {
16101609
ebml_w.end_tag(); // tag_lang_items
16111610
}
16121611

1613-
fn encode_link_args(ecx: &EncodeContext, ebml_w: &mut writer::Encoder) {
1614-
ebml_w.start_tag(tag_link_args);
1615-
1616-
let link_args = cstore::get_used_link_args(ecx.cstore);
1617-
for link_arg in link_args.iter() {
1618-
ebml_w.start_tag(tag_link_args_arg);
1619-
ebml_w.writer.write(link_arg.as_bytes());
1620-
ebml_w.end_tag();
1621-
}
1622-
1623-
ebml_w.end_tag();
1624-
}
1625-
16261612
struct ImplVisitor<'self> {
16271613
ecx: &'self EncodeContext<'self>,
16281614
ebml_w: &'self mut writer::Encoder,
@@ -1740,7 +1726,6 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
17401726
attr_bytes: 0,
17411727
dep_bytes: 0,
17421728
lang_item_bytes: 0,
1743-
link_args_bytes: 0,
17441729
impl_bytes: 0,
17451730
misc_bytes: 0,
17461731
item_bytes: 0,
@@ -1797,11 +1782,6 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
17971782
encode_lang_items(&ecx, &mut ebml_w);
17981783
ecx.stats.lang_item_bytes = wr.tell() - i;
17991784

1800-
// Encode the link args.
1801-
i = wr.tell();
1802-
encode_link_args(&ecx, &mut ebml_w);
1803-
ecx.stats.link_args_bytes = wr.tell() - i;
1804-
18051785
// Encode the def IDs of impls, for coherence checking.
18061786
i = wr.tell();
18071787
encode_impls(&ecx, crate, &mut ebml_w);
@@ -1838,7 +1818,6 @@ pub fn encode_metadata(parms: EncodeParams, crate: &Crate) -> ~[u8] {
18381818
println!(" attribute bytes: {}", ecx.stats.attr_bytes);
18391819
println!(" dep bytes: {}", ecx.stats.dep_bytes);
18401820
println!(" lang item bytes: {}", ecx.stats.lang_item_bytes);
1841-
println!(" link args bytes: {}", ecx.stats.link_args_bytes);
18421821
println!(" impl bytes: {}", ecx.stats.impl_bytes);
18431822
println!(" misc bytes: {}", ecx.stats.misc_bytes);
18441823
println!(" item bytes: {}", ecx.stats.item_bytes);

0 commit comments

Comments
 (0)