refactor: remove QBE backend, improve bootstrap compiler and stdlib

Bootstrap compiler improvements:
- Extract findStdlibDir() to remove hardcoded path and deduplicate
- Extract prepareProject()/mergeProject() to share code between cmdCheck/cmdBuild
- Fix C backend to emit warning on unknown types instead of silent 'int'
- Clean up all unused imports across 7 modules
- Makefile: add strip, debug target, clean-all, selfhost strip

QBE removal:
- Remove vendor/qbe/ (74K lines)
- Remove compiler/selfhost/qbe_backend.bux, nim_backend.bux

Stdlib improvements:
- Add Result.bux + Option.bux modules
- Fix Json.bux memory leak (removed double String_Copy)
- Add missing imports in Crypto.bux (Alloc/Free) and Test.bux (PrintLine/PrintInt)
- Clean stale buxc_debug binary
This commit is contained in:
2026-06-06 00:51:11 +03:00
parent 7b32cad3e9
commit 0dade151d2
146 changed files with 183 additions and 74747 deletions
+15 -6
View File
@@ -5,15 +5,19 @@ BUILD_DIR := build
EXAMPLES := hello fibonacci factorial structs enums methods algebraic_enums generics generics_struct generic_infer generic_infer2 extend_generic pattern_matching strings strings2 map result_option try_operator ownership ctfe async concurrency os_time process json iter
.PHONY: all build dev test clean test-examples
.PHONY: all build dev debug test clean clean-all test-examples selfhost
all: build
build:
$(NIM) c -o:$(OUT) -d:release $(SRC)
$(NIM) c -o:$(OUT) -d:release --opt:size $(SRC)
strip $(OUT)
dev:
$(NIM) c -o:$(OUT) $(SRC)
$(NIM) c -o:buxc_debug -d:debug --stackTrace:on --lineTrace:on $(SRC)
debug: dev
@echo "Debug binary: buxc_debug"
test: build test-examples
@echo "Running lexer tests..."
@@ -50,17 +54,22 @@ test-examples: build
@echo "All examples passed!"
clean:
rm -f $(OUT)
rm -f $(OUT) buxc_debug
rm -rf $(BUILD_DIR)
rm -rf nimcache
rm -rf examples_pkg
rm -rf _test_tmp_pkg
rm -rf _test_cast _test_cast2 _test_cast3 _test_channel
clean-all: clean
rm -rf _selfhost/src _selfhost/build
selfhost: build
@echo "=== Phase 7.9: Building self-hosted compiler ==="
@rm -rf _selfhost/src
@echo "=== Building self-hosted compiler ==="
@rm -rf _selfhost/src _selfhost/build
@mkdir -p _selfhost/src
@cp compiler/selfhost/*.bux _selfhost/src/
@mv _selfhost/src/main.bux _selfhost/src/Main.bux 2>/dev/null || true
@cd _selfhost && ../$(OUT) build
@strip _selfhost/build/buxc2
@echo "=== Self-hosted compiler built successfully ==="