This will be used later for clang-analyzer and libfuzzer.
We intentionally use the LLVM project apt repositories for greater
flexibility in the versions we want to use, e.g. LLVM 20 is not yet
available on Debian Bookworm.

kernel.org also hosts more barebones LLVM toolchains, but we are
interested in more than that.

The LLVM layer added to the container sits at 1.04GiB, which is about
200MiB less than what we are using for the GCC toolchains.
It contains support for cross-compiling 47 different targets.

Cc: Jules Maselbas <jmasel...@zdiv.net>
Signed-off-by: Ahmad Fatoum <a.fat...@pengutronix.de>
---
 test/Containerfile | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/test/Containerfile b/test/Containerfile
index e9b044c87ab7..20402c384b6f 100644
--- a/test/Containerfile
+++ b/test/Containerfile
@@ -58,6 +58,16 @@ RUN apt-get update && apt-get install -y 
--no-install-recommends \
        && rm -rf /var/lib/apt/lists/*
 
 ENV GCC_VERSION=14.2.0
+ENV LLVM_VERSION=20
+
+RUN apt-get update && apt-get install -y --no-install-recommends \
+       lsb-release software-properties-common gnupg \
+       && wget https://apt.llvm.org/llvm.sh \
+       && chmod +x llvm.sh && ./llvm.sh ${LLVM_VERSION} \
+       && apt-get remove -y lsb-release software-properties-common gnupg \
+       && apt-get autoremove -y --purge \
+       && apt-get clean \
+       && rm -rf llvm.sh /var/lib/apt/lists/*
 
 # Manually install the kernel.org Crosstool based toolchains
 RUN korg_crosstool_dl() { wget -nv -O - 
https://mirrors.edge.kernel.org/pub/tools/crosstool/files/bin/${1}/${2}/${1}-gcc-${2}-nolibc-${3}.tar.xz
 | tar -C /opt -xJ ; } && \
@@ -92,4 +102,9 @@ ENV 
CROSS_COMPILE_powerpc=/opt/gcc-${GCC_VERSION}-nolibc/powerpc-linux/bin/power
 ENV 
CROSS_COMPILE_riscv=/opt/gcc-${GCC_VERSION}-nolibc/riscv64-linux/bin/riscv64-linux-
 ENV CROSS_COMPILE_kvx=/opt/gcc-kalray-kvx-v5.0.0/bin/kvx-elf-
 
+ENV CROSS_COMPILE_llvm=-${LLVM_VERSION}
+# Workaround for https://github.com/llvm/llvm-project/issues/112458
+RUN ln -Ts /usr/lib/llvm-${LLVM_VERSION}/lib/clang/${LLVM_VERSION}/lib/linux/ \
+           
/usr/lib/llvm-${LLVM_VERSION}/lib/clang/${LLVM_VERSION}/lib/x86_64-pc-linux-gnu
+
 USER barebox:barebox
-- 
2.39.5


Reply via email to