Skip to content

Commit 7dd632f

Browse files
committed
---
yaml --- r: 3691 b: refs/heads/master c: deca79f h: refs/heads/master i: 3689: 4c99473 3687: e8f4e5a v: v3
1 parent 2287342 commit 7dd632f

Some content is hidden

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

45 files changed

+804
-724
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: f6117173c9f26efdcf50cb664d006ea2bdf0d0cb
2+
refs/heads/master: deca79f37256b359139822f0f8706ac7c3cce26f

trunk/mk/snap.mk

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

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

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

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

trunk/mk/stage1.mk

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ 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) --shared -o $@ $<
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 $@ $<
612

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

trunk/mk/stage2.mk

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ 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) --shared -o $@ $<
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 $@ $<
612

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

trunk/mk/stage3.mk

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ 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) --shared -o $@ $<
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 $@ $<
612

713
stage3/lib/glue.o: stage3/rustc$(X) stage2/lib/$(CFG_STDLIB) \
814
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) --shared -o $@ $<
211+
$(STAGE2) --lib -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: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import lib::llvm::llvm;
44
import front::attr;
55
import middle::trans;
66
import middle::ty;
7+
import metadata::encoder;
78
import std::str;
89
import std::fs;
910
import std::vec;
@@ -348,7 +349,7 @@ fn build_link_meta(&session::session sess, &ast::crate c,
348349
}
349350

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

404-
auto cx =
405-
@rec(ds=metadata::encoder::def_to_str,
406-
tcx=tcx,
407-
abbrevs=metadata::tyencode::ac_no_abbrevs);
408405
sha.reset();
409406
sha.input_str(link_meta.name);
410407
sha.input_str("-");
411408
// FIXME: This wants to be link_meta.meta_hash
412409
sha.input_str(link_meta.name);
413410
sha.input_str("-");
414-
sha.input_str(metadata::tyencode::ty_str(cx, t));
411+
sha.input_str(encoder::encoded_ty(tcx, t));
415412
auto hash = truncated_sha1_result(sha);
416413
// Prefix with _ so that it never blends into adjacent digits
417414

trunk/src/comp/driver/rustc.rs

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

282283
fn build_session_options(str binary, getopts::match match, str binary_dir) ->
283284
@session::options {
284-
auto shared = opt_present(match, "shared");
285+
auto library = opt_present(match, "lib");
286+
auto static = opt_present(match, "static");
285287
auto library_search_paths = [binary_dir + "/lib"];
286288
library_search_paths += getopts::opt_strs(match, "L");
287289
auto output_type =
@@ -330,7 +332,8 @@ fn build_session_options(str binary, getopts::match match, str binary_dir) ->
330332
auto cfg = parse_cfgspecs(getopts::opt_strs(match, "cfg"));
331333
auto test = opt_present(match, "test");
332334
let @session::options sopts =
333-
@rec(shared=shared,
335+
@rec(library=library,
336+
static=static,
334337
optimize=opt_level,
335338
debuginfo=debuginfo,
336339
verify=verify,
@@ -369,11 +372,12 @@ fn main(vec[str] args) {
369372
[optflag("h"), optflag("help"), optflag("v"), optflag("version"),
370373
optflag("glue"), optflag("emit-llvm"), optflagopt("pretty"),
371374
optflag("ls"), optflag("parse-only"), optflag("O"),
372-
optopt("OptLevel"), optflag("shared"), optmulti("L"), optflag("S"),
375+
optopt("OptLevel"), optmulti("L"), optflag("S"),
373376
optflag("c"), optopt("o"), optflag("g"), optflag("save-temps"),
374377
optopt("sysroot"), optflag("stats"), optflag("time-passes"),
375378
optflag("time-llvm-passes"), optflag("no-typestate"),
376-
optflag("noverify"), optmulti("cfg"), optflag("test")];
379+
optflag("noverify"), optmulti("cfg"), optflag("test"),
380+
optflag("lib"), optflag("static")];
377381
auto binary = vec::shift[str](args);
378382
auto binary_dir = fs::dirname(binary);
379383
auto match =
@@ -453,13 +457,10 @@ fn main(vec[str] args) {
453457

454458
saved_out_filename = ofile;
455459
auto temp_filename;
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; }
460+
if (sopts.output_type == link::output_type_exe && !sopts.static) {
461+
temp_filename = ofile + ".o";
462+
} else {
463+
temp_filename = ofile;
463464
}
464465
compile_input(sess, cfg, ifile, temp_filename);
465466
}
@@ -469,88 +470,90 @@ fn main(vec[str] args) {
469470
// gcc to link the object file with some libs
470471
//
471472
// TODO: Factor this out of main.
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-
}
473+
if (sopts.output_type != link::output_type_exe || sopts.static) {
474+
ret;
475+
}
490476

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, ".");
507-
}
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-
};
513-
}
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+
}
514494

515-
for (str cratepath in sess.get_used_crate_files()) {
516-
auto dir = fs::dirname(cratepath);
517-
if (dir != "") {
518-
gcc_args += ["-L" + dir];
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;
519505
}
520-
auto libarg = unlib(sess.get_targ_cfg(), fs::basename(cratepath));
521-
gcc_args += ["-l" + libarg];
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, ".");
522511
}
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+
}
523518

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];
519+
for (str cratepath in sess.get_used_crate_files()) {
520+
auto dir = fs::dirname(cratepath);
521+
if (dir != "") {
522+
gcc_args += ["-L" + dir];
528523
}
524+
auto libarg = unlib(sess.get_targ_cfg(), fs::basename(cratepath));
525+
gcc_args += ["-l" + libarg];
526+
}
529527

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
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+
}
537533

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
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
545541

546-
if (sess.get_targ_cfg().os == session::os_macos) {
547-
run::run_program("dsymutil", [saved_out_filename]);
548-
}
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
549549

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-
}
550+
if (sess.get_targ_cfg().os == session::os_macos) {
551+
run::run_program("dsymutil", [saved_out_filename]);
552+
}
553+
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"]);
554557
}
555558
}
556559
// Local Variables:

trunk/src/comp/driver/session.rs

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

2525
type options =
26-
rec(bool shared,
26+
rec(bool library,
27+
bool static,
2728
uint optimize,
2829
bool debuginfo,
2930
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 = vec::filter_map(filter, b.stmts);
86-
ret rec(stmts=vec::map(fld.fold_stmt, filtered_stmts),
85+
auto filtered_stmts = ivec::filter_map(filter, b.stmts);
86+
ret rec(stmts=ivec::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(),

0 commit comments

Comments
 (0)