Files
llvm-mingw/Dockerfile.dev
T
Martin Storsjö 609fe4b81d Use binutils objcopy and strip if available
For x86 architectures, binutils objcopy and strip can be used as
such.

For armv7 and aarch64, binutils doesn't recognize the architectures
and refuse to touch the files. For most/everything that objcopy/strip
do, the actual architecture doesn't really matter though. Therefore,
provide a wrapper script and a minimal tool for editing PE executables,
that change the architecture from armv7 and aarch64 to i686 and x86_64
respectively before invoking binutils, and change it back afterwards.

In case the binutils tools are missing, just return a successful result
without doing anything for stripping operations (previously, we had the
<triplet>-strip tool symlinked to /bin/true, so this isn't any worse than
before) and fail for other objcopy operations.
2018-07-25 00:56:58 +03:00

85 lines
2.4 KiB
Docker

FROM ubuntu:16.04
RUN apt-get update -qq && apt-get install -qqy \
git wget bzip2 file unzip libtool pkg-config cmake build-essential \
automake yasm gettext autopoint vim python git-svn ninja-build \
subversion && \
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
ARG CORES=4
ENV TOOLCHAIN_PREFIX=/opt/llvm-mingw
# Build LLVM
COPY build-llvm.sh .
RUN ./build-llvm.sh $TOOLCHAIN_PREFIX
ENV TOOLCHAIN_ARCHS="i686 x86_64 armv7 aarch64"
# Install the usual $TUPLE-clang binaries
COPY wrappers/*.sh ./wrappers/
COPY wrappers/*.c ./wrappers/
COPY install-wrappers.sh .
RUN ./install-wrappers.sh $TOOLCHAIN_PREFIX
# Build MinGW-w64
COPY build-mingw-w64.sh .
RUN ./build-mingw-w64.sh $TOOLCHAIN_PREFIX
# Build compiler-rt
COPY build-compiler-rt.sh .
RUN ./build-compiler-rt.sh $TOOLCHAIN_PREFIX
# Build mingw-w64's extra libraries
COPY build-mingw-w64-libraries.sh .
RUN ./build-mingw-w64-libraries.sh $TOOLCHAIN_PREFIX
# Build C test applications
ENV PATH=$TOOLCHAIN_PREFIX/bin:$PATH
COPY test/*.c ./test/
RUN cd test && \
for arch in $TOOLCHAIN_ARCHS; do \
for test in hello hello-tls crt-test setjmp; do \
$arch-w64-mingw32-clang $test.c -o $test-$arch.exe || exit 1; \
done; \
done
# Build libunwind/libcxxabi/libcxx
COPY build-libcxx.sh merge-archives.sh ./
RUN ./build-libcxx.sh $TOOLCHAIN_PREFIX
# Build C++ test applications
COPY test/*.cpp ./test/
RUN cd test && \
for arch in $TOOLCHAIN_ARCHS; do \
for test in hello-cpp hello-exception; do \
$arch-w64-mingw32-clang++ $test.cpp -o $test-$arch.exe || exit 1; \
done; \
done
# Build libssp
COPY build-libssp.sh libssp-Makefile ./
RUN ./build-libssp.sh $TOOLCHAIN_PREFIX
# Strip the final toolchain. (This doesn't reduce the total docker image
# size as long as it is in a separate RUN layer though.)
COPY strip-llvm.sh .
RUN ./strip-llvm.sh $TOOLCHAIN_PREFIX
# Cheating: Pull strip and objcopy from the normal binutils package.
RUN apt-get update -qq && \
apt-get install -qqy binutils-mingw-w64-x86-64 && \
cp /usr/bin/x86_64-w64-mingw32-strip $TOOLCHAIN_PREFIX/bin/binutils-strip && \
cp /usr/bin/x86_64-w64-mingw32-objcopy $TOOLCHAIN_PREFIX/bin/binutils-objcopy && \
apt-get remove -qqy binutils-mingw-w64-x86-64 && \
apt-get clean -y && \
rm -rf /var/lib/apt/lists/*