Skip to content

Commit b80e251

Browse files
author
auREAX
committed
---
yaml --- r: 31013 b: refs/heads/incoming c: 26ed387 h: refs/heads/master i: 31011: a24cfda v: v3
1 parent 7165158 commit b80e251

Some content is hidden

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

49 files changed

+119
-111
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: d324a424d8f84b1eb049b12cf34182bda91b0024
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
9-
refs/heads/incoming: edc317b8212fe1c29b5e7e2e4e260b9a4d72b447
9+
refs/heads/incoming: 26ed387d7faec2e86289855098f08c56986e2568
1010
refs/heads/dist-snap: 2f32a1581f522e524009138b33b1c7049ced668d
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/configure

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ opt manage-submodules 1 "let the build manage the git submodules"
295295
opt mingw-cross 0 "cross-compile for win32 using mingw"
296296
opt clang 0 "prefer clang to gcc for building the runtime"
297297
opt local-rust 0 "use an installed rustc rather than downloading a snapshot"
298-
opt pax-marks 0 "apply PaX markings to rustc binaries (required for GRSecurity/PaX-patched kernels)"
298+
opt pax-flags 0 "apply PaX flags to rustc binaries (required for GRSecurity/PaX-patched kernels)"
299299
valopt prefix "/usr/local" "set installation prefix"
300300
valopt local-rust-root "/usr/local" "set prefix for local rust binary"
301301
valopt llvm-root "" "set LLVM root"
@@ -344,8 +344,11 @@ probe CFG_PDFLATEX pdflatex
344344
probe CFG_XETEX xetex
345345
probe CFG_LUATEX luatex
346346
probe CFG_NODE nodejs node
347-
probe CFG_PAXCTL paxctl /sbin/paxctl
348-
probe CFG_ZCAT zcat
347+
if [ "$CFG_OSTYPE" = "unknown-linux-gnu" ]
348+
then
349+
probe CFG_PAXCTL paxctl /sbin/paxctl
350+
probe CFG_ZCAT zcat
351+
fi
349352

350353
if [ ! -z "$CFG_PANDOC" ]
351354
then
@@ -359,19 +362,18 @@ fi
359362

360363
if [ "$CFG_OSTYPE" = "unknown-linux-gnu" ]
361364
then
362-
if [ ! -z "$CFG_ENABLE_PAX_MARKS" -a -z "$CFG_PAXCTL" ]
365+
if [ ! -z "$CFG_ENABLE_PAX_FLAGS" -a -z "$CFG_PAXCTL" ]
363366
then
364367
err "enabled PaX markings but no paxctl binary found"
365368
fi
366369

367-
if [ -z "$CFG_DISABLE_PAX_MARKS" ]
370+
if [ -z "$CFG_DISABLE_PAX_FLAGS" ]
368371
then
369372
# GRSecurity/PaX detection. This can be very flaky.
370373
GRSEC_DETECTED=
371374

372375
# /dev/grsec only exists if CONFIG_GRKERNSEC_NO_RBAC is not set.
373-
# /proc is normally only available to root and users in the CONFIG_GRKERNSEC_PROC_GID group,
374-
# and /proc/sys/kernel/grsecurity is not available if ÇONFIG_GRKERNSEC_SYSCTL is not set.
376+
# /proc/sys/kernel/grsecurity is not available if ÇONFIG_GRKERNSEC_SYSCTL is not set.
375377
if [ -e /dev/grsec -o -d /proc/sys/kernel/grsecurity ]
376378
then
377379
GRSEC_DETECTED=1
@@ -393,9 +395,9 @@ then
393395
step_msg "GRSecurity: yes"
394396
if [ ! -z "$CFG_PAXCTL" ]
395397
then
396-
CFG_ENABLE_PAX_MARKS=1
398+
CFG_ENABLE_PAX_FLAGS=1
397399
else
398-
warn "GRSecurity kernel detected but no paxctl binary found: not setting CFG_ENABLE_PAX_MARKS"
400+
warn "GRSecurity kernel detected but no paxctl binary found: not setting CFG_ENABLE_PAX_FLAGS"
399401
fi
400402
else
401403
step_msg "GRSecurity: no"
@@ -748,9 +750,9 @@ putvar CFG_C_COMPILER
748750
putvar CFG_LIBDIR
749751
putvar CFG_DISABLE_MANAGE_SUBMODULES
750752

751-
if [ ! -z "$CFG_ENABLE_PAX_MARKS" ]
753+
if [ ! -z "$CFG_ENABLE_PAX_FLAGS" ]
752754
then
753-
putvar CFG_ENABLE_PAX_MARKS
755+
putvar CFG_ENABLE_PAX_FLAGS
754756
putvar CFG_PAXCTL
755757
fi
756758

branches/incoming/mk/stage0.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ ifdef CFG_ENABLE_LOCAL_RUST
1212
$(Q)$(S)src/etc/local_stage0.sh $(CFG_HOST_TRIPLE) $(CFG_LOCAL_RUST_ROOT)
1313
else
1414
$(Q)$(S)src/etc/get-snapshot.py $(CFG_HOST_TRIPLE) $(SNAPSHOT_FILE)
15-
ifdef CFG_ENABLE_PAX_MARKS
16-
@$(call E, apply PaX markings: $@)
15+
ifdef CFG_ENABLE_PAX_FLAGS
16+
@$(call E, apply PaX flags: $@)
1717
@"$(CFG_PAXCTL)" -cm "$@"
1818
endif
1919
endif

branches/incoming/mk/target.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X): \
2929
$$(TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3))
3030
@$$(call E, compile_and_link: $$@)
3131
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$<
32-
ifdef CFG_ENABLE_PAX_MARKS
33-
@$$(call E, apply PaX markings: $$@)
32+
ifdef CFG_ENABLE_PAX_FLAGS
33+
@$$(call E, apply PaX flags: $$@)
3434
@"$(CFG_PAXCTL)" -cm "$$@"
3535
endif
3636

branches/incoming/src/cargo/cargo.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,8 +1889,7 @@ Commands:
18891889
set-method Change the method for a source.");
18901890
}
18911891

1892-
fn main() {
1893-
let argv = os::args();
1892+
fn main(argv: ~[~str]) {
18941893
let o = build_cargo_options(argv);
18951894

18961895
if vec::len(o.free) < 2u {

branches/incoming/src/compiletest/compiletest.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ use common::mode_pretty;
1212
use common::mode;
1313
use util::logv;
1414

15-
fn main() {
16-
let args = os::args();
15+
fn main(++args: ~[~str]) {
1716
let config = parse_config(args);
1817
log_config(config);
1918
run_tests(config);

branches/incoming/src/etc/combine-tests.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def scrub(b):
1919
run_pass = os.path.join(src_dir, "src", "test", "run-pass")
2020
run_pass = os.path.abspath(run_pass)
2121
stage2_tests = []
22+
take_args = {}
2223

2324
for t in os.listdir(run_pass):
2425
if t.endswith(".rs") and not (
@@ -29,6 +30,8 @@ def scrub(b):
2930
"xfail-fast" in s or
3031
"xfail-win32" in s):
3132
stage2_tests.append(t)
33+
if "fn main(args:" in s or "fn main(++args:" in s:
34+
take_args[t] = True
3235
f.close()
3336

3437
stage2_tests.sort()
@@ -61,6 +64,9 @@ def scrub(b):
6164
p = os.path.join("test", "run-pass", t)
6265
p = p.replace("\\", "\\\\")
6366
d.write(" out.write_str(~\"run-pass [stage2]: %s\\n\");\n" % p)
64-
d.write(" t_%d::main();\n" % i)
67+
if t in take_args:
68+
d.write(" t_%d::main(~[~\"arg0\"]);\n" % i)
69+
else:
70+
d.write(" t_%d::main();\n" % i)
6571
i += 1
6672
d.write("}\n")

branches/incoming/src/fuzzer/fuzzer.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,8 +599,7 @@ fn check_variants(files: &[Path], cx: context) {
599599
}
600600
}
601601

602-
fn main() {
603-
let args = os::args();
602+
fn main(args: ~[~str]) {
604603
if vec::len(args) != 2u {
605604
error!("usage: %s <testdir>", args[0]);
606605
return;

branches/incoming/src/rustc/driver/rustc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,7 @@ fn monitor(+f: fn~(diagnostic::emitter)) {
277277
}
278278
}
279279

280-
fn main() {
281-
let args = os::args();
280+
fn main(args: ~[~str]) {
282281
do monitor |demitter| {
283282
run_compiler(args, demitter);
284283
}

branches/incoming/src/rustc/front/test.rs

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,34 @@ fn mk_test_wrapper(cx: test_ctxt,
415415
}
416416

417417
fn mk_main(cx: test_ctxt) -> @ast::item {
418+
let str_pt = path_node(~[cx.sess.ident_of(~"str")]);
419+
let str_ty_inner = @{id: cx.sess.next_node_id(),
420+
node: ast::ty_path(str_pt, cx.sess.next_node_id()),
421+
span: dummy_sp()};
422+
let str_ty = @{id: cx.sess.next_node_id(),
423+
node: ast::ty_uniq({ty: str_ty_inner, mutbl: ast::m_imm}),
424+
span: dummy_sp()};
425+
let args_mt = {ty: str_ty, mutbl: ast::m_imm};
426+
let args_ty_inner = @{id: cx.sess.next_node_id(),
427+
node: ast::ty_vec(args_mt),
428+
span: dummy_sp()};
429+
let args_ty = {id: cx.sess.next_node_id(),
430+
node: ast::ty_uniq({ty: args_ty_inner, mutbl: ast::m_imm}),
431+
span: dummy_sp()};
432+
433+
434+
let args_arg: ast::arg =
435+
{mode: ast::expl(ast::by_val),
436+
ty: @args_ty,
437+
ident: cx.sess.ident_of(~"args"),
438+
id: cx.sess.next_node_id()};
439+
418440
let ret_ty = {id: cx.sess.next_node_id(),
419441
node: ast::ty_nil,
420442
span: dummy_sp()};
421443

422444
let decl: ast::fn_decl =
423-
{inputs: ~[],
445+
{inputs: ~[args_arg],
424446
output: @ret_ty,
425447
cf: ast::return_val};
426448

@@ -443,24 +465,16 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
443465
}
444466

445467
fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
446-
// Call os::args to generate the vector of test_descs
447-
let args_path = path_node(~[
448-
cx.sess.ident_of(~"os"),
449-
cx.sess.ident_of(~"args")
450-
]);
468+
469+
// Get the args passed to main so we can pass the to test_main
470+
let args_path = path_node(~[cx.sess.ident_of(~"args")]);
451471

452472
let args_path_expr_: ast::expr_ = ast::expr_path(args_path);
453473

454474
let args_path_expr: ast::expr =
455475
{id: cx.sess.next_node_id(), callee_id: cx.sess.next_node_id(),
456476
node: args_path_expr_, span: dummy_sp()};
457477

458-
let args_call_expr_ = ast::expr_call(@args_path_expr, ~[], false);
459-
460-
let args_call_expr: ast::expr =
461-
{id: cx.sess.next_node_id(), callee_id: cx.sess.next_node_id(),
462-
node: args_call_expr_, span: dummy_sp()};
463-
464478
// Call __test::test to generate the vector of test_descs
465479
let test_path = path_node(~[cx.sess.ident_of(~"tests")]);
466480

@@ -489,7 +503,7 @@ fn mk_test_main_call(cx: test_ctxt) -> @ast::expr {
489503

490504
let test_main_call_expr_: ast::expr_ =
491505
ast::expr_call(@test_main_path_expr,
492-
~[@args_call_expr, @test_call_expr], false);
506+
~[@args_path_expr, @test_call_expr], false);
493507

494508
let test_main_call_expr: ast::expr =
495509
{id: cx.sess.next_node_id(), callee_id: cx.sess.next_node_id(),

branches/incoming/src/rustc/middle/trans/base.rs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1953,23 +1953,32 @@ fn register_fn_fuller(ccx: @crate_ctxt, sp: span, path: path,
19531953
ast_map::path_to_str(path, ccx.sess.parse_sess.interner));
19541954

19551955
let is_main = is_main_name(path) && !ccx.sess.building_library;
1956-
if is_main { create_main_wrapper(ccx, sp, llfn); }
1956+
if is_main { create_main_wrapper(ccx, sp, llfn, node_type); }
19571957
llfn
19581958
}
19591959

19601960
// Create a _rust_main(args: ~[str]) function which will be called from the
19611961
// runtime rust_start function
1962-
fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef) {
1962+
fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef,
1963+
main_node_type: ty::t) {
19631964

19641965
if ccx.main_fn != None::<ValueRef> {
19651966
ccx.sess.span_fatal(sp, ~"multiple 'main' functions");
19661967
}
19671968

1968-
let llfn = create_main(ccx, main_llfn);
1969+
let main_takes_argv =
1970+
// invariant!
1971+
match ty::get(main_node_type).sty {
1972+
ty::ty_fn(ref fn_ty) => fn_ty.sig.inputs.len() != 0u,
1973+
_ => ccx.sess.span_fatal(sp, ~"main has a non-function type")
1974+
};
1975+
1976+
let llfn = create_main(ccx, main_llfn, main_takes_argv);
19691977
ccx.main_fn = Some(llfn);
19701978
create_entry_fn(ccx, llfn);
19711979

1972-
fn create_main(ccx: @crate_ctxt, main_llfn: ValueRef) -> ValueRef {
1980+
fn create_main(ccx: @crate_ctxt, main_llfn: ValueRef,
1981+
takes_argv: bool) -> ValueRef {
19731982
let unit_ty = ty::mk_estr(ccx.tcx, ty::vstore_uniq);
19741983
let vecarg_ty: ty::arg =
19751984
{mode: ast::expl(ast::by_val),
@@ -1989,6 +1998,9 @@ fn create_main_wrapper(ccx: @crate_ctxt, sp: span, main_llfn: ValueRef) {
19891998
let lloutputarg = llvm::LLVMGetParam(llfdecl, 0 as c_uint);
19901999
let llenvarg = llvm::LLVMGetParam(llfdecl, 1 as c_uint);
19912000
let mut args = ~[lloutputarg, llenvarg];
2001+
if takes_argv {
2002+
args.push(llvm::LLVMGetParam(llfdecl, 2 as c_uint));
2003+
}
19922004
Call(bcx, main_llfn, args);
19932005

19942006
build_return(bcx);

branches/incoming/src/rustc/middle/typeck.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,14 @@ fn check_main_fn_ty(ccx: @crate_ctxt,
301301
}
302302
let mut ok = ty::type_is_nil(fn_ty.sig.output);
303303
let num_args = vec::len(fn_ty.sig.inputs);
304-
ok &= num_args == 0u;
304+
ok &= num_args == 0u || num_args == 1u &&
305+
arg_is_argv_ty(tcx, fn_ty.sig.inputs[0]);
305306
if !ok {
306307
tcx.sess.span_err(
307308
main_span,
308309
fmt!("Wrong type in main function: found `%s`, \
309-
expected `fn() -> ()`",
310+
expected `extern fn(++v: ~[~str]) -> ()` \
311+
or `extern fn() -> ()`",
310312
ty_to_str(tcx, main_t)));
311313
}
312314
}

branches/incoming/src/rustdoc/rustdoc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ use doc::Item;
33
use pass::Pass;
44
use config::Config;
55

6-
fn main() {
7-
let args = os::args();
6+
fn main(args: ~[~str]) {
87

98
if args.contains(&~"-h") || args.contains(&~"--help") {
109
config::usage();

branches/incoming/src/test/bench/core-map.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ fn empty_results() -> Results {
142142
}
143143
}
144144

145-
fn main() {
146-
let args = os::args();
145+
fn main(++args: ~[~str]) {
147146
let num_keys = {
148147
if args.len() == 2 {
149148
uint::from_str(args[1]).get()

branches/incoming/src/test/bench/core-std.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ use std::map::{Map, HashMap};
88

99
use io::{Reader, ReaderUtil};
1010

11-
fn main() {
12-
let argv = os::args();
11+
fn main(++argv: ~[~str]) {
1312
#macro[
1413
[#bench[id],
1514
maybe_run_test(argv, #stringify(id), id)

branches/incoming/src/test/bench/core-uint-to-str.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
fn main() {
2-
let args = os::args();
1+
fn main(++args: ~[~str]) {
32
let args = if os::getenv(~"RUST_BENCH").is_some() {
43
~[~"", ~"10000000"]
54
} else if args.len() <= 1u {

branches/incoming/src/test/bench/core-vec-append.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ fn collect_dvec(num: uint) -> ~[uint] {
2020
return dvec::unwrap(move result);
2121
}
2222

23-
fn main() {
24-
let args = os::args();
23+
fn main(++args: ~[~str]) {
2524
let args = if os::getenv(~"RUST_BENCH").is_some() {
2625
~[~"", ~"50000000"]
2726
} else if args.len() <= 1u {

branches/incoming/src/test/bench/graph500-bfs.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,7 @@ fn validate(edges: ~[(node_id, node_id)],
384384
true
385385
}
386386
387-
fn main() {
388-
let args = os::args();
387+
fn main(++args: ~[~str]) {
389388
let args = if os::getenv(~"RUST_BENCH").is_some() {
390389
~[~"", ~"15", ~"48"]
391390
} else if args.len() <= 1u {

branches/incoming/src/test/bench/msgsend-pipes-shared.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,7 @@ fn run(args: &[~str]) {
9090
assert result == num_bytes * size;
9191
}
9292

93-
fn main() {
94-
let args = os::args();
93+
fn main(++args: ~[~str]) {
9594
let args = if os::getenv(~"RUST_BENCH").is_some() {
9695
~[~"", ~"1000000", ~"10000"]
9796
} else if args.len() <= 1u {

branches/incoming/src/test/bench/msgsend-pipes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ fn run(args: &[~str]) {
8787
assert result == num_bytes * size;
8888
}
8989

90-
fn main() {
91-
let args = os::args();
90+
fn main(++args: ~[~str]) {
9291
let args = if os::getenv(~"RUST_BENCH").is_some() {
9392
~[~"", ~"1000000", ~"8"]
9493
} else if args.len() <= 1u {

branches/incoming/src/test/bench/msgsend-ring-mutex-arcs.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ fn thread_ring(i: uint,
5656
};
5757
}
5858

59-
fn main() {
60-
let args = os::args();
59+
fn main(++args: ~[~str]) {
6160
let args = if os::getenv(~"RUST_BENCH").is_some() {
6261
~[~"", ~"100", ~"10000"]
6362
} else if args.len() <= 1u {

0 commit comments

Comments
 (0)