Skip to content

Instantly share code, notes, and snippets.

@liweitianux
Last active April 19, 2023 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liweitianux/90f900c9a4565d0135851d8a473bd9bc to your computer and use it in GitHub Desktop.
Save liweitianux/90f900c9a4565d0135851d8a473bd9bc to your computer and use it in GitHub Desktop.
Build Clang 13 on CentOS 7

Build Clang 13 on CentOS 7

Requirements [1]:

  • CMake >=3.13.4
  • GCC >=7.1.0
  • Python >=3.6 (automated test suite)
  • zlib >=1.2.3.4
  • GNU Make >=3.79

Notes:

  • Extracted source occupies ~1.3 GB
  • Configure with CMAKE_BUILD_TYPE=Release, which defaults to Debug
  • Build of LLVM, Clang and LLD uses ~4 GB extra disk space
  • Build takes ~42 minutes on Xeon E5-2630v4 (2.2 GHz) with 8 jobs
  • Installation uses ~1.8 GB
  1. Install dependencies

    $ yum -y install centos-release-scl
    $ yum makecache fast
    $ yum -y install devtoolset-11 cmake3
    
  2. Download source tarball and extract

    $ wget https://github.com/llvm/llvm-project/archive/refs/tags/llvmorg-13.0.1.tar.gz \
          -O llvm-project-llvmorg-13.0.1.tar.gz
    $ tar xf llvm-project-llvmorg-13.0.1.tar.gz
    $ cd llvm-project-llvmorg-13.0.1
    
  3. Build

    $ . /opt/rh/devtoolset-11/enable
    $ cmake3 -S llvm -B build -G 'Unix Makefiles' \
          -DLLVM_ENABLE_PROJECTS='clang;lld' \
          -DCMAKE_BUILD_TYPE=Release
    $ cmake3 --build build -j8
    
  4. Install

    $ cmake3 --install build
    

References

[1] LLVM Requirements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment