Skip to content

Latest commit

 

History

History
144 lines (102 loc) · 3.58 KB

File metadata and controls

144 lines (102 loc) · 3.58 KB

LLVM: Quick install on the main platforms

These are the easiest package-manager based options for a working LLVM/Clang toolchain.

macOS (Homebrew)

brew update
brew install llvm
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc   # Apple Silicon
# echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.zshrc     # Intel Macs
source ~/.zshrc
llvm-config --version

Managing several LLVM versions

See the script at llvm-version.sh. It helps me to switch between different LLVM versions installed via Homebrew. You can use it as a template to create your own version manager for LLVM.

Linux

Ubuntu/Debian:

sudo apt update
sudo apt install -y llvm clang lld
llvm-config --version

ULL iaas virtual machines

When using the ULL iaas environment, you have a Ubuntu image:

usuario@ubuntu:~/pl/llvm$ sudo apt update
sudo apt install -y llvm clang lld
[sudo] password for usuario: 
Des:1 https://cli.github.com/packages stable InRelease [3.917 B]
...

You can use the scripts/llvm-health-check.sh to check that LLVM is working:

usuario@ubuntu:~/pl/hello-llvm$ scripts/llvm-health-check.sh
[check] Platform: Linux
[check] Workspace: /home/usuario/pl/hello-llvm
[check] clang: Ubuntu clang version 18.1.3 (1ubuntu1)
[check] llvm-config: 18.1.3
[check] Detected Linux (Codespaces environment)
[check] Compiling factorial example...
[check] Running tmp/f...

Fedora:

sudo dnf install -y llvm clang lld
llvm-config --version

Arch Linux:

sudo pacman -S llvm clang lld
llvm-config --version

Windows

Option 1 (easiest): winget

winget install LLVM.LLVM
clang --version

Option 2: choco

choco install llvm -y
clang --version

If clang is not recognized after installation, reopen the terminal or add LLVM's bin folder to PATH.

GitHub CodeSpaces DevContainer

This repo devcontainer is configured for the LLVM Learning Tutorial for the Procesadores de Lenguajes course. It uses the script setup.sh to install LLVM and related tools in a GitHub Codespaces environment. Use it as a template for your own LLVM projects.

See section /docs/installing/github-codespaces.md

GitHub Actions

If you want to run LLVM-based tests in a GitHub Actions workflow, you can use the following configuration as a starting point. This example installs LLVM and runs tests on a Linux environment.

See also https://github.com/ULL-ESIT-PL/dragon2js/blob/LLVM-simple/.github/workflows/llvm-simple-tests.yml (private repo, but you can see the file content in the link above)

File .github/workflows/llvm-simple-tests.yml:

name: LLVM Simple Tests

on:
  push:
    branches:
      - LLVM-simple

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - name: Check out repository
        uses: actions/checkout@v4

      - name: Install LLVM
        run: |
          sudo apt-get update
          sudo apt-get install -y llvm llvm-runtime

      - name: Check LLVM tools
        run: |
          which lli
          lli --version

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 25
          cache: npm

      - name: Install dependencies
        run: npm ci

      - name: Run main test suite
        run: npm test

Building from source

See also the LLVM section Getting Started with the LLVM System¶