rustc: Add flag for enabling GC.

This commit is contained in:
Elliott Slaughter 2012-06-26 14:27:09 -07:00
parent 30768d3609
commit 7706262a73
3 changed files with 11 additions and 0 deletions
src/rustc
driver
middle/trans

@ -421,6 +421,7 @@ fn build_session_options(matches: getopts::matches,
session::unknown_crate
};
let static = opt_present(matches, ~"static");
let gc = opt_present(matches, ~"gc");
let parse_only = opt_present(matches, ~"parse-only");
let no_trans = opt_present(matches, ~"no-trans");
@ -519,6 +520,7 @@ fn build_session_options(matches: getopts::matches,
let sopts: @session::options =
@{crate_type: crate_type,
static: static,
gc: gc,
optimize: opt_level,
debuginfo: debuginfo,
extra_debuginfo: extra_debuginfo,

@ -82,6 +82,7 @@ type options =
// with additional crate configurations during the compile process
{crate_type: crate_type,
static: bool,
gc: bool,
optimize: OptLevel,
debuginfo: bool,
extra_debuginfo: bool,
@ -221,6 +222,7 @@ fn basic_options() -> @options {
@{
crate_type: session::lib_crate,
static: false,
gc: false,
optimize: No,
debuginfo: false,
extra_debuginfo: false,

@ -4792,6 +4792,13 @@ fn trans_closure(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
some(body.span));
create_llargs_for_fn_args(fcx, ty_self, decl.inputs);
// Set GC for function.
if ccx.sess.opts.gc {
do str::as_c_str("generic") |strategy| {
llvm::LLVMSetGC(fcx.llfn, strategy);
}
}
// Create the first basic block in the function and keep a handle on it to
// pass to finish_fn later.
let bcx_top = top_scope_block(fcx, body.info());