diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index 97358154e99..087c6c3b833 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -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, diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index 039a5b4d14a..cd663c06ce7 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -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, diff --git a/src/rustc/middle/trans/base.rs b/src/rustc/middle/trans/base.rs index 74eab331f46..1f1e204d54e 100644 --- a/src/rustc/middle/trans/base.rs +++ b/src/rustc/middle/trans/base.rs @@ -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());