Skip to content

Commit 32936b9

Browse files
committed
---
yaml --- r: 2228 b: refs/heads/master c: bc6e981 h: refs/heads/master v: v3
1 parent 830a525 commit 32936b9

File tree

8 files changed

+402
-137
lines changed

8 files changed

+402
-137
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: 418b23a5389482c2889c5c01f7f31ba5061c5bc5
2+
refs/heads/master: bc6e9815379e31ac42b4d9fd2b0e20f708c1cc1c

trunk/Makefile.in

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ CFG_GCC_LINK_FLAGS :=
1616
CFG_BOOT_FLAGS := $(BOOT_FLAGS)
1717
ifdef CFG_DISABLE_OPTIMIZE
1818
$(info cfg: disabling rustc optimization (CFG_DISABLE_OPTIMIZE))
19-
CFG_RUSTC_FLAGS := -nowarn
19+
CFG_RUSTC_FLAGS := --nowarn
2020
else
21-
CFG_RUSTC_FLAGS := -nowarn -O
21+
CFG_RUSTC_FLAGS := --nowarn -O
2222
endif
2323

2424
ifdef SAVE_TEMPS
25-
CFG_RUSTC_FLAGS += -save-temps
25+
CFG_RUSTC_FLAGS += --save-temps
2626
endif
2727

2828
# On Darwin, we need to run dsymutil so the debugging information ends
@@ -471,7 +471,7 @@ boot/$(CFG_STDLIB): $(STDLIB_CRATE) $(STDLIB_INPUTS) \
471471

472472
stage0/std.o: $(STDLIB_CRATE) $(STDLIB_INPUTS) stage0/rustc$(X) $(MKFILES)
473473
@$(call E, compile: $@)
474-
$(STAGE0) -c -shared -o $@ $<
474+
$(STAGE0) -c --shared -o $@ $<
475475

476476
stage0/$(CFG_STDLIB): stage0/std.o stage0/glue.o
477477
@$(call E, link: $@)
@@ -480,7 +480,7 @@ stage0/$(CFG_STDLIB): stage0/std.o stage0/glue.o
480480

481481
stage1/std.o: $(STDLIB_CRATE) $(STDLIB_INPUTS) stage1/rustc$(X) $(MKFILES)
482482
@$(call E, compile: $@)
483-
$(STAGE1) -c -shared -o $@ $<
483+
$(STAGE1) -c --shared -o $@ $<
484484

485485
stage1/$(CFG_STDLIB): stage1/std.o stage1/glue.o
486486
@$(call E, link: $@)
@@ -489,7 +489,7 @@ stage1/$(CFG_STDLIB): stage1/std.o stage1/glue.o
489489

490490
stage2/std.o: $(STDLIB_CRATE) $(STDLIB_INPUTS) stage2/rustc$(X) $(MKFILES)
491491
@$(call E, compile: $@)
492-
$(STAGE2) -c -shared -o $@ $<
492+
$(STAGE2) -c --shared -o $@ $<
493493

494494
stage2/$(CFG_STDLIB): stage2/std.o stage2/glue.o
495495
@$(call E, link: $@)
@@ -516,17 +516,17 @@ stage2/rustc.o: $(COMPILER_CRATE) $(COMPILER_INPUTS) $(SREQ1)
516516
stage0/glue.o: stage0/rustc$(X) boot/$(CFG_STDLIB) \
517517
rustllvm/$(CFG_RUSTLLVM) rt/$(CFG_RUNTIME)
518518
@$(call E, generate: $@)
519-
$(STAGE0) -c -o $@ -glue
519+
$(STAGE0) -c -o $@ --glue
520520

521521
stage1/glue.o: stage1/rustc$(X) stage0/$(CFG_STDLIB) \
522522
rustllvm/$(CFG_RUSTLLVM) rt/$(CFG_RUNTIME)
523523
@$(call E, generate: $@)
524-
$(STAGE1) -c -o $@ -glue
524+
$(STAGE1) -c -o $@ --glue
525525

526526
stage2/glue.o: stage2/rustc$(X) stage1/$(CFG_STDLIB) \
527527
rustllvm/$(CFG_RUSTLLVM) rt/$(CFG_RUNTIME)
528528
@$(call E, generate: $@)
529-
$(STAGE2) -c -o $@ -glue
529+
$(STAGE2) -c -o $@ --glue
530530

531531
# Due to make not wanting to run the same implicit rules twice on the same
532532
# rule tree (implicit-rule recursion prevention, see "Chains of Implicit

trunk/src/comp/driver/rustc.rs

Lines changed: 78 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ import std._str;
2020
import std._vec;
2121
import std.io;
2222

23+
import std.GetOpts;
24+
import std.GetOpts.optopt;
25+
import std.GetOpts.optmulti;
26+
import std.GetOpts.optflag;
27+
import std.GetOpts.opt_present;
28+
2329
fn default_environment(session.session sess,
2430
str argv0,
2531
str input) -> eval.env {
@@ -105,18 +111,18 @@ fn usage(session.session sess, str argv0) {
105111
options:
106112
107113
-o <filename> write output to <filename>
108-
-nowarn suppress wrong-compiler warning
109-
-glue generate glue.bc file
110-
-shared compile a shared-library crate
111-
-pp pretty-print the input instead of compiling
112-
-ls list the symbols defined by a crate file
114+
--nowarn suppress wrong-compiler warning
115+
--glue generate glue.bc file
116+
--shared compile a shared-library crate
117+
--pretty pretty-print the input instead of compiling
118+
--ls list the symbols defined by a crate file
113119
-L <path> add a directory to the library search path
114-
-noverify suppress LLVM verification step (slight speedup)
115-
-parse-only parse only; do not compile, assemble, or link
120+
--noverify suppress LLVM verification step (slight speedup)
121+
--parse-only parse only; do not compile, assemble, or link
116122
-O optimize
117123
-S compile only; do not assemble or link
118124
-c compile and assemble, but do not link
119-
-save-temps write intermediate files in addition to normal output
125+
--save-temps write intermediate files in addition to normal output
120126
-h display this message\n\n");
121127
}
122128

@@ -142,133 +148,81 @@ fn main(vec[str] args) {
142148
auto sess = session.session(target_crate_num, target_cfg, crate_cache,
143149
md, front.codemap.new_codemap());
144150

145-
let option.t[str] input_file = none[str];
146-
let option.t[str] output_file = none[str];
147-
let vec[str] library_search_paths = vec();
148-
let bool do_warn = true;
149-
let bool shared = false;
150-
let bool pretty = false;
151-
let bool ls = false;
152-
auto ot = trans.output_type_bitcode;
153-
let bool glue = false;
154-
let bool verify = true;
155-
let bool save_temps = false;
151+
auto opts = vec(optflag("nowarn"), optflag("h"), optflag("glue"),
152+
optflag("pretty"), optflag("ls"), optflag("parse-only"),
153+
optflag("O"), optflag("shared"), optmulti("L"),
154+
optflag("S"), optflag("c"), optopt("o"),
155+
optflag("save-temps"), optflag("noverify"));
156+
auto binary = _vec.shift[str](args);
157+
auto match;
158+
alt (GetOpts.getopts(args, opts)) {
159+
case (GetOpts.failure(?f)) { sess.err(GetOpts.fail_str(f)); fail; }
160+
case (GetOpts.success(?m)) { match = m; }
161+
}
162+
if (!opt_present(match, "nowarn")) {
163+
warn_wrong_compiler();
164+
}
165+
if (opt_present(match, "h")) {
166+
usage(sess, binary);
167+
ret;
168+
}
156169

170+
auto pretty = opt_present(match, "pretty");
171+
auto ls = opt_present(match, "ls");
172+
auto glue = opt_present(match, "glue");
173+
auto shared = opt_present(match, "shared");
174+
auto output_file = GetOpts.opt_maybe_str(match, "o");
175+
auto library_search_paths = GetOpts.opt_strs(match, "L");
176+
auto ot = trans.output_type_bitcode;
177+
if (opt_present(match, "parse-only")) {
178+
ot = trans.output_type_none;
179+
} else if (opt_present(match, "S")) {
180+
ot = trans.output_type_assembly;
181+
} else if (opt_present(match, "c")) {
182+
ot = trans.output_type_object;
183+
}
184+
auto verify = !opt_present(match, "noverify");
185+
auto save_temps = opt_present(match, "save-temps");
157186
// FIXME: Maybe we should support -O0, -O1, -Os, etc
158-
let bool optimize = false;
187+
auto optimize = opt_present(match, "O");
188+
auto n_inputs = _vec.len[str](match.free);
159189

160-
auto i = 1u;
161-
auto len = _vec.len[str](args);
162-
163-
// FIXME: a getopt module would be nice.
164-
while (i < len) {
165-
auto arg = args.(i);
166-
if (_str.byte_len(arg) > 0u && arg.(0) == '-' as u8) {
167-
if (_str.eq(arg, "-nowarn")) {
168-
do_warn = false;
169-
} else if (_str.eq(arg, "-O")) {
170-
optimize = true;
171-
} else if (_str.eq(arg, "-glue")) {
172-
glue = true;
173-
} else if (_str.eq(arg, "-shared")) {
174-
shared = true;
175-
} else if (_str.eq(arg, "-pp")) {
176-
pretty = true;
177-
} else if (_str.eq(arg, "-ls")) {
178-
ls = true;
179-
} else if (_str.eq(arg, "-parse-only")) {
180-
ot = trans.output_type_none;
181-
} else if (_str.eq(arg, "-S")) {
182-
ot = trans.output_type_assembly;
183-
} else if (_str.eq(arg, "-c")) {
184-
ot = trans.output_type_object;
185-
} else if (_str.eq(arg, "-o")) {
186-
if (i+1u < len) {
187-
output_file = some(args.(i+1u));
188-
i += 1u;
189-
} else {
190-
usage(sess, args.(0));
191-
sess.err("-o requires an argument");
192-
}
193-
} else if (_str.eq(arg, "-save-temps")) {
194-
save_temps = true;
195-
} else if (_str.eq(arg, "-L")) {
196-
if (i+1u < len) {
197-
library_search_paths += vec(args.(i+1u));
198-
i += 1u;
199-
} else {
200-
usage(sess, args.(0));
201-
sess.err("-L requires an argument");
202-
}
203-
} else if (_str.eq(arg, "-noverify")) {
204-
verify = false;
205-
} else if (_str.eq(arg, "-h")) {
206-
usage(sess, args.(0));
207-
} else {
208-
usage(sess, args.(0));
209-
sess.err("unrecognized option: " + arg);
210-
}
211-
} else {
212-
alt (input_file) {
213-
case (some[str](_)) {
214-
usage(sess, args.(0));
215-
sess.err("multiple inputs provided");
216-
}
217-
case (none[str]) {
218-
input_file = some[str](arg);
219-
}
220-
}
190+
if (glue) {
191+
if (n_inputs > 0u) {
192+
sess.err("No input files allowed with --glue.");
221193
}
222-
i += 1u;
194+
auto out = option.from_maybe[str]("glue.bc", output_file);
195+
middle.trans.make_common_glue(out, optimize, verify, save_temps, ot);
196+
ret;
223197
}
224198

225-
if (do_warn) {
226-
warn_wrong_compiler();
199+
if (n_inputs == 0u) {
200+
sess.err("No input filename given.");
201+
} else if (n_inputs > 1u) {
202+
sess.err("Multiple input filenames provided.");
227203
}
228204

229-
if (glue) {
205+
auto ifile = match.free.(0);
206+
auto env = default_environment(sess, args.(0), ifile);
207+
if (pretty) {
208+
pretty_print_input(sess, env, ifile);
209+
} else if (ls) {
210+
front.creader.list_file_metadata(ifile, std.io.stdout());
211+
} else {
230212
alt (output_file) {
231213
case (none[str]) {
232-
middle.trans.make_common_glue("glue.bc", optimize, verify,
233-
save_temps, ot);
234-
}
235-
case (some[str](?s)) {
236-
middle.trans.make_common_glue(s, optimize, verify, save_temps,
237-
ot);
214+
let vec[str] parts = _str.split(ifile, '.' as u8);
215+
_vec.pop[str](parts);
216+
parts += vec(".bc");
217+
auto ofile = _str.concat(parts);
218+
compile_input(sess, env, ifile, ofile, shared,
219+
optimize, verify, save_temps, ot,
220+
library_search_paths);
238221
}
239-
}
240-
ret;
241-
}
242-
243-
alt (input_file) {
244-
case (none[str]) {
245-
usage(sess, args.(0));
246-
sess.err("no input filename");
247-
}
248-
case (some[str](?ifile)) {
249-
250-
auto env = default_environment(sess, args.(0), ifile);
251-
if (pretty) {
252-
pretty_print_input(sess, env, ifile);
253-
} else if (ls) {
254-
front.creader.list_file_metadata(ifile, std.io.stdout());
255-
} else {
256-
alt (output_file) {
257-
case (none[str]) {
258-
let vec[str] parts = _str.split(ifile, '.' as u8);
259-
_vec.pop[str](parts);
260-
parts += vec(".bc");
261-
auto ofile = _str.concat(parts);
262-
compile_input(sess, env, ifile, ofile, shared,
263-
optimize, verify, save_temps, ot,
264-
library_search_paths);
265-
}
266-
case (some[str](?ofile)) {
267-
compile_input(sess, env, ifile, ofile, shared,
268-
optimize, verify, save_temps, ot,
269-
library_search_paths);
270-
}
271-
}
222+
case (some[str](?ofile)) {
223+
compile_input(sess, env, ifile, ofile, shared,
224+
optimize, verify, save_temps, ot,
225+
library_search_paths);
272226
}
273227
}
274228
}

trunk/src/comp/middle/ty.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,9 @@ fn ty_to_str(ctxt cx, &t typ) -> str {
630630
fn ty_to_abbrev_str(ctxt cx, t typ) -> str {
631631
auto f = def_to_str;
632632
auto ecx = @rec(ds=f, tcx=cx);
633-
ret metadata.Encode.ty_str(ecx, typ);
633+
auto s = metadata.Encode.ty_str(ecx, typ);
634+
if (_str.byte_len(s) >= 64u) { s = _str.substr(s, 0u, 64u); }
635+
ret s;
634636
}
635637

636638
// Type folds

0 commit comments

Comments
 (0)