Geant4 Build hanging at G4Processes

Ubuntu 18.04 LTS (used under Windows WSL)
gcc 7.5.0
GNU Make 4.1
cmake version 3.10.2

I used to use Geant4 v10.6.2 in Ubuntu under WSL and but now changed PC and I can’t get to build it even though I follow the same process as before.
Once running

cd geant4.10.06.p02-build/

I get

-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test HAVE_TLS
-- Performing Test HAVE_TLS - Success
-- Found EXPAT: /usr/lib/x86_64-linux-gnu/ (found version "2.2.5")
-- Found OpenGL: /usr/lib/x86_64-linux-gnu/
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/
-- Looking for XOpenDisplay in /usr/lib/x86_64-linux-gnu/;/usr/lib/x86_64-linux-gnu/ - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Looking for IceConnectionNumber in ICE
-- Looking for IceConnectionNumber in ICE - found
-- Found X11: /usr/lib/x86_64-linux-gnu/
-- Configuring download of missing dataset G4NDL (4.6)
-- Configuring download of missing dataset G4EMLOW (7.9.1)
-- Configuring download of missing dataset PhotonEvaporation (5.5)
-- Configuring download of missing dataset RadioactiveDecay (5.4)
-- Configuring download of missing dataset G4PARTICLEXS (2.1)
-- Configuring download of missing dataset G4PII (1.3)
-- Configuring download of missing dataset RealSurface (2.1.1)
-- Configuring download of missing dataset G4SAIDDATA (2.0)
-- Configuring download of missing dataset G4ABLA (3.1)
-- Configuring download of missing dataset G4INCL (1.0)
-- Configuring download of missing dataset G4ENSDFSTATE (2.2)
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of off64_t
-- Check size of off64_t - done
-- Looking for fseeko
-- Looking for fseeko - found
-- Looking for unistd.h
-- Looking for unistd.h - found
-- The following Geant4 features are enabled:
GEANT4_BUILD_CXXSTD: Compiling against C++ Standard '11'
GEANT4_BUILD_MULTITHREADED: Build multithread enabled libraries
GEANT4_BUILD_TLS_MODEL: Building with TLS model 'initial-exec'
GEANT4_USE_SYSTEM_EXPAT: Using system EXPAT library
GEANT4_USE_QT: Build Geant4 with Qt support
GEANT4_USE_OPENGL_X11: Build Geant4 OpenGL driver with X11 support

-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/d/Linux_Software/GEANT4/geant4.10.06.p02-build

which seems OK to me.
Now, when going for sudo make -j4 install all goes well until G4Processes. Every time make reaches G4Processes, it seems to hang and not progress at all

[ 27%] Building CXX object source/digits_hits/CMakeFiles/G4digits_hits.dir/utils/src/
[ 27%] Building CXX object source/digits_hits/CMakeFiles/G4digits_hits.dir/utils/src/
[ 27%] Linking CXX shared library ../../BuildProducts/lib/
[ 27%] Built target G4digits_hits
Scanning dependencies of target G4processes

To understand what’s going on, I then try sudo strace -p <makepid> which shows me that make is trapped inside an infinite loop of not finding specific files. Below I have attached part of the output i get
strace_output.txt (709.1 KB)

It seems that make is looking for files that are not included inside the source folder, which seems strange. Does anyone have an idea what is going on or could give me a tip on what to try?
Thank you very much,

I have re-uploaded the strace file when trying v10.6.p03 as the result is the same. But this time I have added 4000 lines now

Could you try and isolate where the infinite loop is happening please? I think there’s a lot of “correct” lookup in the report as the compiler goes through a list of things needed to be included, and it then goes through the paths configured to search for them. So isolating the actual file causing the loop will be needed (if that indeed is what’s causing things).

Do you have any additional environment settings for CMake, GCC etc?

Hi @bmorgan and thank you for taking a look at this.
Apologies for the term “infinite loop” and “hanging”. It is clear, as you observed, that this is not what’s happening here. The compiler is looking up things it is supposed to be.

After your response, I started building v10.7.02 and let my machine to see if Scanning dependencies of target G4processes will ever complete and it did after 4 hours and then it started building the target. The same searches took place for the rest targets as well but these were smaller directories so did not take such a long time.
I ran make in single-threaded mode.

I am not sure why that happens. Maybe my machine is making redundant searches? or it is slow (intel i5 2.4GhZ)?

Regarding my gcc configuration, gcc -v -E -x c++ - < /dev/null outputs

Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 7.5.0-3ubuntu1~18.04' --with-bugurl=file:///usr/share/doc/gcc-7/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-7 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-werror --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)
COLLECT_GCC_OPTIONS='-v' '-E' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/7/cc1plus -E -quiet -v -imultiarch x86_64-linux-gnu -D_GNU_SOURCE - -mtune=generic -march=x86-64 -fstack-protector-strong -Wformat -Wformat-security
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/7"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-linux-gnu/7/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 1 "<command-line>" 2
# 1 "<stdin>"
COLLECT_GCC_OPTIONS='-v' '-E' '-mtune=generic' '-march=x86-64'

while printenv (before Geant4 install and sourcing its .sh files) outputs

LESSCLOSE=/usr/bin/lesspipe %s %s
PATH=/mnt/d/Linux_Software/ROOT/6.22.02-install/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Program Files/WindowsApps/CanonicalGroupLimited.Ubuntu18.04onWindows_1804.2020.824.0_x64__79rhkp1fndgsc:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Windows/System32/OpenSSH/:/mnt/d/CMake/bin:/mnt/d/Microsoft VS Code/bin:/mnt/c/Program Files/Wolfram Research/WolframScript/:/mnt/d/Git/cmd:/mnt/c/Program Files (x86)/Windows Kits/10/Windows Performance Toolkit/:/mnt/c/Users/Alex/AppData/Local/Microsoft/WindowsApps:/mnt/d/MiKTeX/miktex/bin/x64/:/snap/bin
LESSOPEN=| /usr/bin/lesspipe %s

Does anything look out of place?
Thank you very much again.

Hello again,

I changed the building directory from /mnt/ to $HOME and building is fast as a lightning! Built it in 20 mins.
It seems all these recursive accesses were very time-consuming for WSL.
That is interesting since in my previous machine I had an AMD CPU (roughly speaking equivalent to my current i5 CPU) and working with a Geant4 installation in /mnt/ was sufficiently fast.

I am aware that the Geant4 Collaboration is not officially supporting WSL systems but thank you for the help.
Maybe we can change the title of this post to something more representative of the problem I described.


Hi @AlexAerPhys, many thanks for the detailed info - whilst we don’t officially support WSL as you say, feedback like this is valuable both for us and other users of this system!

I don’t see anything amiss in your environment settings, so I think that’s fine. I don’t have recent WSL experience, but a very quick search suggested there may be some I/O performance issues with /mnt (e.g. this post on StackOverflow). That might offer some ways to mitigate things. G4processes is the largest component of Geant4, so file lookups for #includes will expose any I/O issues.

Good idea on changing the title - would “Slow Geant4 build on WSL due to I/O issues” be o.k. for you?

That sounds great. Can you please make the title change?
Thank you, Alex

The G4processes library is the largest library in all of Geant4. It can take well over half the total time required to build the package. On my MacBook, it’s typically about an hour. If I do the build on our compute cluster with a single thread, it can be three to four hours (because of contention for the networked filesystem).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.