Skip to content

Commit 638db28

Browse files
z0w0brson
authored andcommitted
jit: Correct formatting and argv[0] for JITted programs
1 parent efb576a commit 638db28

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

src/compiletest/runtest.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ fn run_rfail_test(config: config, props: test_props, testfile: &Path) {
5151
let procres = if !config.jit {
5252
let procres = compile_test(config, props, testfile);
5353

54-
if procres.status != 0 { fatal_procres(~"compilation failed!", procres); }
54+
if procres.status != 0 {
55+
fatal_procres(~"compilation failed!", procres);
56+
}
5557
5658
exec_compiled_test(config, props, testfile)
5759
} else {
@@ -83,11 +85,15 @@ fn run_rpass_test(config: config, props: test_props, testfile: &Path) {
8385
if !config.jit {
8486
let mut procres = compile_test(config, props, testfile);
8587

86-
if procres.status != 0 { fatal_procres(~"compilation failed!", procres); }
88+
if procres.status != 0 {
89+
fatal_procres(~"compilation failed!", procres);
90+
}
8791
8892
procres = exec_compiled_test(config, props, testfile);
8993
90-
if procres.status != 0 { fatal_procres(~"test run failed!", procres); }
94+
if procres.status != 0 {
95+
fatal_procres(~"test run failed!", procres);
96+
}
9197
} else {
9298
let mut procres = jit_test(config, props, testfile);
9399

src/rustc/back/link.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,22 +85,19 @@ mod jit {
8585
m: ModuleRef,
8686
opt: c_int,
8787
stacks: bool) unsafe {
88-
let ptr = llvm::LLVMRustJIT(rusti::morestack_addr(), pm, m, opt, stacks);
88+
let ptr = llvm::LLVMRustJIT(rusti::morestack_addr(),
89+
pm, m, opt, stacks);
8990

9091
if ptr::is_null(ptr) {
9192
llvm_err(sess, ~"Could not JIT");
9293
} else {
93-
let bin = match os::self_exe_path() {
94-
Some(path) => path.to_str(),
95-
_ => ~"rustc"
96-
};
9794
let closure = Closure {
9895
code: ptr,
9996
env: ptr::null()
10097
};
10198
let func: fn(~[~str]) = unsafe::transmute(closure);
10299

103-
func(~[bin]);
100+
func(~[sess.opts.binary]);
104101
}
105102
}
106103
}

src/rustc/driver/driver.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,8 @@ fn host_triple() -> ~str {
428428
};
429429
}
430430

431-
fn build_session_options(matches: getopts::Matches,
431+
fn build_session_options(binary: ~str,
432+
matches: getopts::Matches,
432433
demitter: diagnostic::emitter) -> @session::options {
433434
let crate_type = if opt_present(matches, ~"lib") {
434435
session::lib_crate
@@ -553,6 +554,7 @@ fn build_session_options(matches: getopts::Matches,
553554
maybe_sysroot: sysroot_opt,
554555
target_triple: target,
555556
cfg: cfg,
557+
binary: binary,
556558
test: test,
557559
parse_only: parse_only,
558560
no_trans: no_trans,
@@ -736,7 +738,8 @@ mod test {
736738
Err(f) => fail ~"test_switch_implies_cfg_test: " +
737739
getopts::fail_str(f)
738740
};
739-
let sessopts = build_session_options(matches, diagnostic::emit);
741+
let sessopts = build_session_options(
742+
~"rustc", matches, diagnostic::emit);
740743
let sess = build_session(sessopts, diagnostic::emit);
741744
let cfg = build_configuration(sess, ~"whatever", str_input(~""));
742745
assert (attr::contains_name(cfg, ~"test"));
@@ -754,7 +757,8 @@ mod test {
754757
getopts::fail_str(f);
755758
}
756759
};
757-
let sessopts = build_session_options(matches, diagnostic::emit);
760+
let sessopts = build_session_options(
761+
~"rustc", matches, diagnostic::emit);
758762
let sess = build_session(sessopts, diagnostic::emit);
759763
let cfg = build_configuration(sess, ~"whatever", str_input(~""));
760764
let test_items = attr::find_meta_items_by_name(cfg, ~"test");

src/rustc/driver/rustc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) {
166166
_ => early_error(demitter, ~"multiple input filenames provided")
167167
};
168168
169-
let sopts = build_session_options(matches, demitter);
169+
let sopts = build_session_options(binary, matches, demitter);
170170
let sess = build_session(sopts, demitter);
171171
let odir = getopts::opt_maybe_str(matches, ~"out-dir");
172172
let odir = option::map(odir, |o| Path(o));

src/rustc/driver/session.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ type options =
114114
maybe_sysroot: Option<Path>,
115115
target_triple: ~str,
116116
cfg: ast::crate_cfg,
117+
binary: ~str,
117118
test: bool,
118119
parse_only: bool,
119120
no_trans: bool,
@@ -256,6 +257,7 @@ fn basic_options() -> @options {
256257
maybe_sysroot: None,
257258
target_triple: driver::host_triple(),
258259
cfg: ~[],
260+
binary: ~"rustc",
259261
test: false,
260262
parse_only: false,
261263
no_trans: false,

0 commit comments

Comments
 (0)