Skip to content

Instantly share code, notes, and snippets.

@dfsp-spirit
Created July 14, 2023 09:07
Show Gist options
  • Save dfsp-spirit/241b9dcc1ddcad47eb49217fe7cd114f to your computer and use it in GitHub Desktop.
Save dfsp-spirit/241b9dcc1ddcad47eb49217fe7cd114f to your computer and use it in GitHub Desktop.
Compile and install clang into user home under Ubuntu Linux
#!/bin/sh
#
# This is a recipe, you should type things manually and check for errors
# after each command instead of treating this as a fire & forget shell script.
#
# This follows the official clang docs at https://clang.llvm.org/get_started.html
#
# Done under Ubuntu 22.04 LTS, with clang fetched from Github on 2023-07-04, commit 61e0822ef.
#
# This does not require root, but it uses cmake. If you don't have that, building it is easy, or just use autotools.
# checkout llvm git repo
git clone --depth=1 https://github.com/llvm/llvm-project.git
cd llvm-project/
mkdir build
cd build/
# build with cmake
mkdir ~/software/ # or whatever you prefer, adapt it below if you change it.
cmake -DCMAKE_INSTALL_PREFIX=$HOME/software/clang -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" ../llvm
make # This is gonna take a while.
make install
# set PATH so you can actually use it. You will want to persist this in your shell's startup file, like ~/.bash_profile.
export PATH=$PATH:$HOME/software/clang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment