Repository navigation
COMP: Build and test on Windows - #93
hjmjohnson wants to merge 12 commits into
Conversation
5f432d3 to
d68c3ff
Compare
d8f8581 to
be1e2d5
Compare
d68c3ff to
f1c76aa
Compare
be1e2d5 to
6581cec
Compare
|
Force-push: plain rebase onto the rebased #92 and current |
gdevenyi
left a comment
There was a problem hiding this comment.
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:
- Restack to just the 2 Windows commits (
2746addand6581cec): 12 of the 14 commits on this branch are stale copies of already-merged PRs (#85,#86,#88— causing merge conflicts ininstall_linking_test.shandcmake-multi-platform.yml) and outdated copies of open PRs (#89,#90,#92). Cherry-picking only2746addand6581cecontomasterafter#90and#89merge will make the diff clean and conflict-free. - Do not pass
--no-tests=ignoretocteston Windows (cmake-multi-platform.yml:276): Unlikeminimal(NIFTI_BUILD_APPLICATIONS=OFF),windowsbuilds applications and registers ~330 tests;--no-tests=ignorewould let a broken test discovery pass silently. - Move
CMAKE_RUNTIME_OUTPUT_DIRECTORYdefault intoCMakeLists.txt(underif(WIN32)): Putting-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=...only in the workflow YAML leaves local Windows developers hitting0xC0000135(STATUS_DLL_NOT_FOUND) when runningctestonBUILD_SHARED_LIBS=ONbuilds because each library lives in its own subdirectory (znzlib/,niftilib/,nifti2/,cifti/). - Enable
-DUSE_FSL_CODE=ONand-DFSLSTYLE=ONon at least one Windows leg: All 8#ifdef _MSC_VER(_popen/_pclose) sites innifti1_io.c/nifti2_io.csit behind#ifdef PIGZ(-DFSLSTYLE=ON), andFSL_API__declspec(dllexport/dllimport)sits behind-DUSE_FSL_CODE=ON— neither is currently compiled by thewindowsjob despite the comment at line 235!
| -DCMAKE_TOOLCHAIN_FILE="$toolchain" ` | ||
| -DVCPKG_TARGET_TRIPLET=${{ matrix.triplet }} ` | ||
| -DBUILD_SHARED_LIBS=${{ matrix.shared }} ` | ||
| -DCMAKE_RUNTIME_OUTPUT_DIRECTORY="${{ github.workspace }}/build/bin" ` |
There was a problem hiding this comment.
[Google Carbon] Two suggestions on the Windows CMake configuration:
- Instead of passing
-DCMAKE_RUNTIME_OUTPUT_DIRECTORYonly in CI YAML, set aWIN32default in rootCMakeLists.txt(beforeadd_subdirectory, if not already defined by the caller) so local WindowsBUILD_SHARED_LIBS=ONbuilds also place.dlland.exeartifacts together forctest. - Line 235 notes that twelve source files carry
WIN32or_MSC_VERguards, yet all#ifdef _MSC_VER(_popen/_pclose) blocks innifti1_io.c&nifti2_io.crequire-DFSLSTYLE=ON(PIGZ), andfsliolib'sFSL_APIDLL exports require-DUSE_FSL_CODE=ON. Please add-DUSE_FSL_CODE=ON(and-DFSLSTYLE=ONon at least one leg) so those Windows guards are actually compiled! (Enabling GitHub Actions binary caching forvcpkg installon line 254 will also save ~2–4 minutes per run.)
There was a problem hiding this comment.
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.
f1c76aa to
a1e97ca
Compare
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)
6f7552f to
8514828
Compare
Re-submission of #82, reverted from
masteron 2026-09-24 so it can bereviewed before merging. Content is unchanged from the original.
Stack position 9 of 10. Base:
ci/missing-declarations(#81), notmaster.Merge the PRs above it in this stack first, or the diff shown here will
include their commits too.
Ordering for this stack
ci/install-linking-srcdirmasterci/test-output-on-failureci/install-linking-srcdirci/guard-cmp0169ci/test-output-on-failureci/build-all-codepathsci/guard-cmp0169ci/widen-coverageci/build-all-codepathspr/fix-missing-prototypesci/widen-coveragefix/buildyml-jobspr/fix-missing-prototypesci/missing-declarationsfix/buildyml-jobsci/windowsci/missing-declarationsci/workflow-trigger-lintci/windowsThe order is the order these changes sat on
masterbefore the revert, soit 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.txtand
cifti/afni_xml.h. Cherry-picked ontomasteralone, the later onesconflict. 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_linkingto find its source directory.Commits
See #84 for the ordering of all 49 re-submitted pull requests.