Building GROMACS on MI300X/MI325X using AdaptiveCpp and ROCM 6.33 failed due to incorrect GLIBCXX

GROMACS version: 2025.2
GROMACS modification: No

Hi there,
Below is my system configuration:

  • OS: Ubuntu 22.04
  • GPU: AMD MI300X / AMD MI325X (gfx942)
  • ROCm 6.3.3

I am trying to build GROMACS following this link.

I built AdaptiveCpp as follows:

cmake -DCMAKE_INSTALL_PREFIX=/opt/AdaptiveCpp \
      -DROCM_PATH=/opt/rocm \
 	  -DWITH_ROCM_BACKEND=ON \
 	  -DWITH_SSCP_COMPILER=OFF \
 	  -DWITH_OPENCL_BACKEND=OFF \
 	  -DWITH_LEVEL_ZERO_BACKEND=OFF \
 	  -DWITH_CUDA_BACKEND=OFF \
 	  -DCMAKE_C_COMPILER=/opt/rocm/llvm/bin/clang \
 	  -DCMAKE_CXX_COMPILER=/opt/rocm/llvm/bin/clang++ \
 	  -DLLVM_DIR=/opt/rocm/llvm/lib/cmake/llvm/  \
 	  -DACPP_COMPILER_FEATURE_PROFILE=minimal \
 	  -DACPP_EXPERIMENTAL_LLVM=ON \
 	  -DDEFAULT_TARGETS='hip:gfx942' ..

After AdaptiveCpp is successfully built and installed, I build GROMACS as follows:

cmake -DCMAKE_C_COMPILER=/opt/rocm/llvm/bin/clang \ 
      -DCMAKE_CXX_COMPILER=/opt/rocm/llvm/bin/clang++ \
 	  -DGMX_GPU=SYCL \
	  -DGMX_SYCL=ACPP \
 	  -DACPP_TARGETS='hip:gfx942' \
 	  -Dadaptivecpp_DIR=‘/opt/AdaptiveCpp/lib/cmake/AdaptiveCpp/’ \
 	  -Dhipsycl_DIR=‘/opt/AdaptiveCpp/lib/cmake/hipSycl/’ ..

It fails when checking AdaptiveCpp:

-- Checking for valid AdaptiveCpp/hipSYCL compiler
CMake Error at cmake/gmxManageSyclAdaptiveCpp.cmake:153 (message):
  AdaptiveCpp/hipSYCL compiler not working:

  Change Dir:
  '/home/bagus/gromacs/gromacs-2025.2/build/CMakeTmpAdaptiveCppTest'



  Run Build Command(s): /usr/bin/cmake -E env VERBOSE=1 /usr/bin/gmake -f
  Makefile

  /usr/bin/cmake -S/home/bagus/gromacs/gromacs-2025.2/cmake/AdaptiveCppTest
  -B/home/bagus/gromacs/gromacs-2025.2/build/CMakeTmpAdaptiveCppTest
  --check-build-system CMakeFiles/Makefile.cmake 0

  /usr/bin/cmake -E cmake_progress_start
  /home/bagus/gromacs/gromacs-2025.2/build/CMakeTmpAdaptiveCppTest/CMakeFiles
  /home/bagus/gromacs/gromacs-2025.2/build/CMakeTmpAdaptiveCppTest//CMakeFiles/progress.marks

  /usr/bin/gmake -f CMakeFiles/Makefile2 all

  gmake[1]: Entering directory
  '/home/bagus/gromacs/gromacs-2025.2/build/CMakeTmpAdaptiveCppTest'

  /usr/bin/gmake -f CMakeFiles/AdaptiveCppTest.dir/build.make
  CMakeFiles/AdaptiveCppTest.dir/depend

  gmake[2]: Entering directory
  '/home/bagus/gromacs/gromacs-2025.2/build/CMakeTmpAdaptiveCppTest'

  cd /home/bagus/gromacs/gromacs-2025.2/build/CMakeTmpAdaptiveCppTest &&
  /usr/bin/cmake -E cmake_depends "Unix Makefiles"
  /home/bagus/gromacs/gromacs-2025.2/cmake/AdaptiveCppTest
  /home/bagus/gromacs/gromacs-2025.2/cmake/AdaptiveCppTest
  /home/bagus/gromacs/gromacs-2025.2/build/CMakeTmpAdaptiveCppTest
  /home/bagus/gromacs/gromacs-2025.2/build/CMakeTmpAdaptiveCppTest
  /home/bagus/gromacs/gromacs-2025.2/build/CMakeTmpAdaptiveCppTest/CMakeFiles/AdaptiveCppTest.dir/DependInfo.cmake

  gmake[2]: Leaving directory
  '/home/bagus/gromacs/gromacs-2025.2/build/CMakeTmpAdaptiveCppTest'

  /usr/bin/gmake -f CMakeFiles/AdaptiveCppTest.dir/build.make
  CMakeFiles/AdaptiveCppTest.dir/build

  gmake[2]: Entering directory
  '/home/bagus/gromacs/gromacs-2025.2/build/CMakeTmpAdaptiveCppTest'

  [ 50%] Building CXX object CMakeFiles/AdaptiveCppTest.dir/main.cpp.o

  /opt/AdaptiveCpp/lib/cmake/AdaptiveCpp/syclcc-launcher
  --launcher-cxx-compiler=/opt/rocm/llvm/bin/clang++
  --launcher-syclcc=/opt/AdaptiveCpp/bin/acpp -Wno-unknown-cuda-version
  -Wno-unknown-attributes --acpp-targets="hip:gfx942"
  --acpp-clang=/opt/rocm/llvm/bin/clang++ /opt/rocm/llvm/bin/clang++ -isystem
  /opt/AdaptiveCpp/include -isystem /opt/AdaptiveCpp/include/AdaptiveCpp -O3
  -DNDEBUG -ffast-math -DHIPSYCL_ALLOW_INSTANT_SUBMISSION=1
  -DACPP_ALLOW_INSTANT_SUBMISSION=1 -fgpu-inline-threshold=99999
  -Wno-deprecated-declarations -MD -MT
  CMakeFiles/AdaptiveCppTest.dir/main.cpp.o -MF
  CMakeFiles/AdaptiveCppTest.dir/main.cpp.o.d -o
  CMakeFiles/AdaptiveCppTest.dir/main.cpp.o -c
  /home/bagus/gromacs/gromacs-2025.2/cmake/AdaptiveCppTest/main.cpp

  /home/bagus/gromacs/gromacs-2025.2/cmake/AdaptiveCppTest/main.cpp:55:6:
  warning: GMX_SYCL_TEST_HAVE_HIP_TARGET [-W#warnings]

     55 | #    warning GMX_SYCL_TEST_HAVE_HIP_TARGET
        |      ^

  /home/bagus/gromacs/gromacs-2025.2/cmake/AdaptiveCppTest/main.cpp:57:10:
  warning: GMX_SYCL_TEST_HAVE_HIP_WAVE64_TARGET [-W#warnings]

     57 | #        warning GMX_SYCL_TEST_HAVE_HIP_WAVE64_TARGET
        |          ^

  2 warnings generated when compiling for gfx942.

  [100%] Linking CXX executable AdaptiveCppTest

  /usr/bin/cmake -E cmake_link_script CMakeFiles/AdaptiveCppTest.dir/link.txt
  --verbose=1

  ld.lld: error: undefined reference due to --no-allow-shlib-undefined:
  std::condition_variable::wait(std::unique_lock<std::mutex>&)@GLIBCXX_3.4.30

  >>> referenced by /opt/AdaptiveCpp/lib/libacpp-rt.so

  clang++: error: linker command failed with exit code 1 (use -v to see
  invocation)

   /opt/AdaptiveCpp/lib/cmake/AdaptiveCpp/syclcc-launcher --launcher-cxx-compiler=/opt/rocm/llvm/bin/clang++ --launcher-syclcc=/opt/AdaptiveCpp/bin/acpp -Wno-unknown-cuda-version -Wno-unknown-attributes --acpp-targets="hip:gfx942" --acpp-clang=/opt/rocm/llvm/bin/clang++ /opt/rocm/llvm/bin/clang++ -O3 -DNDEBUG CMakeFiles/AdaptiveCppTest.dir/main.cpp.o -o AdaptiveCppTest  -Wl,-rpath,/opt/AdaptiveCpp/lib /opt/AdaptiveCpp/lib/libacpp-rt.so /opt/AdaptiveCpp/lib/libacpp-common.so

  gmake[2]: *** [CMakeFiles/AdaptiveCppTest.dir/build.make:104:
  AdaptiveCppTest] Error 1

  gmake[2]: Leaving directory
  '/home/bagus/gromacs/gromacs-2025.2/build/CMakeTmpAdaptiveCppTest'

  gmake[1]: *** [CMakeFiles/Makefile2:87: CMakeFiles/AdaptiveCppTest.dir/all]
  Error 2

  gmake[1]: Leaving directory
  '/home/bagus/gromacs/gromacs-2025.2/build/CMakeTmpAdaptiveCppTest'

  gmake: *** [Makefile:91: all] Error 2



Call Stack (most recent call first):
  cmake/gmxManageSycl.cmake:45 (include)
  CMakeLists.txt:726 (include)

The libacpp-rt.so has dynamic links as follows

> ldd /opt/AdaptiveCpp/lib/libacpp-rt.so
        linux-vdso.so.1 (0x00007ffdf0290000)
        libacpp-common.so => /opt/AdaptiveCpp/lib/libacpp-common.so (0x00007fe2cf75d000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fe2cf4e2000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe2cf3fb000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fe2cf3db000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe2cf1b2000)
        /lib64/ld-linux-x86-64.so.2 (0x00007fe2cf7fa000)

I believe there is something wrong with how the AdaptiveCpp is linked against libstdc++ of GCC.

Thank you in advance :)

I figured it out.
The environment where I built the AdaptiveCpp was polluted by Conda. I rebuilt AdaptiveCpp by running conda deactivate first, and GROMACS can compile successfully :)

Thank you :)

1 Like