Skip to content

Commit d16a578

Browse files
authored
geant4: fix 10.7 build with c++20 (spack#48347)
1 parent aee2f5c commit d16a578

File tree

5 files changed

+46
-18
lines changed

5 files changed

+46
-18
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
diff --git a/source/g3tog4/include/G3EleTable.hh b/source/g3tog4/include/G3EleTable.hh
2+
index 0ab9c4fd566..18c6f73fde6 100644
3+
--- a/source/g3tog4/include/G3EleTable.hh
4+
+++ b/source/g3tog4/include/G3EleTable.hh
5+
@@ -56,7 +56,7 @@ public: // with description
6+
private:
7+
8+
void LoadUp();
9+
- G4int parse(G4double& Z, char* name, char* sym, G4double& A);
10+
+ G4int parse(G4double& Z, char (&name)[20], char (&sym)[3], G4double& A);
11+
12+
private:
13+
14+
diff --git a/source/g3tog4/src/G3EleTable.cc b/source/g3tog4/src/G3EleTable.cc
15+
index cecc494b201..a2f3af3d6a2 100644
16+
--- a/source/g3tog4/src/G3EleTable.cc
17+
+++ b/source/g3tog4/src/G3EleTable.cc
18+
@@ -64,7 +64,7 @@ G3EleTable::GetEle(G4double Z){
19+
}
20+
21+
G4int
22+
-G3EleTable::parse(G4double& Z, char* name, char* sym, G4double& A){
23+
+G3EleTable::parse(G4double& Z, char (&name)[20], char (&sym)[3], G4double& A){
24+
G4int rc = 0;
25+
if (Z>0 && Z <=_MaxEle){
26+
G4int z = (G4int) Z-1;

var/spack/repos/builtin/packages/geant4/package.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Geant4(CMakePackage):
2020
executables = ["^geant4-config$"]
2121

2222
maintainers("drbenmorgan", "sethrj")
23+
2324
version("11.3.0", sha256="d9d71daff8890a7b5e0e33ea9a65fe6308ad6713000b43ba6705af77078e7ead")
2425
version("11.2.2", sha256="3a8d98c63fc52578f6ebf166d7dffaec36256a186d57f2520c39790367700c8d")
2526
version("11.2.1", sha256="76c9093b01128ee2b45a6f4020a1bcb64d2a8141386dea4674b5ae28bcd23293")
@@ -203,29 +204,30 @@ def std_when(values):
203204
depends_on("[email protected]:", when="@11.2:")
204205
conflicts("@:11.1 ^[virtuals=qmake] qt-base", msg="Qt6 not supported before 11.2")
205206

207+
# CMAKE PROBLEMS #
206208
# As released, 10.0.4 has inconsistently capitalised filenames
207209
# in the cmake files; this patch also enables cxxstd 14
208210
patch("geant4-10.0.4.patch", when="@10.0.4")
209-
# Fix member field typo in g4tools wroot
210-
# See https://bugzilla-geant4.kek.jp/show_bug.cgi?id=2640
211-
patch("columns-11.patch", when="@11:11.2.2")
212-
patch("columns-10.patch", when="@10.4:10")
213-
# As released, 10.03.03 has issues with respect to using external
214-
# CLHEP.
215-
patch("CLHEP-10.03.03.patch", level=1, when="@10.3")
216211
# Build failure on clang 15, ubuntu 22: see Geant4 problem report #2444
217212
# fixed by ascii-V10-07-03
218-
patch("geant4-10.6.patch", level=1, when="@10.0:10.6")
219-
# These patches can be applied independent of the cxxstd value?
220-
patch("cxx17.patch", when="@10.3 cxxstd=17")
221-
patch("cxx17_geant4_10_0.patch", level=1, when="@10.4.0 cxxstd=17")
222-
patch("geant4-10.4.3-cxx17-removed-features.patch", level=1, when="@10.4.3 cxxstd=17")
223-
224-
# See https://bugzilla-geant4.kek.jp/show_bug.cgi?id=2556
225-
patch("package-cache.patch", level=1, when="@10.7.0:11.1.2^[email protected]:")
226-
227-
# Issue with Twisted tubes, see https://bugzilla-geant4.kek.jp/show_bug.cgi?id=2619
228-
patch("twisted-tubes.patch", level=1, when="@11.2.0:11.2.2")
213+
patch("geant4-10.6.patch", when="@10.0:10.6")
214+
# Enable "17" cxxstd option in CMake (2 different filenames)
215+
patch("geant4-10.3-cxx17-cmake.patch", when="@10.3 cxxstd=17")
216+
patch("geant4-10.4-cxx17-cmake.patch", when="@10.4:10.4.2 cxxstd=17")
217+
# Fix exported cmake: https://bugzilla-geant4.kek.jp/show_bug.cgi?id=2556
218+
patch("package-cache.patch", when="@10.7.0:11.1.2^[email protected]:")
219+
220+
# BUILD ERRORS #
221+
# Fix C++17: add -D_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES C++ flag
222+
patch("geant4-10.4.3-cxx17-removed-features.patch", when="@10.4.3 cxxstd=17")
223+
# Fix C++20: build error due to removed-in-C++20 `ostream::operator>>(char*)`
224+
# (different, simpler approach than upstream Geant4 changes)
225+
patch("geant4-10.7-cxx20-g3tog4.patch", when="@:10.7 cxxstd=20")
226+
# Fix member field typo in g4tools wroot: https://bugzilla-geant4.kek.jp/show_bug.cgi?id=2640
227+
patch("columns-10.patch", when="@10.4:10")
228+
patch("columns-11.patch", when="@11:11.2.2")
229+
# Fix navigation errors with twisted tubes: https://bugzilla-geant4.kek.jp/show_bug.cgi?id=2619
230+
patch("twisted-tubes.patch", when="@11.2.0:11.2.2")
229231

230232
# NVHPC: "thread-local declaration follows non-thread-local declaration"
231233
conflicts("%nvhpc", when="+threads")

0 commit comments

Comments
 (0)