Files
llvm-mingw/Dockerfile.dev
T
Martin Storsjö ed0234b254 docker: Bump the base images to Ubuntu 24.04
As the releases are built (without a surrounding extra container)
on GitHub Actions these days, we don't need to hold the docker
images back to an old version for the sake of compatibility;
instead, updating to a newer version provides more modern tools
for users of the docker image.

The script release.sh, which earlier was used for building releases,
uses docker for doing clean isolated builds, and thus needs to be
updated with the distro version used in the dockerfiles.
2025-04-09 14:28:54 +03:00

153 lines
5.3 KiB
Docker

FROM ubuntu:24.04
RUN apt-get update -qq && \
DEBIAN_FRONTEND="noninteractive" apt-get install -qqy --no-install-recommends \
git wget bzip2 file unzip libtool pkg-config cmake build-essential \
automake nasm gettext autopoint vim-tiny python3 \
ninja-build ca-certificates curl less zip && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*
RUN git config --global user.name "LLVM MinGW" && \
git config --global user.email root@localhost
WORKDIR /build
ENV TOOLCHAIN_PREFIX=/opt/llvm-mingw
ARG FULL_LLVM
# Build LLVM
COPY build-llvm.sh ./
RUN ./build-llvm.sh $TOOLCHAIN_PREFIX
# Build LLDB-MI
COPY build-lldb-mi.sh ./
RUN ./build-lldb-mi.sh $TOOLCHAIN_PREFIX
# Strip the LLVM install output immediately. (This doesn't reduce the
# total docker image size as long as it is in a separate RUN layer though,
# but reduces build times if tweaking the contents of strip-llvm.sh.)
# Most of the size of the docker image comes from the build directory that
# we keep in any case.
COPY strip-llvm.sh ./
RUN ./strip-llvm.sh $TOOLCHAIN_PREFIX
ARG TOOLCHAIN_ARCHS="i686 x86_64 armv7 aarch64"
# Install the usual $TUPLE-clang binaries
COPY wrappers/*.sh wrappers/*.c wrappers/*.h wrappers/*.cfg ./wrappers/
COPY install-wrappers.sh ./
RUN ./install-wrappers.sh $TOOLCHAIN_PREFIX
ARG DEFAULT_CRT=ucrt
ARG CFGUARD_ARGS=--enable-cfguard
# Build MinGW-w64
COPY build-mingw-w64.sh ./
RUN ./build-mingw-w64.sh $TOOLCHAIN_PREFIX --with-default-msvcrt=$DEFAULT_CRT $CFGUARD_ARGS
COPY build-mingw-w64-tools.sh ./
RUN ./build-mingw-w64-tools.sh $TOOLCHAIN_PREFIX
# Build compiler-rt
COPY build-compiler-rt.sh ./
RUN ./build-compiler-rt.sh $TOOLCHAIN_PREFIX $CFGUARD_ARGS
# Build libunwind/libcxxabi/libcxx
COPY build-libcxx.sh ./
RUN ./build-libcxx.sh $TOOLCHAIN_PREFIX $CFGUARD_ARGS
# Build mingw-w64's extra libraries
COPY build-mingw-w64-libraries.sh ./
RUN ./build-mingw-w64-libraries.sh $TOOLCHAIN_PREFIX $CFGUARD_ARGS
# Build C test applications
ENV PATH=$TOOLCHAIN_PREFIX/bin:$PATH
COPY test/*.c test/*.h test/*.idl ./test/
RUN cd test && \
for arch in $TOOLCHAIN_ARCHS; do \
mkdir -p $arch && \
for test in hello hello-tls crt-test setjmp; do \
$arch-w64-mingw32-clang $test.c -o $arch/$test.exe || exit 1; \
done; \
for test in autoimport-lib; do \
$arch-w64-mingw32-clang $test.c -shared -o $arch/$test.dll -Wl,--out-implib,$arch/lib$test.dll.a || exit 1; \
done; \
for test in autoimport-main; do \
$arch-w64-mingw32-clang $test.c -o $arch/$test.exe -L$arch -l${test%-main}-lib || exit 1; \
done; \
for test in idltest; do \
# The IDL output isn't arch specific, but test each arch frontend \
$arch-w64-mingw32-widl $test.idl -h -o $arch/$test.h && \
$arch-w64-mingw32-clang $test.c -I$arch -o $arch/$test.exe -lole32 || exit 1; \
done; \
for test in stacksmash; do \
$arch-w64-mingw32-clang $test.c -o $arch/$test.exe -fstack-protector-strong || exit 1; \
done; \
for test in bufferoverflow; do \
$arch-w64-mingw32-clang $test.c -o $arch/$test.exe -D_FORTIFY_SOURCE=2 -O2 || exit 1; \
done; \
done
# Build C++ test applications
COPY test/*.cpp ./test/
RUN cd test && \
for arch in $TOOLCHAIN_ARCHS; do \
mkdir -p $arch && \
for test in hello-cpp hello-exception tlstest-main exception-locale exception-reduced global-terminate longjmp-cleanup; do \
$arch-w64-mingw32-clang++ $test.cpp -o $arch/$test.exe || exit 1; \
done; \
for test in hello-exception; do \
$arch-w64-mingw32-clang++ $test.cpp -static -o $arch/$test-static.exe || exit 1; \
done; \
for test in tlstest-lib throwcatch-lib; do \
$arch-w64-mingw32-clang++ $test.cpp -shared -o $arch/$test.dll -Wl,--out-implib,$arch/lib$test.dll.a || exit 1; \
done; \
for test in throwcatch-main; do \
$arch-w64-mingw32-clang++ $test.cpp -o $arch/$test.exe -L$arch -l${test%-main}-lib || exit 1; \
done; \
done
# Build sanitizers. Ubsan includes <typeinfo> from the C++ headers, so
# we need to build this after libcxx.
# $CFGUARD_ARGS is intentionally omitted here.
RUN ./build-compiler-rt.sh $TOOLCHAIN_PREFIX --build-sanitizers
# Sanitizers on windows only support x86.
RUN cd test && \
for arch in $TOOLCHAIN_ARCHS; do \
case $arch in \
i686|x86_64) \
;; \
*) \
continue \
;; \
esac && \
for test in stacksmash; do \
$arch-w64-mingw32-clang $test.c -o $arch/$test-asan.exe -fsanitize=address -g -gcodeview -Wl,--pdb= || exit 1; \
done; \
for test in ubsan; do \
$arch-w64-mingw32-clang $test.c -o $arch/$test.exe -fsanitize=undefined -fno-sanitize-recover=all || exit 1; \
done; \
done
# Build OpenMP
COPY build-openmp.sh ./
RUN ./build-openmp.sh $TOOLCHAIN_PREFIX $CFGUARD_ARGS
RUN cd test && \
for arch in $TOOLCHAIN_ARCHS; do \
for test in hello-omp; do \
$arch-w64-mingw32-clang $test.c -o $arch/$test.exe -fopenmp=libomp || exit 1; \
done; \
done
RUN cd test && \
for arch in $TOOLCHAIN_ARCHS; do \
cp $TOOLCHAIN_PREFIX/$arch-w64-mingw32/bin/*.dll $arch || exit 1; \
done