clang was broken on Ubuntu 22.04
Summary
This is Ubuntu 22.04's bug, not GROMACS's. Ubuntu 22.04 broke clang so I can not build GROMACS (but hipSYCL was ok). The problem was solved but I wrote this just in case someone got the same issue.
GROMACS version
GROMACS 2024-dev (from source)
cmake command:
cmake .. -DCMAKE_C_COMPILER=/opt/rocm/llvm/bin/clang -DCMAKE_CXX_COMPILER=/opt/rocm/llvm/bin/clang++ -DGMX_GPU=SYCL -DGMX_SYCL_HIPSYCL=ON -DHIPSYCL_TARGETS='hip:gfx1030' -DGMX_BUILD_OWN_FFTW=ON -DREGRESSIONTEST_DOWNLOAD=ON
gmx version:
:-) GROMACS - gmx, 2024-dev-20221124-bb312a6a8b (-:
Executable: /usr/local/gromacs/bin/gmx
Data prefix: /usr/local/gromacs
Working dir: /home/labhhc
Command line:
gmx --quiet --version
GROMACS version: 2024-dev-20221124-bb312a6a8b
GIT SHA1 hash: bb312a6a8befd5f41ca3114891caa07822f7ad5e
Precision: mixed
Memory model: 64 bit
MPI library: thread_mpi
OpenMP support: enabled (GMX_OPENMP_MAX_THREADS = 128)
GPU support: SYCL (hipSYCL)
NB cluster size: 8
SIMD instructions: AVX2_256
CPU FFT library: fftw-3.3.8-sse2-avx-avx2-avx2_128
GPU FFT library: VkFFT 1.2.26-b15cb0ca3e884bdb6c901a12d87aa8aadf7637d8
Multi-GPU FFT: none
RDTSCP usage: enabled
TNG support: enabled
Hwloc support: disabled
Tracing support: disabled
C compiler: /opt/rocm/llvm/bin/clang Clang 15.0.0
C compiler flags: -mavx2 -mfma -Wall -Wno-unused -Wunused-value -Wunused-parameter -Wno-missing-field-initializers -O3 -DNDEBUG
C++ compiler: /opt/rocm/llvm/bin/clang++ Clang 15.0.0
C++ compiler flags: -mavx2 -mfma -Wall -Wextra -Wpointer-arith -Wmissing-prototypes -Wdeprecated -Wno-unused-function -Wno-reserved-identifier -Wno-missing-field-initializers -Weverything -Wno-c++98-compat -Wno-c++98-compat-pedantic -Wno-source-uses-openmp -Wno-c++17-extensions -Wno-documentation-unknown-command -Wno-covered-switch-default -Wno-switch-enum -Wno-extra-semi-stmt -Wno-weak-vtables -Wno-shadow -Wno-padded -Wno-reserved-id-macro -Wno-double-promotion -Wno-exit-time-destructors -Wno-global-constructors -Wno-documentation -Wno-format-nonliteral -Wno-used-but-marked-unused -Wno-float-equal -Wno-cuda-compat -Wno-conditional-uninitialized -Wno-conversion -Wno-disabled-macro-expansion -Wno-unused-macros -Wno-unused-parameter -Wno-unused-variable -Wno-newline-eof -Wno-old-style-cast -Wno-zero-as-null-pointer-constant -Wno-unused-but-set-variable -Wno-sign-compare -fopenmp=libomp -O3 -DNDEBUG
hipSYCL launcher: /usr/local/lib/cmake/hipSYCL/syclcc-launcher
hipSYCL flags: -Wno-unknown-cuda-version -Wno-unknown-attributes --hipsycl-targets="hip:gfx1030"
hipSYCL GPU flags: -ffast-math;-fgpu-inline-threshold=99999
hipSYCL targets: hip:gfx1030
hipSYCL version: hipSYCL 0.9.3-git
ROCm version: 5.4
Steps to reproduce
hipSYCL built was successful without any issue. Building GROMACS with the above cmake command got this error:
The C++ compiler cannot find a working standard library and it is
not libstdc++. The GROMACS build cannot handle this case. Please use a working
C++17 compiler and standard library.
Reinstalled ROCm 5.3.3, 5.4 and rocFFT, rebuilt hipSYCL many times but still had the same issue. Further checking, ROCm clang++ can not build a simple 'Hello Wolrd' cpp file.
/opt/rocm/llvm/bin/clang++ -fopenmp main.cpp && readelf -d ./a.out && ldd ./a.out
main.cpp:1:10: fatal error: 'iostream' file not found
#include <iostream>
^~~~~~~~~~
1 error generated.
Possible fixes
Installing g++-12 on Ubuntu 22.04 fixed the issue:
sudo apt install g++-12
Source: https://askubuntu.com/questions/1441844/todays-ubuntu-22-04-updates-seem-to-break-clang-compiler