FairRootGroup/FairRoot

RPATH resolution sometimes broken when linking against `FairRoot::FastSim`

Closed this issue · 7 comments

edit: Related FairRootGroup/FairSoft#535


Affected: Ubuntu 20.04 & 22.04, Debian 11 & 12
NOT affected: Debian 10, Fedora 39, macOS

Example from Debian 12:

Singularity> /usr/bin/c++ -Wshadow -Wall -O2 -g -Wl,--enable-new-dtags -z defs CMakeFiles/test_ExSimulation1.dir/test_FairTutorialDet1Geo.cxx.o -o test_ExSimulation1\
                          -Wl,-rpath,/home/dklein/projects/FairRoot4/build_debian12/lib:/fairsoft/jan24_patches/lib\
                          ../../../../lib/libExSimulation1.so.19.0.0\
                          ../../../../lib/libCatch2Main.so.3.4.0\
                          ../../../../lib/libFairFastSim.so.19.0.0\
                          /fairsoft/jan24_patches/lib/libgeant4vmc.so\
                          /fairsoft/jan24_patches/lib/libg4root.so\
                          /fairsoft/jan24_patches/lib/libXmlVGM.so\
                          /fairsoft/jan24_patches/lib/libGeant4GM.so\
                          /fairsoft/jan24_patches/lib/libClhepVGM.so\
                          /fairsoft/jan24_patches/lib/libRootGM.so\
                          /fairsoft/jan24_patches/lib/libBaseVGM.so\
                          /fairsoft/jan24_patches/lib/libG4Tree.so\
                          /fairsoft/jan24_patches/lib/libG4FR.so\
                          /fairsoft/jan24_patches/lib/libG4GMocren.so\
                          /fairsoft/jan24_patches/lib/libG4visHepRep.so\
                          /fairsoft/jan24_patches/lib/libG4RayTracer.so\
                          /fairsoft/jan24_patches/lib/libG4VRML.so\
                          /fairsoft/jan24_patches/lib/libG4ToolsSG.so\
                          /fairsoft/jan24_patches/lib/libG4vis_management.so\
                          /fairsoft/jan24_patches/lib/libG4modeling.so\
                          /fairsoft/jan24_patches/lib/libG4interfaces.so\
                          /fairsoft/jan24_patches/lib/libG4mctruth.so\
                          /fairsoft/jan24_patches/lib/libG4geomtext.so\
                          /fairsoft/jan24_patches/lib/libG4gdml.so\
                          /usr/lib/x86_64-linux-gnu/libxerces-c.so\
                          /fairsoft/jan24_patches/lib/libG3toG4.so\
                          /fairsoft/jan24_patches/lib/libG4error_propagation.so\
                          /fairsoft/jan24_patches/lib/libG4readout.so\
                          /fairsoft/jan24_patches/lib/libG4physicslists.so\
                          /fairsoft/jan24_patches/lib/libG4run.so\
                          /fairsoft/jan24_patches/lib/libG4event.so\
                          /fairsoft/jan24_patches/lib/libG4tracking.so\
                          /fairsoft/jan24_patches/lib/libG4parmodels.so\
                          /fairsoft/jan24_patches/lib/libG4processes.so\
                          /fairsoft/jan24_patches/lib/libG4analysis.so\
                          /usr/lib/x86_64-linux-gnu/libexpat.so\
                          /usr/lib/x86_64-linux-gnu/libz.so\
                          /fairsoft/jan24_patches/lib/libG4digits_hits.so\
                          /fairsoft/jan24_patches/lib/libG4track.so\
                          /fairsoft/jan24_patches/lib/libG4geometry.so\
                          /fairsoft/jan24_patches/lib/libG4materials.so\
                          /fairsoft/jan24_patches/lib/libG4particles.so\
                          /fairsoft/jan24_patches/lib/libG4graphics_reps.so\
                          /fairsoft/jan24_patches/lib/libG4intercoms.so\
                          /fairsoft/jan24_patches/lib/libG4global.so\
                          /fairsoft/jan24_patches/lib/libCLHEP-2.4.7.1.so\
                          /fairsoft/jan24_patches/lib/libG4ptl.so.2.3.3\
                          /fairsoft/jan24_patches/lib/libRint.so.6.30.04\
                          ../../../../lib/libGen.so.19.0.0\
                          ../../../../lib/libExPassive.so.19.0.0\
                          /fairsoft/jan24_patches/lib/libboost_program_options.so.1.83.0\
                          ../../../../lib/libBase.so.19.0.0\
                          ../../../../lib/libParBase.so.19.0.0\
                          ../../../../lib/libAlignment.so.19.0.0\
                          /fairsoft/jan24_patches/lib/libGeomPainter.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libVMCLibrary.so\
                          /fairsoft/jan24_patches/lib/libTree.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libEG.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libPhysics.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libGenVector.so.6.30.04\
                          ../../../../lib/libGeoBase.so.19.0.0\
                          ../../../../lib/libFairTools.so.19.0.0\
                          /fairsoft/jan24_patches/lib/libFairLogger.so.1.11.1\
                          /fairsoft/jan24_patches/lib/libGeom.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libGraf3d.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libGpad.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libGraf.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libHist.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libMatrix.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libMathCore.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libImt.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libMultiProc.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libNet.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libRIO.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libThread.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libCore.so.6.30.04\
                          /fairsoft/jan24_patches/lib/libfmt.a\
                          ../../../../lib/libCatch2.so.3.4.0\
                          -Wl,-rpath-link,/home/dklein/projects/FairRoot4/build_debian12/lib:/fairsoft/jan24_patches/lib

works, but

Singularity> ldd test_ExSimulation1
        linux-vdso.so.1 (0x00007ffe576ff000)
        libExSimulation1.so.19.0.0 => /home/dklein/projects/FairRoot4/build_debian12/lib/libExSimulation1.so.19.0.0 (0x00007fd2b9bf9000)
        libCatch2Main.so.3.4.0 => /home/dklein/projects/FairRoot4/build_debian12/lib/libCatch2Main.so.3.4.0 (0x00007fd2b9bf4000)
        libGeoBase.so.19.0.0 => /home/dklein/projects/FairRoot4/build_debian12/lib/libGeoBase.so.19.0.0 (0x00007fd2b9b6a000)
        libCore.so.6.30 => /fairsoft/jan24_patches/lib/libCore.so.6.30 (0x00007fd2b96bd000)
        libCatch2.so.3.4.0 => /home/dklein/projects/FairRoot4/build_debian12/lib/libCatch2.so.3.4.0 (0x00007fd2b95d2000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd2b93ad000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd2b938d000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd2b91ac000)
        libFairFastSim.so.19.0.0 => /home/dklein/projects/FairRoot4/build_debian12/lib/libFairFastSim.so.19.0.0 (0x00007fd2b919b000)
        libboost_program_options.so.1.83.0 => /fairsoft/jan24_patches/lib/libboost_program_options.so.1.83.0 (0x00007fd2b9132000)
        libExMCStack.so.19.0.0 => /home/dklein/projects/FairRoot4/build_debian12/lib/libExMCStack.so.19.0.0 (0x00007fd2b9118000)
        libBase.so.19.0.0 => /home/dklein/projects/FairRoot4/build_debian12/lib/libBase.so.19.0.0 (0x00007fd2b8faa000)
        libParBase.so.19.0.0 => /home/dklein/projects/FairRoot4/build_debian12/lib/libParBase.so.19.0.0 (0x00007fd2b8f4e000)
        libFairLogger.so.1.11 => /fairsoft/jan24_patches/lib/libFairLogger.so.1.11 (0x00007fd2b8f15000)
        libVMCLibrary.so => /fairsoft/jan24_patches/lib/libVMCLibrary.so (0x00007fd2b8ed9000)
        libGeom.so.6.30 => /fairsoft/jan24_patches/lib/libGeom.so.6.30 (0x00007fd2b8c99000)
        libPhysics.so.6.30 => /fairsoft/jan24_patches/lib/libPhysics.so.6.30 (0x00007fd2b8c4a000)
        libGraf3d.so.6.30 => /fairsoft/jan24_patches/lib/libGraf3d.so.6.30 (0x00007fd2b8b9d000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd2b8abe000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007fd2b8a9f000)
        liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007fd2b8a70000)
        libzstd.so.1 => /lib/x86_64-linux-gnu/libzstd.so.1 (0x00007fd2b89b2000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fd2b9c5e000)
        libgeant4vmc.so => /fairsoft/jan24_patches/lib/libgeant4vmc.so (0x00007fd2b8866000)
        libEG.so.6.30 => /fairsoft/jan24_patches/lib/libEG.so.6.30 (0x00007fd2b87cb000)
        libG4processes.so => /fairsoft/jan24_patches/lib/libG4processes.so (0x00007fd2b6c3e000)
        libG4particles.so => /fairsoft/jan24_patches/lib/libG4particles.so (0x00007fd2b6b17000)
        libG4global.so => /fairsoft/jan24_patches/lib/libG4global.so (0x00007fd2b6a98000)
        libFairTools.so.19.0.0 => /home/dklein/projects/FairRoot4/build_debian12/lib/libFairTools.so.19.0.0 (0x00007fd2b6a75000)
        libAlignment.so.19.0.0 => /home/dklein/projects/FairRoot4/build_debian12/lib/libAlignment.so.19.0.0 (0x00007fd2b6a69000)
        libGeomPainter.so.6.30 => /fairsoft/jan24_patches/lib/libGeomPainter.so.6.30 (0x00007fd2b6a2c000)
        libGdml.so.6.30 => /fairsoft/jan24_patches/lib/libGdml.so.6.30 (0x00007fd2b69c9000)
        libTree.so.6.30 => /fairsoft/jan24_patches/lib/libTree.so.6.30 (0x00007fd2b682b000)
        libHist.so.6.30 => /fairsoft/jan24_patches/lib/libHist.so.6.30 (0x00007fd2b63fd000)
        libMatrix.so.6.30 => /fairsoft/jan24_patches/lib/libMatrix.so.6.30 (0x00007fd2b6297000)
        libMathCore.so.6.30 => /fairsoft/jan24_patches/lib/libMathCore.so.6.30 (0x00007fd2b6064000)
        libRIO.so.6.30 => /fairsoft/jan24_patches/lib/libRIO.so.6.30 (0x00007fd2b5ca9000)
        libGpad.so.6.30 => /fairsoft/jan24_patches/lib/libGpad.so.6.30 (0x00007fd2b5bc1000)
        libGraf.so.6.30 => /fairsoft/jan24_patches/lib/libGraf.so.6.30 (0x00007fd2b5a69000)
        libg4root.so => not found
        libXmlVGM.so => not found
        libGeant4GM.so => not found
        libRootGM.so => not found
        libG4Tree.so => not found
        libG4FR.so => not found
        libG4GMocren.so => not found
        libG4visHepRep.so => not found
        libG4RayTracer.so => not found
        libG4VRML.so => not found
        libG4ToolsSG.so => not found
        libG4vis_management.so => not found
        libG4modeling.so => not found
        libG4interfaces.so => not found
        libG3toG4.so => not found
        libG4physicslists.so => not found
        libG4run.so => not found
        libG4event.so => not found
        libG4tracking.so => not found
        libG4parmodels.so => not found
        libG4digits_hits.so => not found
        libG4track.so => not found
        libG4geometry.so => not found
        libG4materials.so => not found
        libG4graphics_reps.so => not found
        libRint.so.6.30 => not found
        libG4analysis.so => not found
        libG4intercoms.so => not found
        libCLHEP-2.4.7.1.so => not found
        libBaseVGM.so => not found
        libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007fd2b5a32000)
        libG4analysis.so => not found
        libG4digits_hits.so => not found
        libG4track.so => not found
        libG4geometry.so => not found
        libG4materials.so => not found
        libG4intercoms.so => not found
        libCLHEP-2.4.7.1.so => not found
        libG4intercoms.so => not found
        libCLHEP-2.4.7.1.so => not found
        libCLHEP-2.4.7.1.so => not found
        libXMLIO.so.6.30 => /fairsoft/jan24_patches/lib/libXMLIO.so.6.30 (0x00007fd2b59d2000)
        libImt.so.6.30 => /fairsoft/jan24_patches/lib/libImt.so.6.30 (0x00007fd2b59c0000)
        libNet.so.6.30 => /fairsoft/jan24_patches/lib/libNet.so.6.30 (0x00007fd2b58e5000)
        libThread.so.6.30 => /fairsoft/jan24_patches/lib/libThread.so.6.30 (0x00007fd2b5883000)
        libfreetype.so.6 => /lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007fd2b57b8000)
        libMultiProc.so.6.30 => /fairsoft/jan24_patches/lib/libMultiProc.so.6.30 (0x00007fd2b57ab000)
        libtbb.so.12 => /fairsoft/jan24_patches/lib/libtbb.so.12 (0x00007fd2b5755000)
        libssl.so.3 => /lib/x86_64-linux-gnu/libssl.so.3 (0x00007fd2b56a9000)
        libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x00007fd2b5227000)
        libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007fd2b51f1000)
        libbrotlidec.so.1 => /lib/x86_64-linux-gnu/libbrotlidec.so.1 (0x00007fd2b51e4000)
        libbrotlicommon.so.1 => /lib/x86_64-linux-gnu/libbrotlicommon.so.1 (0x00007fd2b51c1000)

just in case anyone wonders where those files exist:

Singularity> ldd test_ExSimulation1 | grep "not found" | cut -f2 | cut -d' ' -f1 | xargs -I {} file ${SIMPATH}/lib/{}
/fairsoft/jan24_patches/lib/libg4root.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=57c68a0499b13e7f519496bfb1d3f10c11cfacee, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libXmlVGM.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=e1829c7e8b731dfb2e5cd89201390576a79125d2, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libGeant4GM.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=14b868dccc40cbe23f6eee3282625fe003bafaf4, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libRootGM.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=c16d8bbad4d8fd6f96a01dfd62bba21ef9adc294, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4Tree.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=ac8db4e92225c5a485944693f06e2a7f29ce2bce, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4FR.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=ed12ae67b30c949f1947c0745197f8dddb4ed993, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4GMocren.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=fb04e90343da17a4c428681612538b3b33e07941, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4visHepRep.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=ddf82478dca5a29f8da2aaf1276840ef3c772ba8, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4RayTracer.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=9942faa64a66676b5bfad97a4714a564d29faf09, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4VRML.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=3368a33d352e7973fd8a7b3c9c30e02cb56eb419, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4ToolsSG.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=3677a5c461183a180809a8198ec468e6671d973e, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4vis_management.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=1dc44451a5c695e8f87bb6f1c89fe075facfd326, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4modeling.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=9af57f620661ab56bf7ee28b59bd720a177798a9, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4interfaces.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=d22e51bac3ce9478ad16d7a7a008a3bcee5d3b3a, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG3toG4.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=dc15343fe6fd62869b85a29d103b6ed89bf9757c, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4physicslists.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=cf1c7847dea5ac24d410bbb15efa343a7547a6d9, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4run.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=4741d949befa743953cd634ba6cdf0b498638763, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4event.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=d3b491e105fc987ca3dbe7b6dcef3434ce26b759, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4tracking.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=139769be70413502ee82cbe6807c65381bee49f0, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4parmodels.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=818a7e297a3b2fea852022d8bfcbc952f4eacd62, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4digits_hits.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=2c0ef0f5fc1e289861e745b5f266f694186ed2be, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4track.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=47e6a6291a1b6fb243d4d04884c88d5d5cbbcdb7, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4geometry.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=06ecac5ded0de84f5c7715b2213dc6616b3112e4, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4materials.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=df8f595d7723ae659eee5af3b940f3807566bac9, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4graphics_reps.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=40e0fcab7aa4bd89cc9ba4cc5438786af6235456, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libRint.so.6.30: symbolic link to libRint.so.6.30.04
/fairsoft/jan24_patches/lib/libG4analysis.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=d2cd1e0aac15bc7ef340455eeda2967f63375a8c, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4intercoms.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=4e455d3e6934796cd384e468fb4522b1d266aaf3, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libCLHEP-2.4.7.1.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=fd9341c7c646fedfaac768dd639c0ff38679f915, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libBaseVGM.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=99583c219aa3ebeefcfcdda095bd853c6746b7c8, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4analysis.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=d2cd1e0aac15bc7ef340455eeda2967f63375a8c, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4digits_hits.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=2c0ef0f5fc1e289861e745b5f266f694186ed2be, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4track.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=47e6a6291a1b6fb243d4d04884c88d5d5cbbcdb7, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4geometry.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=06ecac5ded0de84f5c7715b2213dc6616b3112e4, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4materials.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=df8f595d7723ae659eee5af3b940f3807566bac9, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4intercoms.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=4e455d3e6934796cd384e468fb4522b1d266aaf3, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libCLHEP-2.4.7.1.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=fd9341c7c646fedfaac768dd639c0ff38679f915, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libG4intercoms.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=4e455d3e6934796cd384e468fb4522b1d266aaf3, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libCLHEP-2.4.7.1.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=fd9341c7c646fedfaac768dd639c0ff38679f915, with debug_info, not stripped
/fairsoft/jan24_patches/lib/libCLHEP-2.4.7.1.so: ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=fd9341c7c646fedfaac768dd639c0ff38679f915, with debug_info, not stripped
Singularity> ldd test_ExSimulation1 | grep "not found" | cut -f2 | cut -d' ' -f1 | xargs -I {} du -hs ${SIMPATH}/lib/{}
2.1M    /fairsoft/jan24_patches/lib/libg4root.so
4.7M    /fairsoft/jan24_patches/lib/libXmlVGM.so
6.6M    /fairsoft/jan24_patches/lib/libGeant4GM.so
4.7M    /fairsoft/jan24_patches/lib/libRootGM.so
1.9M    /fairsoft/jan24_patches/lib/libG4Tree.so
1.2M    /fairsoft/jan24_patches/lib/libG4FR.so
3.5M    /fairsoft/jan24_patches/lib/libG4GMocren.so
1.5M    /fairsoft/jan24_patches/lib/libG4visHepRep.so
3.8M    /fairsoft/jan24_patches/lib/libG4RayTracer.so
1008K   /fairsoft/jan24_patches/lib/libG4VRML.so
18M     /fairsoft/jan24_patches/lib/libG4ToolsSG.so
21M     /fairsoft/jan24_patches/lib/libG4vis_management.so
17M     /fairsoft/jan24_patches/lib/libG4modeling.so
2.5M    /fairsoft/jan24_patches/lib/libG4interfaces.so
4.9M    /fairsoft/jan24_patches/lib/libG3toG4.so
46M     /fairsoft/jan24_patches/lib/libG4physicslists.so
17M     /fairsoft/jan24_patches/lib/libG4run.so
8.7M    /fairsoft/jan24_patches/lib/libG4event.so
7.1M    /fairsoft/jan24_patches/lib/libG4tracking.so
2.9M    /fairsoft/jan24_patches/lib/libG4parmodels.so
20M     /fairsoft/jan24_patches/lib/libG4digits_hits.so
2.2M    /fairsoft/jan24_patches/lib/libG4track.so
39M     /fairsoft/jan24_patches/lib/libG4geometry.so
12M     /fairsoft/jan24_patches/lib/libG4materials.so
4.8M    /fairsoft/jan24_patches/lib/libG4graphics_reps.so
0       /fairsoft/jan24_patches/lib/libRint.so.6.30
82M     /fairsoft/jan24_patches/lib/libG4analysis.so
6.1M    /fairsoft/jan24_patches/lib/libG4intercoms.so
18M     /fairsoft/jan24_patches/lib/libCLHEP-2.4.7.1.so
2.6M    /fairsoft/jan24_patches/lib/libBaseVGM.so
82M     /fairsoft/jan24_patches/lib/libG4analysis.so
20M     /fairsoft/jan24_patches/lib/libG4digits_hits.so
2.2M    /fairsoft/jan24_patches/lib/libG4track.so
39M     /fairsoft/jan24_patches/lib/libG4geometry.so
12M     /fairsoft/jan24_patches/lib/libG4materials.so
6.1M    /fairsoft/jan24_patches/lib/libG4intercoms.so
18M     /fairsoft/jan24_patches/lib/libCLHEP-2.4.7.1.so
6.1M    /fairsoft/jan24_patches/lib/libG4intercoms.so
18M     /fairsoft/jan24_patches/lib/libCLHEP-2.4.7.1.so
18M     /fairsoft/jan24_patches/lib/libCLHEP-2.4.7.1.so
Singularity> readelf -d test_ExSimulation1

Dynamic section at offset 0x21d10 contains 34 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libExSimulation1.so.19.0.0]
 0x0000000000000001 (NEEDED)             Shared library: [libCatch2Main.so.3.4.0]
 0x0000000000000001 (NEEDED)             Shared library: [libGeoBase.so.19.0.0]
 0x0000000000000001 (NEEDED)             Shared library: [libCore.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libCatch2.so.3.4.0]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000001d (RUNPATH)            Library runpath: [/home/dklein/projects/FairRoot4/build_debian12/lib:/fairsoft/jan24_patches/lib]
 0x000000000000000c (INIT)               0x4000
 0x000000000000000d (FINI)               0x1b0f0
 0x0000000000000019 (INIT_ARRAY)         0x216f8
 0x000000000000001b (INIT_ARRAYSZ)       24 (bytes)
 0x000000000000001a (FINI_ARRAY)         0x21710
 0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
 0x000000006ffffef5 (GNU_HASH)           0x3a0
 0x0000000000000005 (STRTAB)             0xdd8
 0x0000000000000006 (SYMTAB)             0x3e8
 0x000000000000000a (STRSZ)              3989 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000015 (DEBUG)              0x0
 0x0000000000000003 (PLTGOT)             0x21fe8
 0x0000000000000002 (PLTRELSZ)           1848 (bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0x29e0
 0x0000000000000007 (RELA)               0x1f18
 0x0000000000000008 (RELASZ)             2760 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000006ffffffb (FLAGS_1)            Flags: PIE
 0x000000006ffffffe (VERNEED)            0x1e48
 0x000000006fffffff (VERNEEDNUM)         3
 0x000000006ffffff0 (VERSYM)             0x1d6e
 0x000000006ffffff9 (RELACOUNT)          72
 0x0000000000000000 (NULL)               0x0

The problem comes through the inclusion of the target FairFastSim which depends on Geant4. If this target and the related source files are excluded the compilation works without problems.

When checking the library on Debian12 also here the Geant4 related libraries are not properly resolved.

ldd build/lib/libFairFastSim.so
   linux-vdso.so.1 (0x00007ffeeefb3000)
   libBase.so.19.0.0 => /tmp/uhlig/fairoot/build/lib/libBase.so.19.0.0 (0x00007f1528a82000)
   libgeant4vmc.so => /opt/fairsoft/nov22p1/lib/libgeant4vmc.so (0x00007f152893b000)
   libGeoBase.so.19.0.0 => /tmp/uhlig/fairoot/build/lib/libGeoBase.so.19.0.0 (0x00007f15288b3000)
   libFairLogger.so.1.11 => /opt/fairsoft/nov22p1/lib/libFairLogger.so.1.11 (0x00007f152887d000)
   libVMCLibrary.so => /opt/fairsoft/nov22p1/lib/libVMCLibrary.so (0x00007f1528840000)
   libEG.so.6.26 => /opt/fairsoft/nov22p1/lib/libEG.so.6.26 (0x00007f15287a3000)
   libGeom.so.6.26 => /opt/fairsoft/nov22p1/lib/libGeom.so.6.26 (0x00007f1528562000)
   libPhysics.so.6.26 => /opt/fairsoft/nov22p1/lib/libPhysics.so.6.26 (0x00007f1528515000)
   libG4processes.so => /opt/fairsoft/nov22p1/lib/libG4processes.so (0x00007f1526a75000)
   libG4track.so => /opt/fairsoft/nov22p1/lib/libG4track.so (0x00007f1526a55000)
   libG4particles.so => /opt/fairsoft/nov22p1/lib/libG4particles.so (0x00007f1526926000)
   libG4global.so => /opt/fairsoft/nov22p1/lib/libG4global.so (0x00007f15268aa000)
   libCore.so.6.26 => /opt/fairsoft/nov22p1/lib/libCore.so.6.26 (0x00007f1526348000)
   libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1526125000)
   libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1526046000)
   libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f1526026000)
   libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1525e45000)
   libAlignment.so.19.0.0 => /tmp/uhlig/fairoot/build/lib/libAlignment.so.19.0.0 (0x00007f1525e37000)
   libParBase.so.19.0.0 => /tmp/uhlig/fairoot/build/lib/libParBase.so.19.0.0 (0x00007f1525ddc000)
   libGeomPainter.so.6.26 => /opt/fairsoft/nov22p1/lib/libGeomPainter.so.6.26 (0x00007f1525d9f000)
   libGdml.so.6.26 => /opt/fairsoft/nov22p1/lib/libGdml.so.6.26 (0x00007f1525d3e000)
   libFairTools.so.19.0.0 => /tmp/uhlig/fairoot/build/lib/libFairTools.so.19.0.0 (0x00007f1525d1b000)
   libTree.so.6.26 => /opt/fairsoft/nov22p1/lib/libTree.so.6.26 (0x00007f1525b8e000)
   libHist.so.6.26 => /opt/fairsoft/nov22p1/lib/libHist.so.6.26 (0x00007f1525771000)
   libMatrix.so.6.26 => /opt/fairsoft/nov22p1/lib/libMatrix.so.6.26 (0x00007f152560c000)
   libMathCore.so.6.26 => /opt/fairsoft/nov22p1/lib/libMathCore.so.6.26 (0x00007f15253e2000)
   libRIO.so.6.26 => /opt/fairsoft/nov22p1/lib/libRIO.so.6.26 (0x00007f152501d000)
   /lib64/ld-linux-x86-64.so.2 (0x00007f1528bff000)
   libg4root.so => not found
   libXmlVGM.so => not found
   libGeant4GM.so => not found
   libRootGM.so => not found
   libG4Tree.so => not found
   libG4FR.so => not found
   libG4GMocren.so => not found
   libG4visHepRep.so => not found
   libG4RayTracer.so => not found
   libG4VRML.so => not found
   libG4vis_management.so => not found
   libG4modeling.so => not found
   libG4interfaces.so => not found
   libG3toG4.so => not found
   libG4physicslists.so => not found
   libG4parmodels.so => not found
   libRint.so.6.26 => not found
   libG4run.so => not found
   libG4event.so => not found
   libG4tracking.so => not found
   libG4analysis.so => not found
   libG4digits_hits.so => not found
   libG4geometry.so => not found
   libG4materials.so => not found
   libG4graphics_reps.so => not found
   libG4intercoms.so => not found
   libCLHEP-2.4.5.1.so => not found
   libBaseVGM.so => not found
   libGraf3d.so.6.26 => /opt/fairsoft/nov22p1/lib/libGraf3d.so.6.26 (0x00007f1524f63000)
   libGpad.so.6.26 => /opt/fairsoft/nov22p1/lib/libGpad.so.6.26 (0x00007f1524e87000)
   libGraf.so.6.26 => /opt/fairsoft/nov22p1/lib/libGraf.so.6.26 (0x00007f1524d2d000)
   libexpat.so.1 => /lib/x86_64-linux-gnu/libexpat.so.1 (0x00007f1524d02000)
   libG4analysis.so => not found
   libG4digits_hits.so => not found
   libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f1524ce3000)
   libG4geometry.so => not found
   libG4materials.so => not found
   libG4intercoms.so => not found
   libCLHEP-2.4.5.1.so => not found
   libG4geometry.so => not found
   libG4materials.so => not found
   libCLHEP-2.4.5.1.so => not found
   libG4intercoms.so => not found
   libCLHEP-2.4.5.1.so => not found
   libCLHEP-2.4.5.1.so => not found
   libXMLIO.so.6.26 => /opt/fairsoft/nov22p1/lib/libXMLIO.so.6.26 (0x00007f1524c81000)
   libImt.so.6.26 => /opt/fairsoft/nov22p1/lib/libImt.so.6.26 (0x00007f1524c70000)
   libNet.so.6.26 => /opt/fairsoft/nov22p1/lib/libNet.so.6.26 (0x00007f1524b98000)
   libThread.so.6.26 => /opt/fairsoft/nov22p1/lib/libThread.so.6.26 (0x00007f1524b36000)
   libfreetype.so.6 => /lib/x86_64-linux-gnu/libfreetype.so.6 (0x00007f1524a69000)
   libMultiProc.so.6.26 => /opt/fairsoft/nov22p1/lib/libMultiProc.so.6.26 (0x00007f1524a5c000)
   libtbb.so.2 => /opt/fairsoft/nov22p1/lib/libtbb.so.2 (0x00007f1524a1b000)
   libssl.so.3 => /lib/x86_64-linux-gnu/libssl.so.3 (0x00007f1524972000)
   libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x00007f15244f1000)
   libpng16.so.16 => /lib/x86_64-linux-gnu/libpng16.so.16 (0x00007f15244b9000)
   libbrotlidec.so.1 => /lib/x86_64-linux-gnu/libbrotlidec.so.1 (0x00007f15244ac000)
   libbrotlicommon.so.1 => /lib/x86_64-linux-gnu/libbrotlicommon.so.1 (0x00007f1524489000)

When checking the Geant4 libraries ion Debian12 t looks like there is already a problem since the libraries are not properly found

/opt/fairsoft/nov22p1/lib/libG4RayTracer.so:
	linux-vdso.so.1 (0x00007ffcffb72000)
	libG4vis_management.so => not found
	libG4modeling.so => not found
	libG4tasking.so => not found
	libG4run.so => not found
	libG4event.so => not found
	libG4tracking.so => not found
	libG4processes.so => not found
	libG4digits_hits.so => not found
	libG4geometry.so => not found
	libG4graphics_reps.so => not found
	libG4particles.so => not found
	libG4intercoms.so => not found
	libG4global.so => not found
	libCLHEP-2.4.5.1.so => not found
	libG4ptl.so.0 => not found
	libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f38d5621000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f38d5542000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f38d5522000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f38d5341000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f38d5877000)

The difference is introduced in my opinion by the linker. If you check the information on Debian12 only the direct
library dependencies are included in the library.

readelf -d build_debian12_newcmake/lib/libFairFastSim.so

Dynamic section at offset 0xfc00 contains 42 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libBase.so.19.0.0]
 0x0000000000000001 (NEEDED)             Shared library: [libgeant4vmc.so]
 0x0000000000000001 (NEEDED)             Shared library: [libGeoBase.so.19.0.0]
 0x0000000000000001 (NEEDED)             Shared library: [libFairLogger.so.1.11]
 0x0000000000000001 (NEEDED)             Shared library: [libVMCLibrary.so]
 0x0000000000000001 (NEEDED)             Shared library: [libEG.so.6.26]
 0x0000000000000001 (NEEDED)             Shared library: [libGeom.so.6.26]
 0x0000000000000001 (NEEDED)             Shared library: [libPhysics.so.6.26]
 0x0000000000000001 (NEEDED)             Shared library: [libG4processes.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4track.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4particles.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4global.so]
 0x0000000000000001 (NEEDED)             Shared library: [libCore.so.6.26]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000000e (SONAME)             Library soname: [libFairFastSim.so.19.0.0]
 0x000000000000001d (RUNPATH)            Library runpath: [/tmp/uhlig/fairoot/build_debian12_newcmake/lib:/opt/fairsoft/nov22p1/lib:]
 0x000000000000000c (INIT)               0x7000
 0x000000000000000d (FINI)               0xaa30
 0x0000000000000019 (INIT_ARRAY)         0xf6a0
 0x000000000000001b (INIT_ARRAYSZ)       48 (bytes)
 0x000000000000001a (FINI_ARRAY)         0xf6d0
 0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
 0x000000006ffffef5 (GNU_HASH)           0x260
 0x0000000000000005 (STRTAB)             0x20d0
 0x0000000000000006 (SYMTAB)             0x630
 0x000000000000000a (STRSZ)              10826 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000003 (PLTGOT)             0xffe8
 0x0000000000000002 (PLTRELSZ)           2136 (bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0x63a0
 0x0000000000000007 (RELA)               0x4e28
 0x0000000000000008 (RELASZ)             5496 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000006ffffffe (VERNEED)            0x4d58
 0x000000006fffffff (VERNEEDNUM)         4
 0x000000006ffffff0 (VERSYM)             0x4b1a
 0x000000006ffffff9 (RELACOUNT)          40
 0x0000000000000000 (NULL)               0x0

The problem appears since libgeant4vmc.so does not properly contains the RPATH and such can't find its dependencies when linking the test.
In contrast the library on fedora39 contains the full list of dependencies of dependencies (direct and indirect)

readelf -d build/lib/libFairFastSim.so

Dynamic section at offset 0x10878 contains 98 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libBase.so.19.0.0]
 0x0000000000000001 (NEEDED)             Shared library: [libgeant4vmc.so]
 0x0000000000000001 (NEEDED)             Shared library: [libGeoBase.so.19.0.0]
 0x0000000000000001 (NEEDED)             Shared library: [libAlignment.so.19.0.0]
 0x0000000000000001 (NEEDED)             Shared library: [libParBase.so.19.0.0]
 0x0000000000000001 (NEEDED)             Shared library: [libFairTools.so.19.0.0]
 0x0000000000000001 (NEEDED)             Shared library: [libFairLogger.so.1.11]
 0x0000000000000001 (NEEDED)             Shared library: [libGeomPainter.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libg4root.so]
 0x0000000000000001 (NEEDED)             Shared library: [libVMCLibrary.so]
 0x0000000000000001 (NEEDED)             Shared library: [libEG.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libGraf3d.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libGpad.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libGraf.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libTree.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libXmlVGM.so]
 0x0000000000000001 (NEEDED)             Shared library: [libGeant4GM.so]
 0x0000000000000001 (NEEDED)             Shared library: [libClhepVGM.so]
 0x0000000000000001 (NEEDED)             Shared library: [libRootGM.so]
 0x0000000000000001 (NEEDED)             Shared library: [libGeom.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libHist.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libPhysics.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libMatrix.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libGenVector.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libMathCore.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libImt.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libMultiProc.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libNet.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libRIO.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libBaseVGM.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4Tree.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4FR.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4GMocren.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4visHepRep.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4RayTracer.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4VRML.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4ToolsSG.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4vis_management.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4modeling.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4interfaces.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4mctruth.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4geomtext.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4gdml.so]
 0x0000000000000001 (NEEDED)             Shared library: [libxerces-c-3.2.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG3toG4.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4error_propagation.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4readout.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4physicslists.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4run.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4event.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4tracking.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4parmodels.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4processes.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4analysis.so]
 0x0000000000000001 (NEEDED)             Shared library: [libexpat.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libz.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libG4digits_hits.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4track.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4geometry.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4materials.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4particles.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4graphics_reps.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4intercoms.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4global.so]
 0x0000000000000001 (NEEDED)             Shared library: [libCLHEP-2.4.7.1.so]
 0x0000000000000001 (NEEDED)             Shared library: [libG4ptl.so.2]
 0x0000000000000001 (NEEDED)             Shared library: [libRint.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libThread.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libCore.so.6.30]
 0x0000000000000001 (NEEDED)             Shared library: [libstdc++.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so.6]
 0x0000000000000001 (NEEDED)             Shared library: [libgcc_s.so.1]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so.6]
 0x000000000000000e (SONAME)             Library soname: [libFairFastSim.so.19.0.0]
 0x000000000000001d (RUNPATH)            Library runpath: [/tmp/uhlig/fairoot/build/lib:/opt/fairsoft/jan24p1/lib:]
 0x000000000000000c (INIT)               0x8000
 0x000000000000000d (FINI)               0xbd30
 0x0000000000000019 (INIT_ARRAY)         0x10308
 0x000000000000001b (INIT_ARRAYSZ)       40 (bytes)
 0x000000000000001a (FINI_ARRAY)         0x10330
 0x000000000000001c (FINI_ARRAYSZ)       8 (bytes)
 0x000000006ffffef5 (GNU_HASH)           0x300
 0x0000000000000005 (STRTAB)             0x2180
 0x0000000000000006 (SYMTAB)             0x6e0
 0x000000000000000a (STRSZ)              11946 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000003 (PLTGOT)             0x10fe8
 0x0000000000000002 (PLTRELSZ)           2088 (bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0x68d0
 0x0000000000000007 (RELA)               0x5328
 0x0000000000000008 (RELASZ)             5544 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000006ffffffe (VERNEED)            0x5268
 0x000000006fffffff (VERNEEDNUM)         3
 0x000000006ffffff0 (VERSYM)             0x502a
 0x000000006ffffff9 (RELACOUNT)          39
 0x0000000000000000 (NULL)               0x0

So for fedora39 the linker finds all the libraries when linking the test executable.
I will check if there is a possibility to have the same feature also for Debian12 and other OSs.

Interesting observation. I agree, would be good to understand how to steer this behaviour.

With the help of Matthias it was now possible to extract the linker parameters used when the linker is executed by gcc.
Since Debian11 the parameter --as-needed was added as linker default parameter which only adds a library as dependency if this library is actually needed.

--as-needed
--no-as-needed
     This option affects ELF DT_NEEDED tags for dynamic libraries mentioned on the command line after the --as-needed option.  Normally the linker will add a
     DT_NEEDED tag for each dynamic library mentioned on the command line, regardless of whether the library is actually needed or not.  --as-needed causes a
     DT_NEEDED tag to only be emitted for a library that at that point in the link satisfies a non-weak undefined symbol reference from a regular object file or,
     if the library is not found in the DT_NEEDED lists of other needed libraries, a non-weak undefined symbol reference from another needed dynamic library.
     Object files or libraries appearing on the command line after the library in question do not affect whether the library is seen as needed.  This is similar to
     the rules for extraction of object files from archives.  --no-as-needed restores the default behaviour.

The old behaviour was that any library passed to the linker was added as dependency.

This change explains the observed differences of different OSs.