about summary refs log tree commit diff
path: root/src/rustc
diff options
context:
space:
mode:
authorElliott Slaughter <eslaughter@mozilla.com>2012-08-28 10:58:04 -0700
committerElliott Slaughter <eslaughter@mozilla.com>2012-08-28 11:05:32 -0700
commit0031617f30f159df2cef301c9d574cd219e16b16 (patch)
treeeebd184e7e3abe6daad7d879ca4da906f30b1f3d /src/rustc
parentadf9fa229fbf9da048c766ec966d6d7c0babb5c9 (diff)
downloadrust-0031617f30f159df2cef301c9d574cd219e16b16.tar.gz
rust-0031617f30f159df2cef301c9d574cd219e16b16.zip
rustc: Add cfg(gc) and cfg(nogc).
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.
Diffstat (limited to 'src/rustc')
-rw-r--r--src/rustc/driver/driver.rs25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs
index 8023194f3d9..8b70b25f88a 100644
--- a/src/rustc/driver/driver.rs
+++ b/src/rustc/driver/driver.rs
@@ -62,6 +62,14 @@ 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
@@ -69,15 +77,14 @@ fn build_configuration(sess: session, argv0: ~str, input: input) ->
     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