selfhost: C backend becomes primary backend; QBE path removed from CLI

Major changes:
- Cli_BuildProject now uses CBackend_Generate instead of QBE SSA generation
- Replaced QBE invocation (vendor/qbe/qbe) with direct cc compilation
- Cli_Build (single-file) now compiles C output with cc including runtime.c/io.c
- Added import-based stdlib merging: only imported Std::* modules are merged,
  eliminating unused generic code from Array/Map/Set/Channel in simple programs

C backend fixes:
- Fixed struct typedef redefinition: struct definitions now use 'struct Name {}'
  instead of 'typedef struct {} Name' to avoid conflicting with forward typedefs
- Added enum support: HirEnum struct, enum emission in C backend, variant
  constants emitted as #define Name_Value
- Added char8 typedef
- Skip generic structs/functions (T/K/V type parameters) in C emission

Sema fixes:
- Fixed Sema_IsNumeric: now correctly recognizes uint, float32, float64
- Fixed return type check: allow pointer compatibility (String <-> *T)

Tested: hello, fibonacci, factorial, enums examples build and run via buxc2
This commit is contained in:
2026-06-05 14:42:18 +03:00
parent 5ae85d5bd9
commit 0c1f230286
10 changed files with 614 additions and 242 deletions
+5
View File
@@ -115,6 +115,10 @@ struct HirConst {
value: int;
}
struct HirEnum {
name: String;
}
struct HirModule {
funcCount: int;
funcs: *HirFunc;
@@ -123,6 +127,7 @@ struct HirModule {
structCount: int;
structs: *HirStruct;
enumCount: int;
enums: *HirEnum;
constCount: int;
consts: *HirConst;
}