Difference between revisions of "Talk:D on esp32/esp8266(llvm-xtensa+ldc) and how to get started"
m |
(→2023 update) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
Place this script as <code>build-toolchain.sh</code> in an empty directory and run it: | Place this script as <code>build-toolchain.sh</code> in an empty directory and run it: | ||
− | (Note that you might have to temporarily uninstall ldc from your system first) | + | (Note that you might have to temporarily uninstall llvm, clang and ldc from your system first) |
<syntaxhighlight lang="shell"> | <syntaxhighlight lang="shell"> | ||
Line 25: | Line 25: | ||
-B llvm-build \ | -B llvm-build \ | ||
-G "Ninja" \ | -G "Ninja" \ | ||
− | -DCMAKE_BUILD_TYPE= | + | -DCMAKE_BUILD_TYPE=Debug \ |
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="Xtensa" \ | -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="Xtensa" \ | ||
-DLLVM_ENABLE_PROJECTS="clang" \ | -DLLVM_ENABLE_PROJECTS="clang" \ | ||
-DCMAKE_INSTALL_PREFIX=/opt/llvm-xtensa \ | -DCMAKE_INSTALL_PREFIX=/opt/llvm-xtensa \ | ||
− | -DCMAKE_C_COMPILER= | + | -DCMAKE_C_COMPILER=gcc \ |
− | -DCMAKE_CXX_COMPILER= | + | -DCMAKE_CXX_COMPILER=g++ \ |
− | -DCMAKE_ASM_COMPILER= | + | -DCMAKE_ASM_COMPILER=gcc |
cmake --build llvm-build | cmake --build llvm-build | ||
sudo cmake --install llvm-build | sudo cmake --install llvm-build | ||
Line 42: | Line 42: | ||
-B ldc-build \ | -B ldc-build \ | ||
-G Ninja \ | -G Ninja \ | ||
− | -DCMAKE_BUILD_TYPE= | + | -DCMAKE_BUILD_TYPE=Debug \ |
-DCMAKE_INSTALL_PREFIX=/opt/ldc-xtensa \ | -DCMAKE_INSTALL_PREFIX=/opt/ldc-xtensa \ | ||
-DLLVM_ROOT_DIR=/opt/llvm-xtensa \ | -DLLVM_ROOT_DIR=/opt/llvm-xtensa \ | ||
− | -DCMAKE_C_COMPILER= | + | -DCMAKE_C_COMPILER=gcc \ |
− | -DCMAKE_CXX_COMPILER= | + | -DCMAKE_CXX_COMPILER=g++ \ |
− | -DCMAKE_ASM_COMPILER= | + | -DCMAKE_ASM_COMPILER=gcc |
cmake --build ldc-build | cmake --build ldc-build | ||
sudo cmake --install ldc-build | sudo cmake --install ldc-build | ||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | Note that I've yet to use Release mode. | ||
I have yet to change the actual tutorial to include this. | I have yet to change the actual tutorial to include this. |
Latest revision as of 14:09, 29 May 2023
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:
(Note that you might have to temporarily uninstall llvm, clang and ldc from your system first)
#!/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=Debug \
-DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="Xtensa" \
-DLLVM_ENABLE_PROJECTS="clang" \
-DCMAKE_INSTALL_PREFIX=/opt/llvm-xtensa \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_ASM_COMPILER=gcc
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=Debug \
-DCMAKE_INSTALL_PREFIX=/opt/ldc-xtensa \
-DLLVM_ROOT_DIR=/opt/llvm-xtensa \
-DCMAKE_C_COMPILER=gcc \
-DCMAKE_CXX_COMPILER=g++ \
-DCMAKE_ASM_COMPILER=gcc
cmake --build ldc-build
sudo cmake --install ldc-build
Note that I've yet to use Release mode.
I have yet to change the actual tutorial to include this.