You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
c_import on macOS without SDKROOT reads only the libc-only embedded sysroot: examples/c-interop fails, sqlite3.h not found #2530
examples/c-interop does not build in a shell without SDKROOT:
$ cd examples/c-interop && with build
error: failed to compile C header snippet: sqlite3.h: 'sqlite3.h' file not found
--> examples/c-interop/src/main.w:77:1
$ SDKROOT=$(xcrun --show-sdk-path) with build # green
$ SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX15.4.sdk with build # green
Installed compiler built from main (2026-10-20); it also turns src/main build :gate red (examples-tests: examples_c-interop.run/.test failed) in any shell without SDKROOT. Batteries pass only because their shells carry it.
Cause.darwin_sdk_root() (src/compiler/EmbeddedSysroot.w:259) reads WITH_SDKROOT, then SDKROOT, then with.toml [c_import] sdk_path, and otherwise falls back to the embedded darwin sysroot. That sysroot is libc only by design (build/sdk.w:1722, #1915/D81: Zig's darwin libc headers, libSystem.tbd, the lib{c,m,pthread,dl} aliases, libc++). sqlite3.h is not libc: the materialized copy (~/.cache/with/sysroot/darwin-*/usr/include/) has no sqlite3.h, while every Apple SDK on the host does (Xcode MacOSX.sdk, CLT MacOSX26.5.sdk and MacOSX15.4.sdk).
So a program that c_imports a macOS system library outside libc compiles only when the user exports an SDK path, which the mission says they should never have to do ("the programmer never has to become the build system"). examples/ is a contract, so the example itself stays as written.
Direction (needs a ruling: C interop). One fact decides it: on macOS, which headers outside libc does a c_import resolve, and from where?
(a) a header absent from the embedded sysroot is looked up in the host SDK (xcrun --show-sdk-path, or the CLT SDK), with the embedded sysroot still first for libc so builds stay reproducible;
(b) system libraries a program names (sqlite3 here) come through with get as source builds, like the other corpora, and the host SDK is never read;
(c) the error names the missing header and the exact fix instead of clang's bare "file not found".
Whichever is chosen, (c) applies: today's message gives no hint that the header exists on the machine and that SDKROOT reaches it.
Found 2026-10-21 while gating the ceremony-bar fix (branch ceremony-bar-on-install); unrelated to that change.
Triage 2026-10-25, with v0.15.3.0 (main a261b65): reproduced.
$ cd examples/c-interop
$ env -u SDKROOT with check src/main.w
error: failed to compile C header snippet: sqlite3.h: 'sqlite3.h' file not found
--> src/main.w:77:1
pre-release: a published example fails in a default shell; under the zero-dependency ruling (#1915) the headers must come from our SDK, not SDKROOT.
Fix campaign 2026-10-25: the cause is a design boundary, not a code defect, and both ways out are Eric's call (a published example, and the zero-dependency ruling).
What happens. Without SDKROOT, c_import reads the embedded macOS sysroot (#1915, compiler.EmbeddedSysroot, "libc-only"). examples/c-interop/src/main.w:8 imports sqlite3.h, which macOS ships in its SDK's /usr/include but which is not libc, so the parse fails; with SDKROOT set, clang reads Xcode's SDK and finds it. The example says so itself (print("-- a system library: sqlite3")).
The example gets sqlite through with get c.sqlite3 like every other C dependency, and c_import of a non-libc system header without SDKROOT is an error that says so. This edits a published example, which only Eric may approve.
Both: the example moves to with get and the system path keeps working when SDKROOT names an SDK.
Prediction (60%): option 1, since #1915 puts the OS's own libraries on the "system" side of the line and the example exists to show that path.
Phase-3 fix campaign, 2026-10-26: the diagnostic half (option (c), which applies under either design outcome) is on main in ec88cbc (#2753). Without SDKROOT the error now reads:
error: failed to compile C header snippet: sqlite3.h: 'sqlite3.h' file not found; the embedded macOS sysroot this compiler carries (#1915) holds libc only, and 'sqlite3.h' is not in it — name an SDK that has it (WITH_SDKROOT, SDKROOT, or [c_import] sdk_path in with.toml), or take the library through `with get`
Previously the remedy text was appended only when no sysroot existed at all; the embedded-sysroot case got clang's bare "file not found". Fixture: err_2530_header_outside_embedded_sysroot (darwin; env directives force the embedded sysroot).
The issue itself stays open on do-before-release + human attn needed: options (a) embed the system libraries' headers and (b) move the example to with get are the design call from the 2026-10-25 comment (prediction 60% for (a)).
Fixed by #2767 (fc27c65), battery-green on 4062c27 and merged. (The diagnostic half landed earlier in #2753.)
The embedded darwin sysroot now carries headers and .tbd stubs for the declared macOS system libraries: sqlite3, z, bz2, xml2, curl, iconv. Headers are pinned, sha256-checked upstream archives at macOS-11-era versions (sqlite 3.32.2, bzip2 1.0.6, libxml2 2.9.4 with xmlversion.h substituted in-build, curl 7.64.1; zlib/iconv from the sysroot's own libc set) so nothing newer than the minimum deployment target is declared. No Apple SDK file is read or copied — stub install names, versions and feature facts only; stub symbol lists are extracted from each header's own API macros.
Proof: env -u SDKROOT with-stage1 run in examples/c-interop builds, links -lsqlite3 through the new stub, and runs green. The example was not moved to with get (per ruling: a compiler change breaking a published program is the compiler's defect).
Assumption flagged at ruling time: the six-library list (its head was garbled in paste).
Follow-up on main in #2775 and #2778 (squash 455ff0b and its parents): the sysroot's link stubs now name only what macOS exports (a call of an Apple-omitted function such as sqlite3_enable_load_extension fails at link instead of crashing at run time), and the c_import cache key names the sysroot the header was read from.
Activity
ehartford commentedon Oct 25, 2026
Triage 2026-10-25,
with v0.15.3.0(main a261b65): reproduced.pre-release: a published example fails in a default shell; under the zero-dependency ruling (#1915) the headers must come from our SDK, not
SDKROOT.ehartford commentedon Oct 25, 2026
Fix campaign 2026-10-25: the cause is a design boundary, not a code defect, and both ways out are Eric's call (a published example, and the zero-dependency ruling).
What happens. Without
SDKROOT, c_import reads the embedded macOS sysroot (#1915,compiler.EmbeddedSysroot, "libc-only").examples/c-interop/src/main.w:8importssqlite3.h, which macOS ships in its SDK's/usr/includebut which is not libc, so the parse fails; withSDKROOTset, clang reads Xcode's SDK and finds it. The example says so itself (print("-- a system library: sqlite3")).The options.
/usr/lib(sqlite3, libxml2, zlib, curl, …), so a system library works with no Xcode or CLT, in keeping with Zero dependencies on every platform: the SDK carries link stubs, CRT, builtins, libc++ and headers (no Xcode/CLT, no MSVC/Windows SDK, no system glibc/libgcc) #1915 ("run time depends only on what the OS ships"). Cost: more embedded bytes and an Apple-header refresh per SDK bump.with get c.sqlite3like every other C dependency, and c_import of a non-libc system header withoutSDKROOTis an error that says so. This edits a published example, which only Eric may approve.with getand the system path keeps working whenSDKROOTnames an SDK.Prediction (60%): option 1, since #1915 puts the OS's own libraries on the "system" side of the line and the example exists to show that path.
The question: which of the three?
c_import: a header outside the embedded macOS sysroot says what was s…
ehartford commentedon Oct 27, 2026
Phase-3 fix campaign, 2026-10-26: the diagnostic half (option (c), which applies under either design outcome) is on main in ec88cbc (#2753). Without SDKROOT the error now reads:
Previously the remedy text was appended only when no sysroot existed at all; the embedded-sysroot case got clang's bare "file not found". Fixture: err_2530_header_outside_embedded_sysroot (darwin; env directives force the embedded sysroot).
The issue itself stays open on
do-before-release+human attn needed: options (a) embed the system libraries' headers and (b) move the example towith getare the design call from the 2026-10-25 comment (prediction 60% for (a)).build: sysroot carries the declared macOS system libraries (#2530)
build: sysroot carries the declared macOS system libraries (#2530)
build: sysroot carries the declared macOS system libraries (#2530) (#…
ehartford commentedon Oct 28, 2026
Fixed by #2767 (fc27c65), battery-green on 4062c27 and merged. (The diagnostic half landed earlier in #2753.)
The embedded darwin sysroot now carries headers and .tbd stubs for the declared macOS system libraries: sqlite3, z, bz2, xml2, curl, iconv. Headers are pinned, sha256-checked upstream archives at macOS-11-era versions (sqlite 3.32.2, bzip2 1.0.6, libxml2 2.9.4 with xmlversion.h substituted in-build, curl 7.64.1; zlib/iconv from the sysroot's own libc set) so nothing newer than the minimum deployment target is declared. No Apple SDK file is read or copied — stub install names, versions and feature facts only; stub symbol lists are extracted from each header's own API macros.
Proof:
env -u SDKROOT with-stage1 runin examples/c-interop builds, links -lsqlite3 through the new stub, and runs green. The example was not moved towith get(per ruling: a compiler change breaking a published program is the compiler's defect).Assumption flagged at ruling time: the six-library list (its head was garbled in paste).
build: a darwin sysroot stub names only what macOS exports (#2530) (#…
frontend: the c_import cache key names the sysroot the header is read…
ehartford commentedon Oct 28, 2026
Follow-up on main in #2775 and #2778 (squash 455ff0b and its parents): the sysroot's link stubs now name only what macOS exports (a call of an Apple-omitted function such as sqlite3_enable_load_extension fails at link instead of crashing at run time), and the c_import cache key names the sysroot the header was read from.
Windows battery fixes; the root module keeps its spelling (#2788, #809,