ecmwf-ifs / fiat

The Fortran IFS and Arpege Toolkit
Apache License 2.0
9 stars 24 forks source link

Necessity of librt #4

Closed samhatfield closed 2 years ago

samhatfield commented 2 years ago

I am building fiat on Fugaku which is admittedly an unusual setup - x86 login nodes compiling for aarch64 compute nodes. The librt.so found by CMake is the x86 one so I have to manually execute the final link for libfiat.so but pointing at the aarch64 instead. This isn't a big deal, and I don't think this cross-compilation issue should necessarily be accounted for by fiat. However, I also noticed that when I just deleted this line, libfiat.so still built just fine. So, do we actually need to link against librt.so anymore?

tlmquintino commented 2 years ago

@samhatfield there is a way to specify (force) which library make should use. Pass this in the config step: -DRT_LIB=/path/to/the/aarch64/library/librt.so

tlmquintino commented 2 years ago

We usually only use librt to use async io. Not sure fiat is using it or not. eckit does need it.

wdeconinck commented 2 years ago

@samhatfield I don't remember exactly which platform or compiler required librt, but it was definitely required for one. It is not an absolute requirement for some platforms, and ${RT_LIB} may as well be an empty value. Instead of specifying RT_LIB as you do you may also try -DCMAKE_DISABLE_FIND_PACKAGE_RealTime=ON. (see https://cmake.org/cmake/help/latest/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName.html) Providing the correct path to RT_LIB is something that could be added to a fugaku toolchain file.

tlmquintino commented 2 years ago

Yes, if in Fugal you are using toolchain file then that is the right place to put it

samhatfield commented 2 years ago

Thanks, I'm trying it with a toolchain file now. Here is my file:

# Set Fujitsu compilers
set(CMAKE_Fortran_COMPILER /opt/FJSVxtclanga/tcsds-mpi-latest/bin/mpifrtpx)
set(CMAKE_C_COMPILER /opt/FJSVxtclanga/tcsds-mpi-latest/bin/mpifccpx)
set(CMAKE_CXX_COMPILER /opt/FJSVxtclanga/tcsds-mpi-latest/bin/mpiFCCpx)

# Location of aarch64 version of Real Time library
set(RT_LIB "/FJSVxos/devkit/aarch64/rfs/usr/lib64/librt.so")

However CMake interprets librt.so as a target now, and fails:

Scanning dependencies of target fiat
make[2]: *** No rule to make target '/FJSVxos/devkit/aarch64/rfs/usr/lib64/librt.so', needed by 'lib/libfiat.so'.  Stop.
make[1]: *** [CMakeFiles/Makefile2:1054: src/fiat/CMakeFiles/fiat.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

Could a CMake wizard point out what I'm missing?

samhatfield commented 2 years ago

Nevermind, wrong path!