Skip to content

Commit 09b4123

Browse files
authored
[HIP] Fix libclang_rt.builtins.a not found (#532)
* The solution to the libclang_rt builtins problem has changed with newer version of ROCm, as used by the Codeplay AMD plugin. The old suggested solution does not work. * This PR: * Suggests a new solution, with accompanying minor CMake work. * Updates documentation.
1 parent 5b5f3f4 commit 09b4123

File tree

2 files changed

+20
-6
lines changed

2 files changed

+20
-6
lines changed

cmake/FindCompiler.cmake

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,15 @@ if(is_dpcpp)
6969
INTERFACE_LINK_LIBRARIES ${SYCL_LIBRARY})
7070
endif()
7171

72-
endif()
72+
if(ENABLE_ROCBLAS_BACKEND OR ENABLE_ROCRAND_BACKEND OR ENABLE_ROCSOLVER_BACKEND)
73+
# Allow find_package(HIP) to find the correct path to libclang_rt.builtins.a
74+
# HIP's CMake uses the command `${HIP_CXX_COMPILER} -print-libgcc-file-name --rtlib=compiler-rt` to find this path.
75+
# This can print a non-existing file if the compiler used is icpx.
76+
if(NOT HIP_CXX_COMPILER)
77+
find_path(HIP_CXX_COMPILER clang++
78+
HINTS ENV HIPROOT ENV ROCM_PATH
79+
)
80+
endif()
81+
endif()
82+
83+
endif(is_dpcpp)

docs/building_the_project_with_dpcpp.rst

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,11 +457,14 @@ Build FAQ
457457

458458
clangrt builtins lib not found
459459
Encountered when trying to build oneMKL with some ROCm libraries. There are
460-
several possible solutions: * If building Open DPC++ from source, add
461-
``compiler-rt`` to the external projects compile option:
462-
``--llvm-external-projects compiler-rt``. * The *clangrt* from ROCm can be
463-
used, depending on ROCm version: ``export
464-
LIBRARY_PATH=/path/to/rocm-$rocm-version$/llvm/lib/clang/$clang-version$/lib/linux/:$LIBRARY_PATH``
460+
several possible solutions:
461+
462+
* If building Open DPC++ from source, add ``compiler-rt`` to the external
463+
projects compile option: ``--llvm-external-projects compiler-rt``.
464+
* Manually set the variable ``HIP_CXX_COMPILER`` to HIP's toolkit ``clang++``
465+
path, for instance ``-DHIP_CXX_COMPILER=/opt/rocm/6.1.0/llvm/bin/clang++``.
466+
oneMKL may fail to link if the clang versions of ``icpx`` and ``rocm`` are
467+
not compatible.
465468

466469
Could NOT find CBLAS (missing: CBLAS file)
467470
Encountered when tests are enabled along with the BLAS domain. The tests

0 commit comments

Comments
 (0)