Skip to content

Commit

Permalink
rustc: Add cfg(gc) and cfg(nogc).
Browse files Browse the repository at this point in the history
Needed in libcore to determine whether core::gc is being compiled with
GC on or not, which then affects various safety checks to avoid
collecting memory the GC is itself using.
  • Loading branch information
Elliott Slaughter committed Aug 28, 2012
1 parent adf9fa2 commit 0031617
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/rustc/driver/driver.rs
Expand Up @@ -62,22 +62,29 @@ fn default_configuration(sess: session, argv0: ~str, input: input) ->
mk(~"build_input", source_name(input))];
}

fn append_configuration(cfg: ast::crate_cfg, name: ~str) -> ast::crate_cfg {
if attr::contains_name(cfg, name) {
return cfg;
} else {
return vec::append_one(cfg, attr::mk_word_item(name));
}
}

fn build_configuration(sess: session, argv0: ~str, input: input) ->
ast::crate_cfg {
// Combine the configuration requested by the session (command line) with
// some default and generated configuration items
let default_cfg = default_configuration(sess, argv0, input);
let user_cfg = sess.opts.cfg;
// If the user wants a test runner, then add the test cfg
let gen_cfg =
{
if sess.opts.test && !attr::contains_name(user_cfg, ~"test") {
~[attr::mk_word_item(~"test")]
} else {
~[attr::mk_word_item(~"notest")]
}
};
return vec::append(vec::append(user_cfg, gen_cfg), default_cfg);
let user_cfg = append_configuration(
user_cfg,
if sess.opts.test { ~"test" } else { ~"notest" });
// If the user requested GC, then add the GC cfg
let user_cfg = append_configuration(
user_cfg,
if sess.opts.gc { ~"gc" } else { ~"nogc" });
return vec::append(user_cfg, default_cfg);
}

// Convert strings provided as --cfg [cfgspec] into a crate_cfg
Expand Down

0 comments on commit 0031617

Please sign in to comment.