diff --git a/src/librustc/metadata/creader.rs b/src/librustc/metadata/creader.rs index a2203f0a3998a..d069c95c5ec9d 100644 --- a/src/librustc/metadata/creader.rs +++ b/src/librustc/metadata/creader.rs @@ -55,6 +55,7 @@ pub fn read_crates(diag: span_handler, visit_view_item: |a| visit_view_item(e, a), visit_item: |a| visit_item(e, a), .. *visit::default_simple_visitor()}); + visit_crate(e, crate); visit::visit_crate(crate, (), v); dump_crates(e.crate_cache); warn_if_multiple_versions(e, diag, e.crate_cache); @@ -125,6 +126,20 @@ struct Env { intr: @ident_interner } +fn visit_crate(e: @mut Env, c: ast::crate) { + let cstore = e.cstore; + let link_args = attr::find_attrs_by_name(c.node.attrs, "link_args"); + + for link_args.each |a| { + match attr::get_meta_item_value_str(attr::attr_meta(*a)) { + Some(ref linkarg) => { + cstore::add_used_link_args(cstore, (/*bad*/copy *linkarg)); + } + None => {/* fallthrough */ } + } + } +} + fn visit_view_item(e: @mut Env, i: @ast::view_item) { match /*bad*/copy i.node { ast::view_item_use(ident, meta_items, id) => { @@ -181,7 +196,7 @@ fn visit_item(e: @mut Env, i: @ast::item) { for link_args.each |a| { match attr::get_meta_item_value_str(attr::attr_meta(*a)) { Some(ref linkarg) => { - cstore::add_used_link_args(cstore, (/*bad*/copy *linkarg)); + cstore::add_used_link_args(cstore, *linkarg); } None => {/* fallthrough */ } } diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index 73ec872b6a6ec..84a588e48860c 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -119,7 +119,7 @@ pub fn get_used_libraries(cstore: @mut CStore) -> ~[~str] { return /*bad*/copy cstore.used_libraries; } -pub fn add_used_link_args(cstore: @mut CStore, args: ~str) { +pub fn add_used_link_args(cstore: @mut CStore, args: &str) { cstore.used_link_args.push_all(str::split_char(args, ' ')); }