💢 The truth about Rust + LLVM development hell
ChatGPT5 struggling for 34+ minutes with Rust lifetime/build errors...
This perfectly illustrates why we need Phase 22 (Nyash LLVM compiler)\!
Key insights:
- 'Rust is safe and beautiful' - Gemini (who never fought lifetime errors)
- Reality: 500-line error messages, 34min debug sessions, lifetime hell
- C would just work: void* compile(void* mir) { done; }
- Python would work: 100 lines with llvmlite
- ANY language with C ABI would work\!
The frustration is real:
- We're SO CLOSE to Nyash self-hosting paradise
- Once bootstrapped, EVERYTHING can be written in Nyash
- No more Rust complexity, no more 5-7min builds
- Just simple, beautiful Box-based code
Current status:
- PHI/SSA hardening in progress (ChatGPT5)
- 'phi incoming value missing' in Main.esc_json/1
- Sealed SSA approach being implemented
The dream is near: Everything is Box, even the compiler\! 🌟
This commit is contained in:
@ -5,7 +5,7 @@ use std::collections::HashMap;
|
||||
use crate::backend::llvm::context::CodegenContext;
|
||||
use crate::mir::{function::MirFunction, BasicBlockId, ValueId};
|
||||
|
||||
use super::super::types::to_bool;
|
||||
use super::super::types::{to_bool, map_mirtype_to_basic};
|
||||
|
||||
pub(in super::super) fn emit_return<'ctx>(
|
||||
codegen: &CodegenContext<'ctx>,
|
||||
@ -20,9 +20,22 @@ pub(in super::super) fn emit_return<'ctx>(
|
||||
}
|
||||
(_t, Some(vid)) => {
|
||||
let v = *vmap.get(vid).ok_or("ret value missing")?;
|
||||
// If function expects a pointer but we have an integer handle, convert i64 -> ptr
|
||||
let expected = map_mirtype_to_basic(codegen.context, &func.signature.return_type);
|
||||
use inkwell::types::BasicTypeEnum as BT;
|
||||
let v_adj = match (expected, v) {
|
||||
(BT::PointerType(pt), BasicValueEnum::IntValue(iv)) => {
|
||||
codegen
|
||||
.builder
|
||||
.build_int_to_ptr(iv, pt, "ret_i2p")
|
||||
.map_err(|e| e.to_string())?
|
||||
.into()
|
||||
}
|
||||
_ => v,
|
||||
};
|
||||
codegen
|
||||
.builder
|
||||
.build_return(Some(&v))
|
||||
.build_return(Some(&v_adj))
|
||||
.map_err(|e| e.to_string())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user