Skip to content

cimport: resolve amalgamation unit prototypes against installed <stem>.h header - #3651

Merged
ehartford merged 1 commit into
mainfrom
sqlite3-amalgamation-headers
Nov 27, 2026
Merged

ehartford merged 1 commit into
mainfrom
sqlite3-amalgamation-headers

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Fixes with get c.sqlite3 drafting 0 functions, 0 presented safely (part of #3146).

Root cause

Amalgamation C libraries (sqlite3.c) embed their public prototypes directly inside the .c unit instead of #include "sqlite3.h". CiMigrate.with left symbol.header_file empty whenever the prototype's location was not a header file (ci_migrate_location_is_header(loc)), so migrate_c_facade_for_package demoted every public sqlite3_* function as "declared only by headers the package does not install".

Fix

  • src/CiMigrate.with: when a header_declared symbol has an empty header_file, fall back to its owning .c unit in ci_facade_import_spelling. For a .c file with declares non-empty, match a unique installed <stem>.h under import_dirs mentioning declares, then let process_c_import_with_defines + with_cimport_is_name_emitted verify with clang that the installed header actually declares the function (excluding .c-only internal forward declarations). Record the resolved header on symbol.header_file so use c_import("<stem>.h", ...) is emitted.
  • test/internals/conan_facade_amalgamation_header_test.with: verifies an amalgamation .c unit (amalg.c + installed include/amalg.h) presents public functions, emits use c_import("amalg.h", ...), and excludes .c-only forward declarations.

Measured impact on sqlite3 3.54.1

  • Before: 0 functions, 0 presented safely, 0 raw
  • After: 285 functions, 35 presented safely, 250 raw, emitting use c_import("sqlite3.h", link: "sqlite3")

@ehartford

Copy link
Copy Markdown
Contributor Author

Battery & :release-checks verdict on 3e70a4462:

  • with run tools/battery.with: GREEN (rc=0, wall=1401s; verified via with run tools/verdict.with out/battery/battery.log)
  • src/main build :release-checks: GREEN (wall=897.8s, stage2 == stage3 over all 16 units of the compiler, EMIT-C OK, EMIT-C FIXPOINT)

@ehartford
ehartford marked this pull request as ready for review November 27, 2026 10:05
@ehartford
ehartford merged commit f1126ec into main Nov 27, 2026
1 check passed
@ehartford
ehartford deleted the sqlite3-amalgamation-headers branch November 27, 2026 10:05
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