Skip to content

#2972, #2980: a package's units are read under its own defines; a unity include is one definition - #3025

Merged
ehartford merged 1 commit into
mainfrom
sqlite-proofs
Nov 3, 2026
Merged

ehartford merged 1 commit into
mainfrom
sqlite-proofs

Conversation

@ehartford

Copy link
Copy Markdown
Contributor

Closes #2972. Closes #2980.

Root cause of #2972 (exact line): migrate_add_define turned a bare -DNAME into #define NAME (empty) where a C compiler means NAME=1. sqlite3.c line 26374 #if HAVE_LOCALTIME_R then preprocessed as #if with nothing to test, clang refused the amalgamation ("invalid token at start of a preprocessor expression"), and the facade saw 18 of 319 functions (3 presented). The macOS report's "could not read the Conan Center recipe" was a transient network failure; locally the Arch shape reproduces. Now #define NAME 1.

With the fixed stage1, with get c.sqlite3: 303 functions, 34 presented safely, 269 raw, 0 unreadable units (was 18 / 3 / 1 unreadable). The 269 raw are proof limits, not reading failures.

What the hunt needed and the reports asked for, in the same change:

  • the bridge's parse error names the file, line and column clang gives (cimport_record_parse_error kept the spelling alone; the failing #if could not be found among 250k lines);
  • WITH_KEEP_BUILD keeps the fetched and configured source tree under dep_dir/.build after the facade, so an unread unit can be migrated by hand under the same compile_commands.json;
  • Migrator: a unity build sees the same global from two units and reports every function of the included unit unreadable (libcurl: 183 of its units) #2980: a global defined in a unit a unity unit #includes is seen from two units at one definition site: one definition, the first owner publishing it, as the function path already read it (libcurl's unity_0_c.c marked 183 units unreadable);
  • main is an entry point per unit, never a project symbol: a package's examples each carry one beside the library's (libcurl's docs/examples).

Migrator basic checks (run in the gate): bare_define_is_one (the defined branch is taken; a failing #if is located as empty.c:2:10: expected value in expression), unity_include_is_one_definition (two units including one .c and two mains migrate with every unit read; the included unit's producer and destroyer make the resource). The unity fixture fails on the installed compiler with "duplicate function definition for main".

With the fixed stage1, with get c.libcurl 8.23.0: 152 functions, 15 presented safely, 137 raw, every source unit read (the unity include no longer marks 183 units unreadable, and the examples' mains are no duplicate). The six units the build generates (tool_hugehelp.c, the test servers) are absent in a configured-only tree and are now reported apart: "6 unit(s) the build generates were not there (the package was configured, not built)", never as unreadable source. The summary's "N functions" already counts the functions the installed headers declare, which is the public-surface coverage the Arch report asked for.

Also filed today: #3024 (a failed early target reported as "a dependency cycle").

…ty include is one definition

A bare `-DNAME` is `NAME=1` to a C compiler; the migrator defined it
empty, so sqlite3.c's `#if HAVE_LOCALTIME_R` preprocessed as `#if` with
nothing to test, clang refused the amalgamation, and the facade saw 18
of 319 functions (3 presented). Now `#define NAME 1`; sqlite3 reads
whole: 303 functions, 34 presented safely, 0 unreadable units.

With it, what the hunt needed and the reports asked for:
- the bridge's parse error names the file, line and column clang gives
  (cimport_record_parse_error kept the spelling alone; the failing
  `#if` could not be found in 250k lines);
- `WITH_KEEP_BUILD` keeps the fetched and configured source tree under
  dep_dir/.build after the facade, so an unread unit can be migrated
  by hand under the same compile_commands.json;
- #2980: a global defined in a unit a unity unit `#include`s is seen
  from two units at one site — one definition, the first owner
  publishing it, as the function path already read it (libcurl's
  unity_0_c.c marked 183 units unreadable);
- `main` is an entry point per unit, never a project symbol (a
  package's examples each carry one: libcurl's docs/examples).

Migrator basic checks: bare_define_is_one (the defined branch is taken;
a failing `#if` is located as `empty.c:2:10: expected value in
expression`), unity_include_is_one_definition (two units including one
.c and two `main`s migrate; the included unit's producer and destroyer
make the resource).
@ehartford

Copy link
Copy Markdown
Contributor Author

Gate green on 9178b99 (465 s, seed-driven; the first run was red on sema-order-check because the bridge's located parse error leaked the per-run synthetic temp path into two c_import header-error fixtures — now the synthetic main is skipped, as collect_inclusion skips it). The migrator basic checks bare_define_is_one and unity_include_is_one_definition ran in the gate. Battery running.

@ehartford
ehartford marked this pull request as ready for review November 3, 2026 17:26
@ehartford

Copy link
Copy Markdown
Contributor Author

Battery green on 9178b99 (seed-driven gate, uat, battery-checks; out/battery/battery.log rc=0 green).

@ehartford
ehartford merged commit ec0f3ae into main Nov 3, 2026
@ehartford
ehartford deleted the sqlite-proofs branch November 3, 2026 17:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant