Skip to content

Stop building the libgit2 test suite on every build - #108

Merged
hannesa2 merged 1 commit into
gitx:masterfrom
goneng:stop-building-the-libgit2-test-suite
Sep 21, 2026
Merged

hannesa2 merged 1 commit into
gitx:masterfrom
goneng:stop-building-the-libgit2-test-suite

Conversation

@goneng

@goneng goneng commented Sep 21, 2026 •

Copy link
Copy Markdown

The flag meant to switch the Clar tests off has not matched the option
libgit2 declares since its 1.x rename, so every build compiles a test
suite that is never run.

  • Pass -DBUILD_TESTS:BOOL=OFF, the name the pinned libgit2 declares, in
    place of the -DBUILD_CLAR:BOOL=OFF that now matches nothing.
  • Leave the rest of the configure line untouched: BUILD_TESTS gates only
    enable_testing() and the tests subdirectory, never src, so the
    archive this script installs is unchanged.

Why the flag stopped working

libgit2 renamed the option in its 1.x line. The pinned 1.9.7 declares

option(BUILD_TESTS  "Build Tests using the Clar suite"  ON)

at CMakeLists.txt:23, and BUILD_CLAR appears nowhere in the tree.
cmake accepts the unknown -D without complaint, caches it, and warns
about it only if you ask, so the line has read as if it were doing its
job. BUILD_TESTS defaults to ON, so the suite has been built on every
run since the bump.

Nothing consumes it. script/update_libgit2 installs libgit2.a and
nothing else, and this repo's own workflow has the Test project step
commented out, so the Clar binaries were compiled and then discarded on
every CI run on both architectures.

The one other thing BUILD_TESTS gates is tests/headertest, a
compile-only self-containment check over libgit2's own headers. That is
worth having upstream, where the headers are edited, but not here, where
libgit2 is a pinned submodule we do not modify.

Measurements

Timed back to back on an Intel Mac, same checkout, rm -rf build both
times as the script always does:

objects compiled wall clock
before 667 16m40s
after 196 7m40s

471 of the 667 objects, 71%, were the test suite, and this script runs
from an Xcode Run Script phase as well as from CI.

On the CI runners, comparing the Run script/update_libgit2 step of this
PR against the same step on master at 442b5dd:

before after
macos-15-intel, x86_64 2m43s 1m58s
macos-26, arm64 1m21s 38s

Less than the nine minutes above, in proportion as well as absolutely:
the runners are much faster than the machine that produced the first
table, and a fixed slice of that step is cmake's configure probes, which
this change does not touch.

The logs confirm the same per-build object counts there as locally: 196
objects with none of them tests, against 667 with 470 tests on master.

Note that each job builds libgit2 twice over, once in the
Run script/update_libgit2 step and again from the Xcode Run Script
phase during Archive project, each time from scratch because the
script always does rm -rf build. So the saving above lands twice per
job, and the x86_64 job compiles 392 objects here against 1334 on
master.

Test plan

  • Ran the script before and after on the same checkout. The resulting
    External/libgit2.a is the same size to the byte, 6,433,360, and
    exports an identical set of 2,097 global text symbols, diffed via
    nm -g.
  • Confirmed the build log after the change has zero libgit2_tests.dir
    or util_tests.dir objects, and that the 196 remaining objects are the
    same library objects as before, headertest.c.o excepted.
  • script/update_libgit2 is what the Build job runs on both
    macos-15-intel and macos-26, so CI exercises this directly on both
    architectures through to xcodebuild archive.

Not addressed here

The script still does rm -rf build and reconfigures from scratch on
every invocation, so it pays the remaining 7m40s even when nothing
changed. #97 is the change for that, and the two are independent: this
one shrinks the rebuild, that one avoids it. Worth noting that #97 as it
stands also adds EXCLUDED_ARCHS = x86_64 to four build configurations,
which would stop the project building on Intel hardware.

The flag meant to switch the Clar tests off has not matched the option
libgit2 declares since its 1.x rename, so every build compiles a test
suite that is never run.

- Pass -DBUILD_TESTS:BOOL=OFF, the name the pinned libgit2 declares, in
  place of the -DBUILD_CLAR:BOOL=OFF that now matches nothing.
- Leave the rest of the configure line untouched: BUILD_TESTS gates only
  enable_testing() and the tests subdirectory, never src, so the archive
  this script installs is unchanged.
@hannesa2
hannesa2 merged commit 3e671f1 into gitx:master Sep 21, 2026
2 checks passed
goneng added a commit to goneng/gitx that referenced this pull request Sep 21, 2026
Every GitX build runs libgit2's cmake build, which compiled a Clar test
suite that is never run, because the flag meant to switch it off stopped
matching libgit2's own option name at the 1.x rename.

- Move the objective-git pointer onto gitx/objective-git#108, which
  passes -DBUILD_TESTS:BOOL=OFF in place of the dead -DBUILD_CLAR:BOOL=OFF
  and cuts 471 of the 667 objects the build compiles.
- Take that fix alone rather than the current objective-git master, which
  has since moved on to unrelated work in gitx#107.
@goneng
goneng deleted the stop-building-the-libgit2-test-suite branch September 22, 2026 10:20
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.

2 participants