jit: Correct formatting and argv[0] for JITted programs
This commit is contained in:
parent
efb576a60d
commit
638db28c47
@ -51,7 +51,9 @@ fn run_rfail_test(config: config, props: test_props, testfile: &Path) {
|
||||
let procres = if !config.jit {
|
||||
let procres = compile_test(config, props, testfile);
|
||||
|
||||
if procres.status != 0 { fatal_procres(~"compilation failed!", procres); }
|
||||
if procres.status != 0 {
|
||||
fatal_procres(~"compilation failed!", procres);
|
||||
}
|
||||
|
||||
exec_compiled_test(config, props, testfile)
|
||||
} else {
|
||||
@ -83,11 +85,15 @@ fn run_rpass_test(config: config, props: test_props, testfile: &Path) {
|
||||
if !config.jit {
|
||||
let mut procres = compile_test(config, props, testfile);
|
||||
|
||||
if procres.status != 0 { fatal_procres(~"compilation failed!", procres); }
|
||||
if procres.status != 0 {
|
||||
fatal_procres(~"compilation failed!", procres);
|
||||
}
|
||||
|
||||
procres = exec_compiled_test(config, props, testfile);
|
||||
|
||||
if procres.status != 0 { fatal_procres(~"test run failed!", procres); }
|
||||
if procres.status != 0 {
|
||||
fatal_procres(~"test run failed!", procres);
|
||||
}
|
||||
} else {
|
||||
let mut procres = jit_test(config, props, testfile);
|
||||
|
||||
|
@ -85,22 +85,19 @@ mod jit {
|
||||
m: ModuleRef,
|
||||
opt: c_int,
|
||||
stacks: bool) unsafe {
|
||||
let ptr = llvm::LLVMRustJIT(rusti::morestack_addr(), pm, m, opt, stacks);
|
||||
let ptr = llvm::LLVMRustJIT(rusti::morestack_addr(),
|
||||
pm, m, opt, stacks);
|
||||
|
||||
if ptr::is_null(ptr) {
|
||||
llvm_err(sess, ~"Could not JIT");
|
||||
} else {
|
||||
let bin = match os::self_exe_path() {
|
||||
Some(path) => path.to_str(),
|
||||
_ => ~"rustc"
|
||||
};
|
||||
let closure = Closure {
|
||||
code: ptr,
|
||||
env: ptr::null()
|
||||
};
|
||||
let func: fn(~[~str]) = unsafe::transmute(closure);
|
||||
|
||||
func(~[bin]);
|
||||
func(~[sess.opts.binary]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -428,7 +428,8 @@ fn host_triple() -> ~str {
|
||||
};
|
||||
}
|
||||
|
||||
fn build_session_options(matches: getopts::Matches,
|
||||
fn build_session_options(binary: ~str,
|
||||
matches: getopts::Matches,
|
||||
demitter: diagnostic::emitter) -> @session::options {
|
||||
let crate_type = if opt_present(matches, ~"lib") {
|
||||
session::lib_crate
|
||||
@ -553,6 +554,7 @@ fn build_session_options(matches: getopts::Matches,
|
||||
maybe_sysroot: sysroot_opt,
|
||||
target_triple: target,
|
||||
cfg: cfg,
|
||||
binary: binary,
|
||||
test: test,
|
||||
parse_only: parse_only,
|
||||
no_trans: no_trans,
|
||||
@ -736,7 +738,8 @@ mod test {
|
||||
Err(f) => fail ~"test_switch_implies_cfg_test: " +
|
||||
getopts::fail_str(f)
|
||||
};
|
||||
let sessopts = build_session_options(matches, diagnostic::emit);
|
||||
let sessopts = build_session_options(
|
||||
~"rustc", matches, diagnostic::emit);
|
||||
let sess = build_session(sessopts, diagnostic::emit);
|
||||
let cfg = build_configuration(sess, ~"whatever", str_input(~""));
|
||||
assert (attr::contains_name(cfg, ~"test"));
|
||||
@ -754,7 +757,8 @@ mod test {
|
||||
getopts::fail_str(f);
|
||||
}
|
||||
};
|
||||
let sessopts = build_session_options(matches, diagnostic::emit);
|
||||
let sessopts = build_session_options(
|
||||
~"rustc", matches, diagnostic::emit);
|
||||
let sess = build_session(sessopts, diagnostic::emit);
|
||||
let cfg = build_configuration(sess, ~"whatever", str_input(~""));
|
||||
let test_items = attr::find_meta_items_by_name(cfg, ~"test");
|
||||
|
@ -166,7 +166,7 @@ fn run_compiler(args: ~[~str], demitter: diagnostic::emitter) {
|
||||
_ => early_error(demitter, ~"multiple input filenames provided")
|
||||
};
|
||||
|
||||
let sopts = build_session_options(matches, demitter);
|
||||
let sopts = build_session_options(binary, matches, demitter);
|
||||
let sess = build_session(sopts, demitter);
|
||||
let odir = getopts::opt_maybe_str(matches, ~"out-dir");
|
||||
let odir = option::map(odir, |o| Path(o));
|
||||
|
@ -114,6 +114,7 @@ type options =
|
||||
maybe_sysroot: Option<Path>,
|
||||
target_triple: ~str,
|
||||
cfg: ast::crate_cfg,
|
||||
binary: ~str,
|
||||
test: bool,
|
||||
parse_only: bool,
|
||||
no_trans: bool,
|
||||
@ -256,6 +257,7 @@ fn basic_options() -> @options {
|
||||
maybe_sysroot: None,
|
||||
target_triple: driver::host_triple(),
|
||||
cfg: ~[],
|
||||
binary: ~"rustc",
|
||||
test: false,
|
||||
parse_only: false,
|
||||
no_trans: false,
|
||||
|
Loading…
x
Reference in New Issue
Block a user