Skip to content

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
OpenGATE:developfrom
MateuszBala:fix/io-missing-cstdint
Open

MateuszBala wants to merge 4 commits into
OpenGATE:developfrom
MateuszBala:fix/io-missing-cstdint

Conversation

@MateuszBala

@MateuszBala MateuszBala commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

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 on OpenGATE/develop (f53b44fa)
Target: OpenGATE/Gate:develop
Commits: 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 headers
Files: 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.cc
Depends on: nothing

The ubuntu-latest runner image now ships GCC 15.2, and the CI build of develop fails with it.
This pull request fixes three failures: a missing include in GATE itself, the ITK version used by
the rtk job, and the libtorch version used by the torch job. The newer libtorch exposed a
fourth problem, a name clash between libtorch 2 and a ROOT macro, which is fixed in GATE as well.

The problem

The CI build of develop fails on ubuntu-latest in all four configurations (none, optic,
rtk, torch). The scheduled runs fail as well (for example run
42965500658 on f53b44fa), and so do
pull requests built on top of develop:

source/io/include/GateTreeFile.hh:118:34: error: 'uint64_t' does not name a type
  118 |   virtual void read_entrie(const uint64_t& i) = 0;
source/io/include/GateTreeFile.hh:17:1: note: 'uint64_t' is defined in header '<cstdint>';
  this is probably fixable by adding '#include <cstdint>'

The same error is reported for GateTreeFileManager.hh, GateNumpyFile.hh, GateAsciiFile.hh
and GateRootTreeFile.hh. The follow-up errors in GateAsciiFile.cc, GateNumpyFile.cc and
GateRootTreeFile.cc ("no declaration matches", "does not have any field named") are caused by the
same missing type.

Cause

These headers have used uint64_t since they were added in 43cc7c79 (2019-04-30, numpy
input/output for GatePhaseSpaceActor / GateSourcePhaseSpace), but none of them includes
<cstdint>. The git history of source/io contains no commit that adds or removes a
<cstdint>, <stdint.h> or <inttypes.h> include, so this is not a regression. The include was
never there.

The code compiled until now because older versions of libstdc++ pulled in <cstdint> through
other standard headers (<string>, <map>, ...). GCC 15 no longer does this. The runner image
now ships GCC 15.2 (gcc version 15.2.0 (Ubuntu 15.2.0-16ubuntu1) in the CI log), and the build
fails there. With GCC 14.2 the same code still compiles.

What changed

#include <cstdint> is added to the five headers that use uint64_t, as the compiler suggests.
GateTreeFile.cc, GateTreeFileManager.cc, GateAsciiFile.cc, GateNumpyFile.cc and
GateRootTreeFile.cc include their own headers, so they need no change. No other file in source
uses uint64_t.

Six added lines in total, with no other change to the code.

Verification

Checked with GCC 15.2 (gcc:15.2 Docker 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 and
include paths of a full GATE build (Geant4 and ROOT headers, GATE_USE_OPTICAL=ON):

tree compiler source/io (7 files) all of source (721 files)
develop (f53b44fa) GCC 15.2 5 fail - 'uint64_t' does not name a type, as in CI -
this branch GCC 15.2 7 OK 721 OK
this branch GCC 14.2 7 OK -

The run on develop reproduces the CI error. It also fails in GateTreeFile.cc and
GateTreeFileManager.cc, which CI never reached because the build stopped at 82%. The run on all
721 sources shows that, with this fix, no other file fails with GCC 15 in this configuration.

Code behind GATE_USE_RTK, GATE_USE_TORCH and GATE_USE_ITK (about 30 guarded blocks) was not
compiled locally. The rtk and torch CI jobs cover it.

ITK for the rtk job

With the cstdint fix in place, the rtk job gets further but fails while building ITK itself,
before GATE is compiled:

Modules/ThirdParty/MINC/src/libminc/libcommon/ParseArgv.c:320:15: error: too many arguments to
  function 'handlerProc'; expected 0, have 3
  320 |          if ((*handlerProc)(infoPtr->dst, infoPtr->key,

GCC 15 compiles C as C23 by default. In C23 int (*handlerProc)() declares a function that takes
no 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.4
series:

ITK tag ParseArgv.c
v5.4.2 (used by the workflow) ... v5.4.5 old int (*handlerProc)()
v5.4.6, v5.4.7, v5.4.8 fixed

The workflow now builds ITK_VERSION: 'v5.4.7', the latest 5.4 release. It is a patch release of
the series already in use, so no move to ITK 6 is needed. GATE asks CMake only for a minimal ITK
version, which v5.4.7 satisfies.

Checked in the gcc:15.2 Docker image (g++ (GCC) 15.2.0, cmake 3.31.6). Both versions were
cloned and configured with the exact CMake options of the workflow (including
-DModule_RTK=ON -DREMOTE_GIT_TAG_RTK=master), then the MINC library target itkminc2 was built:

ITK configure itkminc2
v5.4.2 OK FAIL - ParseArgv.c:320:15: error: too many arguments to function 'handlerProc'; expected 0, have 3, as in CI
v5.4.7 OK OK

Only the MINC target was built, not the whole of ITK and RTK. The rtk CI job of this pull
request builds the rest.

libtorch for the torch job

With the cstdint fix in place, the torch job on ubuntu-latest fails in the headers of
libtorch, while compiling GateSourcePhaseSpace.cc:

libtorch/include/c10/util/StringUtil.h:128:3: error: 'uint32_t' does not name a type
  128 |   uint32_t line;

On Linux the workflow downloads libtorch 1.10.1 (2021), whose headers use uint32_t without
<cstdint>, the same problem as in source/io. (The workflow also lists libtorch 2.2.0 for
macOS, but the matrix excludes macos-latest with torch, so that download is never used and
GATE 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-only in the gcc:15.2 image against the headers of the official CPU packages from
download.pytorch.org:

libtorch GCC 15.2
1.10.1 (used by the workflow on Linux) FAIL - 54 errors, c10/util/StringUtil.h:128:3: error: 'uint32_t' does not name a type, as in CI
2.2.0 OK
2.6.0 OK
2.9.1 OK

The workflow now downloads libtorch-cxx11-abi-shared-with-deps-2.2.0+cpu.zip on Linux, the
version already named in the workflow for macOS. The archive unpacks to the same libtorch/
directory, so Torch_DIR does not change.

ROOT ClassDef and libtorch 2

With libtorch 2.2.0 the torch job gets further and fails in another libtorch header:

libtorch/include/torch/csrc/jit/frontend/tree_views.h:497:47: error: expected primary-expression before ';' token
  497 |          Maybe<List<Assign>>::create(range)}));

ROOT defines ClassDef(name,id) as a macro in Rtypes.h. libtorch 2 has a class
torch::jit::ClassDef in tree_views.h, and calls ClassDef(...) there. When a GATE source
includes 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):

// ROOT defines ClassDef(name,id) as a macro (Rtypes.h); libtorch has a class of the same name
#pragma push_macro("ClassDef")
#undef ClassDef
#include <torch/script.h>
#pragma pop_macro("ClassDef")

The rest of the translation unit, including any ROOT class declared after it, still sees the macro.
GateSourcePhaseSpace.cc already orders its includes for a similar clash with macros from the IAEA
header.

The five GATE sources that include libtorch were compiled (-fsyntax-only, flags and include paths
of a full GATE build, GATE_USE_TORCH defined) with GCC 14.2:

source libtorch 1.10.1 2.2.0 2.2.0 with this fix
Gate_NN_ARF_Actor.cc OK FAIL OK
Gate_NN_ARF_ActorMessenger.cc OK FAIL OK
GateSourceMgr.cc OK FAIL OK
GateSourcePhaseSpace.cc OK OK OK
GateSourcePhaseSpaceMessenger.cc OK OK OK

The FAIL entries reproduce the CI error (GateSourceMgr.cc was not reached in CI before the build
stopped). 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.2 image
(g++ (GCC) 15.2.0), with the same flags and the Geant4 and ROOT headers of a GATE build mounted
into the container:

source libtorch 1.10.1 libtorch 2.2.0
Gate_NN_ARF_Actor.cc OK OK
Gate_NN_ARF_ActorMessenger.cc OK OK
GateSourceMgr.cc OK OK
GateSourcePhaseSpace.cc FAIL - c10/util/StringUtil.h:128:3: error: 'uint32_t' does not name a type, as in CI OK
GateSourcePhaseSpaceMessenger.cc OK OK

With libtorch 1.10.1 only GateSourcePhaseSpace.cc fails: it includes libtorch first, before any
other header, while in the other sources earlier GATE, Geant4 or ROOT headers happen to bring in
<cstdint>. With libtorch 2.2.0 and the ClassDef fix all five sources compile with GCC 15.2.
Linking against libtorch 2.2.0 is left to the torch CI 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.2 image, without Geant4, ROOT or a CMake configuration. Only
Docker and a checkout of the repository are needed.

Run from the root of the repository:

docker run --rm -v "$PWD":/src -w /src gcc:15.2 bash -c '
  g++ --version | head -1
  for h in GateTreeFile GateTreeFileManager GateAsciiFile GateNumpyFile GateRootTreeFile; do
    echo "#include \"$h.hh\"" | g++ -std=c++17 -fsyntax-only -Isource/io/include -x c++ - 2>/dev/null \
      && echo "OK   $h.hh" || echo "FAIL $h.hh"
  done'

On develop (git checkout f53b44fa) every header fails:

g++ (GCC) 15.2.0
FAIL GateTreeFile.hh
FAIL GateTreeFileManager.hh
FAIL GateAsciiFile.hh
FAIL GateNumpyFile.hh
FAIL GateRootTreeFile.hh

On this branch (git checkout fix/io-missing-cstdint) every header compiles:

g++ (GCC) 15.2.0
OK   GateTreeFile.hh
OK   GateTreeFileManager.hh
OK   GateAsciiFile.hh
OK   GateNumpyFile.hh
OK   GateRootTreeFile.hh

Remove 2>/dev/null to see the compiler messages; on develop they are the same
'uint64_t' does not name a type errors as in the CI log. Running the same command with GCC 14
(gcc:14 image) gives OK for all five headers even on develop. This shows that the failure
depends 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.2 with the Geant4 and ROOT headers of an existing GATE
build mounted into the container, so it is not as easy to reproduce.

@MateuszBala MateuszBala changed the title fix(io): include cstdint where uint64_t is used Build with GCC 15: include cstdint in source/io, bump ITK and libtorch in CI, guard ClassDef for libtorch 2 Nov 15, 2026
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.

1 participant