tools: remove llvm-patch (#15)

* tools: remove llvm-patch
* docs: update reference to 1.53 compiler binaries from esp-rs/rust repo
This commit is contained in:
Juraj Michálek 2021-07-28 16:14:45 +02:00 committed by GitHub
parent bc610399e6
commit 0cf3bf1554
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 97 additions and 141 deletions

View File

@ -5,32 +5,25 @@ ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8
ENV RUSTUP_HOME=/opt/rust
ENV CARGO_HOME=/opt/cargo
ENV PATH=/opt/cargo/bin:/opt/rust/bin:/opt/xtensa-esp32-elf-clang/bin:/opt/llvm-patch/bin:$PATH
ENV PATH=/opt/cargo/bin:/opt/rust/bin:/opt/xtensa-esp32-elf-clang/bin:$PATH
RUN curl https://sh.rustup.rs -sSf | bash -s -- --profile minimal --default-toolchain nightly -y
WORKDIR /opt
RUN wget -q https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/bionic/rust-1.50.0-dev-x86_64-unknown-linux-gnu-bionic.tar.xz \
&& tar xvf rust-1.50.0-dev-x86_64-unknown-linux-gnu-bionic.tar.xz \
&& cd rust-1.50.0-dev-x86_64-unknown-linux-gnu \
&& ./install.sh --destdir=/opt/xtensa --prefix="" --without=rust-docs \
&& cd /opt \
&& rm -rf rust-1.50.0-dev-x86_64-unknown-linux-gnu*
RUN wget -q https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/rust-1.53.0-dev-x86_64-unknown-linux-gnu.tar.xz \
&& tar xvf rust-1.53.0-dev-x86_64-unknown-linux-gnu.tar.xz \
&& ./rust-1.53.0-dev-x86_64-unknown-linux-gnu/install.sh --destdir=/opt/esp --prefix="" --without=rust-docs \
&& rm -rf rust-1.53.0-dev-x86_64-unknown-linux-gnu*
RUN wget -q https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/rust-src-1.50.0-dev.tar.xz \
&& tar xvf rust-src-1.50.0-dev.tar.xz \
&& cd rust-src-1.50.0-dev \
&& ./install.sh --destdir=/opt/xtensa --prefix="" --without=rust-docs \
&& cd /opt \
&& rm -rf rust-src-1.50.0-dev* \
&& rustup toolchain link xtensa /opt/xtensa \
&& rustup default xtensa
RUN wget -q https://dl.espressif.com/dl/idf-rust/dist/noarch/rust-src-1.53.0-dev.tar.xz \
&& tar xvf rust-src-1.53.0-dev.tar.xz \
&& ./rust-src-1.53.0-dev/install.sh --destdir=/opt/esp --prefix="" --without=rust-docs \
&& rm -rf rust-src-1.53.0-dev* \
&& rustup toolchain link esp /opt/esp \
&& rustup default esp
RUN wget -q https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21247-g65ed48e-linux-amd64.tar.xz \
&& tar xf xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21247-g65ed48e-linux-amd64.tar.xz \
&& rm xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21247-g65ed48e-linux-amd64.tar.xz \
&& wget -q https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/bionic/llvm-patch-0.1.x86_64-unknown-linux-gnu-bionic.tar.gz \
&& tar xzf llvm-patch-0.1.x86_64-unknown-linux-gnu-bionic.tar.gz \
&& rm llvm-patch-0.1.x86_64-unknown-linux-gnu-bionic.tar.gz
RUN wget -q https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21249-g36dbc8b-linux-amd64.tar.xz \
&& tar xf xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21249-g36dbc8b-linux-amd64.tar.xz \
&& rm xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21249-g36dbc8b-linux-amd64.tar.xz
RUN git clone https://github.com/espressif/rust-esp32-example.git

View File

@ -2,7 +2,7 @@
An example project demonstrating integration with Rust for the ESP32-S2 and ESP32-C3 microcontrollers.
This example starts a FreeRTOS task to call a function in Rust and display the results in C.
This example starts a FreeRTOS task to call a function in Rust and display the results in C.
## Setup
@ -12,6 +12,13 @@ First, install the ESP-IDF SDK as shown in the [Get Started](https://docs.espres
To support the Xtensa instruction set, build and install custom LLVM and Rust toolchains as shown in the [Rust On Xtensa](docs/rust-on-xtensa.md) guide.
Alternatively you might build the project in the container where image already contains pre-installed Rust and ESP-IDF:
```
docker run -it georgikrocks/esp-idf-rust /bin/bash
idf.py build
```
### ESP32-C3
Install the RISCV target for Rust:

View File

@ -12,7 +12,7 @@ if(CONFIG_IDF_TARGET_ARCH_RISCV)
set(CARGO_TARGET "riscv32i-unknown-none-elf")
set(CARGO_FEATURES_ARG "")
elseif(CONFIG_IDF_TARGET_ARCH_XTENSA)
set(CARGO_TARGET "xtensa-esp32-none-elf")
set(CARGO_TARGET "xtensa-esp32-espidf")
set(CARGO_FEATURES_ARG "--features=std")
endif()

View File

@ -37,7 +37,7 @@ fn run_bindgen(target: &str, out_dir: &Path) {
builder = builder.use_core();
builder = builder.ctypes_prefix("crate::ffi");
}
"xtensa-esp32-none-elf" => {
"xtensa-esp32-espidf" => {
// Make sure that LLVM_CONFIG_PATH has been set to point to the
// Xtensa build of llvm-config.
builder = builder.clang_arg("--target=xtensa-esp32-elf");

View File

@ -11,21 +11,17 @@ Tested OS: macOS Big Sur M1
```
rustup toolchain install nightly
mkdir -p ~/.rustup/toolchains/xtensa
mkdir -p ~/.rustup/toolchains/esp
wget --continue https://dl.espressif.com/dl/idf-rust/dist/aarch64-apple-darwin/rust-1.50.0-dev-aarch64-apple-darwin.tar.xz
tar xvf rust-1.50.0-dev-aarch64-apple-darwin.tar.xz
pushd rust-1.50.0-dev-aarch64-apple-darwin
./install.sh --destdir=~/.rustup/toolchains/xtensa --prefix="" --without=rust-docs
popd
wget --continue https://dl.espressif.com/dl/idf-rust/dist/aarch64-apple-darwin/rust-1.53.0-dev-aarch64-apple-darwin.tar.xz
tar xvf rust-1.53.0-dev-aarch64-apple-darwin.tar.xz
./rust-1.53.0-dev-aarch64-apple-darwin/install.sh --destdir=~/.rustup/toolchains/xtensa --prefix="" --without=rust-docs
wget --continue https://dl.espressif.com/dl/idf-rust/dist/aarch64-apple-darwin/rust-src-1.50.0-dev.tar.xz
tar xvf rust-src-1.50.0-dev.tar.xz
pushd rust-src-1.50.0-dev
./install.sh --destdir=~/.rustup/toolchains/xtensa --prefix=""
popd
wget --continue https://dl.espressif.com/dl/idf-rust/dist/noarch/rust-src-1.53.0-dev.tar.xz
tar xvf rust-src-1.53.0-dev.tar.xz
./rust-src-1.53.0-dev/install.sh --destdir=~/.rustup/toolchains/esp --prefix=""
rustup default xtensa
rustup default esp
wget --continue https://dl.espressif.com/dl/idf-rust/dist/aarch64-apple-darwin/xtensa-esp32-elf-llvm11_0_0-aarch64-apple-darwin.tar.xz
tar xf xtensa-esp32-elf-llvm11_0_0-aarch64-apple-darwin.tar.xz

View File

@ -11,21 +11,17 @@ Tested OS: macOS Big Sur x64
```
rustup toolchain install nightly
mkdir -p ~/.rustup/toolchains/xtensa
mkdir -p ~/.rustup/toolchains/esp
wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-apple-darwin/rust-1.50.0-dev-x86_64-apple-darwin.tar.xz
tar xvf rust-1.50.0-dev-x86_64-apple-darwin.tar.xz
pushd rust-1.50.0-dev-x86_64-apple-darwin
./install.sh --destdir=~/.rustup/toolchains/xtensa --prefix="" --without=rust-docs
popd
wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-apple-darwin/rust-1.53.0-dev-x86_64-apple-darwin.tar.xz
tar xvf rust-1.53.0-dev-x86_64-apple-darwin.tar.xz
./rust-1.53.0-dev-x86_64-apple-darwin/install.sh --destdir=~/.rustup/toolchains/esp --prefix="" --without=rust-docs
wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-apple-darwin/rust-src-1.50.0-dev.tar.xz
tar xvf rust-src-1.50.0-dev.tar.xz
pushd rust-src-1.50.0-dev
./install.sh --destdir=~/.rustup/toolchains/xtensa --prefix="" --without=rust-docs
popd
wget https://dl.espressif.com/dl/idf-rust/dist/noarch/rust-src-1.53.0-dev.tar.xz
tar xvf rust-src-1.53.0-dev.tar.xz
./rust-src-1.53.0-dev/install.sh --destdir=~/.rustup/toolchains/esp --prefix="" --without=rust-docs
rustup default xtensa
rustup default esp
wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-apple-darwin/xtensa-esp32-elf-llvm11_0_0-x86_64-apple-darwin.tar.xz
tar xf xtensa-esp32-elf-llvm11_0_0-x86_64-apple-darwin.tar.xz

View File

@ -15,37 +15,32 @@ choco install 7zip
rustup toolchain install nightly
mkdir -p ~/.rustup/toolchains/xtensa
mkdir -p ~\.rustup\toolchains\esp
Invoke-WebRequest https://dl.espressif.com/dl/idf-rust/dist/x86_64-pc-windows-msvc/rust-1.50.0-dev-x86_64-pc-windows-msvc.tar.xz -OutFile rust-1.50.0-dev-x86_64-pc-windows-msvc.tar.xz
7z e .\rust-1.50.0-dev-x86_64-pc-windows-msvc.tar.xz
7z x .\rust-1.50.0-dev-x86_64-pc-windows-msvc.tar
pushd rust-1.50.0-dev-x86_64-pc-windows-msvc
cp -Recurse .\rustc\bin ~\.rustup\toolchains\xtensa\
cp -Recurse .\rustc\lib ~\.rustup\toolchains\xtensa\
cp -Recurse .\rustc\share ~\.rustup\toolchains\xtensa\
cp -Recurse .\rust-std-x86_64-pc-windows-msvc\lib\* ~\.rustup\toolchains\xtensa\lib\
Invoke-WebRequest https://dl.espressif.com/dl/idf-rust/dist/x86_64-pc-windows-msvc/rust-1.53.0-dev-x86_64-pc-windows-msvc.tar.xz -OutFile rust-1.53.0-dev-x86_64-pc-windows-msvc.tar.xz
7z e .\rust-1.53.0-dev-x86_64-pc-windows-msvc.tar.xz
7z x .\rust-1.53.0-dev-x86_64-pc-windows-msvc.tar
pushd rust-1.53.0-dev-x86_64-pc-windows-msvc
cp -Recurse .\rustc\bin ~\.rustup\toolchains\esp\
cp -Recurse .\rustc\lib ~\.rustup\toolchains\esp\
cp -Recurse .\rustc\share ~\.rustup\toolchains\esp\
cp -ErrorAction SilentlyContinue -Recurse .\rust-std-x86_64-pc-windows-msvc\lib\* ~\.rustup\toolchains\esp\lib\
popd
Invoke-WebRequest https://dl.espressif.com/dl/idf-rust/dist/x86_64-pc-windows-msvc/rust-src-1.50.0-dev.tar.xz -OutFile rust-src-1.50.0-dev.tar.xz
7z e .\rust-src-1.50.0-dev.tar.xz
7z x .\rust-src-1.50.0-dev.tar
pushd rust-src-1.50.0-dev
cp -Recurse .\rust-src\lib\* ~\.rustup\toolchains\xtensa\lib\
Invoke-WebRequest https://dl.espressif.com/dl/idf-rust/dist/noarch/rust-src-1.53.0-dev.tar.xz -OutFile rust-src-1.53.0-dev.tar.xz
7z e .\rust-src-1.53.0-dev.tar.xz
7z x .\rust-src-1.53.0-dev.tar
pushd rust-src-1.53.0-dev
cp -ErrorAction SilentlyContinue -Recurse .\rust-src\lib\* ~\.rustup\toolchains\esp\lib\
popd
rustup default xtensa
rustup default esp
Invoke-WebRequest https://dl.espressif.com/dl/idf-rust/dist/x86_64-pc-windows-msvc/xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21247-g65ed48e-win64.zip -OutFile xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21247-g65ed48e-win64.zip
7z x xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21247-g65ed48e-win64.zip
Invoke-WebRequest https://dl.espressif.com/dl/idf-rust/dist/x86_64-pc-windows-msvc/xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21249-g36dbc8b-win64.zip -OutFile xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21249-g36dbc8b-win64.zip
7z x xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21249-g36dbc8b-win64.zip
$ClangPath=Join-Path -Path (Get-Location) -ChildPath xtensa-esp32-elf-clang\bin
$env:PATH="${ClangPath};$env:PATH"
Invoke-WebRequest https://dl.espressif.com/dl/idf-rust/dist/x86_64-pc-windows-msvc/llvm-patch-0.1.x86_64-pc-windows-msvc.tar.gz -OutFile llvm-patch-0.1.x86_64-pc-windows-msvc.tar.gz
tar xzf llvm-patch-0.1.x86_64-pc-windows-msvc.tar.gz
$ClangPatchPath=Join-Path -Path (Get-Location) -ChildPath llvm-patch\bin
$env:PATH="${ClangPatchPath};$env:PATH"
Invoke-WebRequest https://github.com/espressif/rust-esp32-example/archive/refs/heads/main.zip -OutFile rust-esp32-example.zip
7z x rust-esp32-example.zip
cd rust-esp32-example-main

View File

@ -1,44 +0,0 @@
# Rust on Xtensa Installation for Linux x64
Tested OS: Ubuntu 18 x64
## Prerequisites
- rustup - installed with nightly toolchain - https://rustup.rs/
## Commands
```
sudo apt install gcc wget xz-utils
rustup toolchain install nightly
mkdir -p ~/.rustup/toolchains/xtensa
wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/bionic/rust-1.50.0-dev-x86_64-unknown-linux-gnu-bionic.tar.xz
tar xvf rust-1.50.0-dev-x86_64-unknown-linux-gnu-bionic.tar.xz
pushd rust-1.50.0-dev-x86_64-unknown-linux-gnu
./install.sh --destdir=~/.rustup/toolchains/xtensa --prefix="" --without=rust-docs
popd
wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/rust-src-1.50.0-dev.tar.xz
tar xvf rust-src-1.50.0-dev.tar.xz
pushd rust-src-1.50.0-dev
./install.sh --destdir=~/.rustup/toolchains/xtensa --prefix="" --without=rust-docs
popd
rustup default xtensa
wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21247-g65ed48e-linux-amd64.tar.xz
tar xf xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21247-g65ed48e-linux-amd64.tar.xz
export PATH="`pwd`/xtensa-esp32-elf-clang/bin/:$PATH"
wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/llvm-patch-0.1.x86_64-unknown-linux-gnu.tar.gz
tar xzf llvm-patch-0.1.x86_64-unknown-linux-gnu.tar.gz
export PATH="`pwd`/llvm-patch/bin/:$PATH"
wget --continue https://github.com/espressif/rust-esp32-example/archive/refs/heads/main.zip
unzip main.zip
cd rust-esp32-example-main
idf.py build
```

View File

@ -1,8 +1,6 @@
# Rust on Xtensa Installation for Linux x64
Tested OS: Ubuntu 20 x64, Mint 20 x64
Ubuntu 18: Please follow instructions for [Linux Ubuntu 18 x64](rust-on-xtensa-installation-x86_64-unknown-linux-gnu-bionic.md) to avoid problem with `GLIBC_2.29' not found.
Tested OS: Ubuntu 18 x64, Ubuntu 20 x64, Mint 20 x64, OpenSUSE Thumbleweed
## Prerequisites
@ -15,30 +13,22 @@ sudo apt install gcc wget xz-utils
rustup toolchain install nightly
mkdir -p ~/.rustup/toolchains/xtensa
mkdir -p ~/.rustup/toolchains/esp
wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/rust-1.50.0-dev-x86_64-unknown-linux-gnu.tar.xz
tar xvf rust-1.50.0-dev-x86_64-unknown-linux-gnu.tar.xz
pushd rust-1.50.0-dev-x86_64-unknown-linux-gnu
./install.sh --destdir=~/.rustup/toolchains/xtensa --prefix="" --without=rust-docs
popd
wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/rust-1.53.0-dev-x86_64-unknown-linux-gnu.tar.xz
tar xvf rust-1.53.0-dev-x86_64-unknown-linux-gnu.tar.xz
./rust-1.53.0-dev-x86_64-unknown-linux-gnu/install.sh --destdir=~/.rustup/toolchains/esp --prefix="" --without=rust-docs
wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/rust-src-1.50.0-dev.tar.xz
tar xvf rust-src-1.50.0-dev.tar.xz
pushd rust-src-1.50.0-dev
./install.sh --destdir=~/.rustup/toolchains/xtensa --prefix="" --without=rust-docs
popd
wget https://dl.espressif.com/dl/idf-rust/dist/noarch/rust-src-1.53.0-dev.tar.xz
tar xvf rust-src-1.53.0-dev.tar.xz
./rust-src-1.53.0-dev/install.sh --destdir=~/.rustup/toolchains/esp --prefix="" --without=rust-docs
rustup default xtensa
rustup default esp
wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21247-g65ed48e-linux-amd64.tar.xz
tar xf xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21247-g65ed48e-linux-amd64.tar.xz
wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21249-g36dbc8b-linux-amd64.tar.xz
tar xf xtensa-esp32-elf-llvm11_0_0-llvmorg-11-init-21249-g36dbc8b-linux-amd64.tar.xz
export PATH="`pwd`/xtensa-esp32-elf-clang/bin/:$PATH"
wget https://dl.espressif.com/dl/idf-rust/dist/x86_64-unknown-linux-gnu/llvm-patch-0.1.x86_64-unknown-linux-gnu.tar.gz
tar xzf llvm-patch-0.1.x86_64-unknown-linux-gnu.tar.gz
export PATH="`pwd`/llvm-patch/bin/:$PATH"
wget --continue https://github.com/espressif/rust-esp32-example/archive/refs/heads/main.zip
unzip main.zip
cd rust-esp32-example-main

View File

@ -4,11 +4,15 @@
The installation process of ready to use custom build of Rust and LLVM is described here:
* [Linux Ubuntu 20 x64/Mint 20 x64](rust-on-xtensa-installation-x86_64-unknown-linux-gnu.md)
* [Linux Ubuntu 18 x64](rust-on-xtensa-installation-x86_64-unknown-linux-gnu-bionic.md)
* [Linux Ubuntu 18, Ubuntu 20 x64, Mint 20 x64, OpenSUSE Thumbleweed x64](rust-on-xtensa-installation-x86_64-unknown-linux-gnu.md)
* [macOS Big Sur x64](rust-on-xtensa-installation-x86_64-apple-darwin.md)
* [macOS Big Sur arm64](rust-on-xtensa-installation-aarch64-apple-darwin.md)
* [Windows 10 x64](rust-on-xtensa-installation-x86_64-pc-windows-msvc.md)
* Not supported: Linux arm64 - missing support in ESP-IDF - https://github.com/espressif/esp-idf/issues/6475
## Troubleshooting
### Can't find crate for `std`
Make sure to install Rust toolchain nightly:
@ -22,6 +26,27 @@ error[E0463]: can't find crate for `std`
= note: the `xtensa-esp32-none-elf` target may not be installed
```
### Error: use of unstable library feature 'restricted_std'
Error message:
```
Compiling rustlib v0.1.0 (rust-esp32-example-main/components/rustlib)
error[E0658]: use of unstable library feature 'restricted_std'
|
= help: add `#![feature(restricted_std)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.
error: could not compile `rustlib`
```
Solution:
Change the target to `xtensa-esp32-espidf`.
## Building from the scratch
Following text describes the build process when building LLVM and Rust from the scratch.

View File

@ -3,10 +3,8 @@ WORKDIR /opt
RUN apt update \
&& apt install -y gcc cmake ccache ninja-build git python3 curl g++ pkg-config libssl-dev
RUN git clone https://github.com/ivmarkov/rust.git \
RUN git clone https://github.com/esp-rs/rust.git \
&& cd rust \
&& git checkout stable \
&& ./configure --experimental-targets=Xtensa --enable-extended --tools=rustfmt --disable-docs --disable-compiler-docs --set="build.python=python3" \
&& ./configure --experimental-targets=Xtensa --enable-extended --tools=rustfmt \
&& python3 x.py dist --stage 2 || echo "Build failed - silencing error to persist current build artifacts"
# speed-up rebuild: --set="local-rebuild=true"