Skip to content

Commit 7706262

Browse files
author
Elliott Slaughter
committed
rustc: Add flag for enabling GC.
1 parent 30768d3 commit 7706262

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

src/rustc/driver/driver.rs

+2
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,7 @@ fn build_session_options(matches: getopts::matches,
421421
session::unknown_crate
422422
};
423423
let static = opt_present(matches, ~"static");
424+
let gc = opt_present(matches, ~"gc");
424425

425426
let parse_only = opt_present(matches, ~"parse-only");
426427
let no_trans = opt_present(matches, ~"no-trans");
@@ -519,6 +520,7 @@ fn build_session_options(matches: getopts::matches,
519520
let sopts: @session::options =
520521
@{crate_type: crate_type,
521522
static: static,
523+
gc: gc,
522524
optimize: opt_level,
523525
debuginfo: debuginfo,
524526
extra_debuginfo: extra_debuginfo,

src/rustc/driver/session.rs

+2
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ type options =
8282
// with additional crate configurations during the compile process
8383
{crate_type: crate_type,
8484
static: bool,
85+
gc: bool,
8586
optimize: OptLevel,
8687
debuginfo: bool,
8788
extra_debuginfo: bool,
@@ -221,6 +222,7 @@ fn basic_options() -> @options {
221222
@{
222223
crate_type: session::lib_crate,
223224
static: false,
225+
gc: false,
224226
optimize: No,
225227
debuginfo: false,
226228
extra_debuginfo: false,

src/rustc/middle/trans/base.rs

+7
Original file line numberDiff line numberDiff line change
@@ -4792,6 +4792,13 @@ fn trans_closure(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
47924792
some(body.span));
47934793
create_llargs_for_fn_args(fcx, ty_self, decl.inputs);
47944794

4795+
// Set GC for function.
4796+
if ccx.sess.opts.gc {
4797+
do str::as_c_str("generic") |strategy| {
4798+
llvm::LLVMSetGC(fcx.llfn, strategy);
4799+
}
4800+
}
4801+
47954802
// Create the first basic block in the function and keep a handle on it to
47964803
// pass to finish_fn later.
47974804
let bcx_top = top_scope_block(fcx, body.info());

0 commit comments

Comments
 (0)