Files
vercel-labs--zerolang/docs/articles/c-interop.md
T
wehub-resource-sync e7738de6d2
CI / Deep Native Runtime Cases (1/6) (push) Has been skipped
CI / Native Preflight (push) Failing after 1s
CI / Native Runtime Cases (1/2) (push) Failing after 0s
CI / Native Runtime Cases (2/2) (push) Failing after 1s
CI / Native Metadata Reports (push) Failing after 0s
CI / Native Direct Backend Artifacts (push) Failing after 0s
CI / Native Sanitizer Smoke (push) Failing after 1s
CI / Command Contract Snapshots (push) Failing after 1s
CI / Deep Conformance Suite (push) Has been skipped
CI / Graph Build Perf (push) Failing after 1s
CI / Deep Native Preflight (push) Has been skipped
CI / Deep Native Runtime Cases (2/6) (push) Has been skipped
CI / Deep Native Runtime Cases (3/6) (push) Has been skipped
CI / Conformance Suite (push) Failing after 1s
CI / Workspace Checks (push) Failing after 0s
CI / Deep Native Runtime Cases (5/6) (push) Has been skipped
CI / Deep Native Runtime Cases (6/6) (push) Has been skipped
CI / Deep Native Runtime Cases (4/6) (push) Has been skipped
CI / Deep Graph Build Perf (push) Has been skipped
chore: import upstream snapshot with attribution
2026-07-13 12:29:30 +08:00

77 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## The C Boundary
Zerolang supports a small explicit C ABI surface from graph inputs. C-facing code
should stay narrow, inspectable, and target-aware.
```json-render
{
"messages": [
{
"role": "user",
"text": "can this call my tiny c helper on linux musl?"
},
{
"role": "assistant",
"text": "Ill check the target link plan and tell you what blocks the call."
},
{
"role": "tools",
"calls": [
{
"command": "zero inspect --json --target linux-musl-x64",
"output": "{\"cLibraries\":[{\"linkPlan\":{\"sysrootStatus\":\"configured\"}}]}"
}
]
}
]
}
```
## What This Means
Projection example:
```zero
export c fn add(a: i32, b: i32) -> i32 {
return a + b
}
```
Graph checks:
```sh
zero check conformance/native/pass/c-abi-export.graph
zero abi dump --json conformance/native/pass/c-abi-export.graph
```
`zero abi dump --json` reports exported symbols and generated header facts such
as `generatedHeader.available`.
## Import Metadata
Header imports expose typed metadata:
```sh
zero inspect --json --target linux-musl-x64 conformance/check/pass/c-header-import.graph
```
The JSON includes `cImports[].typedModel` with imported functions, constants,
structs, enums, and typedefs.
Callable imports are limited to direct scalar ABI types today: `Void`, `Bool`,
`u8`, `u16`, `usize`, `i32`, `u32`, `i64`, and `u64`. Pointer, array, struct,
and unsupported-width parameters should be wrapped by a small C shim.
## Link Plans
Executable builds with direct extern C calls require package link metadata in
`zero.toml`. Imported headers must appear in `c.libs.*.headers`, and the
library must provide `lib` or `link` inputs.
`zero inspect --json` reports each `cLibraries[].linkPlan` with include paths,
library paths, sysroot status, target ABI, host discovery status, and header
hash data.
Unsafe foreign-target discovery fails with `CIMP003`. Missing or unsafe link
inputs fail with `CIMP005`.