Skip to content

Commit f6109b6

Browse files
committed
riotbuild: Split out and clean up build logic
- Remove second MSP430 toolchain - Update RISC-V toolchain from unmaintained deprecated xpack to new xpack version - update picolibc - build picolibc also for MSP430
1 parent 58bf7ae commit f6109b6

File tree

3 files changed

+508
-351
lines changed

3 files changed

+508
-351
lines changed

riotbuild/Dockerfile

Lines changed: 17 additions & 334 deletions
Original file line numberDiff line numberDiff line change
@@ -24,341 +24,24 @@ FROM ${DOCKER_REGISTRY}/static-test-tools:latest
2424

2525
LABEL maintainer="Kaspar Schleiser <[email protected]>"
2626

27-
ENV DEBIAN_FRONTEND noninteractive
28-
29-
ENV LC_ALL C.UTF-8
30-
ENV LANG C.UTF-8
31-
32-
# copy some included packages
33-
RUN mkdir /pkgs
34-
COPY files/libsocketcan-dev_0.0.11-1_i386.deb /pkgs/libsocketcan-dev_0.0.11-1_i386.deb
35-
COPY files/libsocketcan2_0.0.11-1_i386.deb /pkgs/libsocketcan2_0.0.11-1_i386.deb
36-
37-
# The following package groups will be installed:
38-
# - update the package index files to latest available version
39-
# - native platform development and build system functionality (about 400 MB installed)
40-
# - Cortex-M development (about 550 MB installed), through the gcc-arm-embedded PPA
41-
# - MSP430 development (about 120 MB installed)
42-
# - AVR development (about 110 MB installed)
43-
# - LLVM/Clang build environment (about 125 MB installed)
44-
# - QEMU
45-
# All apt files will be deleted afterwards to reduce the size of the container image.
46-
# The OS must not be updated by apt. Docker image should be build against the latest
47-
# updated base OS image. This can be forced with `--pull` flag.
48-
# This is all done in a single RUN command to reduce the number of layers and to
49-
# allow the cleanup to actually save space.
50-
# Total size without cleaning is approximately 1.525 GB (2016-03-08)
51-
# After adding the cleanup commands the size is approximately 1.497 GB
52-
ARG LLVM_VERSION=14
53-
RUN \
54-
dpkg --add-architecture i386 >&2 && \
55-
echo 'Update the package index files to latest available versions' >&2 && \
56-
apt-get update \
57-
&& echo 'Installing native toolchain and build system functionality' >&2 && \
58-
apt-get -y --no-install-recommends install \
59-
afl++ \
60-
automake \
61-
bsdmainutils \
62-
build-essential \
63-
ca-certificates \
64-
ccache \
65-
cmake \
66-
curl \
67-
cython3 \
68-
gcc-multilib \
69-
gdb \
70-
g++-multilib \
71-
libffi-dev \
72-
libpcre3 \
73-
libtool \
74-
libsdl2-dev:i386 \
75-
m4 \
76-
ninja-build \
77-
parallel \
78-
protobuf-compiler \
79-
python2 \
80-
python3-setuptools \
81-
python3-wheel \
82-
p7zip \
83-
qemu-system-arm \
84-
rsync \
85-
socat \
86-
ssh-client \
87-
subversion \
88-
unzip \
89-
vim-common \
90-
xsltproc \
91-
&& echo 'Installing MSP430 toolchain' >&2 && \
92-
apt-get -y --no-install-recommends install \
93-
gcc-msp430 \
94-
msp430-libc \
95-
&& echo 'Installing AVR toolchain' >&2 && \
96-
apt-get -y --no-install-recommends install \
97-
gcc-avr \
98-
binutils-avr \
99-
avr-libc \
100-
&& echo 'Installing LLVM/Clang toolchain' >&2 && \
101-
apt-get -y --no-install-recommends install \
102-
llvm-${LLVM_VERSION} \
103-
clang-${LLVM_VERSION} \
104-
clang-tools-${LLVM_VERSION} \
105-
lld-${LLVM_VERSION} \
106-
llvm \
107-
clang \
108-
clang-tools \
109-
&& echo 'Installing C2Rust (build) dependencies' >&2 && \
110-
apt-get -y --no-install-recommends install \
111-
libclang-dev \
112-
libssl-dev \
113-
llvm-dev \
114-
&& \
115-
SYMS=$(find /usr/bin -type l) && \
116-
for file in ${SYMS}; do \
117-
SYMTARGET=$(readlink -f ${file}) && \
118-
SYMNAME=${file%"-${LLVM_VERSION}"} && \
119-
# Filter by symlinks starting with /usr/bin/llvm-${LLVM_VERSION}
120-
case "${SYMTARGET}" in "/usr/lib/llvm-${LLVM_VERSION}"* ) ln -sf ${SYMTARGET} ${SYMNAME}; esac \
121-
done \
122-
&& echo 'Installing additional packages required for ESP32 toolchain' >&2 && \
123-
apt-get -y --no-install-recommends install \
124-
python3-serial \
125-
libpython2.7 \
126-
telnet \
127-
&& echo 'Installing local packages' >&2 && \
128-
apt-get install -y --no-install-recommends /pkgs/*.deb \
129-
&& echo 'Cleaning up installation files' >&2 && \
130-
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /pkgs
131-
132-
# Install ARM GNU embedded toolchain
133-
# For updates, see https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads
134-
ARG ARM_URLBASE=https://developer.arm.com/-/media/Files/downloads/gnu-rm
135-
ARG ARM_URL=${ARM_URLBASE}/10.3-2021.10/gcc-arm-none-eabi-10.3-2021.10-x86_64-linux.tar.bz2
136-
ARG ARM_MD5=2383e4eb4ea23f248d33adc70dc3227e
137-
ARG ARM_FOLDER=gcc-arm-none-eabi-10.3-2021.10
138-
RUN echo 'Installing arm-none-eabi toolchain from arm.com' >&2 && \
139-
mkdir -p /opt && \
140-
curl -L -o /opt/gcc-arm-none-eabi.tar.bz2 ${ARM_URL} && \
141-
echo "${ARM_MD5} /opt/gcc-arm-none-eabi.tar.bz2" | md5sum -c && \
142-
tar -C /opt -jxf /opt/gcc-arm-none-eabi.tar.bz2 && \
143-
rm -f /opt/gcc-arm-none-eabi.tar.bz2 && \
144-
echo 'Removing documentation' >&2 && \
145-
rm -rf /opt/gcc-arm-none-eabi-*/share/doc
146-
# No need to dedup, the ARM toolchain is already using hard links for the duplicated files
147-
148-
ENV PATH ${PATH}:/opt/${ARM_FOLDER}/bin
149-
150-
# Install MIPS binary toolchain
151-
# For updates: https://www.mips.com/develop/tools/codescape-mips-sdk/ (select "Codescape GNU Toolchain")
152-
ARG MIPS_VERSION=2020.06-01
153-
RUN echo 'Installing mips-mti-elf toolchain from mips.com' >&2 && \
154-
mkdir -p /opt && \
155-
curl -L "https://codescape.mips.com/components/toolchain/${MIPS_VERSION}/Codescape.GNU.Tools.Package.${MIPS_VERSION}.for.MIPS.MTI.Bare.Metal.CentOS-6.x86_64.tar.gz" -o - \
156-
| tar -C /opt -zx && \
157-
echo 'Removing documentation and translations' >&2 && \
158-
rm -rf /opt/mips-mti-elf/*/share/{doc,info,man,locale} && \
159-
echo 'Deduplicating binaries' && \
160-
cd /opt/mips-mti-elf/*/mips-mti-elf/bin && \
161-
for f in *; do test -f "../../bin/mips-mti-elf-$f" && ln -f "../../bin/mips-mti-elf-$f" "$f"; done && cd -
162-
163-
ENV MIPS_ELF_ROOT /opt/mips-mti-elf/${MIPS_VERSION}
164-
165-
ENV PATH ${PATH}:${MIPS_ELF_ROOT}/bin
166-
167-
# Install RISC-V binary toolchain
168-
ARG RISCV_VERSION=10.2.0-1.2
169-
RUN mkdir -p /opt && \
170-
wget -q https://github.com/xpack-dev-tools/riscv-none-embed-gcc-xpack/releases/download/v${RISCV_VERSION}/xpack-riscv-none-embed-gcc-${RISCV_VERSION}-linux-x64.tar.gz -O- \
171-
| tar -C /opt -xz && \
172-
echo 'Removing documentation' >&2 && \
173-
rm -rf /opt/xpack-riscv-none-embed-gcc-${RISCV_VERSION}/share/doc && \
174-
echo 'Deduplicating binaries' >&2 && \
175-
cd /opt/xpack-riscv-none-embed-gcc-${RISCV_VERSION}/riscv-none-embed/bin && \
176-
for f in *; do test -f "../../bin/riscv-none-embed-$f" && \
177-
ln -f "../../bin/riscv-none-embed-$f" "$f"; \
178-
done && \
179-
cd -
180-
181-
ENV PATH $PATH:/opt/xpack-riscv-none-embed-gcc-${RISCV_VERSION}/bin
182-
183-
# Install complete ESP8266 toolchain in /opt/esp (139 MB after cleanup)
184-
# remember https://github.com/RIOT-OS/RIOT/pull/10801 when updating
185-
RUN echo 'Installing ESP8266 toolchain' >&2 && \
186-
mkdir -p /opt/esp && \
187-
cd /opt/esp && \
188-
git clone https://github.com/gschorcht/xtensa-esp8266-elf && \
189-
cd xtensa-esp8266-elf && \
190-
git checkout -q 696257c2b43e2a107d3108b2c1ca6d5df3fb1a6f && \
191-
rm -rf .git && \
192-
cd /opt/esp && \
193-
git clone https://github.com/gschorcht/RIOT-Xtensa-ESP8266-RTOS-SDK.git ESP8266_RTOS_SDK && \
194-
cd ESP8266_RTOS_SDK/ && \
195-
git checkout -q c0174eff7278eb5beea66ce1f65b7af57432d2a9 && \
196-
rm -rf .git* docs examples Kconfig make README.md tools && \
197-
cd components && \
198-
rm -rf app_update aws_iot bootloader cjson coap espos esptool_py esp-tls \
199-
freertos jsmn libsodium log mdns mqtt newlib partition_table \
200-
pthread smartconfig_ack spiffs ssl tcpip_adapter vfs && \
201-
find . -type f -name '*.[csS]' -exec rm {} \; && \
202-
find . -type f -name '*.cpp' -exec rm {} \;
203-
204-
ENV PATH $PATH:/opt/esp/xtensa-esp8266-elf/bin
205-
ENV ESP8266_RTOS_SDK_DIR /opt/esp/ESP8266_RTOS_SDK
206-
207-
# Install ESP32 toolchain in /opt/esp (289 MB)
208-
ARG ESP32_GCC_RELEASE="esp-2021r2-patch3"
209-
ARG ESP32_GCC_VERSION="gcc8_4_0"
210-
ARG ESP32_GCC_REPO=https://github.com/espressif/crosstool-NG/releases/download
211-
ARG ESP32_GCC_FILE=xtensa-esp32-elf-${ESP32_GCC_VERSION}-${ESP32_GCC_RELEASE}-linux-amd64.tar.gz
212-
ARG ESP32_GCC_URL=${ESP32_GCC_REPO}/${ESP32_GCC_RELEASE}/${ESP32_GCC_FILE}
213-
214-
RUN echo 'Installing ESP32 toolchain' >&2 && \
215-
curl -L ${ESP32_GCC_URL} | tar -C /opt/esp -xz && \
216-
pip install --no-cache-dir pyserial
217-
ENV PATH $PATH:/opt/esp/xtensa-esp32-elf/bin
218-
219-
# Install ESP32 QEMU in /opt/esp (89 MB)
220-
ARG ESP32_QEMU_VERSION="esp-develop-20220203"
221-
ARG ESP32_QEMU_REPO=https://github.com/espressif/qemu/releases/download
222-
ARG ESP32_QEMU_FILE=qemu-${ESP32_QEMU_VERSION}.tar.bz2
223-
ARG ESP32_QEMU_URL=${ESP32_QEMU_REPO}/${ESP32_QEMU_VERSION}/${ESP32_QEMU_FILE}
224-
225-
RUN echo 'Installing ESP32 QEMU' >&2 && \
226-
curl -L ${ESP32_QEMU_URL} | tar -C /opt/esp -xj
227-
ENV PATH $PATH:/opt/esp/qemu/bin
228-
229-
# Install ESP32-C3 toolchain in /opt/esp (344 MB)
230-
ARG ESP32_GCC_FILE=riscv32-esp-elf-${ESP32_GCC_VERSION}-${ESP32_GCC_RELEASE}-linux-amd64.tar.gz
231-
ARG ESP32_GCC_URL=${ESP32_GCC_REPO}/${ESP32_GCC_RELEASE}/${ESP32_GCC_FILE}
232-
233-
RUN echo 'Installing ESP32-C3 toolchain' >&2 && \
234-
curl -L ${ESP32_GCC_URL} | tar -C /opt/esp -xz && \
235-
pip install --no-cache-dir pyserial
236-
ENV PATH $PATH:/opt/esp/riscv32-esp-elf/bin
237-
238-
# Install ESP32-S2 toolchain in /opt/esp (290 MB)
239-
ARG ESP32_GCC_FILE=xtensa-esp32s2-elf-${ESP32_GCC_VERSION}-${ESP32_GCC_RELEASE}-linux-amd64.tar.gz
240-
ARG ESP32_GCC_URL=${ESP32_GCC_REPO}/${ESP32_GCC_RELEASE}/${ESP32_GCC_FILE}
241-
242-
RUN echo 'Installing ESP32-S2 toolchain' >&2 && \
243-
curl -L ${ESP32_GCC_URL} | tar -C /opt/esp -xz && \
244-
pip install --no-cache-dir pyserial
245-
ENV PATH $PATH:/opt/esp/xtensa-esp32s2-elf/bin
246-
247-
# Install ESP32-S3 toolchain in /opt/esp (292 MB)
248-
ARG ESP32_GCC_FILE=xtensa-esp32s3-elf-${ESP32_GCC_VERSION}-${ESP32_GCC_RELEASE}-linux-amd64.tar.gz
249-
ARG ESP32_GCC_URL=${ESP32_GCC_REPO}/${ESP32_GCC_RELEASE}/${ESP32_GCC_FILE}
250-
251-
RUN echo 'Installing ESP32-S3 toolchain' >&2 && \
252-
curl -L ${ESP32_GCC_URL} | tar -C /opt/esp -xz && \
253-
pip install --no-cache-dir pyserial
254-
ENV PATH $PATH:/opt/esp/xtensa-esp32s3-elf/bin
255-
256-
ARG PICOLIBC_REPO=https://github.com/keith-packard/picolibc
257-
ARG PICOLIBC_TAG=1.4.6
258-
ARG PICOLIBC_URL=${PICOLIBC_REPO}/archive/${PICOLIBC_TAG}.tar.gz
259-
ARG PICOLIBC_ARCHIVE=${PICOLIBC_TAG}.tar.gz
260-
261-
RUN echo 'Building and Installing PicoLIBC' >&2 && \
262-
pip3 install --no-cache-dir meson && \
263-
mkdir -p /usr/src/picolibc && \
264-
cd /usr/src/picolibc/ &&\
265-
curl -L -o ${PICOLIBC_ARCHIVE} ${PICOLIBC_URL} && \
266-
tar -xf ${PICOLIBC_ARCHIVE} && \
267-
cd picolibc-${PICOLIBC_TAG}
268-
269-
COPY cross-riscv-none-embed.txt /usr/src/picolibc/picolibc-${PICOLIBC_TAG}/
270-
271-
RUN cd /usr/src/picolibc/picolibc-${PICOLIBC_TAG} && \
272-
which riscv-none-embed-gcc && \
273-
ls -al /opt/xpack-riscv-none-embed-gcc-${RISCV_VERSION}/bin && \
274-
mkdir build-arm build-riscv build-esp32 && \
275-
cd build-riscv && \
276-
meson .. -Dtests=true -Dmultilib=false -Dincludedir=picolibc/riscv-none-embed/include -Dlibdir=picolibc/riscv-none-embed/lib --cross-file ../cross-riscv-none-embed.txt && \
277-
ninja && ninja install && \
278-
cd ../build-esp32 && \
279-
sh ../do-esp32-configure && \
280-
ninja && ninja install && \
281-
cd ../build-arm && \
282-
sh ../do-arm-configure && \
283-
ninja && ninja install
284-
285-
# No need to keep the sources around
286-
RUN rm -rf /usr/src/picolibc
287-
288-
# RIOT toolchains
289-
ARG RIOT_TOOLCHAIN_GCC_VERSION=10.1.0
290-
ARG RIOT_TOOLCHAIN_PACKAGE_VERSION=18
291-
ARG RIOT_TOOLCHAIN_TAG=20200722112854-64162e7
292-
ARG RIOT_TOOLCHAIN_GCCPKGVER=${RIOT_TOOLCHAIN_GCC_VERSION}-${RIOT_TOOLCHAIN_PACKAGE_VERSION}
293-
ARG RIOT_TOOLCHAIN_SUBDIR=${RIOT_TOOLCHAIN_GCCPKGVER}-${RIOT_TOOLCHAIN_TAG}
294-
295-
ARG MSP430_URL=https://github.com/RIOT-OS/toolchains/releases/download/${RIOT_TOOLCHAIN_SUBDIR}/riot-msp430-elf-${RIOT_TOOLCHAIN_GCCPKGVER}.tgz
296-
RUN echo 'Installing RIOT MSP430 ELF toolchain' >&2 && \
297-
wget -q ${MSP430_URL} -O- | tar -C /opt -xz
298-
ENV PATH $PATH:/opt/riot-toolchain/msp430-elf/${RIOT_TOOLCHAIN_GCCPKGVER}/bin
299-
300-
# install required python packages from file
301-
# numpy must be already installed before installing some other requirements (emlearn)
302-
RUN pip3 install --no-cache-dir numpy==1.22.4
303-
COPY requirements.txt /tmp/requirements.txt
304-
RUN echo 'Installing python3 packages' >&2 \
305-
&& pip3 install --no-cache-dir pybind11 \
306-
&& pip3 install --no-cache-dir -r /tmp/requirements.txt \
307-
&& rm /tmp/requirements.txt
308-
309-
# While sourcing ~/.cargo/env later would have the right short-term effect,
310-
# we'd still need to set the right path even later when HOME is
311-
# /data/riotbuild -- so setting it right away.
312-
ENV PATH ${PATH}:/opt/rustup/.cargo/bin
313-
# Install nightly Rust via rustup; this is needed for Rust-on-RIOT builds and
314-
# contains all CARGO_TARGETs currently recognized for RIOT targets.
315-
#
316-
# *_HOMEs moved to /opt to make them world readable. RUSTUP_HOME is set
317-
# persistently in case someone in their image wants to do a quick `sudo rustup
318-
# toolchain add` or similar; CARGO_HOME is not because the user will need to
319-
# write there, and all rustup does here is to place some binaries that later
320-
# fan out to RUSTUP_HOME anyway.
321-
#
322-
# Components: rust-src is needed to run `-Z build-std=core`, which in turn is
323-
# needed on AVR (which thus doesn't need the avr-unknown-gnu-atmega328 target;
324-
# being able to build core might be useful for other targets as well).
325-
ENV RUSTUP_HOME /opt/rustup/.rustup
326-
RUN \
327-
RUSTUP_HOME=/opt/rustup/.rustup \
328-
CARGO_HOME=/opt/rustup/.cargo sh -c "\
329-
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal --default-toolchain nightly-2022-09-25 && \
330-
rustup toolchain add stable && \
331-
for T in nightly-2022-09-25 stable; do \
332-
rustup component add rust-src --toolchain \$T && \
333-
rustup target add i686-unknown-linux-gnu --toolchain \$T && \
334-
rustup target add riscv32imac-unknown-none-elf --toolchain \$T && \
335-
rustup target add thumbv7em-none-eabihf --toolchain \$T && \
336-
rustup target add thumbv7em-none-eabi --toolchain \$T && \
337-
rustup target add thumbv7m-none-eabi --toolchain \$T && \
338-
rustup target add thumbv6m-none-eabi --toolchain \$T && \
339-
rustup target add thumbv8m.main-none-eabihf --toolchain \$T && \
340-
rustup target add thumbv8m.main-none-eabi --toolchain \$T && \
341-
rustup target add thumbv8m.base-none-eabi --toolchain \$T && \
342-
true; \
343-
done"
344-
345-
RUN \
346-
echo 'Installing C2Rust' >&2 && \
347-
CARGO_HOME=/opt/rustup/.cargo cargo install --no-track --locked c2rust --git https://github.com/chrysn-pull-requests/c2rust --branch riscv-vector-types && \
348-
echo 'Cleaning up root-owned crates.io cache' >&2 && \
349-
rm -rf /opt/rustup/.cargo/{git,registry,.package-cache}
350-
351-
# get Dockerfile version from build args
35227
ARG RIOTBUILD_VERSION=unknown
353-
ENV RIOTBUILD_VERSION $RIOTBUILD_VERSION
354-
35528
ARG RIOTBUILD_COMMIT=unknown
356-
ENV RIOTBUILD_COMMIT $RIOTBUILD_COMMIT
357-
35829
ARG RIOTBUILD_BRANCH=unknown
359-
ENV RIOTBUILD_BRANCH $RIOTBUILD_BRANCH
36030

361-
# watch for single ">" vs double ">>"!
362-
RUN echo "RIOTBUILD_VERSION=$RIOTBUILD_VERSION" > /etc/riotbuild
363-
RUN echo "RIOTBUILD_COMMIT=$RIOTBUILD_COMMIT" >> /etc/riotbuild
364-
RUN echo "RIOTBUILD_BRANCH=$RIOTBUILD_BRANCH" >> /etc/riotbuild
31+
ENV DEBIAN_FRONTEND="noninteractive" \
32+
LC_ALL="C.UTF-8" \
33+
LANG="C.UTF-8" \
34+
ESP8266_RTOS_SDK_DIR="/opt/esp/ESP8266_RTOS_SDK" \
35+
RUSTUP_HOME="/opt/rustup/.rustup" \
36+
PATH="${PATH}:/opt/arm-none-eabi/bin:/opt/riscv-none-elf/bin:/opt/esp/xtensa-esp8266-elf/bin:/opt/esp/xtensa-esp32-elf/bin:/opt/esp/qemu/bin:/opt/esp/riscv32-esp-elf/bin:/opt/esp/xtensa-esp32s2-elf/bin:/opt/esp/xtensa-esp32s3-elf/bin:/opt/msp430-elf/bin:/opt/rustup/.cargo/bin" \
37+
RIOTBUILD_VERSION="$RIOTBUILD_VERSION" \
38+
RIOTBUILD_COMMIT="$RIOTBUILD_COMMIT" \
39+
RIOTBUILD_BRANCH="$RIOTBUILD_BRANCH"
40+
41+
RUN \
42+
--mount=type=bind,source=build.sh,target=/root/build.sh \
43+
--mount=type=bind,source=requirements.txt,target=/root/requirements.txt \
44+
--mount=type=bind,source=files/libsocketcan-dev_0.0.11-1_i386.deb,target=/root/libsocketcan-dev_0.0.11-1_i386.deb \
45+
--mount=type=bind,source=files/libsocketcan2_0.0.11-1_i386.deb,target=/root/libsocketcan2_0.0.11-1_i386.deb \
46+
cd /root && ./build.sh
47+

0 commit comments

Comments
 (0)