From 638db28c472c1edadc3c37f900df28f14cca7665 Mon Sep 17 00:00:00 2001 From: Zack Corr Date: Thu, 30 Aug 2012 12:24:43 +1000 Subject: [PATCH] jit: Correct formatting and argv[0] for JITted programs --- src/compiletest/runtest.rs | 12 +++++++++--- src/rustc/back/link.rs | 9 +++------ src/rustc/driver/driver.rs | 10 +++++++--- src/rustc/driver/rustc.rs | 2 +- src/rustc/driver/session.rs | 2 ++ 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index e456b4469fa..65835e9b470 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -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); diff --git a/src/rustc/back/link.rs b/src/rustc/back/link.rs index 9632da761cb..695bdcbc5ea 100644 --- a/src/rustc/back/link.rs +++ b/src/rustc/back/link.rs @@ -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]); } } } diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index 2d5b36debaa..a1864357d60 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -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"); diff --git a/src/rustc/driver/rustc.rs b/src/rustc/driver/rustc.rs index 42982550325..2289a51e7c4 100644 --- a/src/rustc/driver/rustc.rs +++ b/src/rustc/driver/rustc.rs @@ -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)); diff --git a/src/rustc/driver/session.rs b/src/rustc/driver/session.rs index 47aa3019de1..a1785355af8 100644 --- a/src/rustc/driver/session.rs +++ b/src/rustc/driver/session.rs @@ -114,6 +114,7 @@ type options = maybe_sysroot: Option, 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,