2025-04-09 11:08:43 +03:00
|
|
|
FROM ubuntu:24.04
|
2018-04-01 22:30:01 +03:00
|
|
|
|
2022-02-02 23:36:26 +02:00
|
|
|
RUN apt-get update -qq && \
|
|
|
|
|
DEBIAN_FRONTEND="noninteractive" apt-get install -qqy --no-install-recommends \
|
2018-04-01 22:30:01 +03:00
|
|
|
git wget bzip2 file unzip libtool pkg-config cmake build-essential \
|
2025-01-07 15:49:19 +02:00
|
|
|
automake nasm gettext autopoint vim-tiny python3 \
|
2021-01-25 13:05:42 +02:00
|
|
|
ninja-build ca-certificates curl less zip && \
|
2018-04-01 22:30:01 +03:00
|
|
|
apt-get clean -y && \
|
|
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
2023-06-09 15:00:20 +03:00
|
|
|
|
2018-04-01 22:30:01 +03:00
|
|
|
RUN git config --global user.name "LLVM MinGW" && \
|
|
|
|
|
git config --global user.email root@localhost
|
|
|
|
|
|
|
|
|
|
WORKDIR /build
|
|
|
|
|
|
|
|
|
|
ENV TOOLCHAIN_PREFIX=/opt/llvm-mingw
|
|
|
|
|
|
2019-03-10 20:47:08 +02:00
|
|
|
ARG FULL_LLVM
|
|
|
|
|
|
2018-04-01 22:30:01 +03:00
|
|
|
# Build LLVM
|
2018-10-16 19:56:15 +03:00
|
|
|
COPY build-llvm.sh ./
|
2018-04-01 22:30:01 +03:00
|
|
|
RUN ./build-llvm.sh $TOOLCHAIN_PREFIX
|
|
|
|
|
|
2020-10-09 13:31:32 +03:00
|
|
|
# Build LLDB-MI
|
|
|
|
|
COPY build-lldb-mi.sh ./
|
|
|
|
|
RUN ./build-lldb-mi.sh $TOOLCHAIN_PREFIX
|
|
|
|
|
|
2018-02-28 11:52:00 +02:00
|
|
|
# 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.)
|
2018-08-03 11:56:23 +03:00
|
|
|
# Most of the size of the docker image comes from the build directory that
|
|
|
|
|
# we keep in any case.
|
2018-10-16 19:56:15 +03:00
|
|
|
COPY strip-llvm.sh ./
|
2018-02-28 11:52:00 +02:00
|
|
|
RUN ./strip-llvm.sh $TOOLCHAIN_PREFIX
|
|
|
|
|
|
2024-07-30 14:54:07 +03:00
|
|
|
ARG TOOLCHAIN_ARCHS="i686 x86_64 armv7 aarch64 arm64ec"
|
2018-04-01 22:30:01 +03:00
|
|
|
|
|
|
|
|
# Install the usual $TUPLE-clang binaries
|
2018-04-21 10:55:53 +03:00
|
|
|
COPY wrappers/*.sh wrappers/*.c wrappers/*.h wrappers/*.cfg ./wrappers/
|
2018-10-16 19:56:15 +03:00
|
|
|
COPY install-wrappers.sh ./
|
2018-04-01 22:30:01 +03:00
|
|
|
RUN ./install-wrappers.sh $TOOLCHAIN_PREFIX
|
|
|
|
|
|
2019-11-13 12:39:30 +02:00
|
|
|
ARG DEFAULT_CRT=ucrt
|
|
|
|
|
|
2022-09-29 01:42:36 +08:00
|
|
|
ARG CFGUARD_ARGS=--enable-cfguard
|
2022-09-29 01:29:51 +08:00
|
|
|
|
2018-04-01 22:30:01 +03:00
|
|
|
# Build MinGW-w64
|
2018-10-16 16:14:37 +03:00
|
|
|
COPY build-mingw-w64.sh ./
|
2022-09-29 01:29:51 +08:00
|
|
|
RUN ./build-mingw-w64.sh $TOOLCHAIN_PREFIX --with-default-msvcrt=$DEFAULT_CRT $CFGUARD_ARGS
|
2018-04-01 22:30:01 +03:00
|
|
|
|
2020-09-14 14:24:16 +03:00
|
|
|
COPY build-mingw-w64-tools.sh ./
|
|
|
|
|
RUN ./build-mingw-w64-tools.sh $TOOLCHAIN_PREFIX
|
|
|
|
|
|
2018-04-01 22:30:01 +03:00
|
|
|
# Build compiler-rt
|
2018-10-16 19:56:15 +03:00
|
|
|
COPY build-compiler-rt.sh ./
|
2022-09-29 01:29:51 +08:00
|
|
|
RUN ./build-compiler-rt.sh $TOOLCHAIN_PREFIX $CFGUARD_ARGS
|
2018-04-01 22:30:01 +03:00
|
|
|
|
2021-11-05 14:36:09 +02:00
|
|
|
# Build libunwind/libcxxabi/libcxx
|
|
|
|
|
COPY build-libcxx.sh ./
|
2022-09-29 01:29:51 +08:00
|
|
|
RUN ./build-libcxx.sh $TOOLCHAIN_PREFIX $CFGUARD_ARGS
|
2021-11-05 14:36:09 +02:00
|
|
|
|
2018-06-30 19:33:34 +03:00
|
|
|
# Build mingw-w64's extra libraries
|
2018-10-16 19:56:15 +03:00
|
|
|
COPY build-mingw-w64-libraries.sh ./
|
2022-09-29 01:29:51 +08:00
|
|
|
RUN ./build-mingw-w64-libraries.sh $TOOLCHAIN_PREFIX $CFGUARD_ARGS
|
2018-04-30 10:06:47 +01:00
|
|
|
|
2018-04-01 22:30:01 +03:00
|
|
|
# Build C test applications
|
|
|
|
|
ENV PATH=$TOOLCHAIN_PREFIX/bin:$PATH
|
|
|
|
|
|
2020-09-15 16:43:14 +03:00
|
|
|
COPY test/*.c test/*.h test/*.idl ./test/
|
2018-04-01 22:30:01 +03:00
|
|
|
RUN cd test && \
|
|
|
|
|
for arch in $TOOLCHAIN_ARCHS; do \
|
2018-08-13 13:39:02 +03:00
|
|
|
mkdir -p $arch && \
|
2018-03-20 12:00:22 +02:00
|
|
|
for test in hello hello-tls crt-test setjmp; do \
|
2018-08-13 13:39:02 +03:00
|
|
|
$arch-w64-mingw32-clang $test.c -o $arch/$test.exe || exit 1; \
|
2018-04-01 22:30:01 +03:00
|
|
|
done; \
|
2018-09-05 12:21:24 +03:00
|
|
|
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; \
|
2020-09-15 16:43:14 +03:00
|
|
|
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; \
|
2022-10-31 10:34:41 +02:00
|
|
|
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; \
|
2018-04-01 22:30:01 +03:00
|
|
|
done
|
|
|
|
|
|
|
|
|
|
# Build C++ test applications
|
|
|
|
|
COPY test/*.cpp ./test/
|
|
|
|
|
RUN cd test && \
|
|
|
|
|
for arch in $TOOLCHAIN_ARCHS; do \
|
2018-08-13 13:39:02 +03:00
|
|
|
mkdir -p $arch && \
|
2020-10-12 00:51:46 +03:00
|
|
|
for test in hello-cpp hello-exception tlstest-main exception-locale exception-reduced global-terminate longjmp-cleanup; do \
|
2018-08-13 13:39:02 +03:00
|
|
|
$arch-w64-mingw32-clang++ $test.cpp -o $arch/$test.exe || exit 1; \
|
2018-04-01 22:30:01 +03:00
|
|
|
done; \
|
2020-10-23 12:10:02 +03:00
|
|
|
for test in hello-exception; do \
|
|
|
|
|
$arch-w64-mingw32-clang++ $test.cpp -static -o $arch/$test-static.exe || exit 1; \
|
|
|
|
|
done; \
|
2021-02-19 14:15:31 +02:00
|
|
|
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; \
|
2018-09-05 11:53:46 +03:00
|
|
|
done; \
|
2018-04-01 22:30:01 +03:00
|
|
|
done
|
|
|
|
|
|
2018-08-31 12:30:05 +03:00
|
|
|
# Build sanitizers. Ubsan includes <typeinfo> from the C++ headers, so
|
|
|
|
|
# we need to build this after libcxx.
|
2022-10-02 10:13:53 +03:00
|
|
|
# $CFGUARD_ARGS is intentionally omitted here.
|
2018-08-31 12:30:05 +03:00
|
|
|
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 \
|
2022-10-12 12:32:07 +03:00
|
|
|
$arch-w64-mingw32-clang $test.c -o $arch/$test-asan.exe -fsanitize=address -g -gcodeview -Wl,--pdb= || exit 1; \
|
2018-08-31 12:30:05 +03:00
|
|
|
done; \
|
2018-10-08 13:27:44 +03:00
|
|
|
for test in ubsan; do \
|
2022-09-14 15:03:59 +03:00
|
|
|
$arch-w64-mingw32-clang $test.c -o $arch/$test.exe -fsanitize=undefined -fno-sanitize-recover=all || exit 1; \
|
2018-10-08 13:27:44 +03:00
|
|
|
done; \
|
2018-08-31 12:30:05 +03:00
|
|
|
done
|
|
|
|
|
|
2020-10-10 23:57:44 +03:00
|
|
|
# Build OpenMP
|
|
|
|
|
COPY build-openmp.sh ./
|
2022-09-29 01:29:51 +08:00
|
|
|
RUN ./build-openmp.sh $TOOLCHAIN_PREFIX $CFGUARD_ARGS
|
2020-10-10 23:57:44 +03:00
|
|
|
|
|
|
|
|
RUN cd test && \
|
|
|
|
|
for arch in $TOOLCHAIN_ARCHS; do \
|
2025-07-18 14:23:17 +03:00
|
|
|
if [ "$arch" = "arm64ec" ]; then continue; fi; \
|
2020-10-10 23:57:44 +03:00
|
|
|
for test in hello-omp; do \
|
|
|
|
|
$arch-w64-mingw32-clang $test.c -o $arch/$test.exe -fopenmp=libomp || exit 1; \
|
|
|
|
|
done; \
|
|
|
|
|
done
|
|
|
|
|
|
2018-02-06 13:40:14 +02:00
|
|
|
RUN cd test && \
|
|
|
|
|
for arch in $TOOLCHAIN_ARCHS; do \
|
|
|
|
|
cp $TOOLCHAIN_PREFIX/$arch-w64-mingw32/bin/*.dll $arch || exit 1; \
|
|
|
|
|
done
|