manual c function interop

This commit is contained in:
2026-06-11 22:46:12 +02:00
parent 2a79010a57
commit a5ceb727c1
20 changed files with 725 additions and 74 deletions
+21
View File
@@ -8,6 +8,25 @@ odin build . -out:brolang
/tmp/prototype
```
Bodyless `c func` declarations bind exact external symbols and require concrete
types:
```bro
foreign_add :: c func(a, b i32) i32
```
Additional native inputs and libraries are passed to the final `zig cc`
invocation in command-line order:
```sh
./brolang examples/interop/manual -o /tmp/manual \
--link examples/interop/manual/native.c
```
`--link` accepts C sources, object files, and direct library paths.
`--library-path <dir>` becomes `-L<dir>`, and `--library <name>` becomes
`-l<name>`.
Compilation phases are isolated under `compiler/`:
```text
@@ -41,6 +60,8 @@ Current prototype features:
- Directory packages with merged declarations and file-local relative imports
- Qualified imported globals and functions with package-aware symbol mangling
- Demand-monomorphized Brolang and C-ABI functions
- Bodyless concrete C function declarations with exact external symbol names
- Ordered linking of additional C sources, objects, and libraries
- Checked signed addition
- Static, eager runtime, and deferred problematic globals
- Runtime diagnostics followed by `llvm.trap`