Skip to content

Commit 9b34cbe

Browse files
committed
---
yaml --- r: 2349 b: refs/heads/master c: ce94687 h: refs/heads/master i: 2347: 765cb82 v: v3
1 parent feb2657 commit 9b34cbe

File tree

3 files changed

+31
-19
lines changed

3 files changed

+31
-19
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: b73a640ce070ff8059039fdffb9d667f13a716e1
2+
refs/heads/master: ce9468761c8381e8ebaa451e8bd0730ec9b087a5

trunk/src/comp/driver/rustc.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ fn compile_input(session.session sess,
8282
str input, str output,
8383
bool shared,
8484
bool optimize,
85+
bool debuginfo,
8586
bool verify,
8687
bool save_temps,
8788
trans.output_type ot,
@@ -115,11 +116,12 @@ fn compile_input(session.session sess,
115116

116117
auto llmod = time[llvm.ModuleRef](time_passes, "translation",
117118
bind trans.trans_crate(sess, crate, ty_cx, type_cache, output,
118-
shared));
119+
debuginfo, shared));
119120

120121
time[()](time_passes, "LLVM passes",
121-
bind trans.run_passes(llmod, optimize, verify, save_temps, output,
122-
ot));
122+
bind trans.run_passes(llmod, optimize, debuginfo,
123+
verify, save_temps, output,
124+
ot));
123125
}
124126

125127
fn pretty_print_input(session.session sess,
@@ -144,6 +146,7 @@ options:
144146
--noverify suppress LLVM verification step (slight speedup)
145147
--depend print dependencies, in makefile-rule form
146148
--parse-only parse only; do not compile, assemble, or link
149+
-g produce debug info
147150
-O optimize
148151
-S compile only; do not assemble or link
149152
-c compile and assemble, but do not link
@@ -178,7 +181,7 @@ fn main(vec[str] args) {
178181
auto opts = vec(optflag("h"), optflag("glue"),
179182
optflag("pretty"), optflag("ls"), optflag("parse-only"),
180183
optflag("O"), optflag("shared"), optmulti("L"),
181-
optflag("S"), optflag("c"), optopt("o"),
184+
optflag("S"), optflag("c"), optopt("o"), optopt("g"),
182185
optflag("save-temps"), optflag("time-passes"),
183186
optflag("no-typestate"), optflag("noverify"));
184187
auto binary = _vec.shift[str](args);
@@ -210,6 +213,7 @@ fn main(vec[str] args) {
210213
auto save_temps = opt_present(match, "save-temps");
211214
// FIXME: Maybe we should support -O0, -O1, -Os, etc
212215
auto optimize = opt_present(match, "O");
216+
auto debuginfo = opt_present(match, "g");
213217
auto time_passes = opt_present(match, "time-passes");
214218
auto run_typestate = !opt_present(match, "no-typestate");
215219
auto n_inputs = _vec.len[str](match.free);
@@ -243,15 +247,15 @@ fn main(vec[str] args) {
243247
parts += vec("bc");
244248
auto ofile = _str.connect(parts, ".");
245249
compile_input(sess, env, ifile, ofile, shared,
246-
optimize, verify, save_temps, ot,
247-
time_passes, run_typestate,
248-
library_search_paths);
250+
optimize, debuginfo, verify,
251+
save_temps, ot, time_passes,
252+
run_typestate, library_search_paths);
249253
}
250254
case (some[str](?ofile)) {
251255
compile_input(sess, env, ifile, ofile, shared,
252-
optimize, verify, save_temps, ot,
253-
time_passes, run_typestate,
254-
library_search_paths);
256+
optimize, debuginfo, verify,
257+
save_temps, ot, time_passes,
258+
run_typestate, library_search_paths);
255259
}
256260
}
257261
}

trunk/src/comp/middle/trans.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,8 @@ state type crate_ctxt = rec(session.session sess,
116116
std.sha1.sha1 sha,
117117
hashmap[ty.t, str] type_sha1s,
118118
hashmap[ty.t, metadata.ty_abbrev] type_abbrevs,
119-
ty.ctxt tcx);
119+
ty.ctxt tcx,
120+
bool debuginfo);
120121

121122
type local_ctxt = rec(vec[str] path,
122123
vec[str] module_path,
@@ -1785,8 +1786,13 @@ fn declare_generic_glue(@local_ctxt cx,
17851786
ty.t t,
17861787
TypeRef llfnty,
17871788
str name) -> ValueRef {
1788-
auto fn_nm = mangle_name_by_type_only(cx.ccx, t, "glue_" + name);
1789-
fn_nm = sanitize(fn_nm);
1789+
auto fn_nm;
1790+
if (cx.ccx.debuginfo) {
1791+
fn_nm = mangle_name_by_type_only(cx.ccx, t, "glue_" + name);
1792+
fn_nm = sanitize(fn_nm);
1793+
} else {
1794+
fn_nm = mangle_name_by_seq(cx.ccx, cx.path, "glue_" + name);
1795+
}
17901796
auto llfn = decl_internal_fastcall_fn(cx.ccx.llmod, fn_nm, llfnty);
17911797
ret llfn;
17921798
}
@@ -7241,8 +7247,8 @@ fn is_object_or_assembly(output_type ot) -> bool {
72417247
ret false;
72427248
}
72437249

7244-
fn run_passes(ModuleRef llmod, bool opt, bool verify, bool save_temps,
7245-
str output, output_type ot) {
7250+
fn run_passes(ModuleRef llmod, bool opt, bool dbg, bool verify,
7251+
bool save_temps, str output, output_type ot) {
72467252
auto pm = mk_pass_manager();
72477253

72487254
// 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,
77337739

77347740
trans_exit_task_glue(glues, new_str_hash[ValueRef](), tn, llmod);
77357741

7736-
run_passes(llmod, optimize, verify, save_temps, output, ot);
7742+
run_passes(llmod, optimize, false, verify, save_temps, output, ot);
77377743
}
77387744

77397745
fn create_module_map(@crate_ctxt ccx) -> ValueRef {
@@ -7785,7 +7791,8 @@ fn create_crate_map(@crate_ctxt ccx) -> ValueRef {
77857791
}
77867792

77877793
fn trans_crate(session.session sess, @ast.crate crate, ty.ctxt tcx,
7788-
ty.type_cache type_cache, str output, bool shared)
7794+
ty.type_cache type_cache, str output,
7795+
bool debuginfo, bool shared)
77897796
-> ModuleRef {
77907797
auto llmod =
77917798
llvm.LLVMModuleCreateWithNameInContext(_str.buf("rust_out"),
@@ -7835,7 +7842,8 @@ fn trans_crate(session.session sess, @ast.crate crate, ty.ctxt tcx,
78357842
sha = std.sha1.mk_sha1(),
78367843
type_sha1s = sha1s,
78377844
type_abbrevs = abbrevs,
7838-
tcx = tcx);
7845+
tcx = tcx,
7846+
debuginfo = debuginfo);
78397847
auto cx = new_local_ctxt(ccx);
78407848

78417849
create_typedefs(ccx);

0 commit comments

Comments
 (0)