Repository navigation
Build with GCC 15: include cstdint in source/io, bump ITK and libtorch in CI, guard ClassDef for libtorch 2 - #777
Open
MateuszBala wants to merge 4 commits into
Open
MateuszBala wants to merge 4 commits into
MateuszBala wants to merge 4 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Build with GCC 15: include cstdint in source/io, bump ITK and libtorch in CI, guard ClassDef for libtorch 2
Branch:
MateuszBala:fix/io-missing-cstdint- based onOpenGATE/develop(f53b44fa)Target:
OpenGATE/Gate:developCommits: 4 -
fix(io): include cstdint where uint64_t is used,ci: bump ITK to v5.4.7 to build with GCC 15,ci: bump libtorch on Linux to 2.2.0 to build with GCC 15,fix(torch): hide the ROOT ClassDef macro while including libtorch headersFiles:
source/io/include/GateTreeFile.hh,source/io/include/GateTreeFileManager.hh,source/io/include/GateNumpyFile.hh,source/io/include/GateAsciiFile.hh,source/io/include/GateRootTreeFile.hh,.github/workflows/main.yml,source/digits_hits/include/Gate_NN_ARF_Actor.hh,source/digits_hits/src/Gate_NN_ARF_Actor.cc,source/physics/include/GateSourcePhaseSpace.hh,source/physics/src/GateSourcePhaseSpace.ccDepends on: nothing
The
ubuntu-latestrunner image now ships GCC 15.2, and the CI build ofdevelopfails with it.This pull request fixes three failures: a missing include in GATE itself, the ITK version used by
the
rtkjob, and the libtorch version used by thetorchjob. The newer libtorch exposed afourth problem, a name clash between libtorch 2 and a ROOT macro, which is fixed in GATE as well.
The problem
The CI build of
developfails onubuntu-latestin all four configurations (none,optic,rtk,torch). The scheduled runs fail as well (for example run42965500658 on
f53b44fa), and so dopull requests built on top of
develop:The same error is reported for
GateTreeFileManager.hh,GateNumpyFile.hh,GateAsciiFile.hhand
GateRootTreeFile.hh. The follow-up errors inGateAsciiFile.cc,GateNumpyFile.ccandGateRootTreeFile.cc("no declaration matches", "does not have any field named") are caused by thesame missing type.
Cause
These headers have used
uint64_tsince they were added in43cc7c79(2019-04-30, numpyinput/output for
GatePhaseSpaceActor/GateSourcePhaseSpace), but none of them includes<cstdint>. The git history ofsource/iocontains no commit that adds or removes a<cstdint>,<stdint.h>or<inttypes.h>include, so this is not a regression. The include wasnever there.
The code compiled until now because older versions of libstdc++ pulled in
<cstdint>throughother standard headers (
<string>,<map>, ...). GCC 15 no longer does this. The runner imagenow ships GCC 15.2 (
gcc version 15.2.0 (Ubuntu 15.2.0-16ubuntu1)in the CI log), and the buildfails there. With GCC 14.2 the same code still compiles.
What changed
#include <cstdint>is added to the five headers that useuint64_t, as the compiler suggests.GateTreeFile.cc,GateTreeFileManager.cc,GateAsciiFile.cc,GateNumpyFile.ccandGateRootTreeFile.ccinclude their own headers, so they need no change. No other file insourceuses
uint64_t.Six added lines in total, with no other change to the code.
Verification
Checked with GCC 15.2 (
gcc:15.2Docker image,g++ (GCC) 15.2.0) and with GCC 14.2(Debian 14.2.0-19). Every file was compiled with
-fsyntax-only, using the compiler flags andinclude paths of a full GATE build (Geant4 and ROOT headers,
GATE_USE_OPTICAL=ON):source/io(7 files)source(721 files)develop(f53b44fa)'uint64_t' does not name a type, as in CIThe run on
developreproduces the CI error. It also fails inGateTreeFile.ccandGateTreeFileManager.cc, which CI never reached because the build stopped at 82%. The run on all721 sources shows that, with this fix, no other file fails with GCC 15 in this configuration.
Code behind
GATE_USE_RTK,GATE_USE_TORCHandGATE_USE_ITK(about 30 guarded blocks) was notcompiled locally. The
rtkandtorchCI jobs cover it.ITK for the
rtkjobWith the
cstdintfix in place, thertkjob gets further but fails while building ITK itself,before GATE is compiled:
GCC 15 compiles C as C23 by default. In C23
int (*handlerProc)()declares a function that takesno arguments, so the call with three or four arguments in the MINC copy bundled with ITK is now an
error. ITK fixed it by giving the handler a full prototype
(
typedef int (*handlerProcType)(void*, const char*, char*)) and backported the fix to the 5.4series:
ParseArgv.cv5.4.2(used by the workflow) ...v5.4.5int (*handlerProc)()v5.4.6,v5.4.7,v5.4.8The workflow now builds
ITK_VERSION: 'v5.4.7', the latest 5.4 release. It is a patch release ofthe series already in use, so no move to ITK 6 is needed. GATE asks CMake only for a minimal ITK
version, which
v5.4.7satisfies.Checked in the
gcc:15.2Docker image (g++ (GCC) 15.2.0,cmake 3.31.6). Both versions werecloned and configured with the exact CMake options of the workflow (including
-DModule_RTK=ON -DREMOTE_GIT_TAG_RTK=master), then the MINC library targetitkminc2was built:itkminc2v5.4.2ParseArgv.c:320:15: error: too many arguments to function 'handlerProc'; expected 0, have 3, as in CIv5.4.7Only the MINC target was built, not the whole of ITK and RTK. The
rtkCI job of this pullrequest builds the rest.
libtorch for the
torchjobWith the
cstdintfix in place, thetorchjob onubuntu-latestfails in the headers oflibtorch, while compiling
GateSourcePhaseSpace.cc:On Linux the workflow downloads libtorch 1.10.1 (2021), whose headers use
uint32_twithout<cstdint>, the same problem as insource/io. (The workflow also lists libtorch 2.2.0 formacOS, but the matrix excludes
macos-latestwithtorch, so that download is never used andGATE was never built against libtorch 2 in CI.)
#include <torch/script.h>, the header that fails in CI, was compiled with-std=c++17 -fsyntax-onlyin thegcc:15.2image against the headers of the official CPU packages fromdownload.pytorch.org:c10/util/StringUtil.h:128:3: error: 'uint32_t' does not name a type, as in CIThe workflow now downloads
libtorch-cxx11-abi-shared-with-deps-2.2.0+cpu.zipon Linux, theversion already named in the workflow for macOS. The archive unpacks to the same
libtorch/directory, so
Torch_DIRdoes not change.ROOT
ClassDefand libtorch 2With libtorch 2.2.0 the
torchjob gets further and fails in another libtorch header:ROOT defines
ClassDef(name,id)as a macro inRtypes.h. libtorch 2 has a classtorch::jit::ClassDefintree_views.h, and callsClassDef(...)there. When a GATE sourceincludes ROOT headers before libtorch, the preprocessor replaces the libtorch code with the ROOT
macro. libtorch 1.10.1 does not trip over it, which is why the job passed with the old version.
Every libtorch 2 release checked (2.2.0, 2.6.0, 2.9.1) has the same code, so any GATE build against
a current libtorch is affected, independently of the compiler.
The fix hides the macro only while libtorch is included, in the four places where GATE includes
it (
Gate_NN_ARF_Actor.hh,Gate_NN_ARF_Actor.cc,GateSourcePhaseSpace.hh,GateSourcePhaseSpace.cc):The rest of the translation unit, including any ROOT class declared after it, still sees the macro.
GateSourcePhaseSpace.ccalready orders its includes for a similar clash with macros from the IAEAheader.
The five GATE sources that include libtorch were compiled (
-fsyntax-only, flags and include pathsof a full GATE build,
GATE_USE_TORCHdefined) with GCC 14.2:Gate_NN_ARF_Actor.ccGate_NN_ARF_ActorMessenger.ccGateSourceMgr.ccGateSourcePhaseSpace.ccGateSourcePhaseSpaceMessenger.ccThe
FAILentries reproduce the CI error (GateSourceMgr.ccwas not reached in CI before the buildstopped). The clash does not depend on the compiler version.
The same five sources from this branch, with the fix, were then compiled in the
gcc:15.2image(
g++ (GCC) 15.2.0), with the same flags and the Geant4 and ROOT headers of a GATE build mountedinto the container:
Gate_NN_ARF_Actor.ccGate_NN_ARF_ActorMessenger.ccGateSourceMgr.ccGateSourcePhaseSpace.ccc10/util/StringUtil.h:128:3: error: 'uint32_t' does not name a type, as in CIGateSourcePhaseSpaceMessenger.ccWith libtorch 1.10.1 only
GateSourcePhaseSpace.ccfails: it includes libtorch first, before anyother header, while in the other sources earlier GATE, Geant4 or ROOT headers happen to bring in
<cstdint>. With libtorch 2.2.0 and theClassDeffix all five sources compile with GCC 15.2.Linking against libtorch 2.2.0 is left to the
torchCI job.How to reproduce with GCC 15.2
The five headers include only the standard library and each other, so each of them can be compiled
on its own in the official
gcc:15.2image, without Geant4, ROOT or a CMake configuration. OnlyDocker and a checkout of the repository are needed.
Run from the root of the repository:
On
develop(git checkout f53b44fa) every header fails:On this branch (
git checkout fix/io-missing-cstdint) every header compiles:Remove
2>/dev/nullto see the compiler messages; ondevelopthey are the same'uint64_t' does not name a typeerrors as in the CI log. Running the same command with GCC 14(
gcc:14image) givesOKfor all five headers even ondevelop. This shows that the failuredepends on the compiler version, not on any recent change in GATE.
The check above covers the headers only. The full results in the table, including all 721
sources, come from a run inside
gcc:15.2with the Geant4 and ROOT headers of an existing GATEbuild mounted into the container, so it is not as easy to reproduce.