Skip to content

COMP: Build and test on Windows - #93

Draft
hjmjohnson wants to merge 12 commits into
ci/missing-declarationsfrom
ci/windows
Draft

hjmjohnson wants to merge 12 commits into
ci/missing-declarationsfrom
ci/windows

Conversation

@hjmjohnson

Copy link
Copy Markdown
Member

Re-submission of #82, reverted from master on 2026-09-24 so it can be
reviewed before merging. Content is unchanged from the original.

Stack position 9 of 10. Base: ci/missing-declarations (#81), not master.
Merge the PRs above it in this stack first, or the diff shown here will
include their commits too.

Ordering for this stack

# PR branch base
1 #29 ci/install-linking-srcdir master
2 #28 ci/test-output-on-failure ci/install-linking-srcdir
3 #30 ci/guard-cmp0169 ci/test-output-on-failure
4 #75 ci/build-all-codepaths ci/guard-cmp0169
5 #77 ci/widen-coverage ci/build-all-codepaths
6 #37 pr/fix-missing-prototypes ci/widen-coverage
7 #78 fix/buildyml-jobs pr/fix-missing-prototypes
8 #81 ci/missing-declarations fix/buildyml-jobs
9 #82 <- this PR ci/windows ci/missing-declarations
10 #83 ci/workflow-trigger-lint ci/windows

The order is the order these changes sat on master before the revert, so
it is known to build and test at every step. Verified again after
rebuilding the stack: the tip configures, compiles with no errors, and
passes 344/344 tests.

Why this one is stacked rather than independent

Each PR in this chain edits the same few files as its predecessors, chiefly
.github/workflows/cmake-multi-platform.yml, cmake/exported_symbols_linux.txt
and cifti/afni_xml.h. Cherry-picked onto master alone, the later ones
conflict. Two members also carry a build-order dependency rather than a
textual one: without #30 the project does not configure at all on CMake
versions that do not know policy CMP0169, and #29 is needed for
install_linking to find its source directory.

Commits
  • COMP: Build and test on Windows
  • COMP: Export the afni_xml half of the cifti library

See #84 for the ordering of all 49 re-submitted pull requests.

@hjmjohnson

Copy link
Copy Markdown
Member Author

Force-push: plain rebase onto the rebased #92 and current master. One commit was dropped because its patch is already on master (COMP: Install the tools the analysis jobs actually invoke); the others are unchanged apart from context in fsliolib/fslio.c. Default build 344/344, and the strict GCC 16 build is clean.

@gdevenyi gdevenyi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review by Google Carbon

Verdict: Request Changes (Draft; conflicts with master via 12 stale stacked commits)

Adding MSVC static & shared (x64-windows-static / x64-windows) CI coverage and fixing CIF_API DLL symbol exports in cifti/afni_xml.h are very valuable additions! Before marking ready for review:

  1. Restack to just the 2 Windows commits (2746add and 6581cec): 12 of the 14 commits on this branch are stale copies of already-merged PRs (#85, #86, #88 — causing merge conflicts in install_linking_test.sh and cmake-multi-platform.yml) and outdated copies of open PRs (#89, #90, #92). Cherry-picking only 2746add and 6581cec onto master after #90 and #89 merge will make the diff clean and conflict-free.
  2. Do not pass --no-tests=ignore to ctest on Windows (cmake-multi-platform.yml:276): Unlike minimal (NIFTI_BUILD_APPLICATIONS=OFF), windows builds applications and registers ~330 tests; --no-tests=ignore would let a broken test discovery pass silently.
  3. Move CMAKE_RUNTIME_OUTPUT_DIRECTORY default into CMakeLists.txt (under if(WIN32)): Putting -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=... only in the workflow YAML leaves local Windows developers hitting 0xC0000135 (STATUS_DLL_NOT_FOUND) when running ctest on BUILD_SHARED_LIBS=ON builds because each library lives in its own subdirectory (znzlib/, niftilib/, nifti2/, cifti/).
  4. Enable -DUSE_FSL_CODE=ON and -DFSLSTYLE=ON on at least one Windows leg: All 8 #ifdef _MSC_VER (_popen/_pclose) sites in nifti1_io.c/nifti2_io.c sit behind #ifdef PIGZ (-DFSLSTYLE=ON), and FSL_API __declspec(dllexport/dllimport) sits behind -DUSE_FSL_CODE=ON — neither is currently compiled by the windows job despite the comment at line 235!

Comment thread cifti/afni_xml.h Resolved
-DCMAKE_TOOLCHAIN_FILE="$toolchain" `
-DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} `
-DBUILD_SHARED_LIBS=${{ matrix.shared }} `
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY="${{ github.workspace }}/build/bin" `

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Google Carbon] Two suggestions on the Windows CMake configuration:

  1. Instead of passing -DCMAKE_RUNTIME_OUTPUT_DIRECTORY only in CI YAML, set a WIN32 default in root CMakeLists.txt (before add_subdirectory, if not already defined by the caller) so local Windows BUILD_SHARED_LIBS=ON builds also place .dll and .exe artifacts together for ctest.
  2. Line 235 notes that twelve source files carry WIN32 or _MSC_VER guards, yet all #ifdef _MSC_VER (_popen/_pclose) blocks in nifti1_io.c & nifti2_io.c require -DFSLSTYLE=ON (PIGZ), and fsliolib's FSL_API DLL exports require -DUSE_FSL_CODE=ON. Please add -DUSE_FSL_CODE=ON (and -DFSLSTYLE=ON on at least one leg) so those Windows guards are actually compiled! (Enabling GitHub Actions binary caching for vcpkg install on line 254 will also save ~2–4 minutes per run.)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Point 2 is in 06026f2: both legs now build fsliolib with -DUSE_FSL_CODE=ON, and the shared leg sets -DFSLSTYLE=ON; this is unverified until the workflow runs, since this PR's base is not master. Point 1 changes the default build layout for every Windows consumer of the root CMakeLists.txt, so I have left it for a maintainer decision rather than folding it in here.

@hjmjohnson
hjmjohnson force-pushed the ci/missing-declarations branch from f1c76aa to a1e97ca Compare November 17, 2026 22:38
gdevenyi and others added 12 commits November 17, 2026 16:40
The test hard-codes the path to the downstream example project:

    cmake ... ../../nifti_clib/real_easy/minimal_example_of_downstream_usage

That only resolves when the build directory happens to be a sibling of a
source tree named exactly "nifti_clib".  It fails for an in-tree build,
for a build directory named anything else, and on CI, where the checkout
lives at <workspace>/nifti_clib and the path resolves to
<workspace>/nifti_clib/nifti_clib/real_easy/...

CMake now passes CMAKE_SOURCE_DIR to the script, the way the other test
scripts in that directory already receive their arguments.

(cherry picked from commit 6458714)
cmake-multi-platform.yml ran ctest without --output-on-failure, so a red
build reported which test failed and nothing about why.

(cherry picked from commit 919dcea)
cmake-multi-platform.yml is the workflow that runs on every pull
request, and it passes no options at all.  With the defaults that means
cifti/ and fsliolib/ are never compiled, and neither are the blocks
behind FSLSTYLE, PIGZ and REJECT_COMPLEX.

  USE_CIFTI_CODE          OFF
  USE_FSL_CODE            OFF
  FSLSTYLE_NAME_CONFLICTS OFF   -> -DFSLSTYLE
  FSLSTYLE_PIGZ_SUPPORT   OFF   -> -DPIGZ
  FSLSTYLE_REJECT_COMPLEX OFF   -> -DREJECT_COMPLEX

So a PR that changes any of those files collects four green checks that
never built it.  Several open PRs are in exactly that position.

The matrix gains an 'options' axis: 'default' is what a consumer gets
with no arguments, 'all' turns the optional libraries and the FSL parity
defines on.  Both are kept, because the default build is what ships and
a change can break it while the fuller one still compiles.  Four jobs
become eight, each about half a minute.

expat is installed for the Linux 'all' jobs; cifti needs it and the
default jobs do not.

Verified on master before writing this, with the test suite:

  default                          build OK, tests pass
  +cifti +fsl                      build OK, tests pass
  +cifti +fsl +FSLSTYLE            build OK, tests pass, doPigz/doPigz2
                                   present in nifti2_io.c.o

COMPILE_NIFTIUNUSED_CODE is deliberately left out.  It guards code the
project itself labels unused, so compiling it in CI would commit to
keeping it working; whether that code should exist at all is a separate
question.

(cherry picked from commit b6531f0)
Run the Build and Test workflow on this repository's branch. Its
trigger named "main" while the branch is "master", so it had never
executed on master and did not execute on pull requests; valgrind,
AddressSanitizer, UndefinedBehaviorSanitizer, scan-build, gcov
coverage, and the only shared-library configuration were all
unexercised. Also move its macOS entry off the retired macos-11 image.

Restructure the per-PR matrix around the axes that change what is
compiled:

  shared     BUILD_SHARED_LIBS gates TEST_INSTALL, so the ON legs are
             the first to run install_linking and cover the install
             and export path.
  fslstyle   -DFSLSTYLE is not additive.  It rewrites behaviour in
             niftilib and nifti2 through global -DFSLSTYLE, -DPIGZ and
             -DREJECT_COMPLEX, and one site has an #else that changes
             the pixdim[0] value written to disk.  Neither value
             subsumes the other.
  build_type One static Debug leg, which is what makes assert() live.

Drop both macos gcc legs: /usr/bin/gcc there is a clang shim reporting
AppleClang, so they duplicated the macos clang legs exactly. The
optional libraries are built everywhere rather than forming an axis,
since they are additive.

Add three jobs. The minimal configuration builds znzlib and niftilib
alone, which is what a downstream project vendoring the core reader
selects and which nothing else configures. The oldest supported CMake
job guards cmake_minimum_required, invisible to runners that all carry
a recent CMake. The exported symbol baseline diffs the dynamic symbol
set against a committed file, so a change to the ABI has to be updated
in the same commit rather than landing unnoticed.

Verified on Ubuntu 24.04 with GCC 13.3.0, the compiler the Linux
runners use:

  shared, Release, FSLSTYLE=OFF   345/345, install_linking passed
  static, Debug,   FSLSTYLE=ON    344/344, no assertion aborts
  minimal                          configures and builds, no tests
  CMake 3.28.3                     344/344

The baseline holds 448 symbols across six libraries, which is the
figure the linkage changes have been asserting without a way to check
it.

The workflow steps were exercised by running them directly in the
runner container image rather than through act, whose image omits
cmake.

(cherry picked from commit 77b7418)
The dashboard script restates the CTestConfig.cmake settings because
CTest's delayed initialization does not pick them up, and the restated
copy had drifted from the original.

Submit over https rather than http. my.cdash.org serves plain http
without redirecting, so submissions were going unencrypted.

Use the 00:00:00 EST nightly start time that CTestConfig.cmake
declares, rather than 01:00:00 UTC. The two differ by four hours, so
nightly builds were filed under the wrong day on the dashboard.

(cherry picked from commit 063e838)
The 2025 conversion to GitHub Actions replaced .travis.yml with two
workflows but left the dashboard script untouched, so it still
required a Travis environment. The workflow that drives it named the
wrong branch and never ran, which is why nothing surfaced the
mismatch.

Rename travis_dashboard.cmake to github_dashboard.cmake and take its
inputs from the runner that actually exists. CTEST_SITE now comes from
RUNNER_OS rather than the required TRAVIS_APP_HOST, whose absence
aborted the script before it configured anything, and the build name
carries RUNNER_OS in place of TRAVIS_OS_NAME.

Compare the branch name against its value rather than against the
literal string "ENV{BUILD_SOURCEBRANCHNAME}", so the Continuous and
Nightly models can be selected at all, and give the workflow a branch
name on push events as well as on pull requests.

Apply the same corrections to local_dashboard.cmake.

(cherry picked from commit f578e03)
FslGetHdrImgNames and FslSetIntensityScaling are defined here but
declared nowhere, while FslGetIntensityScaling and FslInit are already
published.  axml_recur_find_xml sits beside axml_recur in afni_xml.h
the same way.

The upstream fslio was deleted in 2015 in favour of a C++ replacement,
so this copy is the surviving one and its header is ours to correct.

Additive; no symbol changes.

(cherry picked from commit 4673c40)
Nine functions in fslio.c have external linkage and no declaration in
any header.  Nothing in the tree calls them across a translation unit,
AFNI's vendored copy never calls them, and no public source outside a
vendored copy of this file references them, so a caller would have had
to declare them itself.

Collect their prototypes in one block so the boundary between internal
and published is visible in one place.

FslSetVoxUnits and FslGetVoxUnits have no caller at all and are left
under #if 0 rather than deleted; FslSetTimeUnits and FslGetTimeUnits
are published, so the asymmetry is worth keeping visible.

Removes nine symbols from libfslio, which the baseline records.

(cherry picked from commit 8cdcf1a)
nifti1_io.c and nifti2_io.c each define nifti_fileexists with external
linkage, so libniftiio and libnifti2 export the same name and ELF link
order decides which one a caller linking both resolves to.

Declaring it locally silences the warning without choosing between
publishing it and making it static; that choice needs the duplication
settled first, and it covers a hundred names, not this one.

(cherry picked from commit 54e74e1)
Keeps FslGetAuxFile and FslSetAuxFile deriving the same length so the
pair cannot drift if the field width changes.  sizeof is 24, so the
copy still writes at most 23 bytes.

(cherry picked from commit 0c0e66c)
Twelve source files carry WIN32 or _MSC_VER guards and no workflow
has ever compiled them, so a change that breaks the Windows path is
invisible here and surfaces only when a consumer reports it.

Static and shared, because the ZNZ_API and NIFTI_API decorations differ
between them and only the shared build exercises the dllexport path.
Both legs build fsliolib, so FSL_API is compiled too, and the shared leg
sets FSLSTYLE, which is what compiles the _popen/_pclose PIGZ writers.
zlib and expat come from vcpkg, which the runner image already carries.

VCPKG_INSTALLATION_ROOT is set by the runner image, so the toolchain
path is read in PowerShell and checked before cmake runs. ctest fails
when it finds no tests, since the applications register them here.
afni_xml_io.h decorates its declarations with CIF_API and afni_xml.h
decorated none of its own, so a Windows shared build produced a DLL
missing every axml_ entry point and both cifti tools failed to link
against the library they are built with.

The macro definition moves to afni_xml.h, which afni_xml_io.h includes
at its top, so one definition now serves both headers rather than each
carrying its own. Nothing changes where the attribute expands to default
visibility: the exported set of the shared build is byte-identical.

Found by the Windows job added in the preceding commit.

(cherry picked from commit 63b361a)
@hjmjohnson
hjmjohnson force-pushed the ci/windows branch 2 times, most recently from 6f7552f to 8514828 Compare November 17, 2026 22:40
@hjmjohnson

Copy link
Copy Markdown
Member Author

First force-push (6f7552f) = review fixes on the old base; second (8514828) = plain restack onto the updated #92, every commit unchanged.

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.

3 participants