To build Clang from the source, you need following.
Hardware as per the system requirements:
- Linux, Solaries, BSD, Macos or Windows on x86, amd64, ARM, mips, PowerPC or SystemZ with GCC or Clang installed.
- 15-20 GB of disk space.
- And a lot of RAM 😅
Software:
- Python: >= 3.6
- Cmake: >= 3.13.4
- GCC: >= 5.1.0
- zlib: >=1.2.3.4
- GNU Make: 3.79
- Git
Steps to build llvm
are as follows:
Get the source:
$ git clone https://github.com/llvm/llvm-project.git
Generate build files:
$ cd llvm-project $ mkdir build $ cd build $ cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" ../llvm
One thing to note here, without
-DCMAKE_BUILD_TYPE=RelWithDebInfo
this build will take much more time (the build didn’t even finish on my machine).Build clang:
$ make clang
After this you will have clang built under
llvm-project/build/bin
.Try it out:
$ bin/clang <some.c file> -o <some-binery-file>