Skip to content

DOC: Describe the CMake build and how to run the memory checks - #58

Merged
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:masterfrom
gdevenyi:pr/docs-build-and-memory-checking
Sep 22, 2026
Merged

hjmjohnson merged 1 commit into
InsightSoftwareConsortium:masterfrom
gdevenyi:pr/docs-build-and-memory-checking

Conversation

@gdevenyi

@gdevenyi gdevenyi commented Aug 15, 2026 •

Copy link
Copy Markdown

The build instructions in README.md were two lines about 'make all',
which builds a subset of the tree with a Makefile nothing else in the
project uses. They now describe the CMake build the CI and the install
rules actually use, and note that the Makefile is unmaintained and does
not cover nifti2 or cifti.

A new section records how to run the sanitizers and valgrind, including
three things that each cost an afternoon to work out:

  • valgrind's memcheck needs --trace-children=yes here, because most of
    the tests are shell scripts that exec the tools. Without it valgrind
    inspects the shell, sees nothing and reports a clean run;
  • ctest -T memcheck exits 0 even when valgrind reports defects, so the
    logs have to be read;
  • valgrind refuses to start without the C library's debug symbols, and
    on distributions that ship a stripped ld.so with no debuginfo package
    -- Arch and its derivatives -- it cannot be run at all, DEBUGINFOD_URLS
    included, because those builds are not on any debuginfod server. A
    container recipe is given.

Every command in the new sections was run against this tree.


Interface impact: none. On the union of all these changes, configured with USE_FSL_CODE=ON and USE_CIFTI_CODE=ON: all 448 exported symbols across libniftiio, libnifti2, libznz, libfslio, libnifticdf and libcifti are identical to master under nm -D --defined-only, and all ten installed headers are identical under gcc -E -P. Under gcc -dM -E one macro definition differs, intentionally and only in text: #61 makes FSL_RADIOLOGICAL read (-1) so it is safe inside an expression. Its value is still -1, checked by compiling against each installed fslio.h and printing it.

Verification. This branch: builds with gcc 16.1.1, ctest unchanged from master (2 of 345 fail on master itself in this environment; #31 and #29 each fix one). The union of all the PRs: 0 errors under both gcc 16.1.1 and clang 22.1.8, ctest 345/345 under each, and the whole suite under valgrind memcheck with --trace-children=yes gives 484 traced processes with no invalid access, no uninitialised value and no leak in any nifti binary.

Coordination. Every line of every branch was compared, whitespace-normalised, against the diffs of the open PRs (#11, #21, #22, #23, #24). Where one of those already changes a line, the line was left alone, and the few deliberate overlaps are named in the text above. What survives is 17 compiler warnings, all of them on those lines: 9 -Wsign-conversion (5 in fslio.c for #22, 2 in nifti2_io.c and 2 in nifti_tester001.c for #24) and 8 -Wcalloc-transposed-args in nifti_findhdrname and nifti_findimgname, which #11 rewrites. No formatting changes appear anywhere, to stay clear of #10 and #12.

One of a set of independent, single-purpose PRs. Each bases on master and can be merged on its own, in any order.

The full set of PRs (35)

The union of all of them is on the fork as all-changes, if you want to build and test the lot at once.

CI and build

Configuration and documentation

Defects

Warning and check classes

This was referenced Aug 15, 2026
@hjmjohnson

Copy link
Copy Markdown
Member

Rebased onto current master (b4876bf) and pushed as c65e051. Applied cleanly, no conflicts. No test added: documentation.

I checked every option and command the new sections name against this tree rather than taking the "every command was run against this tree" line on trust. DOWNLOAD_TEST_DATA, USE_CIFTI_CODE, USE_FSL_CODE and BUILD_SHARED_LIBS all exist; the NEEDS_DATA label is real and -LE NEEDS_DATA selects 299 of 362 tests; USE_CIFTI_CODE is a cmake_dependent_option on USE_NIFTI2_CODE, which defaults ON, so the documented -DUSE_CIFTI_CODE=ON alone does work.

One finding, pre-existing and not caused by this PR. The no-network recipe does not come out clean:

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DDOWNLOAD_TEST_DATA=OFF
ctest --test-dir build -LE NEEDS_DATA
  -> 99% tests passed, 1 tests failed out of 296
  -> 339 - nifti_dsets_test (Failed)

nifti_dsets_test fails identically on unmodified master in that configuration, so it is not this PR's doing — it appears to need downloaded data without carrying the NEEDS_DATA label. Either the label is missing from that test or it needs a guard; worth a separate issue. Until then, the README sentence promises slightly more than the tree delivers.

What changed in this update
  • Rebased onto master; no conflicts.
  • Commit message: dropped the Co-Authored-By: naming an AI tool and the Claude-Session: URL. Nothing else in the message needed changing.
  • No change to the README content.
Why no test

COSMETIC/DOC class. A README has no runtime seam. The substantive check for a documentation change is whether it is true, which is what is reported above.

The build instructions in README.md were two lines about 'make all',
which builds a subset of the tree with a Makefile nothing else in the
project uses.  They now describe the CMake build the CI and the install
rules actually use, and note that the Makefile is unmaintained and does
not cover nifti2 or cifti.

A new section records how to run the sanitizers and valgrind, including
three things that each cost an afternoon to work out:

  * valgrind's memcheck needs --trace-children=yes here, because most of
    the tests are shell scripts that exec the tools.  Without it valgrind
    inspects the shell, sees nothing and reports a clean run;
  * ctest -T memcheck exits 0 even when valgrind reports defects, so the
    logs have to be read;
  * valgrind refuses to start without the C library's debug symbols, and
    on distributions that ship a stripped ld.so with no debuginfo package
    -- Arch and its derivatives -- it cannot be run at all, DEBUGINFOD_URLS
    included, because those builds are not on any debuginfod server.  A
    container recipe is given.

Every command in the new sections was run against this tree.
@hjmjohnson
hjmjohnson force-pushed the pr/docs-build-and-memory-checking branch from c65e051 to e67d6be Compare September 22, 2026 15:54
@hjmjohnson
hjmjohnson merged commit 36976a2 into InsightSoftwareConsortium:master Sep 22, 2026
25 checks passed
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