Talk:D on esp32/esp8266(llvm-xtensa+ldc) and how to get started
2023 update
Updated version that compiles without issues, even clang -c works. The main change is that espressif now uses a single repo that just a fork of llvm. Espressif is already at llvm 16, while ldc still uses 15 in master at this time, so I used espressif's latest llvm 15 fork.
Place this script as build-toolchain.sh
in an empty directory and run it:
#!/usr/bin/env bash
set -e
function gcl
{
git clone --recurse-submodules --depth 1 $@
}
[[ -d llvm-source ]] && rm -rf llvm-source
[[ -d llvm-build ]] && rm -rf llvm-build
gcl --branch "esp-15.0.0-20230404" https://github.com/espressif/llvm-project.git llvm-source
cmake \
-S llvm-source/llvm \
-B llvm-build \
-G "Ninja" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="Xtensa" \
-DLLVM_ENABLE_PROJECTS="clang" \
-DCMAKE_INSTALL_PREFIX=/opt/llvm-xtensa \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_ASM_COMPILER=clang
cmake --build llvm-build
sudo cmake --install llvm-build
[[ -d ldc-source ]] && rm -rf ldc-source
[[ -d ldc-build ]] && rm -rf ldc-build
gcl --branch "v1.32.2" https://github.com/ldc-developers/ldc.git ldc-source
cmake \
-S ldc-source \
-B ldc-build \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/opt/ldc-xtensa \
-DLLVM_ROOT_DIR=/opt/llvm-xtensa \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
-DCMAKE_ASM_COMPILER=clang
cmake --build ldc-build
sudo cmake --install ldc-build
I have yet to change the actual tutorial to include this.