By enabling the SCL repository you can install Clang 5.0.1 on CentOS 7 using the llvm-toolset-7 package.

$ sudo yum install centos-release-scl
$ sudo yum install llvm-toolset-7

Enable llvm-toolset-7:

$ scl enable llvm-toolset-7 bash

You can now check you clang version with:

$ clang --version

See this Red Hat blog post for more information.

For more information about SCL, see this page.

Answer from johnthagen on Stack Overflow
🌐
Linux Hint
linuxhint.com › install_llvm_centos7
How to Install LLVM on CentOS7 – Linux Hint
In this article, I will show you how to install and use LLVM Clang on CentOS 7.
🌐
Softwarecollections
softwarecollections.org › en › scls › rhscl › llvm-toolset-7.0
Clang and LLVM Toolset 7.0 — Software Collections
llvm-toolset-7.0 - Clang and LLVM Toolset is designed for developers on the CentOS and Red Hat Enterprise Linux platform.
Discussions

How to install Clang and LLVM 3.9 on CentOS 7 - Stack Overflow
I don't remember how I got libomp ... 10 on CentOS 7. I'm doing this just by compiling the source code which is relatively simple: cmake3 -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;openmp' -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/opt/llvm-10.0.1 ../llvm; ... More on stackoverflow.com
🌐 stackoverflow.com
c++ - Install llvm-toolset-10.0 or newer in Centos7 - Stack Overflow
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 tri... More on stackoverflow.com
🌐 stackoverflow.com
centos7 - Installing LLVM / Clang 6+ on centos 7 - Stack Overflow
The llvm-toolset-7 comes with clang 5 but i need to install software that is compatible only with clang 6+. How can i install a more recent clang? More on stackoverflow.com
🌐 stackoverflow.com
Is it possible to install Clangd on CentOS 7 ?
Maybe build gcc from source More on reddit.com
🌐 r/LLVM
9
1
November 23, 2022
🌐
Database Tutorials
dbtut.com › home › postgresql
How To Install llvm-toolset-7 on Centos - Database Tutorials
December 20, 2021 - We will install llvm-toolset-7 on Centos in this article. When installing devel package, llvm-toolset-7 package must be installed.
🌐
jdhao's digital space
jdhao.github.io › 2021 › 07 › 03 › install_clangd_on_linux
Install LLVM/Clangd from Source on CentOS 7 · jdhao's digital space
June 22, 2022 - Install LLVM/Clangd from Source on CentOS 7/ 3 July 2021·Updated: 22 June 2022·445 words·3 mins· · Linux Clang C++ Table of Contents · Table of Contents · Clangd is a language server for C++/C etc. I try to use clangd 12 for C++ code auto-completion on CentOS 7.
Find elsewhere
🌐
Centos
buildlogs.centos.org › c7-llvm-toolset-9.0.x86_64
Index of /c7-llvm-toolset-9.0.x86_64 - CentOS Buildlogs Mirror
This server contains a mix of raw/unsigned packages and/or build logs It should be used mainly for testing purposes
🌐
TheLinuxCode
thelinuxcode.com › home › how to install llvm on centos 7: an in-depth, step-by-step guide
How to Install LLVM on CentOS 7: An In-Depth, Step-by-Step Guide – TheLinuxCode
December 27, 2023 - Now that you have some background on LLVM, let‘s move on to installing it. I‘ll cover the prerequisites, the different installation methods available, verifying the install, and compiling a sample program. I recommend ensuring your CentOS 7 system is fully updated before installing LLVM.
🌐
GitHub
gist.github.com › informationsea › 1734ce9e517986e356300ccd3da47f63
Build LLVM for Cent OS 7 · GitHub
Build LLVM for Cent OS 7 · Raw · Dockerfile · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters ·
🌐
Centos
buildlogs.centos.org › c7-llvm-toolset-7.x86_64 › Packages
Index of /c7-llvm-toolset-7.x86_64/Packages
This server contains a mix of raw/unsigned packages and/or build logs It should be used mainly for testing purposes
🌐
Reddit
reddit.com › r/llvm › is it possible to install clangd on centos 7 ?
r/LLVM on Reddit: Is it possible to install Clangd on CentOS 7 ?
November 23, 2022 -

--- UPDATE ---

I now have :

  • gcc (GCC) 7.1.0 (built from sources)

With it and cmake3 I can now try to build Clangd but I get an error during the make -j 8.

Details of the error can be found in this comment but the takeaway is :

[  6%] Building CXX object lib/Support/CMakeFiles/LLVMSupport.dir/Process.cpp.o
	In file included from /home/kavan/Downloads/llvm-project/llvm/lib/Support/Process.cpp:107:0:
	/home/kavan/Downloads/llvm-project/llvm/lib/Support/Unix/Process.inc: Dans la fonction membre statique « static std::error_code llvm::sys::Process::FixupStandardFileDescriptors() »:
	/home/kavan/Downloads/llvm-project/llvm/lib/Support/Unix/Process.inc:209:54: error: initialisation invalide pour une référence du type « int (&)(int, stat*) noexcept » à partir d'une expression de type « int(int, stat*) noexcept »
	     if (RetryAfterSignal(-1, ::fstat, StandardFD, &st) < 0) {
		                                              ^
	In file included from /home/kavan/Downloads/llvm-project/llvm/lib/Support/Unix/Unix.h:23:0,
		         from /home/kavan/Downloads/llvm-project/llvm/lib/Support/Unix/Process.inc:13,
		         from /home/kavan/Downloads/llvm-project/llvm/lib/Support/Process.cpp:107:
	/home/kavan/Downloads/llvm-project/llvm/include/llvm/Support/Errno.h:32:23: note: dans le passage de l'argument 2 de « decltype(auto) llvm::sys::RetryAfterSignal(const FailT&, const Fun&, const Args& ...) [avec FailT = int; Fun = int(int, stat*) noexcept; Args = {int, stat*}] »
	 inline decltype(auto) RetryAfterSignal(const FailT &Fail, const Fun &F,
		               ^~~~~~~~~~~~~~~~
	make[2]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/Process.cpp.o] Erreur 1
	make[1]: *** [lib/Support/CMakeFiles/LLVMSupport.dir/all] Erreur 2
	make: *** [all] Erreur 2

Any help is welcome.

--- END UPDATE ---

CentOS 7 is required for my work, usually I use Neovim with Clangd to develop.

Here are the version of some programs that could be of use :

  • gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)

  • GNU Make 3.82

  • cmake3 version 3.17.5

  • cmake version 2.8.12.2

  • clang version 3.4.2 (tags/RELEASE_34/dot2-final)

Clangd isn't in the yum repos (although clang version 3.4.2 is).

I tried installing clangd via snap, but clangd --version just never gives the prompt back without printing anything (Ctrl-C needed to get the prompt back).

I tried building it from source, but gcc isn't recent enough :

CMake Error at cmake/modules/CheckCompilerVersion.cmake:37 (message):
  Host GCC version must be at least 7.1, your version is 4.8.5.

Has anyone been in this situation before ?

🌐
GitHub
gist.github.com › liweitianux › 90f900c9a4565d0135851d8a473bd9bc
Build Clang 13 on CentOS 7 · GitHub
$ . /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
🌐
Centos
buildlogs.centos.org › c7-llvm-toolset-10.0.x86_64
Index of /c7-llvm-toolset-10.0.x86_64
This server contains a mix of raw/unsigned packages and/or build logs It should be used mainly for testing purposes