diff --git a/src/comp/driver/rustc.rs b/src/comp/driver/rustc.rs index a6f6ae05062..6a37dece845 100644 --- a/src/comp/driver/rustc.rs +++ b/src/comp/driver/rustc.rs @@ -82,6 +82,7 @@ fn compile_input(session.session sess, str input, str output, bool shared, bool optimize, + bool debuginfo, bool verify, bool save_temps, trans.output_type ot, @@ -115,11 +116,12 @@ fn compile_input(session.session sess, auto llmod = time[llvm.ModuleRef](time_passes, "translation", bind trans.trans_crate(sess, crate, ty_cx, type_cache, output, - shared)); + debuginfo, shared)); time[()](time_passes, "LLVM passes", - bind trans.run_passes(llmod, optimize, verify, save_temps, output, - ot)); + bind trans.run_passes(llmod, optimize, debuginfo, + verify, save_temps, output, + ot)); } fn pretty_print_input(session.session sess, @@ -144,6 +146,7 @@ options: --noverify suppress LLVM verification step (slight speedup) --depend print dependencies, in makefile-rule form --parse-only parse only; do not compile, assemble, or link + -g produce debug info -O optimize -S compile only; do not assemble or link -c compile and assemble, but do not link @@ -178,7 +181,7 @@ fn main(vec[str] args) { auto opts = vec(optflag("h"), optflag("glue"), optflag("pretty"), optflag("ls"), optflag("parse-only"), optflag("O"), optflag("shared"), optmulti("L"), - optflag("S"), optflag("c"), optopt("o"), + optflag("S"), optflag("c"), optopt("o"), optopt("g"), optflag("save-temps"), optflag("time-passes"), optflag("no-typestate"), optflag("noverify")); auto binary = _vec.shift[str](args); @@ -210,6 +213,7 @@ fn main(vec[str] args) { auto save_temps = opt_present(match, "save-temps"); // FIXME: Maybe we should support -O0, -O1, -Os, etc auto optimize = opt_present(match, "O"); + auto debuginfo = opt_present(match, "g"); auto time_passes = opt_present(match, "time-passes"); auto run_typestate = !opt_present(match, "no-typestate"); auto n_inputs = _vec.len[str](match.free); @@ -243,15 +247,15 @@ fn main(vec[str] args) { parts += vec("bc"); auto ofile = _str.connect(parts, "."); compile_input(sess, env, ifile, ofile, shared, - optimize, verify, save_temps, ot, - time_passes, run_typestate, - library_search_paths); + optimize, debuginfo, verify, + save_temps, ot, time_passes, + run_typestate, library_search_paths); } case (some[str](?ofile)) { compile_input(sess, env, ifile, ofile, shared, - optimize, verify, save_temps, ot, - time_passes, run_typestate, - library_search_paths); + optimize, debuginfo, verify, + save_temps, ot, time_passes, + run_typestate, library_search_paths); } } } diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index 6f216a97f8a..7e8e788efa8 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -116,7 +116,8 @@ state type crate_ctxt = rec(session.session sess, std.sha1.sha1 sha, hashmap[ty.t, str] type_sha1s, hashmap[ty.t, metadata.ty_abbrev] type_abbrevs, - ty.ctxt tcx); + ty.ctxt tcx, + bool debuginfo); type local_ctxt = rec(vec[str] path, vec[str] module_path, @@ -1785,8 +1786,13 @@ fn declare_generic_glue(@local_ctxt cx, ty.t t, TypeRef llfnty, str name) -> ValueRef { - auto fn_nm = mangle_name_by_type_only(cx.ccx, t, "glue_" + name); - fn_nm = sanitize(fn_nm); + auto fn_nm; + if (cx.ccx.debuginfo) { + fn_nm = mangle_name_by_type_only(cx.ccx, t, "glue_" + name); + fn_nm = sanitize(fn_nm); + } else { + fn_nm = mangle_name_by_seq(cx.ccx, cx.path, "glue_" + name); + } auto llfn = decl_internal_fastcall_fn(cx.ccx.llmod, fn_nm, llfnty); ret llfn; } @@ -7241,8 +7247,8 @@ fn is_object_or_assembly(output_type ot) -> bool { ret false; } -fn run_passes(ModuleRef llmod, bool opt, bool verify, bool save_temps, - str output, output_type ot) { +fn run_passes(ModuleRef llmod, bool opt, bool dbg, bool verify, + bool save_temps, str output, output_type ot) { auto pm = mk_pass_manager(); // TODO: run the linter here also, once there are llvm-c bindings for it. @@ -7733,7 +7739,7 @@ fn make_common_glue(str output, bool optimize, bool verify, bool save_temps, trans_exit_task_glue(glues, new_str_hash[ValueRef](), tn, llmod); - run_passes(llmod, optimize, verify, save_temps, output, ot); + run_passes(llmod, optimize, false, verify, save_temps, output, ot); } fn create_module_map(@crate_ctxt ccx) -> ValueRef { @@ -7785,7 +7791,8 @@ fn create_crate_map(@crate_ctxt ccx) -> ValueRef { } fn trans_crate(session.session sess, @ast.crate crate, ty.ctxt tcx, - ty.type_cache type_cache, str output, bool shared) + ty.type_cache type_cache, str output, + bool debuginfo, bool shared) -> ModuleRef { auto llmod = llvm.LLVMModuleCreateWithNameInContext(_str.buf("rust_out"), @@ -7835,7 +7842,8 @@ fn trans_crate(session.session sess, @ast.crate crate, ty.ctxt tcx, sha = std.sha1.mk_sha1(), type_sha1s = sha1s, type_abbrevs = abbrevs, - tcx = tcx); + tcx = tcx, + debuginfo = debuginfo); auto cx = new_local_ctxt(ccx); create_typedefs(ccx);