Skip to content

c_import cache key should include bridge/compiler version #79

Closed

Description

@ehartford

The c_import filesystem cache key currently ignores the version of the bridge/compiler that produced the translation output.

This is a separate problem from #74.

Why this matters:

  • A broken clang_bridge.o or compiler can write bad synthetic With output into ~/.cache/with/c_import
  • Fixing the bridge/compiler later does not invalidate those cached translations
  • Users can keep seeing stale or incorrect c_import behavior until they manually clear the cache

Current cache key inputs appear to include:

  • header/import spec
  • link directives
  • optional WITH_CIMPORT_CACHE_EPOCH

But they do not include:

  • clang_bridge.o version/hash
  • compiler version/hash
  • any other bridge ABI/version fingerprint

Minimal repro:

  1. Build or use a compiler/runtime with a broken clang_bridge.o
  2. Run a c_import that writes incorrect cached output
  3. Fix clang_bridge.o or the compiler
  4. Re-run the same c_import
  5. Observe that the stale cached translation is still used until ~/.cache/with/c_import is cleared or WITH_CIMPORT_CACHE_EPOCH is changed

Expected behavior:

  • Any change to the bridge/compiler that can affect c_import translation should produce a cache miss automatically

Likely fix:

  • Add a stable bridge/compiler version component to the cache key, for example:
    • hash of out/lib/clang_bridge.o, or
    • compiler version string / git commit, or
    • explicit c_import translator version constant

Relevant code:

  • src/compiler/Frontend.w cache key generation for c_import

Workaround:

  • rm -rf ~/.cache/with/c_import
  • or set a new WITH_CIMPORT_CACHE_EPOCH

Activity

  1. ehartford commented on Apr 8, 2026

    @ehartford
    ContributorAuthor

    Fixed on main in 8e86d59.

    The c_import cache key now includes a cached fingerprint of the running compiler executable, with a PATH fallback when argv[0] is not directly readable, and the cache format was bumped to cimport-v3 to invalidate old bad entries immediately.

    Verification:

    • make build
    • make selfcheck
    • make fixpoint
    • make test
    • targeted cache check with isolated HOME produced stage2_first=1, stage2_second=1, canonical=2, confirming that two different compiler binaries now produce distinct filesystem cache entries for the same c_import input.
  2. added a commit that references this issue on Jun 8, 2026
    3622694
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions