Phase 25.1a: selfhost builder hotfix (fn rename, docs)
This commit is contained in:
@ -113,8 +113,11 @@ fn main() -> Result<()> {
|
||||
if canary_norm {
|
||||
// Read file, normalize, and write to a temp path
|
||||
let mut buf = String::new();
|
||||
File::open(&p).and_then(|mut f| f.read_to_string(&mut buf)).context("read input json")?;
|
||||
let mut val: serde_json::Value = serde_json::from_str(&buf).context("input is not valid JSON")?;
|
||||
File::open(&p)
|
||||
.and_then(|mut f| f.read_to_string(&mut buf))
|
||||
.context("read input json")?;
|
||||
let mut val: serde_json::Value =
|
||||
serde_json::from_str(&buf).context("input is not valid JSON")?;
|
||||
val = normalize_canary_json(val);
|
||||
let tmp = std::env::temp_dir().join("ny_llvmc_in.json");
|
||||
let mut f = File::create(&tmp).context("create temp json file")?;
|
||||
@ -156,7 +159,9 @@ fn main() -> Result<()> {
|
||||
};
|
||||
|
||||
// Optional: print concise shape hint in verbose mode when not normalizing
|
||||
if env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1") && env::var("HAKO_LLVM_CANARY_NORMALIZE").ok().as_deref() != Some("1") {
|
||||
if env::var("NYASH_CLI_VERBOSE").ok().as_deref() == Some("1")
|
||||
&& env::var("HAKO_LLVM_CANARY_NORMALIZE").ok().as_deref() != Some("1")
|
||||
{
|
||||
if let Ok(mut f) = File::open(&input_path) {
|
||||
let mut buf = String::new();
|
||||
if f.read_to_string(&mut buf).is_ok() {
|
||||
@ -255,17 +260,32 @@ fn normalize_canary_json(mut v: serde_json::Value) -> serde_json::Value {
|
||||
bm.insert("instructions".to_string(), insts);
|
||||
}
|
||||
// Normalize instructions
|
||||
if let Some(Value::Array(ref mut ins_arr)) = bm.get_mut("instructions") {
|
||||
if let Some(Value::Array(ref mut ins_arr)) =
|
||||
bm.get_mut("instructions")
|
||||
{
|
||||
for ins in ins_arr.iter_mut() {
|
||||
if let Value::Object(ref mut im) = ins {
|
||||
if im.get("op").and_then(|x| x.as_str()) == Some("const") {
|
||||
if im.get("op").and_then(|x| x.as_str())
|
||||
== Some("const")
|
||||
{
|
||||
// if 'ty' and flat 'value' exist, wrap into typed value
|
||||
if let (Some(ty), Some(val)) = (im.remove("ty"), im.remove("value")) {
|
||||
if let (Some(ty), Some(val)) =
|
||||
(im.remove("ty"), im.remove("value"))
|
||||
{
|
||||
let mut val_obj = Map::new();
|
||||
if let Value::String(ts) = ty { val_obj.insert("type".to_string(), Value::String(ts)); }
|
||||
else { val_obj.insert("type".to_string(), ty); }
|
||||
if let Value::String(ts) = ty {
|
||||
val_obj.insert(
|
||||
"type".to_string(),
|
||||
Value::String(ts),
|
||||
);
|
||||
} else {
|
||||
val_obj.insert("type".to_string(), ty);
|
||||
}
|
||||
val_obj.insert("value".to_string(), val);
|
||||
im.insert("value".to_string(), Value::Object(val_obj));
|
||||
im.insert(
|
||||
"value".to_string(),
|
||||
Value::Object(val_obj),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -325,7 +345,9 @@ fn propagate_opt_level(cmd: &mut Command) {
|
||||
let level = nyash.clone().or(hako.clone());
|
||||
if let Some(level) = level {
|
||||
if hako.is_some() && nyash.is_none() {
|
||||
eprintln!("[deprecate/env] 'HAKO_LLVM_OPT_LEVEL' is deprecated; use 'NYASH_LLVM_OPT_LEVEL'");
|
||||
eprintln!(
|
||||
"[deprecate/env] 'HAKO_LLVM_OPT_LEVEL' is deprecated; use 'NYASH_LLVM_OPT_LEVEL'"
|
||||
);
|
||||
}
|
||||
cmd.env("HAKO_LLVM_OPT_LEVEL", &level);
|
||||
cmd.env("NYASH_LLVM_OPT_LEVEL", &level);
|
||||
|
||||
Reference in New Issue
Block a user