Skip to content

Instantly share code, notes, and snippets.

@gxyd
Created April 29, 2025 16:55
Show Gist options
  • Select an option

  • Save gxyd/ea46bf72bdee94d8f0b253b2e1b6be68 to your computer and use it in GitHub Desktop.

Select an option

Save gxyd/ea46bf72bdee94d8f0b253b2e1b6be68 to your computer and use it in GitHub Desktop.
$ conda create -n llvm-dev cmake python ninja ccache lld
$ conda activate llvm-dev
$ cmake -GNinja -Bbuild -Hllvm \
    -DLLVM_ENABLE_PROJECTS="clang" \
    -DLLVM_TARGETS_TO_BUILD="AArch64" \
    -DCMAKE_BUILD_TYPE=Debug \
    -DLLVM_ENABLE_ASSERTIONS=true \
    -DLLVM_CCACHE_BUILD=true \
    -DLLVM_ENABLE_LLD=On \
    -DLLVM_PARALLEL_COMPILE_JOBS=6 \
    -DLLVM_PARALLEL_LINK_JOBS=1


$ cmake -GNinja -S llvm -B build \
  -DLLVM_ENABLE_PROJECTS="clang;lld" \
  -DLLVM_TARGETS_TO_BUILD=Native \
  -DCMAKE_BUILD_TYPE=Debug \
  -DLLVM_ENABLE_ASSERTIONS=ON \
  -DLLVM_CCACHE_BUILD=ON \
  -DLLVM_USE_LINKER=lld \
  -DLLVM_PARALLEL_COMPILE_JOBS=10 \
  -DLLVM_PARALLEL_LINK_JOBS=1

$ # Build LLVM
$ ninja -Cbuild

$ # to run tests
$ ninja -Cbuild check-llvm
@gxyd
Copy link
Author

gxyd commented Jul 1, 2025

To work on the issue: llvm/llvm-project#129401, I've used the below build commands for llvm-project

$ cmake -G Ninja -S llvm -B build \
  -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt" \
  -DLLVM_TARGETS_TO_BUILD="AArch64" \
  -DCMAKE_BUILD_TYPE=Debug \
  -DLLVM_ENABLE_ASSERTIONS=ON \
  -DLLVM_CCACHE_BUILD=ON \
  -DLLVM_USE_LINKER=lld \
  -DLLVM_PARALLEL_COMPILE_JOBS=10 \
  -DLLVM_PARALLEL_LINK_JOBS=1 \
  -DCMAKE_C_COMPILER=clang \
  -DCMAKE_CXX_COMPILER=clang++

$ ninja -Cbuild

@gxyd
Copy link
Author

gxyd commented Jul 15, 2025

Commands to use in VSCode for getting more debugging information about the variables:

> frame variable ...
> expression ...
Screenshot 2025-07-15 at 4 58 07 PM

@gxyd
Copy link
Author

gxyd commented Aug 6, 2025

$ cmake -G Ninja -S llvm -B build \
  -DLLVM_ENABLE_PROJECTS="clang;lld;compiler-rt;clang-tools-extra" \
  -DLLVM_ENABLE_RUNTIMES="compiler-rt" \
  -DLLVM_TARGETS_TO_BUILD="AArch64" \
  -DCMAKE_BUILD_TYPE=Debug \
  -DLLVM_ENABLE_ASSERTIONS=ON \
  -DLLVM_CCACHE_BUILD=ON \
  -DLLVM_USE_LINKER=lld \
  -DLLVM_PARALLEL_COMPILE_JOBS=10 \
  -DLLVM_PARALLEL_LINK_JOBS=1 \
  -DCMAKE_C_COMPILER=clang \
  -DCMAKE_CXX_COMPILER=clang++ \
  -DLLVM_ENABLE_LIBCXX=ON \
  -DLLVM_ENABLE_LTO=OFF

$ ninja -Cbuild

Trying the above set of command for clang related issues.

@gxyd
Copy link
Author

gxyd commented Jan 19, 2026

Build with the following commands to try to fix the issue: llvm/llvm-project#121952

$ pwd
/Users/gxyd/OpenSource/llvm-project/build
$ cmake -G Ninja -S ../llvm \
  -DLLVM_ENABLE_PROJECTS="clang;lld" \
  -DLLVM_TARGETS_TO_BUILD="AArch64" \
  -DCMAKE_BUILD_TYPE=Debug \
  -DLLVM_ENABLE_ASSERTIONS=ON \
  -DLLVM_USE_SANITIZER=Address \
  -DLLVM_CCACHE_BUILD=ON \
  -DLLVM_USE_LINKER=lld \
  -DLLVM_PARALLEL_COMPILE_JOBS=10 \
  -DLLVM_PARALLEL_LINK_JOBS=1 \
  -DCMAKE_C_COMPILER=clang \
  -DCMAKE_CXX_COMPILER=clang++

$ ninja clang clang-fuzzer

@gxyd
Copy link
Author

gxyd commented Jan 22, 2026

Point VSCode to the compile database:

through command palette:

C/C++: Edit Configurations (UI)
→ Compile Commands → set build/compile_commands.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment