Skip to content

Check for G4VTrackingManager support via compilation#125

Merged
mnovak42 merged 1 commit intomnovak42:masterfrom
drbenmorgan:support-older-g4tm
Apr 4, 2025
Merged

Check for G4VTrackingManager support via compilation#125
mnovak42 merged 1 commit intomnovak42:masterfrom
drbenmorgan:support-older-g4tm

Conversation

@drbenmorgan
Copy link
Copy Markdown
Contributor

G4HepEm currently uses the Geant4 version to determine availability of the G4VTrackingManager interface/capability. This is always available from Geant4 v11.0 onwards, but experiments may backport the capability to earlier versions (here, request from LHCb).

Use a CMake-time compile check to determine if G4VTrackingManager is available in the found Geant4 irrespective of its version. Output result to CMake variable and use this to determine whether to add G4HepEm tracking manager support. Add a "FOUND" variable to installed CMake config file to indicate if G4HepEm provides tracking manager capability.

Tested locally with raw 10.7 and 11.3 installs which result in same behaviour as before. Would need more testing with LHCb's patched Geant4 to confirm it works in that case.

G4HepEm currently uses the Geant4 version to determine availability
of the `G4VTrackingManager` interface/capability. This is always
available from Geant4 v11.0 onwards, but experiments may backport
the capability to earlier versions (here, request from LHCb).

Use a CMake-time compile check to determine if `G4VTrackingManager`
is available in the found Geant4 irrespective of its version. Output
result to CMake variable and use this to determine whether to add
G4HepEm tracking manager support. Add a "FOUND" variable to installed
CMake config file to indicate if G4HepEm provides tracking manager
capability.
@mnovak42 mnovak42 merged commit 8802628 into mnovak42:master Apr 4, 2025
5 checks passed
@drbenmorgan drbenmorgan deleted the support-older-g4tm branch April 4, 2025 12:27
@WitekPokorski
Copy link
Copy Markdown

The test fails when I build with LHCb Geant4 installation with the following output:

Change Dir: '/home/witoldp/lhcb-sim11-g4+cuda/g4hepem/build/CMakeFiles/CMakeScratch/TryCompile-uXJ448'
        
        Run Build Command(s): /cvmfs/lhcb.cern.ch/lib/var/lib/LbEnv/3461/stable/linux-64/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f Makefile cmTC_75328/fast
        /usr/bin/gmake  -f CMakeFiles/cmTC_75328.dir/build.make CMakeFiles/cmTC_75328.dir/build
        gmake[1]: Entering directory '/home/witoldp/lhcb-sim11-g4+cuda/g4hepem/build/CMakeFiles/CMakeScratch/TryCompile-uXJ448'
        Building CXX object CMakeFiles/cmTC_75328.dir/src.cxx.o
        /usr/bin/c++ -DG4HepEm_HAS_G4VTRACKINGMANAGER -DG4LIB_BUILD_DLL -isystem /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/include/Geant4 -isystem /cvmfs/lhcb.cern.ch/lib/lcg/releases/clhep/2.4.7.1-b7a7d/x86_64-el9-gcc13-opt/include -isystem /cvmfs/lhcb.cern.ch/lib/lcg/releases/XercesC/3.2.4-9e637/x86_64-el9-gcc13-opt/include -std=gnu++20 -o CMakeFiles/cmTC_75328.dir/src.cxx.o -c /home/witoldp/lhcb-sim11-g4+cuda/g4hepem/build/CMakeFiles/CMakeScratch/TryCompile-uXJ448/src.cxx
        Linking CXX executable cmTC_75328
        /cvmfs/lhcb.cern.ch/lib/var/lib/LbEnv/3461/stable/linux-64/bin/cmake -E cmake_link_script CMakeFiles/cmTC_75328.dir/link.txt --verbose=1
        /usr/bin/c++ CMakeFiles/cmTC_75328.dir/src.cxx.o -o cmTC_75328  -Wl,-rpath,/home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib:/cvmfs/lhcb.cern.ch/lib/lcg/releases/XercesC/3.2.4-9e637/x86_64-el9-gcc13-opt/lib:/cvmfs/lhcb.cern.ch/lib/lcg/releases/clhep/2.4.7.1-b7a7d/x86_64-el9-gcc13-opt/lib /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4Tree.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4FR.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4GMocren.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4visHepRep.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4RayTracer.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4VRML.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4vis_management.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4modeling.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4interfaces.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4persistency.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4error_propagation.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4readout.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4physicslists.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4tasking.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4parmodels.so /usr/lib64/libXmu.so /usr/lib64/libXext.so /usr/lib64/libXm.so /usr/lib64/libXt.so /usr/lib64/libICE.so /usr/lib64/libSM.so /usr/lib64/libX11.so /cvmfs/lhcb.cern.ch/lib/lcg/releases/XercesC/3.2.4-9e637/x86_64-el9-gcc13-opt/lib/libxerces-c.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4run.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4event.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4tracking.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4processes.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4analysis.so /usr/lib64/libexpat.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4digits_hits.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4track.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4particles.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4geometry.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4materials.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4zlib.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4graphics_reps.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4intercoms.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4global.so /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4ptl.so.0.0.2 /cvmfs/lhcb.cern.ch/lib/lcg/releases/clhep/2.4.7.1-b7a7d/x86_64-el9-gcc13-opt/lib/libCLHEP-2.4.7.1.so
        /usr/bin/ld: /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4global.so: undefined reference to `std::condition_variable::wait(std::unique_lock<std::mutex>&)@GLIBCXX_3.4.30'
        /usr/bin/ld: /home/witoldp/lhcb-sim11-g4+cuda/Geant4/InstallArea/x86_64_v3-el9-gcc13+cuda12_4-opt+g/lib/libG4Tree.so: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_replace_cold(char*, unsigned long, char const*, unsigned long, unsigned long)@GLIBCXX_3.4.31'
        collect2: error: ld returned 1 exit status
        gmake[1]: *** [CMakeFiles/cmTC_75328.dir/build.make:139: cmTC_75328] Error 1
        gmake[1]: Leaving directory '/home/witoldp/lhcb-sim11-g4+cuda/g4hepem/build/CMakeFiles/CMakeScratch/TryCompile-uXJ448'
        gmake: *** [Makefile:127: cmTC_75328/fast] Error 2

@WitekPokorski
Copy link
Copy Markdown

There is also a warning message before which may be related to it:

CMake Warning at CMakeLists.txt:167 (message):
  Find of Geant4 did not set Geant4_CXX_STANDARD value expected from
  Geant4Config.cmake.  Defaulting to C++11.

@WitekPokorski
Copy link
Copy Markdown

WitekPokorski commented Apr 9, 2025

I see that it tries to test compile the code using /usr/bin/c++ which is gcc version 11.5.0, while the rest of the software was compiled with /usr/local/bin/gcc which is gcc version 13.1.0.

This probably causes the linking problem.

@WitekPokorski
Copy link
Copy Markdown

OK, I have made a quick test by adding -DCMAKE_CXX_COMPILER=g++ when calling cmake. The test passes now. The question now is whether it's my system which is inconsistent (having c++ and gcc commands pointing to different compiler versions) or whether there is something to fix in the CMakeLists.txt? I guess, it's more a problem with my system?

SeverinDiederichs added a commit to apt-sim/AdePT that referenced this pull request Apr 10, 2025
Shamelessly stolen from @drbenmorgan's [PR to G4HepEm
](mnovak42/g4hepem#125), this improves the
version test in AdePT: instead of testing for version > 11, now it is
tested for the `G4VTrackingManager`, as this one is required. This fixes
a compilation issue in Gauss which uses a patched version of 10.7 with
the G4VTrackingManager.

The old test for flush which was needed for the FastSim hook approach is
removed.
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