Skip to content

frontend: the c_import cache key names the sysroot the header is read from (#2530) - #2778

Merged
ehartford merged 1 commit into
fix-2611-scalar-leftfrom
fix-cimport-cache-sysroot
Oct 28, 2026
Merged

ehartford merged 1 commit into
fix-2611-scalar-leftfrom
fix-cimport-cache-sysroot

Conversation

@ehartford

@ehartford ehartford commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

frontend: the c_import cache key names the sysroot the header is read from (#2530)

The battery on the #2530 stub fix went red on
err_2530_stub_names_only_exported: "undefined variable" for
sqlite3_enable_load_extension, a function the embedded sysroot's
sqlite3.h declares. Stage1 and the installed compiler both passed it.

Root cause (Frontend.w c_import cache key): the key is the header's
spelling, links, flags, defines and the compiler's identity, but not the
sysroot the header is read from, and a bare "sqlite3.h" carries no
content fingerprint. The same release binary had imported sqlite3.h
under SDKROOT (the Xcode SDK's header defines SQLITE_OMIT_LOAD_EXTENSION,
so the load-extension API is not declared); the fixture blanks SDKROOT
to read the embedded sysroot and was served that import from
~/.cache/with/c_import. Reproduced with one cache epoch:

SDKROOT= with check u.w -> c_import cache miss
SDKROOT= with check u.w -> c_import cache hit (fs)
error: undefined variable

The key now carries host_c_sysroot() (compiler.EmbeddedSysroot, the one
owner of which sysroot c_import parses against: WITH_SDKROOT, SDKROOT,
[c_import] sdk_path, else the embedded sysroot, whose directory names
its content hash).

Evidence: test/behavior/behav_2530_cimport_cache_keys_sysroot.w (two
throwaway sysroots whose probe_key.h declare different functions)
failed on the installed compiler ("kb.w under sb: undefined variable")
and passes on stage1; after poisoning the cache with an Xcode-SDK import
of sqlite3.h, stage1 still passes err_2530_stub_names_only_exported.

… from (#2530)

The battery on the #2530 stub fix went red on
err_2530_stub_names_only_exported: "undefined variable" for
sqlite3_enable_load_extension, a function the embedded sysroot's
sqlite3.h declares. Stage1 and the installed compiler both passed it.

Root cause (Frontend.w c_import cache key): the key is the header's
spelling, links, flags, defines and the compiler's identity, but not the
sysroot the header is read from, and a bare "sqlite3.h" carries no
content fingerprint. The same release binary had imported sqlite3.h
under SDKROOT (the Xcode SDK's header defines SQLITE_OMIT_LOAD_EXTENSION,
so the load-extension API is not declared); the fixture blanks SDKROOT
to read the embedded sysroot and was served that import from
~/.cache/with/c_import. Reproduced with one cache epoch:

  SDKROOT=<Xcode SDK> with check u.w   -> c_import cache miss
  SDKROOT=            with check u.w   -> c_import cache hit (fs)
                                          error: undefined variable

The key now carries host_c_sysroot() (compiler.EmbeddedSysroot, the one
owner of which sysroot c_import parses against: WITH_SDKROOT, SDKROOT,
[c_import] sdk_path, else the embedded sysroot, whose directory names
its content hash).

Evidence: test/behavior/behav_2530_cimport_cache_keys_sysroot.w (two
throwaway sysroots whose probe_key.h declare different functions)
failed on the installed compiler ("kb.w under sb: undefined variable")
and passes on stage1; after poisoning the cache with an Xcode-SDK import
of sqlite3.h, stage1 still passes err_2530_stub_names_only_exported.
@ehartford
ehartford added this pull request to stack #2777 October 28, 2026 17:33
@ehartford ehartford changed the title fix cimport cache sysroot frontend: the c_import cache key names the sysroot the header is read from (#2530) Oct 28, 2026
@ehartford

Copy link
Copy Markdown
Contributor Author

Seed-driven battery GREEN on the stack top 6cba97b (with run tools/battery.w, 562 s; gate, uat and battery-checks). The first battery (16cc3e0) was red on err_2530_stub_names_only_exported: a c_import cache entry made under the Xcode SDK was served to the embedded-sysroot run. #2778 fixes the cache key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant