Skip to content
This repository was archived by the owner on Aug 20, 2026. It is now read-only.

fix(build): make clean remove the test artefacts, and stop hardcoding clang-only flags - #56

Merged
balbasty merged 1 commit into
teenyfrom
claude/55-make-clean-and-gcc-flags
Aug 1, 2026
Merged

fix(build): make clean remove the test artefacts, and stop hardcoding clang-only flags#56
balbasty merged 1 commit into
teenyfrom
claude/55-make-clean-and-gcc-flags

Conversation

@balbasty

Copy link
Copy Markdown
Contributor

Agent:claude-fastfields-to-teeny

Closesfastfields/fastfields-lib#131.

Why

Two halves of the same trap. make test CXX=g++ in a directory that had been
built with clang did not measure anything — while looking green. fastfields/fastfields-lib#131 was filed
from #54, where exactly that produced a "both compilers pass" claim that was
not true; the same trap is in the way of every subsequent both-compiler gate,
so it is worth ten lines to remove it rather than working around it again.

What changed

1. clean now removes the test artefacts. It removed build/*.o and
build/*.so but not build/testobj/ or the build/test_* binaries, so a
compiler switch in the same directory re-ran the previous compiler's binaries.
The output was real — it was just the wrong build's, which is worse than a
failure. clean now depends on a clean-test that removes both, plus the *.d
dependency files next to the objects.

2. DIAGFLAGS is chosen by probing the compiler.CXXFLAGS/TESTFLAGS
hardcoded -ferror-limit=1 -ftemplate-backtrace-limit=0, which are clang
spellings; g++ rejects both, so make CXX=g++ failed on the flags before
compiling a single file. g++ takes -fmax-errors=1 (the direct equivalent) and
has no counterpart for the backtrace limit.

The choice comes from $(CXX) --version | grep -ci clang, not from
pattern-matching $(CXX): a g++ that is really AppleClang, or a plain cc,
both then get the right answer. $(CXX) is only a name.

IS_CLANG := $(shell$(CXX) --version 2>/dev/null | head -1 | grep -ci clang)ifeq ($(IS_CLANG),0)
DIAGFLAGS = -fmax-errors=1
elseDIAGFLAGS = -ferror-limit=1 -ftemplate-backtrace-limit=0
endif

Verification

By doing the thing that used to be impossible — a from-scratch build under each
compiler, in the same directory, each compiling for real:

$ make clean CXX=g++
rm -f ./build/*.o
rm -f ./build/testobj/*.o ./build/testobj/*.d
rm -f ./build/test_distance ./build/test_distance_mesh … ./build/test_splinc
$ make -j4 test CXX=g++
suiteclang++g++
test_distance23522352
test_distance_mesh46224622
test_distance_spline704704
test_posdef50925092
test_pushpull326326
test_reg_field525525
test_reg_flow854854
test_reg_op186186
test_resize41304130
test_restrict191191
test_splinc45774577

failures: 0 / PASSED on every line, both compilers. Before this change the
g++ column could not be produced at all.

Build-only change; no source touched.


Generated by Claude Code

…ng clang-only flags
Two halves of the same trap (#55): `make test CXX=g++` in a directory that had
been built with clang did not measure anything, while looking green.
1. `clean` removed `build/*.o` and `build/*.so` but not `build/testobj/` or the
`build/test_*` binaries. A compiler switch in the same directory therefore
re-ran the PREVIOUS compiler's binaries -- the test output was real, it was
just the wrong build's. `clean` now depends on a `clean-test` that removes
both (and the `*.d` dependency files alongside the objects).
2. `CXXFLAGS`/`TESTFLAGS` hardcoded `-ferror-limit=1 -ftemplate-backtrace-limit=0`,
which are clang spellings; g++ rejects both, so `make CXX=g++` failed on the
flags before compiling anything. They now come from a `DIAGFLAGS` chosen by
PROBING the compiler (`$(CXX) --version | grep -ci clang`) rather than by
pattern-matching `$(CXX)` -- a `g++` that is really AppleClang, or a plain
`cc`, both get the right answer. g++ takes `-fmax-errors=1`, which is the
direct equivalent; it has no counterpart for the backtrace limit.
Verified by doing the thing that used to be impossible: a from-scratch
`make clean && make -j4 test CXX=g++`, and the same with `CXX=clang++`, in the
same directory, each compiling for real.
Closes #55.
@balbastyClaude

Copy link
Copy Markdown
ContributorAuthor

Compile counts for the verification above, since "it built" is the claim this PR exists to make checkable. Counted from the full build logs:

$ make clean CXX=clang++ && make -j4 test CXX=clang++
clang++ compile invocations: 30 exit=0
$ make clean CXX=g++ && make -j4 test CXX=g++
g++ compile invocations: 30 exit=0

30 is every module object plus every test-driver object, i.e. the whole tree,
under each compiler in turn. Sample g++ command line, showing the probe picked
-fmax-errors=1 rather than the clang spelling:

g++ -std=c++17 -O3 -fmax-errors=1 -DTNY_MAX_RANK=64 -DFF_TEST_SPARSE … -c -o build/testobj/distance.o distance.cpp

and the clean that made the second pass real:

rm -f ./build/*.so
rm -f ./build/*.o
rm -f ./build/testobj/*.o ./build/testobj/*.d
rm -f ./build/test_distance ./build/test_distance_mesh … ./build/test_splinc

Worth noting how this bit me while writing the companion PR: my first attempt at
the two-compiler run piped make through tail, so the compile lines scrolled
away, and one of the two passes silently did no work — I only caught it by
grepping the log for compiler invocations and finding zero. Counting them is the
check; the check-count table alone cannot distinguish a real build from a rerun.


Generated by Claude Code

@balbasty
balbasty merged commit 796aa12 into teenyAug 1, 2026
1 check passed
@balbasty
balbasty deleted the claude/55-make-clean-and-gcc-flags branch August 1, 2026 19:45
Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@balbasty@claude