Skip to content

Commit 54f72fb

Browse files
committed
rustc: Actually hook the crate_type attribute into session
1 parent 4f17131 commit 54f72fb

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/comp/driver/rustc.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ fn compile_input(sess: session::session, cfg: ast::crate_cfg, input: str,
138138
time(time_passes, "parsing", bind parse_input(sess, cfg, input));
139139
if sess.get_opts().parse_only { ret; }
140140

141+
sess.set_building_library(crate);
142+
141143
crate =
142144
time(time_passes, "configuration",
143145
bind front::config::strip_unconfigured_items(crate));
@@ -492,7 +494,7 @@ fn build_session(sopts: @session::options) -> session::session {
492494
sopts.addl_lib_search_paths);
493495
ret session::session(target_cfg, sopts, cstore,
494496
@{cm: codemap::new_codemap(), mutable next_id: 0},
495-
none, 0u, filesearch);
497+
none, 0u, filesearch, false);
496498
}
497499

498500
fn parse_pretty(sess: session::session, &&name: str) -> pp_mode {

src/comp/driver/session.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ obj session(targ_cfg: @config,
5959
// For a library crate, this is always none
6060
mutable main_fn: option::t<node_id>,
6161
mutable err_count: uint,
62-
filesearch: filesearch::filesearch) {
62+
filesearch: filesearch::filesearch,
63+
mutable building_library: bool) {
6364
fn get_targ_cfg() -> @config { ret targ_cfg; }
6465
fn get_opts() -> @options { ret opts; }
6566
fn get_cstore() -> metadata::cstore::cstore { cstore }
@@ -118,7 +119,10 @@ obj session(targ_cfg: @config,
118119
fn set_main_id(d: node_id) { main_fn = some(d); }
119120
fn get_main_id() -> option::t<node_id> { main_fn }
120121
fn filesearch() -> filesearch::filesearch { filesearch }
121-
fn building_library() -> bool { opts.crate_type == lib_crate }
122+
fn building_library() -> bool { building_library }
123+
fn set_building_library(crate: @ast::crate) {
124+
building_library = session::building_library(opts.crate_type, crate);
125+
}
122126
}
123127

124128
fn building_library(req_crate_type: crate_type, crate: @ast::crate) -> bool {

0 commit comments

Comments
 (0)