Skip to content

Commit bc2795b

Browse files
committed
---
yaml --- r: 3568 b: refs/heads/master c: 1e4f198 h: refs/heads/master v: v3
1 parent 0c3b199 commit bc2795b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+888
-1063
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: fb10829aefbb7493c41ee1a5ec4c958692b33c28
2+
refs/heads/master: 1e4f198a1d94e82530456334fe90abd5bfc470b6

trunk/AUTHORS.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,5 @@ Paul Stansifer <[email protected]>
3030
Peter Hull <[email protected]>
3131
Ralph Giles <[email protected]>
3232
Rafael Ávila de Espíndola <[email protected]>
33-
Rob Arnold <[email protected]>
3433
Roy Frostig <[email protected]>
3534
Tim Chevalier <[email protected]>

trunk/Makefile.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ endif
4747
CFG_RUNTIME :=$(call CFG_LIB_NAME,rustrt)
4848
CFG_RUSTLLVM :=$(call CFG_LIB_NAME,rustllvm)
4949
CFG_STDLIB :=$(call CFG_LIB_NAME,std)
50-
CFG_LIBRUSTC :=$(call CFG_LIB_NAME,rustc)
5150

5251
# version-string calculation
5352
CFG_GIT_DIR := $(CFG_SRC_DIR).git

trunk/mk/fuzzer.mk

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
1-
# At the moment the fuzzer only exists in stage1.
1+
# At the moment the fuzzer only exists in stage2. That's the first
2+
# stage built by the non-snapshot compiler so it seems a convenient
3+
# stage to work at.
24

35
FUZZER_CRATE := $(S)src/fuzzer/fuzzer.rc
46
FUZZER_INPUTS := $(wildcard $(addprefix $(S)src/fuzzer/, *.rs))
57

6-
stage1/fuzzer$(X): $(FUZZER_CRATE) $(FUZZER_INPUTS) $(SREQ1)
7-
@$(call E, compile_and_link: $@)
8-
$(STAGE1) -o $@ $<
8+
stage2/fuzzer.o: $(FUZZER_CRATE) $(FUZZER_INPUTS) $(SREQ1)
9+
@$(call E, compile: $@)
10+
$(STAGE1) -c -o $@ $<
11+
12+
stage2/fuzzer$(X): stage2/fuzzer.o $(SREQ1)
13+
@$(call E, link [gcc]: $@)
14+
$(Q)gcc $(CFG_GCCISH_CFLAGS) rt/main.o stage2/glue.o -o $@ $< \
15+
-Lstage2 -Lrustllvm -Lrt -lrustrt -lrustllvm -lstd -lm -lrustc
16+
@# dsymutil sometimes fails or prints a warning, but the
17+
@# program still runs. Since it simplifies debugging other
18+
@# programs, I\'ll live with the noise.
19+
-$(Q)$(CFG_DSYMUTIL) $@

trunk/mk/stage1.mk

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,3 @@ stage1/%.o: stage1/%.s
2929
stage1/%$(X): $(COMPILER_CRATE) $(COMPILER_INPUTS) $(SREQ0) stage0/intrinsics.bc
3030
@$(call E, compile_and_link: $@)
3131
$(STAGE0) -o $@ $<
32-
33-
stage1/lib/$(CFG_LIBRUSTC): $(COMPILER_CRATE) $(COMPILER_INPUTS) $(SREQ1) \
34-
stage1/intrinsics.bc
35-
@$(call E, compile_and_link: $@)
36-
$(STAGE1) --shared -o $@ $<

trunk/src/comp/back/link.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,6 @@ fn build_link_meta(&session::session sess, &ast::crate c,
332332
sha.input_str(len_and_str(name));
333333
}
334334
case (ast::meta_list(_, _)) {
335-
// FIXME (#607): Implement this
336335
fail "unimplemented meta_item variant";
337336
}
338337
}

trunk/src/comp/driver/rustc.rs

Lines changed: 31 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import front::parser;
66
import front::token;
77
import front::eval;
88
import front::ast;
9-
import front::attr;
109
import middle::trans;
1110
import middle::resolve;
1211
import middle::ty;
@@ -36,42 +35,22 @@ import back::link::output_type;
3635

3736
tag pp_mode { ppm_normal; ppm_typed; ppm_identified; }
3837

39-
fn default_configuration(session::session sess, str argv0, str input) ->
40-
ast::crate_cfg {
38+
fn default_environment(session::session sess, str argv0, str input) ->
39+
eval::env {
4140
auto libc =
4241
alt (sess.get_targ_cfg().os) {
4342
case (session::os_win32) { "msvcrt.dll" }
4443
case (session::os_macos) { "libc.dylib" }
4544
case (session::os_linux) { "libc.so.6" }
4645
case (_) { "libc.so" }
4746
};
48-
49-
auto mk = attr::mk_name_value_item;
50-
5147
ret [ // Target bindings.
52-
mk("target_os", std::os::target_os()),
53-
mk("target_arch", "x86"),
54-
mk("target_libc", libc),
48+
tup("target_os", eval::val_str(std::os::target_os())),
49+
tup("target_arch", eval::val_str("x86")),
50+
tup("target_libc", eval::val_str(libc)),
5551
// Build bindings.
56-
mk("build_compiler", argv0),
57-
mk("build_input", input)];
58-
}
59-
60-
fn build_configuration(session::session sess, str argv0,
61-
str input) -> ast::crate_cfg {
62-
// Combine the configuration requested by the session (command line) with
63-
// some default configuration items
64-
ret sess.get_opts().cfg + default_configuration(sess, argv0, input);
65-
}
66-
67-
// Convert strings provided as --cfg [cfgspec] into a crate_cfg
68-
fn parse_cfgspecs(&vec[str] cfgspecs) -> ast::crate_cfg {
69-
// FIXME: It would be nice to use the parser to parse all varieties of
70-
// meta_item here. At the moment we just support the meta_word variant.
71-
fn to_meta_word(&str cfgspec) -> @ast::meta_item {
72-
attr::mk_word_item(cfgspec)
73-
}
74-
ret vec::map(to_meta_word, cfgspecs);
52+
tup("build_compiler", eval::val_str(argv0)),
53+
tup("build_input", eval::val_str(input))];
7554
}
7655

7756
fn parse_input(session::session sess, parser::parser p, str input) ->
@@ -94,10 +73,10 @@ fn time[T](bool do_it, str what, fn() -> T thunk) -> T {
9473
ret rv;
9574
}
9675

97-
fn compile_input(session::session sess, ast::crate_cfg cfg, str input,
76+
fn compile_input(session::session sess, eval::env env, str input,
9877
str output) {
9978
auto time_passes = sess.get_opts().time_passes;
100-
auto p = parser::new_parser(sess, cfg, input, 0u, 0);
79+
auto p = parser::new_parser(sess, env, input, 0u, 0);
10180
auto crate =
10281
time(time_passes, "parsing", bind parse_input(sess, p, input));
10382
if (sess.get_opts().output_type == link::output_type_none) { ret; }
@@ -125,9 +104,9 @@ fn compile_input(session::session sess, ast::crate_cfg cfg, str input,
125104
bind link::write::run_passes(sess, llmod, output));
126105
}
127106

128-
fn pretty_print_input(session::session sess, ast::crate_cfg cfg,
129-
str input, pp_mode ppm) {
130-
auto p = front::parser::new_parser(sess, cfg, input, 0u, 0);
107+
fn pretty_print_input(session::session sess, eval::env env, str input,
108+
pp_mode ppm) {
109+
auto p = front::parser::new_parser(sess, env, input, 0u, 0);
131110
auto crate = parse_input(sess, p, input);
132111
auto mode;
133112
alt (ppm) {
@@ -177,7 +156,6 @@ options:
177156
--emit-llvm produce an LLVM bitcode file
178157
--save-temps write intermediate files in addition to normal output
179158
--stats gather and report various compilation statistics
180-
--cfg [cfgspec] configure the compilation environment
181159
--time-passes time the individual phases of the compiler
182160
--time-llvm-passes time the individual phases of the LLVM backend
183161
--sysroot <path> override the system root (default: rustc's directory)
@@ -275,7 +253,6 @@ fn build_session_options(str binary, getopts::match match, str binary_dir) ->
275253
case (none) { get_default_sysroot(binary) }
276254
case (some(?s)) { s }
277255
};
278-
auto cfg = parse_cfgspecs(getopts::opt_strs(match, "cfg"));
279256
let @session::options sopts =
280257
@rec(shared=shared,
281258
optimize=opt_level,
@@ -288,8 +265,7 @@ fn build_session_options(str binary, getopts::match match, str binary_dir) ->
288265
time_llvm_passes=time_llvm_passes,
289266
output_type=output_type,
290267
library_search_paths=library_search_paths,
291-
sysroot=sysroot,
292-
cfg=cfg);
268+
sysroot=sysroot);
293269
ret sopts;
294270
}
295271

@@ -299,7 +275,7 @@ fn build_session(@session::options sopts) -> session::session {
299275
auto target_crate_num = 0;
300276
auto sess =
301277
session::session(target_crate_num, target_cfg, sopts, crate_cache, [],
302-
[], [], front::codemap::new_codemap(), 0u);
278+
[], front::codemap::new_codemap(), 0u);
303279
ret sess;
304280
}
305281

@@ -322,7 +298,7 @@ fn main(vec[str] args) {
322298
optflag("c"), optopt("o"), optflag("g"), optflag("save-temps"),
323299
optopt("sysroot"), optflag("stats"), optflag("time-passes"),
324300
optflag("time-llvm-passes"), optflag("no-typestate"),
325-
optflag("noverify"), optmulti("cfg")];
301+
optflag("noverify")];
326302
auto binary = vec::shift[str](args);
327303
auto binary_dir = fs::dirname(binary);
328304
auto match =
@@ -361,15 +337,15 @@ fn main(vec[str] args) {
361337
}
362338
auto ifile = match.free.(0);
363339
let str saved_out_filename = "";
364-
auto cfg = build_configuration(sess, binary, ifile);
340+
auto env = default_environment(sess, binary, ifile);
365341
auto pretty =
366342
option::map[str,
367343
pp_mode](bind parse_pretty(sess, _),
368344
getopts::opt_default(match, "pretty", "normal"));
369345
auto ls = opt_present(match, "ls");
370346
alt (pretty) {
371347
case (some[pp_mode](?ppm)) {
372-
pretty_print_input(sess, cfg, ifile, ppm);
348+
pretty_print_input(sess, env, ifile, ppm);
373349
ret;
374350
}
375351
case (none[pp_mode]) {/* continue */ }
@@ -395,7 +371,7 @@ fn main(vec[str] args) {
395371
case (link::output_type_exe) { parts += ["o"]; }
396372
}
397373
auto ofile = str::connect(parts, ".");
398-
compile_input(sess, cfg, ifile, ofile);
374+
compile_input(sess, env, ifile, ofile);
399375
}
400376
case (some(?ofile)) {
401377
// FIXME: what about windows? This will create a foo.exe.o.
@@ -410,7 +386,7 @@ fn main(vec[str] args) {
410386
}
411387
case (_) { temp_filename = ofile; }
412388
}
413-
compile_input(sess, cfg, ifile, temp_filename);
389+
compile_input(sess, env, ifile, temp_filename);
414390
}
415391
}
416392

@@ -430,11 +406,16 @@ fn main(vec[str] args) {
430406
saved_out_filename, saved_out_filename + ".o"];
431407
auto shared_cmd;
432408

433-
auto os = sess.get_targ_cfg().os;
434-
if (os == session::os_macos) {
409+
alt (sess.get_targ_cfg().os) {
410+
case (session::os_win32) {
411+
shared_cmd = "-shared";
412+
}
413+
case (session::os_macos) {
435414
shared_cmd = "-dynamiclib";
436-
} else {
415+
}
416+
case (session::os_linux) {
437417
shared_cmd = "-shared";
418+
}
438419
}
439420

440421
// Converts a library file name into a gcc -l argument
@@ -460,7 +441,7 @@ fn main(vec[str] args) {
460441
case (_) { rmext(filename) }
461442
};
462443
}
463-
444+
464445
for (str cratepath in sess.get_used_crate_files()) {
465446
auto dir = fs::dirname(cratepath);
466447
if (dir != "") {
@@ -470,7 +451,6 @@ fn main(vec[str] args) {
470451
gcc_args += ["-l" + libarg];
471452
}
472453

473-
gcc_args += sess.get_used_link_args();
474454
auto used_libs = sess.get_used_libraries();
475455
for (str l in used_libs) {
476456
gcc_args += ["-l" + l];
@@ -479,8 +459,9 @@ fn main(vec[str] args) {
479459
if (sopts.shared) {
480460
gcc_args += [shared_cmd];
481461
} else {
482-
// FIXME: why do we hardcode -lm?
483-
gcc_args += ["-lm", main];
462+
// FIXME: having -Lrustllvm hardcoded in here is hack
463+
// FIXME: same for -lm
464+
gcc_args += ["-Lrustllvm", "-lm", main];
484465
}
485466
// We run 'gcc' here
486467

trunk/src/comp/driver/session.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import std::map;
1010
import std::option;
1111
import std::option::some;
1212
import std::option::none;
13-
import std::str;
1413

1514
tag os { os_win32; os_macos; os_linux; }
1615

@@ -35,10 +34,7 @@ type options =
3534
bool time_llvm_passes,
3635
back::link::output_type output_type,
3736
vec[str] library_search_paths,
38-
str sysroot,
39-
// The crate config requested for the session, which may be combined
40-
// with additional crate configurations during the compile process
41-
ast::crate_cfg cfg);
37+
str sysroot);
4238

4339
type crate_metadata = rec(str name, vec[u8] data);
4440

@@ -72,7 +68,6 @@ obj session(ast::crate_num cnum,
7268
map::hashmap[int, crate_metadata] crates,
7369
mutable vec[str] used_crate_files,
7470
mutable vec[str] used_libraries,
75-
mutable vec[str] used_link_args,
7671
codemap::codemap cm,
7772
mutable uint err_count) {
7873
fn get_targ_cfg() -> @config { ret targ_cfg; }
@@ -132,25 +127,18 @@ obj session(ast::crate_num cnum,
132127
crates.insert(num, metadata);
133128
}
134129
fn has_external_crate(int num) -> bool { ret crates.contains_key(num); }
135-
fn add_used_link_args(&str args) {
136-
used_link_args += str::split(args, ' ' as u8);
137-
}
138-
fn get_used_link_args() -> vec[str] {
139-
ret used_link_args;
140-
}
141-
fn add_used_library(&str lib) -> bool {
130+
fn add_used_library(&str lib) {
142131
if (lib == "") {
143-
ret false;
132+
ret;
144133
}
145134
// A program has a small number of libraries, so a vector is probably
146135
// a good data structure in here.
147136
for (str l in used_libraries) {
148137
if (l == lib) {
149-
ret false;
138+
ret;
150139
}
151140
}
152141
used_libraries += [lib];
153-
ret true;
154142
}
155143
fn get_used_libraries() -> vec[str] {
156144
ret used_libraries;

trunk/src/comp/front/ast.rs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ type crate_ = rec(vec[@crate_directive] directives,
8888
crate_cfg config);
8989

9090
tag crate_directive_ {
91+
cdir_expr(@expr);
92+
93+
// FIXME: cdir_let should be eliminated
94+
// and redirected to the use of const stmt_decls inside
95+
// crate directive blocks.
96+
cdir_let(ident, @expr, vec[@crate_directive]);
9197
cdir_src_mod(ident, option::t[filename], vec[attribute]);
9298
cdir_dir_mod(ident, option::t[filename],
9399
vec[@crate_directive], vec[attribute]);
@@ -110,15 +116,13 @@ type block = spanned[block_];
110116

111117
type block_ = rec(vec[@stmt] stmts, option::t[@expr] expr, node_id id);
112118

113-
type pat = rec(node_id id,
114-
pat_ node,
115-
span span);
119+
type pat = spanned[pat_];
116120

117121
tag pat_ {
118-
pat_wild;
119-
pat_bind(ident);
120-
pat_lit(@lit);
121-
pat_tag(path, vec[@pat]);
122+
pat_wild(node_id);
123+
pat_bind(ident, node_id);
124+
pat_lit(@lit, node_id);
125+
pat_tag(path, vec[@pat], node_id);
122126
}
123127

124128
tag mutability { mut; imm; maybe_mut; }
@@ -277,7 +281,7 @@ tag expr_ {
277281
expr_index(@expr, @expr);
278282
expr_path(path);
279283
expr_ext(path, vec[@expr], option::t[str], @expr);
280-
expr_fail(option::t[@expr]);
284+
expr_fail(option::t[str]);
281285
expr_break;
282286
expr_cont;
283287
expr_ret(option::t[@expr]);
@@ -600,19 +604,6 @@ fn ternary_to_if(&@expr e) -> @ast::expr {
600604
}
601605
}
602606

603-
// Path stringification
604-
fn path_to_str(&ast::path pth) -> str {
605-
auto result = str::connect(pth.node.idents, "::");
606-
if (vec::len[@ast::ty](pth.node.types) > 0u) {
607-
fn f(&@ast::ty t) -> str { ret pretty::pprust::ty_to_str(*t); }
608-
result += "[";
609-
result += str::connect(vec::map(f, pth.node.types), ",");
610-
result += "]";
611-
}
612-
ret result;
613-
}
614-
615-
616607
//
617608
// Local Variables:
618609
// mode: rust

0 commit comments

Comments
 (0)