Skip to content
Merged

Dev #11

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.10.0] - 2026-08-29

### 🌍 Cross-Compilation & Target Triples (`--target`)
- Added `--target <alias>` flag to `zuv.exe` and `zuv_selfhost.exe` for cross-compiling to any LLVM target:
- `windows-x64` → `x86_64-pc-windows-msvc` (default, full link)
- `linux-x64` → `x86_64-unknown-linux-gnu` (ELF `.o`)
- `linux-arm64` → `aarch64-unknown-linux-gnu` (ELF AArch64 `.o`)
- `macos-arm64` → `arm64-apple-darwin` (Mach-O `.o`)
- `macos-x64` → `x86_64-apple-darwin` (Mach-O `.o`)
- Raw LLVM triple passthrough supported.
- Initialized AArch64 LLVM backend alongside X86 in both compilers.
- Dynamic `target triple` injected into IR before emission.
- Non-Windows targets emit `.o` only (cross-link skipped with a clear message).
- Added `tests/cross_target.test.zv` in both `tests/` dirs.
- `--help` updated with `--target` aliases.

### 🏷️ AST Attribute Declarations & Metaprogramming Annotations
- Added `@name` / `@name(...)` attribute syntax on functions and `obj` declarations.
- `@inline` / `@inline(always)` → LLVM `alwaysinline`; `@noinline` → `noinline`.
- Supports `@test`, `@derive(...)`, `@deprecated`, and custom attribute args.
- Added `tests/attributes.test.zv`.

### 🔗 Multi-line `extern` & Block Declarations
- Added `extern "lib" { ... }` and `pub extern "C" { ... }` block syntax for grouping multiple FFI declarations in one block.
- `pub extern "C" { ... }` auto-emits `dllexport` on all functions inside.
- Removed manual `extern "msvcrt.dll" system` from `cli.zv`; uses builtin `sh` instead.
- Updated tests: `cdylib_export.test.zv`, `c_ffi_lib.test.zv`, `call_cdylib.test.zv`.

## [0.9.0] - 2026-08-27

### 🔌 JS Interop & Shared C Dynamic Library Output (`--cdylib` / `--lib`)
Expand Down
104 changes: 90 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,36 +179,112 @@ zuv --help

## 🛠️ Building & Running the Self-Hosting Compiler

### 1. Compile the Self-Hosting Compiler
Compile the pure Zuv compiler sources:
### Prerequisites
- **Windows** with [LLVM](https://llvm.org/releases/) installed (e.g. `D:\LLVM`)
- **lld-link.exe** — comes with LLVM, used by `zuv.exe` for native linking

---

### 1. Build the Self-Hosting Compiler (`zuv_selfhost.exe`)

```powershell
zuv build src/main.zv
# From the repo root
.\zuv.exe build sub_projects/zuv/src/main.zv -o sub_projects/zuv/zuv_selfhost.exe
```
To install the built compiler to your default binary folder:

To install it as your system `zuv`:
```powershell
Copy-Item output.exe "C:\Users\$env:USERNAME\zuv\bin\zuv.exe" -Force
Copy-Item sub_projects\zuv\zuv_selfhost.exe "$HOME\zuv\bin\zuv.exe" -Force
```

### 2. Run the Native AOT Test Runner
Execute all 27 unit test suites natively using `zuv`:
---

### 2. Run the Test Suite (All 4 Runners)

```powershell
zuv test
# Bootstrap compiler — from repo root
.\zuv.exe test # compile & run all tests/
.\zuv.exe checkall # parse & type-check all tests/ (no LLVM emit)

# Self-hosting compiler — from sub_projects/zuv/
.\zuv_selfhost.exe test
.\zuv_selfhost.exe checkall
```

### 3. Run Static Type & Borrow Checker
Verify syntax and borrow safety across all test suites without emitting binaries:
Expected results:

| Runner | Passing |
|--------|---------|
| `zuv.exe test` | ✅ |
| `zuv.exe checkall` | ✅ |
| `zuv_selfhost.exe test` | ✅ |
| `zuv_selfhost.exe checkall` | ✅ |

> The 2 intentional failures (`redecl_error.test.zv`, `semantic_errors.test.zv`) are negative tests — they are expected to fail.

---

### 3. Build & Run a Single Zuv Program

```powershell
zuv checkall
# Build to output.exe (default)
.\zuv.exe build tests/functions.test.zv

# Build with custom output name
.\zuv.exe build tests/functions.test.zv -o my_app.exe

# Build & run in one step
.\zuv.exe run tests/functions.test.zv

# Release build (-O3)
.\zuv.exe build tests/functions.test.zv --release -o my_app.exe
```

### 4. Build and Run a Zuv Program
---

### 4. Cross-Compile to Another Platform

> Emits a native object file (`.o`) for the target. Cross-linking requires a target sysroot.

```powershell
# Linux x64 (ELF)
.\zuv.exe build src/main.zv --target linux-x64 -o output_linux.o

# Linux ARM64 (ELF AArch64)
.\zuv.exe build src/main.zv --target linux-arm64 -o output_arm64.o

# macOS ARM64 (Mach-O)
.\zuv.exe build src/main.zv --target macos-arm64 -o output_macos.o

# Raw LLVM triple
.\zuv.exe build src/main.zv --target x86_64-unknown-linux-musl -o output.o
```

Also works with `zuv_selfhost.exe`:
```powershell
.\zuv_selfhost.exe build tests/func_simple.test.zv --target linux-x64 -o out.o
```

---

### 5. Shared C Library (`.dll` / `.so`)

```powershell
.\zuv.exe build math.zv --cdylib -o math.dll
```

---

### 6. Emit LLVM IR

```powershell
zuv build tests/functions.test.zv
zuv run tests/functions.test.zv
.\zuv.exe build src/main.zv --emit-llvm
# Produces output.ll and output_debug.ll in the current directory
```

---


## 🤝 Contributing

We welcome contributions from developers worldwide! Please review our [Contributing Guide](CONTRIBUTING.md) and [Code of Conduct](CODE_OF_CONDUCT.md) before submitting pull requests.
Expand Down
Loading
Loading