Skip to content

Fix warning-free debug amalgamation builds - #1799

Merged
InauguralPhysicist merged 2 commits into
InauguralSystems:mainfrom
facelessdevhack:fix/amalgamation-debug-warnings
Oct 20, 2026
Merged

InauguralPhysicist merged 2 commits into
InauguralSystems:mainfrom
facelessdevhack:fix/amalgamation-debug-warnings

Conversation

@facelessdevhack

@facelessdevhack facelessdevhack commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

The two-file amalgamation now compiles without warnings at -O0 and -O1. Keep gather's existing argument guard and add an explicit final return; initialize the bitwise conversion temporaries and JIT index-set local where declared. Runtime control flow and strict/fail-soft results stay the same.

The existing CI-enrolled amalgamation drop-in test now compiles the generated translation unit at both optimization levels with -Wall -Wextra and the shared warning flags. It rejects compiler failures and warning diagnostics, while preserving the existing CC selection and host/evaluation/teardown checks.

Fixes #1775.

Validation on macOS arm64 with actual GNU GCC 15.2.0_1:

Compile Before warning lines After warning lines
-O0 1 (-Wreturn-type) 0
-O1 0 0

The issue's seven -O1 diagnostics were not reproduced on this compiler/architecture; the initializations and persistent -O1 check cover the reported paths. Both exact issue-requested compile commands exit 0 after the fix, with empty diagnostic logs.

  • CC=/opt/homebrew/bin/gcc-15 bash tests/test_amalgamation.sh: 7 passed, 0 failed. The test is invoked directly by existing CI; it is not selected by make test-changed.

  • Regression before the production fix: 6 passed, 1 failed, rejecting the actual zero-exit GCC -O0 warning. In an isolated checkout, removing only the added return reproduces that failure; restoring it returns to 7 passed, 0 failed.

  • make: passed (normal repository compiler selection).

  • make precheck: 19 passed, 0 failed, 0 skipped.

  • make test-changed: 154/154 passed, 0 failed, 0 skipped. The planner identifies both C files as runtime changes; full runtime and sanitizer verification remains for CI.

  • Shared warning-flag checker, Bash 3.2 syntax check, and git diff --check: passed.

  • Warning-free -O0 and -O1 amalgamation compilation locally.

  • Explicit return and initialized locals.

  • Persistent CI check with a real planted-return regression proof.

  • Hosted full-suite and sanitizer checks; Linux GCC verification of the original -O1 diagnostic family.

Prepared with OpenAI Codex assistance and reviewed by a separate Codex agent.

Hosted validation at 44d12b9f233ed6fa3234320d16055c57c57df76d: all 31 reported checks completed, with 25 successful checks and six conditional skips. Successful checks include Linux GCC/Clang, ASan/UBSan, Valgrind, TSan and the changed-row self-test gate.

@codspeed

codspeed Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 13 untouched benchmarks


Comparing facelessdevhack:fix/amalgamation-debug-warnings (94d3929) with main (9465758)

Open in CodSpeed

@facelessdevhack
facelessdevhack marked this pull request as ready for review October 15, 2026 08:41
@InauguralPhysicist

Copy link
Copy Markdown
Member

Thank you. The fix itself is right: the explicit return after ARG_GUARD(1, …) and the two initialisers. One change is needed before it can merge.

The new -O0/-O1 warning check fails under clang. tests/test_amalgamation.sh uses CC="${CC:-cc}", which is Apple clang on the macOS lane. That lane runs only in the merge queue, not on PRs, which is why this PR's checks are green. Running the PR head locally with CC=clang bash tests/test_amalgamation.sh:

  FAIL: amalgamation emits warnings at -O0
  FAIL: amalgamation emits warnings at -O1
Results: 5 passed, 2 failed

That run produced 214 warnings, mostly -Wstring-plus-int, for example eigenscript_all.c:33969:5: warning: adding 'int' to a string does not append to the string. gcc is the reference toolchain for #1775's class (-Wmaybe-uninitialized and -Wreturn-type at low optimisation), and clang's -Wall -Wextra set is different and much noisier. So please apply the warning-free assertion only when the compiler is gcc. Detect it, for example, with $CC --version | grep -q 'Free Software Foundation' or __GNUC__ without __clang__. Under clang, keep the build-must-succeed check and skip the zero-warning one with a message that says why. The Phase 2 branch (#1776) settled on the same rule for its own slot test.

Also, for whoever later touches vm_run_ex: on the Phase 2 branch, callgrind measured initialising exactly these declarations (INT_BINOP_R's _ad/_bd and the index i) as free. Other spellings of the same fix (callees writing their out-params on every path) measured +3.8% on a float loop. CodSpeed passing here agrees.

…uguralSystems#1872)

Under clang, -Wall -Wextra reports about 200 warnings across the tree,
mostly -Wstring-plus-int, so the new check failed on the macOS lane, which
runs only in the merge queue. The preprocessor decides which compiler it
is (Apple's gcc is clang too); clang prints a SKIP line citing InauguralSystems#1872.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KC99CmwatKssQYggkBCgwF
@InauguralPhysicist

Copy link
Copy Markdown
Member

Thank you again, @facelessdevhack: this is a good fix, and the -O0/-O1 check is a real improvement for embedders.

To unblock it I pushed one small commit to your branch (94d3929, using "allow edits by maintainers"). It runs the new -O0/-O1 warning check under gcc only. Under clang, -Wall -Wextra reports about 200 warnings across the whole tree, mostly -Wstring-plus-int. Those predate your change, so they should not block it. They are now #1872, and the test prints a SKIP line citing it under clang. The test asks the preprocessor whether __clang__ is defined, because Apple's gcc is clang too.

Once CI is green it goes into the merge queue, where the macOS (clang) lane runs.

@InauguralPhysicist
InauguralPhysicist added this pull request to the merge queue Oct 20, 2026
Merged via the queue into InauguralSystems:main with commit bbc497e Oct 20, 2026
31 checks passed
@InauguralPhysicist

Copy link
Copy Markdown
Member

Merged: thank you, @facelessdevhack! Debug and -O1 embedders now get a warning-free amalgamation under gcc. The clang side is tracked in #1872 if you ever want to pick it up; it is mostly mechanical -Wstring-plus-int triage.

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.

Amalgamation compiles with warnings at -O0 (-Wreturn-type) and -O1 (-Wmaybe-uninitialized)

2 participants