Skip to content

Instantly share code, notes, and snippets.

@oxycoder
Last active November 20, 2021 00:47
Show Gist options
  • Save oxycoder/40de89c4748ef995da2a409f6d80ae9f to your computer and use it in GitHub Desktop.
Save oxycoder/40de89c4748ef995da2a409f6d80ae9f to your computer and use it in GitHub Desktop.
Build Clang 12 with Meson and conan Ubuntu 20.04
#! /bin/bash
echo "install requires tools"
sudo apt-get update
sudo apt-get install -y cmake libffi-dev libedit-dev swig git gcc g++ pkg-config ninja-build libxml2-dev python3-pip
echo "Download llvm source"
git clone --depth 1 https://github.com/llvm/llvm-project
cd llvm-project
ln -s clang-tools-extra clang/tools/extra
dir=$PWD
echo "Build LLVM\n"
cd $dir
mkdir build
cd $dir/build
CC=gcc CXX=g++ cmake -G "Ninja" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_TARGETS_TO_BUILD="host;AMDGPU;BPF" \
-DLLVM_BUILD_LLVM_DYLIB=ON \
-DLLVM_LINK_LLVM_DYLIB=ON \
-DLLVM_ENABLE_FFI=ON \
-DLLVM_ENABLE_RTTI=ON \
-DLLVM_BUILD_DOCS=OFF \
-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;compiler-rt;libcxx;libcxxabi;libunwind;lld;lldb;llvm;openmp;polly;" \
-DCMAKE_INSTALL_PREFIX=/usr ../llvm
ninja
sudo ninja install/strip
echo "Install meson"
pip3 install meson
echo "download conan deb"
cd ~
wget https://dl.bintray.com/conan/installers/conan-ubuntu-64_1_29_1.deb
sudo dpkg -i ~/conan-ubuntu-64_1_29_1.deb
rm ~/conan-ubuntu-64_1_29_1.deb
echo "Setup conan profile"
conan config init
cat <<EOT >> ~/.conan/profiles/clang
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=clang
compiler.version=12
compiler.libcxx=libc++
build_type=Debug
[options]
[build_requires]
[env]
CXX=clang++
CC=clang
EOT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment