]> git.lizzy.rs Git - rust.git/commitdiff
auto merge of #14320 : kballard/rust/fix_stdlib_inject_attrs, r=alexcrichton
authorbors <bors@rust-lang.org>
Wed, 21 May 2014 16:46:27 +0000 (09:46 -0700)
committerbors <bors@rust-lang.org>
Wed, 21 May 2014 16:46:27 +0000 (09:46 -0700)
The #[phase(syntax,link)] attribute on `extern crate std` needs to be an
outer attribute so it can pretty-print properly.

Also add `#![no_std]` and `#[feature(phase)]` so compiling the
pretty-printed source will work.

1  2 
src/librustc/metadata/encoder.rs
src/librustc/middle/trans/base.rs

index 34baed3acc8e7e18c7223e7d80c323cb7815d67e,e3ded05e17b73a9cee48b5fa3a7e803f2aa850a0..2e478419e77a92508994de825fd580f8de5faede
@@@ -1436,7 -1436,7 +1436,7 @@@ fn synthesize_crate_attrs(ecx: &EncodeC
      fn synthesize_crateid_attr(ecx: &EncodeContext) -> Attribute {
          assert!(!ecx.link_meta.crateid.name.is_empty());
  
-         attr::mk_attr(
+         attr::mk_attr_inner(
              attr::mk_name_value_item_str(
                  InternedString::new("crate_id"),
                  token::intern_and_get_ident(ecx.link_meta.crateid.to_str())))
@@@ -1518,10 -1518,6 +1518,10 @@@ fn encode_lang_items(ecx: &EncodeContex
          }
      }
  
 +    for i in ecx.tcx.lang_items.missing.iter() {
 +        ebml_w.wr_tagged_u32(tag_lang_items_missing, *i as u32);
 +    }
 +
      ebml_w.end_tag();   // tag_lang_items
  }
  
index a88bc2432772bdcc1bfe3b845741dfc774efdc7a,0eabebc9226f90dfb9ffba48156239505e43ae75..fc5fcd98ef6f4d8c65b0544ee06e96c9e506fa8c
@@@ -38,7 -38,6 +38,7 @@@ use lib
  use metadata::{csearch, encoder};
  use middle::astencode;
  use middle::lang_items::{LangItem, ExchangeMallocFnLangItem, StartFnLangItem};
 +use middle::weak_lang_items;
  use middle::trans::_match;
  use middle::trans::adt;
  use middle::trans::build::*;
@@@ -232,7 -231,7 +232,7 @@@ fn get_extern_rust_fn(ccx: &CrateContex
  
      let f = decl_rust_fn(ccx, false, inputs, output, name);
      csearch::get_item_attrs(&ccx.sess().cstore, did, |meta_items| {
-         set_llvm_fn_attrs(meta_items.iter().map(|&x| attr::mk_attr(x))
+         set_llvm_fn_attrs(meta_items.iter().map(|&x| attr::mk_attr_outer(x))
                                      .collect::<Vec<_>>().as_slice(), f)
      });
  
@@@ -1680,19 -1679,6 +1680,19 @@@ fn finish_register_fn(ccx: &CrateContex
          lib::llvm::SetLinkage(llfn, lib::llvm::InternalLinkage);
      }
  
 +    // The stack exhaustion lang item shouldn't have a split stack because
 +    // otherwise it would continue to be exhausted (bad), and both it and the
 +    // eh_personality functions need to be externally linkable.
 +    let def = ast_util::local_def(node_id);
 +    if ccx.tcx.lang_items.stack_exhausted() == Some(def) {
 +        unset_split_stack(llfn);
 +        lib::llvm::SetLinkage(llfn, lib::llvm::ExternalLinkage);
 +    }
 +    if ccx.tcx.lang_items.eh_personality() == Some(def) {
 +        lib::llvm::SetLinkage(llfn, lib::llvm::ExternalLinkage);
 +    }
 +
 +
      if is_entry_fn(ccx.sess(), node_id) {
          create_entry_wrapper(ccx, sp, llfn);
      }
@@@ -1830,13 -1816,8 +1830,13 @@@ fn exported_name(ccx: &CrateContext, id
                  // Don't mangle
                  path.last().unwrap().to_str().to_strbuf()
              } else {
 -                // Usual name mangling
 -                mangle_exported_name(ccx, path, ty, id)
 +                match weak_lang_items::link_name(attrs) {
 +                    Some(name) => name.get().to_strbuf(),
 +                    None => {
 +                        // Usual name mangling
 +                        mangle_exported_name(ccx, path, ty, id)
 +                    }
 +                }
              }
          })
      }