Skip to content

Instantly share code, notes, and snippets.

@theoparis
Created January 14, 2024 02:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theoparis/982db13fcec3f7f9ca9cae1d5256cd54 to your computer and use it in GitHub Desktop.
Save theoparis/982db13fcec3f7f9ca9cae1d5256cd54 to your computer and use it in GitHub Desktop.
Build llvm with C++20 modules + mlir with the vulkan runner
ROOT_DIR = $(PWD)
THIRD_PARTY_DIR = $(ROOT_DIR)/third_party
INSTALL_DIR = $(ROOT_DIR)/install
# TODO: this be in its own git repository
llvm-configure:
cmake -S $(ROOT_DIR)/../llvm-project/llvm \
-B $(ROOT_DIR)/build/llvm \
-G Ninja \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_INSTALL_PREFIX=$(INSTALL_DIR) \
-DLLVM_CCACHE_BUILD=ON \
-DLLVM_ENABLE_PROJECTS="clang;lld;lldb;clang-tools-extra;mlir;polly;bolt;libclc" \
-DLLVM_ENABLE_RUNTIMES="compiler-rt;libc;libcxx;libcxxabi;libunwind" \
-DLLVM_RUNTIME_TARGETS="x86_64-unknown-linux-gnu" \
-DMLIR_ENABLE_VULKAN_RUNNER=ON \
-DCOMPILER_RT_BUILD_SANITIZERS=ON \
-DCOMPILER_RT_BUILD_XRAY=ON \
-DCOMPILER_RT_BUILD_LIBFUZZER=ON \
-DCOMPILER_RT_BUILD_PROFILE=ON \
-DCOMPILER_RT_BUILD_MEMPROF=ON \
-DCOMPILER_RT_BAREMETAL_BUILD=ON \
-DLIBCXX_ENABLE_STD_MODULES=ON \
-DLIBCXXABI_ENABLE_SHARED=OFF \
-DLIBCXXABI_ENABLE_STATIC=ON \
-DLIBCXXABI_HAS_PTHREAD_API=ON \
-DLIBCXX_CXX_ABI=libcxxabi \
-DLIBCXX_ENABLE_SHARED=OFF \
-DLIBCXX_ENABLE_STATIC=ON \
-DLIBCXX_HAS_PTHREAD_API=ON \
-DLIBCXX_HAVE_CXX_ATOMICS_WITHOUT_LIB=ON \
-DLIBCXX_ENABLE_FILESYSTEM=ON \
-DLIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=ON
llvm-build: llvm-configure
cmake --build $(ROOT_DIR)/build/llvm
llvm-install: llvm-build
cmake --build $(ROOT_DIR)/build/llvm --target install/strip
# For some reason this doesn't install runtimes, so we do it manually
cp -r $(ROOT_DIR)/build/llvm/lib/x86_64-unknown-linux-gnu $(INSTALL_DIR)/lib/
cp -r $(ROOT_DIR)/build/llvm/runtimes/runtimes-x86_64-unknown-linux-gnu-bins/libc/lib/libllvmlibc.a $(INSTALL_DIR)/lib/x86_64-unknown-linux-gnu/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment