Skip to content

Getting Started

Develop

To build FORMOSA LLVM, you have to ensure you have successfully install nix package manger on your machine and follow these steps:

  1. Enter the development shell

    nix develop
    

  2. configure

    cmake -G Ninja -S llvm -B build \
        -DLLVM_ENABLE_PROJECTS="clang;lld;libclc" \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_C_COMPILER="gcc" \
        -DCMAKE_CXX_COMPILER="g++" \
        -DLLVM_DEFAULT_TARGET_TRIPLE=riscv64-unknown-elf \
        -DLLVM_TARGETS_TO_BUILD="RISCV;X86" \
        -DLLVM_USE_LINKER=lld \
        -DLIBCLC_TARGETS_TO_BUILD="riscv64-unknown-elf" \
        -DLLVM_BUILD_LLVM_DYLIB=ON
    
    Note: If you don't have lld, you could install with:
    sudo apt install lld
    
    Using lld is strongly suggested to save your time and memory.

  3. build

    cmake --build build
    
    Note: If your memory is not enough for parallel linking, consider adding -DLLVM_PARALLEL_LINK_JOBS=2 to restrict the jobs for linking.