← Back home

Fixing 'Cannot find clang' in Gentoo for dev-lang/ispc

Published on March 30, 2025

I was trying to upgrade Gentoo but go this error when trying to install 'dev-lang/ispc' as a dependency:

loading initial cache file /var/tmp/portage/dev-lang/ispc-1.28.0/work/ispc-1.28.0_build/gentoo_common_config.cmake
-- The C compiler identification is GNU 14.3.1
-- The CXX compiler identification is GNU 14.3.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib/ccache/bin/x86_64-pc-linux-gnu-gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- LLVM_CONFIG_EXECUTABLE: /usr/bin/llvm-config
-- LLVM_TOOLS_BINARY_DIR: /usr/bin
-- LLVM_DIR is /usr/bin/../lib/cmake/llvm
CMake Error at cmake/FindLLVM.cmake:31 (message):
  Failed to find clang
Call Stack (most recent call first):
  CMakeLists.txt:144 (include)

-- Configuring incomplete, errors occurred!
* ERROR: dev-lang/ispc-1.28.0::gentoo failed (configure phase):
*   cmake failed
*
* Call stack:
*     ebuild.sh, line 136:  Called src_configure
*   environment, line 2541:  Called cmake_src_configure
*   environment, line 1370:  Called die
* The specific snippet of code:
*   "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed";

With the main error being:

Failed to find clang

I ran 'clang --version' to ensure that clang was installed. The problem is that the installation is in '/usr/lib/llvm/20/bin' and ispc was expecting the bin in '/usr/bin'. So, I made links to the bin in /usr/bin:

            sudo ln -sf /usr/lib/llvm/20/bin/clang /usr/bin/clang
            sudo ln -sf /usr/lib/llvm/20/bin/clang++ /usr/bin/clang++
            sudo ln -sf /usr/lib/llvm/20/bin/llvm-as /usr/bin/llvm-as
            sudo ln -sf /usr/lib/llvm/20/bin/llvm-dis /usr/bin/llvm-dis
            sudo ln -sf /usr/lib/llvm/20/bin/llvm-config /usr/bin/llvm-config
            sudo ln -sf /usr/lib/llvm/20/bin/llvm-link /usr/bin/llvm-link
            sudo ln -sf /usr/lib/llvm/20/bin/opt /usr/bin/opt
            sudo ln -sf /usr/lib/llvm/20/bin/llc /usr/bin/llc
        

This fixed my llvm issue. I've been having alot of llvm issues with Gentoo recently, but this hack fixes this issue. After that I was able to upgrade successfully.

← Back home