Search code examples
c++centosclangllvmcentos7

Install llvm-toolset-10.0 or newer in Centos7


I used docker image docker run -ti centos:7 /bin/bash, i try install llvm-toolset-10.0 like this yum install llvm-toolset-10.0 but got error No package llvm-toolset-10.0 available.

After that i tried use pre-built binraries from https://github.com/llvm/llvm-project/releases, but got bash: ./clang: cannot execute binary file, i used clang+llvm-13.0.0-powerpc64le-linux-rhel-7.9.

Question how to install clang or llvm with version 10 or higher in Centos7?


Solution

  • There is a llvm-toolset-10 build out on the centos buildlogs. The rpms are unsigned since they never got published out to the official centos scl repos; thus they won't be trusted by default. Also note that since some of the packages in llvm-toolset have a dependency on devtoolset you will need to ensure you have the right devtoolset repo installed as well.

    Add repo for devtoolset

    sudo yum install centos-release-scl-rh
    

    Create a custom repo pointing to buildlogs

    sudo bash -c 'cat << EOF > /etc/yum.repos.d/llvmtoolset-build.repo
    [llvmtoolset-build]
    name=LLVM Toolset 11.0 - Build
    baseurl=https://buildlogs.centos.org/c7-llvm-toolset-11.0.x86_64/
    gpgcheck=0
    enabled=1
    EOF'
    

    Install the llvm toolset packages you need

    sudo yum install --nogpgcheck llvm-toolset-11.0-clang-tools-extra llvm-toolset-11.0-clang
    

    Enable the llvm toolset

    echo "source /opt/rh/llvm-toolset-11.0/enable" >> ~/.bashrc
    source ~/.bashrc