Stage-A selfhost emitter fixes and LLVM opt toggle
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
@ -145,10 +146,10 @@ fn main() -> Result<()> {
|
||||
|
||||
fn run_harness_dummy(harness: &Path, out: &Path) -> Result<()> {
|
||||
ensure_python()?;
|
||||
let status = Command::new("python3")
|
||||
.arg(harness)
|
||||
.arg("--out")
|
||||
.arg(out)
|
||||
let mut cmd = Command::new("python3");
|
||||
cmd.arg(harness).arg("--out").arg(out);
|
||||
propagate_opt_level(&mut cmd);
|
||||
let status = cmd
|
||||
.status()
|
||||
.context("failed to execute python harness (dummy)")?;
|
||||
if !status.success() {
|
||||
@ -159,12 +160,14 @@ fn run_harness_dummy(harness: &Path, out: &Path) -> Result<()> {
|
||||
|
||||
fn run_harness_in(harness: &Path, input: &Path, out: &Path) -> Result<()> {
|
||||
ensure_python()?;
|
||||
let status = Command::new("python3")
|
||||
.arg(harness)
|
||||
let mut cmd = Command::new("python3");
|
||||
cmd.arg(harness)
|
||||
.arg("--in")
|
||||
.arg(input)
|
||||
.arg("--out")
|
||||
.arg(out)
|
||||
.arg(out);
|
||||
propagate_opt_level(&mut cmd);
|
||||
let status = cmd
|
||||
.status()
|
||||
.context("failed to execute python harness")?;
|
||||
if !status.success() {
|
||||
@ -180,6 +183,16 @@ fn ensure_python() -> Result<()> {
|
||||
}
|
||||
}
|
||||
|
||||
fn propagate_opt_level(cmd: &mut Command) {
|
||||
let level = env::var("HAKO_LLVM_OPT_LEVEL")
|
||||
.ok()
|
||||
.or_else(|| env::var("NYASH_LLVM_OPT_LEVEL").ok());
|
||||
if let Some(level) = level {
|
||||
cmd.env("HAKO_LLVM_OPT_LEVEL", &level);
|
||||
cmd.env("NYASH_LLVM_OPT_LEVEL", &level);
|
||||
}
|
||||
}
|
||||
|
||||
fn link_executable(
|
||||
obj: &Path,
|
||||
out_exe: &Path,
|
||||
|
||||
Reference in New Issue
Block a user