Skip to content

Commit 830a525

Browse files
committed
---
yaml --- r: 2227 b: refs/heads/master c: 418b23a h: refs/heads/master i: 2225: 45fc0c7 2223: c95dd56 v: v3
1 parent fb03726 commit 830a525

File tree

9 files changed

+173
-427
lines changed

9 files changed

+173
-427
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: ba3a4f6cc6a9a29c67b325d8a6a5d3b081f97773
2+
refs/heads/master: 418b23a5389482c2889c5c01f7f31ba5061c5bc5

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: 124 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,6 @@ 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-
2923
fn default_environment(session.session sess,
3024
str argv0,
3125
str input) -> eval.env {
@@ -111,18 +105,18 @@ fn usage(session.session sess, str argv0) {
111105
options:
112106
113107
-o <filename> write output to <filename>
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
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
119113
-L <path> add a directory to the library search path
120-
--noverify suppress LLVM verification step (slight speedup)
121-
--parse-only parse only; do not compile, assemble, or link
114+
-noverify suppress LLVM verification step (slight speedup)
115+
-parse-only parse only; do not compile, assemble, or link
122116
-O optimize
123117
-S compile only; do not assemble or link
124118
-c compile and assemble, but do not link
125-
--save-temps write intermediate files in addition to normal output
119+
-save-temps write intermediate files in addition to normal output
126120
-h display this message\n\n");
127121
}
128122

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

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-
}
169-
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");
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;
176152
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");
153+
let bool glue = false;
154+
let bool verify = true;
155+
let bool save_temps = false;
156+
186157
// FIXME: Maybe we should support -O0, -O1, -Os, etc
187-
auto optimize = opt_present(match, "O");
188-
auto n_inputs = _vec.len[str](match.free);
158+
let bool optimize = false;
189159

190-
if (glue) {
191-
if (n_inputs > 0u) {
192-
sess.err("No input files allowed with --glue.");
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+
}
193221
}
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;
222+
i += 1u;
197223
}
198224

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.");
225+
if (do_warn) {
226+
warn_wrong_compiler();
203227
}
204228

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 {
229+
if (glue) {
212230
alt (output_file) {
213231
case (none[str]) {
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);
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);
221238
}
222-
case (some[str](?ofile)) {
223-
compile_input(sess, env, ifile, ofile, shared,
224-
optimize, verify, save_temps, ot,
225-
library_search_paths);
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+
}
226272
}
227273
}
228274
}

0 commit comments

Comments
 (0)