What Is LLVM? Getting Started with LLVM – POFTUT

What Is LLVM? Getting Started with LLVM

LLVM is a project which provides a collection of a modular compiler and toolchain software and technologies. The name “LLVM” is not an acronym that is different from other IT and Opensource projects. LLVM has started a research project at the University of Illinois in order to create a compiler and tool-chain which supports both static and dynamic compilation for different programming languages. Even different programming languages like C, C++, Java, C#, Kotlin, Delphi, Rust, Ruby are supported the most popular programming languages are C and C++ for the LLVM compiler and tool-chain.

LLVM Hardware and Operating System Support

As an opensource project LLVM is supported in different operating systems, platforms, and hardware. LLVM can run on Linux, Solaris, FreeBSD, NetBSD, MacOSX, Windows operating systems. LVVM also supports different hardware and processor architectures like x86, amd64, x86_64, PowerPC, V9, ARM. For more specific hardware and operating support take a look following table.

LLVM Hardware and Operating System Support

LLVM Supported Programming Languages

As stated in the start LLVM supports a wide range of programming languages to compile and bind. Even some programming languages are not fully supported by the LLVM we will list the supported programming languages and support level and supported features.

C and C++ are the top programming languages for the LLVM. Even LLVM is created as a dynamic compiler and toolchain C and C++ are the main targets for support. Also, LLVM is developed with C++.

Objective-C is another completely supported programming language similar to the C and C++.

LLVM Architecture and Components

LLVM provides a complete architecture where there are different components and pieces to complete the picture. LLVM provides Front End, Passes, and Back End. The following graphic illustrates how the LLVM works on source code and generates executables and binaries.

LLVM Components, Architecture and Compiling Steps

Front End will take the source code and convert it to the intermediate representation or IR . This is a preparation process for the other steps and compiler where LLVM runs properly. Front End is nor the core part of the LLVM and generally auxiliary software or a tool like Clang is used.

LEARN MORE  How To List MySQL Database Users?

Pass or IR is the core task of the LLVM where the compilation process takes place. The IR or intermediate code will be optimized again and again with multiple phases.

Back End is the last step where the optimized IR code will be converted into the machine code which is specific to a CPU architecture or operating system.

Below we will list some important tools and components of the LLVM.

Clang is the compiler created for the LLVM specifically. Clang can compile the IR code into the executables and binaries. Also, Clang is almost 3 times faster than the GCC compiler.

LLDB is the debugger created for the LLVM project. LLDB is more faster and efficient than GDB and tightly integrated with the LLVM core and Clang.

libc++ and libc++ ABI are C++ standard library implementations.

compiler-rt is a dynamic testing utility for low-level code. It can be used to run and text the low-level code in real-time.

LLVM Core is the core component for the LLVM where core libraries provide optimizer and code generation support for different CPU and hardware architectures.


Gnu Compiler Collection or GCC is another popular and widely used opensource compiler project. Before the LLVM emerged the GCC was a defacto compiler for different for open source world. With the LLVM things started to change and with its advantages LLVM became popular too. Below we will compare the LLVM and GCC from different points of view.

  • GCC supports more traditional programming languages like Ada, Fortran, and Go than LLVM.
  • GCC supports more hardware and CPU architectures like RISC-V than LLVM.
  • GCC supports more language extensions and assembly language features then LLVM.
  • LLVM is used by emerging languages like Swift, Rust, Julia, and Ruby then GCC.
  • LLVM complies with the C and C++ programming languages more strictly than GCC.
  • LLVM provides more accurate and friendly diagnostics information than GCC.
LEARN MORE  What Is The GNU Project?

Install LLVM

LLVM can be installed on Linux and Ubuntu operating systems like below. We will provide the package names llvm-10 and llvm-10-tools in order to install LLVM version 10 core libraries and tools.

$ sudo apt install llvm-10 llvm-10-tools clang
Install LLVM

Getting Started with LLVM

We have installed required packages named llvm-10, llvm-10-tools, and clang. Now we will compile a simple hello world example with the LLVM as getting started example. The hello world application source code is provided below.

#include <stdio.h>

int main()
   printf("Hello World From Poftut.com via LLVM");

   return 0;


We will compile and create the executable named hello_world with the clang command like below. The LLVM will be executed by the clang command under the hood.

$ clang hello_world.c -o hello_world

The newly created hello_world executable can be run from the console or bash command line like below.

$ ./hello_world

Leave a Comment