Skip to content

Commit 4c99473

Browse files
committed
---
yaml --- r: 3689 b: refs/heads/master c: 2e2e1f7 h: refs/heads/master i: 3687: e8f4e5a v: v3
1 parent fe5fa44 commit 4c99473

Some content is hidden

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

47 files changed

+730
-804
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: 5547e5dd216f2b062809b52abff01b5baca0d6a0
2+
refs/heads/master: 2e2e1f7cb36aeac0abb730a752fcd78cf91a380f

trunk/mk/snap.mk

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11

2-
snap-stage1: stage1/rustc$(X) stage1/glue.o stage1/lib/$(CFG_STDLIB) \
3-
stage1/lib/libstd.rlib
2+
snap-stage1: stage1/rustc$(X) stage1/glue.o stage1/lib/$(CFG_STDLIB)
43
$(S)src/etc/make-snapshot.py stage1
54

6-
snap-stage2: stage2/rustc$(X) stage2/glue.o stage2/lib/$(CFG_STDLIB) \
7-
stage2/lib/libstd.rlib
5+
snap-stage2: stage2/rustc$(X) stage2/glue.o stage2/lib/$(CFG_STDLIB)
86
$(S)src/etc/make-snapshot.py stage2
97

10-
snap-stage3: stage3/rustc$(X) stage3/glue.o stage3/lib/$(CFG_STDLIB) \
11-
stage3/lib/libstd.rlib
8+
snap-stage3: stage3/rustc$(X) stage3/glue.o stage3/lib/$(CFG_STDLIB)
129
$(S)src/etc/make-snapshot.py stage3
1310

trunk/mk/stage1.mk

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@ stage1/lib/$(CFG_STDLIB): $(STDLIB_CRATE) $(STDLIB_INPUTS) \
22
stage1/rustc$(X) stage0/lib/$(CFG_STDLIB) stage1/intrinsics.bc \
33
stage1/glue.o $(LREQ) $(MKFILES)
44
@$(call E, compile_and_link: $@)
5-
$(STAGE1) --lib -o $@ $<
6-
7-
stage1/lib/libstd.rlib: $(STDLIB_CRATE) $(STDLIB_INPUTS) \
8-
stage1/rustc$(X) stage0/lib/$(CFG_STDLIB) stage1/intrinsics.bc \
9-
stage1/glue.o $(LREQ) $(MKFILES)
10-
@$(call E, compile_and_link: $@)
11-
$(STAGE1) --lib --static -o $@ $<
5+
$(STAGE1) --shared -o $@ $<
126

137
stage1/lib/glue.o: stage1/rustc$(X) stage0/lib/$(CFG_STDLIB) \
148
stage1/intrinsics.bc $(LREQ) $(MKFILES)
@@ -39,4 +33,4 @@ stage1/%$(X): $(COMPILER_CRATE) $(COMPILER_INPUTS) $(SREQ0) stage0/intrinsics.bc
3933
stage1/lib/$(CFG_LIBRUSTC): $(COMPILER_CRATE) $(COMPILER_INPUTS) $(SREQ1) \
4034
stage1/intrinsics.bc
4135
@$(call E, compile_and_link: $@)
42-
$(STAGE1) --lib -o $@ $<
36+
$(STAGE1) --shared -o $@ $<

trunk/mk/stage2.mk

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@ stage2/lib/$(CFG_STDLIB): $(STDLIB_CRATE) $(STDLIB_INPUTS) \
22
stage2/rustc$(X) stage1/lib/$(CFG_STDLIB) stage2/intrinsics.bc \
33
stage2/glue.o $(LREQ) $(MKFILES)
44
@$(call E, compile_and_link: $@)
5-
$(STAGE2) --lib -o $@ $<
6-
7-
stage2/lib/libstd.rlib: $(STDLIB_CRATE) $(STDLIB_INPUTS) \
8-
stage2/rustc$(X) stage1/lib/$(CFG_STDLIB) stage2/intrinsics.bc \
9-
stage2/glue.o $(LREQ) $(MKFILES)
10-
@$(call E, compile_and_link: $@)
11-
$(STAGE2) --lib --static -o $@ $<
5+
$(STAGE2) --shared -o $@ $<
126

137
stage2/lib/glue.o: stage2/rustc$(X) stage1/lib/$(CFG_STDLIB) \
148
stage2/intrinsics.bc rustllvm/$(CFG_RUSTLLVM) rt/$(CFG_RUNTIME)

trunk/mk/stage3.mk

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@ stage3/lib/$(CFG_STDLIB): $(STDLIB_CRATE) $(STDLIB_INPUTS) \
22
stage3/rustc$(X) stage2/lib/$(CFG_STDLIB) stage3/intrinsics.bc \
33
stage3/glue.o $(LREQ) $(MKFILES)
44
@$(call E, compile_and_link: $@)
5-
$(STAGE3) --lib -o $@ $<
6-
7-
stage3/lib/libstd.rlib: $(STDLIB_CRATE) $(STDLIB_INPUTS) \
8-
stage3/rustc$(X) stage2/lib/$(CFG_STDLIB) stage3/intrinsics.bc \
9-
stage3/glue.o $(LREQ) $(MKFILES)
10-
@$(call E, compile_and_link: $@)
11-
$(STAGE3) --lib --static -o $@ $<
5+
$(STAGE3) --shared -o $@ $<
126

137
stage3/lib/glue.o: stage3/rustc$(X) stage2/lib/$(CFG_STDLIB) \
148
stage3/intrinsics.bc rustllvm/$(CFG_RUSTLLVM) rt/$(CFG_RUNTIME)

trunk/mk/tests.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ test/$(FT).rc test/$(FT_DRIVER).rs: $(TEST_RPASS_SOURCES_STAGE2) \
208208

209209
stage2/lib/$(FT_LIB): test/$(FT).rc $(SREQ2)
210210
@$(call E, compile_and_link: $@)
211-
$(STAGE2) --lib -o $@ $<
211+
$(STAGE2) --shared -o $@ $<
212212

213213
test/$(FT_DRIVER)$(X): test/$(FT_DRIVER).rs stage2/lib/$(FT_LIB) $(SREQ2)
214214
@$(call E, compile_and_link: $@)

trunk/src/comp/back/link.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import lib::llvm::llvm;
44
import front::attr;
55
import middle::trans;
66
import middle::ty;
7-
import metadata::encoder;
87
import std::str;
98
import std::fs;
109
import std::vec;
@@ -349,7 +348,7 @@ fn build_link_meta(&session::session sess, &ast::crate c,
349348
}
350349

351350
fn warn_missing(&session::session sess, str name, str default) {
352-
if (!sess.get_opts().library) { ret; }
351+
if (!sess.get_opts().shared) { ret; }
353352
sess.warn(#fmt("missing crate link meta '%s', using '%s' as default",
354353
name, default));
355354
}
@@ -402,13 +401,17 @@ fn symbol_hash(ty::ctxt tcx, sha1 sha, &ty::t t,
402401
// NB: do *not* use abbrevs here as we want the symbol names
403402
// to be independent of one another in the crate.
404403

404+
auto cx =
405+
@rec(ds=metadata::encoder::def_to_str,
406+
tcx=tcx,
407+
abbrevs=metadata::tyencode::ac_no_abbrevs);
405408
sha.reset();
406409
sha.input_str(link_meta.name);
407410
sha.input_str("-");
408411
// FIXME: This wants to be link_meta.meta_hash
409412
sha.input_str(link_meta.name);
410413
sha.input_str("-");
411-
sha.input_str(encoder::encoded_ty(tcx, t));
414+
sha.input_str(metadata::tyencode::ty_str(cx, t));
412415
auto hash = truncated_sha1_result(sha);
413416
// Prefix with _ so that it never blends into adjacent digits
414417

trunk/src/comp/driver/rustc.rs

Lines changed: 84 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ options:
213213
214214
-o <filename> write output to <filename>
215215
--glue generate glue.bc file
216-
--lib compile a library crate
217-
--static use or produce static libraries
216+
--shared compile a shared-library crate
218217
--pretty [type] pretty-print the input instead of compiling
219218
--ls list the symbols defined by a crate file
220219
-L <path> add a directory to the library search path
@@ -282,8 +281,7 @@ fn build_target_config() -> @session::config {
282281

283282
fn build_session_options(str binary, getopts::match match, str binary_dir) ->
284283
@session::options {
285-
auto library = opt_present(match, "lib");
286-
auto static = opt_present(match, "static");
284+
auto shared = opt_present(match, "shared");
287285
auto library_search_paths = [binary_dir + "/lib"];
288286
library_search_paths += getopts::opt_strs(match, "L");
289287
auto output_type =
@@ -332,8 +330,7 @@ fn build_session_options(str binary, getopts::match match, str binary_dir) ->
332330
auto cfg = parse_cfgspecs(getopts::opt_strs(match, "cfg"));
333331
auto test = opt_present(match, "test");
334332
let @session::options sopts =
335-
@rec(library=library,
336-
static=static,
333+
@rec(shared=shared,
337334
optimize=opt_level,
338335
debuginfo=debuginfo,
339336
verify=verify,
@@ -372,12 +369,11 @@ fn main(vec[str] args) {
372369
[optflag("h"), optflag("help"), optflag("v"), optflag("version"),
373370
optflag("glue"), optflag("emit-llvm"), optflagopt("pretty"),
374371
optflag("ls"), optflag("parse-only"), optflag("O"),
375-
optopt("OptLevel"), optmulti("L"), optflag("S"),
372+
optopt("OptLevel"), optflag("shared"), optmulti("L"), optflag("S"),
376373
optflag("c"), optopt("o"), optflag("g"), optflag("save-temps"),
377374
optopt("sysroot"), optflag("stats"), optflag("time-passes"),
378375
optflag("time-llvm-passes"), optflag("no-typestate"),
379-
optflag("noverify"), optmulti("cfg"), optflag("test"),
380-
optflag("lib"), optflag("static")];
376+
optflag("noverify"), optmulti("cfg"), optflag("test")];
381377
auto binary = vec::shift[str](args);
382378
auto binary_dir = fs::dirname(binary);
383379
auto match =
@@ -457,10 +453,13 @@ fn main(vec[str] args) {
457453

458454
saved_out_filename = ofile;
459455
auto temp_filename;
460-
if (sopts.output_type == link::output_type_exe && !sopts.static) {
461-
temp_filename = ofile + ".o";
462-
} else {
463-
temp_filename = ofile;
456+
alt (sopts.output_type) {
457+
case (link::output_type_exe) {
458+
// FIXME: what about shared?
459+
460+
temp_filename = ofile + ".o";
461+
}
462+
case (_) { temp_filename = ofile; }
464463
}
465464
compile_input(sess, cfg, ifile, temp_filename);
466465
}
@@ -470,90 +469,88 @@ fn main(vec[str] args) {
470469
// gcc to link the object file with some libs
471470
//
472471
// TODO: Factor this out of main.
473-
if (sopts.output_type != link::output_type_exe || sopts.static) {
474-
ret;
475-
}
476-
477-
let str glu = binary_dir + "/lib/glue.o";
478-
let str main = "rt/main.o";
479-
let str stage = "-L" + binary_dir + "/lib";
480-
let str prog = "gcc";
481-
// The invocations of gcc share some flags across platforms
482-
483-
let vec[str] gcc_args =
484-
[stage, "-Lrt", "-lrustrt", glu, "-m32", "-o",
485-
saved_out_filename, saved_out_filename + ".o"];
486-
auto lib_cmd;
487-
488-
auto os = sess.get_targ_cfg().os;
489-
if (os == session::os_macos) {
490-
lib_cmd = "-dynamiclib";
491-
} else {
492-
lib_cmd = "-shared";
493-
}
472+
if (sopts.output_type == link::output_type_exe) {
473+
let str glu = binary_dir + "/lib/glue.o";
474+
let str main = "rt/main.o";
475+
let str stage = "-L" + binary_dir + "/lib";
476+
let str prog = "gcc";
477+
// The invocations of gcc share some flags across platforms
478+
479+
let vec[str] gcc_args =
480+
[stage, "-Lrt", "-lrustrt", glu, "-m32", "-o",
481+
saved_out_filename, saved_out_filename + ".o"];
482+
auto shared_cmd;
483+
484+
auto os = sess.get_targ_cfg().os;
485+
if (os == session::os_macos) {
486+
shared_cmd = "-dynamiclib";
487+
} else {
488+
shared_cmd = "-shared";
489+
}
494490

495-
// Converts a library file name into a gcc -l argument
496-
fn unlib(@session::config config, str filename) -> str {
497-
auto rmlib = bind fn(@session::config config,
498-
str filename) -> str {
499-
if (config.os == session::os_macos
500-
|| config.os == session::os_linux
501-
&& str::find(filename, "lib") == 0) {
502-
ret str::slice(filename, 3u, str::byte_len(filename));
503-
} else {
504-
ret filename;
491+
// Converts a library file name into a gcc -l argument
492+
fn unlib(@session::config config, str filename) -> str {
493+
auto rmlib = bind fn(@session::config config,
494+
str filename) -> str {
495+
if (config.os == session::os_macos
496+
|| config.os == session::os_linux
497+
&& str::find(filename, "lib") == 0) {
498+
ret str::slice(filename, 3u, str::byte_len(filename));
499+
} else {
500+
ret filename;
501+
}
502+
} (config, _);
503+
fn rmext(str filename) -> str {
504+
auto parts = str::split(filename, '.' as u8);
505+
vec::pop(parts);
506+
ret str::connect(parts, ".");
505507
}
506-
} (config, _);
507-
fn rmext(str filename) -> str {
508-
auto parts = str::split(filename, '.' as u8);
509-
vec::pop(parts);
510-
ret str::connect(parts, ".");
508+
ret alt (config.os) {
509+
case (session::os_macos) { rmext(rmlib(filename)) }
510+
case (session::os_linux) { rmext(rmlib(filename)) }
511+
case (_) { rmext(filename) }
512+
};
511513
}
512-
ret alt (config.os) {
513-
case (session::os_macos) { rmext(rmlib(filename)) }
514-
case (session::os_linux) { rmext(rmlib(filename)) }
515-
case (_) { rmext(filename) }
516-
};
517-
}
518514

519-
for (str cratepath in sess.get_used_crate_files()) {
520-
auto dir = fs::dirname(cratepath);
521-
if (dir != "") {
522-
gcc_args += ["-L" + dir];
515+
for (str cratepath in sess.get_used_crate_files()) {
516+
auto dir = fs::dirname(cratepath);
517+
if (dir != "") {
518+
gcc_args += ["-L" + dir];
519+
}
520+
auto libarg = unlib(sess.get_targ_cfg(), fs::basename(cratepath));
521+
gcc_args += ["-l" + libarg];
523522
}
524-
auto libarg = unlib(sess.get_targ_cfg(), fs::basename(cratepath));
525-
gcc_args += ["-l" + libarg];
526-
}
527523

528-
gcc_args += sess.get_used_link_args();
529-
auto used_libs = sess.get_used_libraries();
530-
for (str l in used_libs) {
531-
gcc_args += ["-l" + l];
532-
}
524+
gcc_args += sess.get_used_link_args();
525+
auto used_libs = sess.get_used_libraries();
526+
for (str l in used_libs) {
527+
gcc_args += ["-l" + l];
528+
}
533529

534-
if (sopts.library) {
535-
gcc_args += [lib_cmd];
536-
} else {
537-
// FIXME: why do we hardcode -lm?
538-
gcc_args += ["-lm", main];
539-
}
540-
// We run 'gcc' here
530+
if (sopts.shared) {
531+
gcc_args += [shared_cmd];
532+
} else {
533+
// FIXME: why do we hardcode -lm?
534+
gcc_args += ["-lm", main];
535+
}
536+
// We run 'gcc' here
541537

542-
auto err_code = run::run_program(prog, gcc_args);
543-
if (0 != err_code) {
544-
sess.err(#fmt("linking with gcc failed with code %d", err_code));
545-
sess.note(#fmt("gcc arguments: %s", str::connect(gcc_args, " ")));
546-
sess.abort_if_errors();
547-
}
548-
// Clean up on Darwin
538+
auto err_code = run::run_program(prog, gcc_args);
539+
if (0 != err_code) {
540+
sess.err(#fmt("linking with gcc failed with code %d", err_code));
541+
sess.note(#fmt("gcc arguments: %s", str::connect(gcc_args, " ")));
542+
sess.abort_if_errors();
543+
}
544+
// Clean up on Darwin
549545

550-
if (sess.get_targ_cfg().os == session::os_macos) {
551-
run::run_program("dsymutil", [saved_out_filename]);
552-
}
546+
if (sess.get_targ_cfg().os == session::os_macos) {
547+
run::run_program("dsymutil", [saved_out_filename]);
548+
}
553549

554-
// Remove the temporary object file if we aren't saving temps
555-
if (!sopts.save_temps) {
556-
run::run_program("rm", [saved_out_filename + ".o"]);
550+
// Remove the temporary object file if we aren't saving temps
551+
if (!sopts.save_temps) {
552+
run::run_program("rm", [saved_out_filename + ".o"]);
553+
}
557554
}
558555
}
559556
// Local Variables:

trunk/src/comp/driver/session.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ type config =
2323
ty_mach float_type);
2424

2525
type options =
26-
rec(bool library,
27-
bool static,
26+
rec(bool shared,
2827
uint optimize,
2928
bool debuginfo,
3029
bool verify,

trunk/src/comp/front/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ fn filter_stmt(&ast::crate_cfg cfg,
8282
fn fold_block(&ast::crate_cfg cfg, &ast::block_ b,
8383
fold::ast_fold fld) -> ast::block_ {
8484
auto filter = bind filter_stmt(cfg, _);
85-
auto filtered_stmts = ivec::filter_map(filter, b.stmts);
86-
ret rec(stmts=ivec::map(fld.fold_stmt, filtered_stmts),
85+
auto filtered_stmts = vec::filter_map(filter, b.stmts);
86+
ret rec(stmts=vec::map(fld.fold_stmt, filtered_stmts),
8787
expr=option::map(fld.fold_expr, b.expr),
8888
id=b.id);
8989
}

trunk/src/comp/front/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ fn mk_main(&test_ctxt cx) -> @ast::item {
7171
auto ret_ty = @rec(node=ast::ty_nil,
7272
span=rec(lo=0u, hi=0u));
7373

74-
let ast::fn_decl decl = rec(inputs = ~[],
74+
let ast::fn_decl decl = rec(inputs = [],
7575
output = ret_ty,
7676
purity = ast::impure_fn,
7777
cf = ast::return,
7878
constraints = ~[]);
7979
auto proto = ast::proto_fn;
8080

81-
let ast::block_ body_ = rec(stmts = ~[],
81+
let ast::block_ body_ = rec(stmts = [],
8282
expr = option::none,
8383
id = cx.next_node_id());
8484
auto body = rec(node = body_, span = rec(lo=0u, hi=0u));
@@ -87,7 +87,7 @@ fn mk_main(&test_ctxt cx) -> @ast::item {
8787
proto = proto,
8888
body = body);
8989

90-
auto item_ = ast::item_fn(fn_, ~[]);
90+
auto item_ = ast::item_fn(fn_, []);
9191
let ast::item item = rec(ident = "main",
9292
attrs = ~[],
9393
id = cx.next_node_id(),

trunk/src/comp/metadata/creader.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import std::option::none;
2323
import std::option::some;
2424
import std::map::hashmap;
2525
import syntax::print::pprust;
26-
import common::*;
26+
import tags::*;
2727

2828
export read_crates;
2929
export list_file_metadata;

0 commit comments

Comments
 (0)