librustc: De-@mut
building_library
in the session
This commit is contained in:
parent
c56bac7f40
commit
d7b152701e
8 changed files with 18 additions and 17 deletions
|
@ -166,7 +166,7 @@ pub fn phase_2_configure_and_expand(sess: Session,
|
||||||
mut crate: ast::Crate) -> ast::Crate {
|
mut crate: ast::Crate) -> ast::Crate {
|
||||||
let time_passes = sess.time_passes();
|
let time_passes = sess.time_passes();
|
||||||
|
|
||||||
*sess.building_library = session::building_library(sess.opts, &crate);
|
sess.building_library.set(session::building_library(sess.opts, &crate));
|
||||||
*sess.outputs = session::collect_outputs(sess.opts, crate.attrs);
|
*sess.outputs = session::collect_outputs(sess.opts, crate.attrs);
|
||||||
|
|
||||||
time(time_passes, "gated feature checking", (), |_|
|
time(time_passes, "gated feature checking", (), |_|
|
||||||
|
@ -878,7 +878,7 @@ pub fn build_session_(sopts: @session::options,
|
||||||
entry_type: Cell::new(None),
|
entry_type: Cell::new(None),
|
||||||
span_diagnostic: span_diagnostic_handler,
|
span_diagnostic: span_diagnostic_handler,
|
||||||
filesearch: filesearch,
|
filesearch: filesearch,
|
||||||
building_library: @mut false,
|
building_library: Cell::new(false),
|
||||||
working_dir: os::getcwd(),
|
working_dir: os::getcwd(),
|
||||||
lints: RefCell::new(HashMap::new()),
|
lints: RefCell::new(HashMap::new()),
|
||||||
node_id: Cell::new(1),
|
node_id: Cell::new(1),
|
||||||
|
@ -1039,7 +1039,7 @@ pub fn build_output_filenames(input: &input,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if *sess.building_library {
|
if sess.building_library.get() {
|
||||||
out_path = dirpath.join(os::dll_filename(stem));
|
out_path = dirpath.join(os::dll_filename(stem));
|
||||||
obj_path = {
|
obj_path = {
|
||||||
let mut p = dirpath.join(stem);
|
let mut p = dirpath.join(stem);
|
||||||
|
@ -1060,7 +1060,7 @@ pub fn build_output_filenames(input: &input,
|
||||||
out_file.with_extension(obj_suffix)
|
out_file.with_extension(obj_suffix)
|
||||||
};
|
};
|
||||||
|
|
||||||
if *sess.building_library {
|
if sess.building_library.get() {
|
||||||
sess.warn("ignoring specified output filename for library.");
|
sess.warn("ignoring specified output filename for library.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,7 @@ pub struct Session_ {
|
||||||
entry_type: Cell<Option<EntryFnType>>,
|
entry_type: Cell<Option<EntryFnType>>,
|
||||||
span_diagnostic: @mut diagnostic::span_handler,
|
span_diagnostic: @mut diagnostic::span_handler,
|
||||||
filesearch: @filesearch::FileSearch,
|
filesearch: @filesearch::FileSearch,
|
||||||
building_library: @mut bool,
|
building_library: Cell<bool>,
|
||||||
working_dir: Path,
|
working_dir: Path,
|
||||||
lints: RefCell<HashMap<ast::NodeId,
|
lints: RefCell<HashMap<ast::NodeId,
|
||||||
~[(lint::lint, codemap::Span, ~str)]>>,
|
~[(lint::lint, codemap::Span, ~str)]>>,
|
||||||
|
|
|
@ -69,7 +69,7 @@ impl fold::ast_fold for StandardLibraryInjector {
|
||||||
span: dummy_sp()
|
span: dummy_sp()
|
||||||
}];
|
}];
|
||||||
|
|
||||||
if use_uv(&crate) && !*self.sess.building_library {
|
if use_uv(&crate) && !self.sess.building_library.get() {
|
||||||
vis.push(ast::view_item {
|
vis.push(ast::view_item {
|
||||||
node: ast::view_item_extern_mod(self.sess.ident_of("green"),
|
node: ast::view_item_extern_mod(self.sess.ident_of("green"),
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -127,7 +127,7 @@ impl fold::ast_fold for TestHarnessGenerator {
|
||||||
// the one we're going to add. Only if compiling an executable.
|
// the one we're going to add. Only if compiling an executable.
|
||||||
|
|
||||||
fn nomain(cx: @TestCtxt, item: @ast::item) -> @ast::item {
|
fn nomain(cx: @TestCtxt, item: @ast::item) -> @ast::item {
|
||||||
if !*cx.sess.building_library {
|
if !cx.sess.building_library.get() {
|
||||||
@ast::item {
|
@ast::item {
|
||||||
attrs: item.attrs.iter().filter_map(|attr| {
|
attrs: item.attrs.iter().filter_map(|attr| {
|
||||||
if "main" != attr.name() {
|
if "main" != attr.name() {
|
||||||
|
|
|
@ -45,7 +45,7 @@ impl Visitor<()> for EntryContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn find_entry_point(session: Session, crate: &Crate, ast_map: ast_map::map) {
|
pub fn find_entry_point(session: Session, crate: &Crate, ast_map: ast_map::map) {
|
||||||
if *session.building_library {
|
if session.building_library.get() {
|
||||||
// No need to find a main function
|
// No need to find a main function
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ fn configure_main(this: &mut EntryContext) {
|
||||||
this.session.entry_fn.set(this.main_fn);
|
this.session.entry_fn.set(this.main_fn);
|
||||||
this.session.entry_type.set(Some(session::EntryMain));
|
this.session.entry_type.set(Some(session::EntryMain));
|
||||||
} else {
|
} else {
|
||||||
if !*this.session.building_library {
|
if !this.session.building_library.get() {
|
||||||
// No main function
|
// No main function
|
||||||
this.session.err("main function not found");
|
this.session.err("main function not found");
|
||||||
if !this.non_main_fns.is_empty() {
|
if !this.non_main_fns.is_empty() {
|
||||||
|
|
|
@ -303,7 +303,7 @@ impl ReachableContext {
|
||||||
fn propagate_node(&self, node: &ast_map::ast_node,
|
fn propagate_node(&self, node: &ast_map::ast_node,
|
||||||
search_item: ast::NodeId,
|
search_item: ast::NodeId,
|
||||||
visitor: &mut MarkSymbolVisitor) {
|
visitor: &mut MarkSymbolVisitor) {
|
||||||
if !*self.tcx.sess.building_library {
|
if !self.tcx.sess.building_library.get() {
|
||||||
// If we are building an executable, then there's no need to flag
|
// If we are building an executable, then there's no need to flag
|
||||||
// anything as external except for `extern fn` types. These
|
// anything as external except for `extern fn` types. These
|
||||||
// functions may still participate in some form of native interface,
|
// functions may still participate in some form of native interface,
|
||||||
|
|
|
@ -2344,7 +2344,7 @@ fn finish_register_fn(ccx: @CrateContext, sp: Span, sym: ~str, node_id: ast::Nod
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if is_entry_fn(&ccx.sess, node_id) && !*ccx.sess.building_library {
|
if is_entry_fn(&ccx.sess, node_id) && !ccx.sess.building_library.get() {
|
||||||
create_entry_wrapper(ccx, sp, llfn);
|
create_entry_wrapper(ccx, sp, llfn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2678,7 +2678,7 @@ pub fn get_item_val(ccx: @CrateContext, id: ast::NodeId) -> ValueRef {
|
||||||
// library then we've already declared the crate map
|
// library then we've already declared the crate map
|
||||||
// so use that instead.
|
// so use that instead.
|
||||||
if attr::contains_name(ni.attrs, "crate_map") {
|
if attr::contains_name(ni.attrs, "crate_map") {
|
||||||
if *ccx.sess.building_library {
|
if ccx.sess.building_library.get() {
|
||||||
let s = "_rust_crate_map_toplevel";
|
let s = "_rust_crate_map_toplevel";
|
||||||
let g = unsafe {
|
let g = unsafe {
|
||||||
s.with_c_str(|buf| {
|
s.with_c_str(|buf| {
|
||||||
|
@ -3044,7 +3044,7 @@ pub fn decl_crate_map(sess: session::Session, mapmeta: LinkMeta,
|
||||||
let mut n_subcrates = 1;
|
let mut n_subcrates = 1;
|
||||||
let cstore = sess.cstore;
|
let cstore = sess.cstore;
|
||||||
while cstore.have_crate_data(n_subcrates) { n_subcrates += 1; }
|
while cstore.have_crate_data(n_subcrates) { n_subcrates += 1; }
|
||||||
let is_top = !*sess.building_library || sess.gen_crate_map();
|
let is_top = !sess.building_library.get() || sess.gen_crate_map();
|
||||||
let sym_name = if is_top {
|
let sym_name = if is_top {
|
||||||
~"_rust_crate_map_toplevel"
|
~"_rust_crate_map_toplevel"
|
||||||
} else {
|
} else {
|
||||||
|
@ -3154,7 +3154,9 @@ pub fn crate_ctxt_to_encode_parms<'r>(cx: &'r CrateContext, ie: encoder::encode_
|
||||||
pub fn write_metadata(cx: &CrateContext, crate: &ast::Crate) -> ~[u8] {
|
pub fn write_metadata(cx: &CrateContext, crate: &ast::Crate) -> ~[u8] {
|
||||||
use extra::flate;
|
use extra::flate;
|
||||||
|
|
||||||
if !*cx.sess.building_library { return ~[]; }
|
if !cx.sess.building_library.get() {
|
||||||
|
return ~[]
|
||||||
|
}
|
||||||
|
|
||||||
let encode_inlined_item: encoder::encode_inlined_item =
|
let encode_inlined_item: encoder::encode_inlined_item =
|
||||||
|ecx, ebml_w, path, ii|
|
|ecx, ebml_w, path, ii|
|
||||||
|
@ -3227,8 +3229,7 @@ pub fn trans_crate(sess: session::Session,
|
||||||
// __rust_crate_map_toplevel symbol (extra underscore) which it will
|
// __rust_crate_map_toplevel symbol (extra underscore) which it will
|
||||||
// subsequently fail to find. So to mitigate that we just introduce
|
// subsequently fail to find. So to mitigate that we just introduce
|
||||||
// an alias from the symbol it expects to the one that actually exists.
|
// an alias from the symbol it expects to the one that actually exists.
|
||||||
if ccx.sess.targ_cfg.os == OsWin32 &&
|
if ccx.sess.targ_cfg.os == OsWin32 && !ccx.sess.building_library.get() {
|
||||||
!*ccx.sess.building_library {
|
|
||||||
|
|
||||||
let maptype = val_ty(ccx.crate_map).to_ref();
|
let maptype = val_ty(ccx.crate_map).to_ref();
|
||||||
|
|
||||||
|
|
|
@ -438,7 +438,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
|
||||||
|
|
||||||
fn check_for_entry_fn(ccx: &CrateCtxt) {
|
fn check_for_entry_fn(ccx: &CrateCtxt) {
|
||||||
let tcx = ccx.tcx;
|
let tcx = ccx.tcx;
|
||||||
if !*tcx.sess.building_library {
|
if !tcx.sess.building_library.get() {
|
||||||
match tcx.sess.entry_fn.get() {
|
match tcx.sess.entry_fn.get() {
|
||||||
Some((id, sp)) => match tcx.sess.entry_type.get() {
|
Some((id, sp)) => match tcx.sess.entry_type.get() {
|
||||||
Some(session::EntryMain) => check_main_fn_ty(ccx, id, sp),
|
Some(session::EntryMain) => check_main_fn_ty(ccx, id, sp),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue