Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 85 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ RUN cat $PREFIX/src/gcc-*.patch | patch -d/dl/gcc -p1 \
&& /dl/gcc/configure \
--prefix=/bootstrap \
--with-sysroot=/bootstrap \
--with-arch-32=pentium4 \
--target=$ARCH \
--enable-static \
--disable-shared \
Expand All @@ -285,7 +286,6 @@ RUN cat $PREFIX/src/gcc-*.patch | patch -d/dl/gcc -p1 \
--disable-dependency-tracking \
--disable-nls \
--disable-lto \
--disable-multilib \
CFLAGS_FOR_TARGET="-O2" \
CXXFLAGS_FOR_TARGET="-O2" \
LDFLAGS_FOR_TARGET="-s" \
Expand All @@ -298,13 +298,19 @@ RUN cat $PREFIX/src/gcc-*.patch | patch -d/dl/gcc -p1 \
ENV PATH="/bootstrap/bin:${PATH}"

COPY src/libmemory.c src/libchkstk.S $PREFIX/src/
RUN mkdir -p $PREFIX/lib \
RUN mkdir -p $PREFIX/lib $PREFIX/lib32 /bootstrap/lib32 \
&& CC=$ARCH-gcc AR=$ARCH-ar DESTDIR=$PREFIX/lib/ \
sh $PREFIX/src/libmemory.c \
&& ln $PREFIX/lib/libmemory.a /bootstrap/lib/ \
&& CC=$ARCH-gcc AR=$ARCH-ar DESTDIR=$PREFIX/lib/ \
sh $PREFIX/src/libchkstk.S \
&& ln $PREFIX/lib/libchkstk.a /bootstrap/lib/
&& ln $PREFIX/lib/libchkstk.a /bootstrap/lib/ \
&& CC="$ARCH-gcc -m32" AR=$ARCH-ar DESTDIR=$PREFIX/lib32/ \
sh $PREFIX/src/libmemory.c \
&& ln $PREFIX/lib32/libmemory.a /bootstrap/lib32/ \
&& CC="$ARCH-gcc -m32" AR=$ARCH-ar DESTDIR=$PREFIX/lib32/ \
sh $PREFIX/src/libchkstk.S \
&& ln $PREFIX/lib32/libchkstk.a /bootstrap/lib32/

WORKDIR /x-mingw-crt
RUN /dl/mingw/mingw-w64-crt/configure \
Expand All @@ -313,7 +319,7 @@ RUN /dl/mingw/mingw-w64-crt/configure \
--host=$ARCH \
--with-default-msvcrt=msvcrt-os \
--disable-dependency-tracking \
--disable-lib32 \
--enable-lib32 \
--enable-lib64 \
CFLAGS="-O2" \
LDFLAGS="-s" \
Expand All @@ -332,6 +338,20 @@ RUN /dl/mingw/mingw-w64-libraries/winpthreads/configure \
&& make -j$(nproc) \
&& make install

WORKDIR /x-winpthreads32
RUN /dl/mingw/mingw-w64-libraries/winpthreads/configure \
--prefix=/bootstrap \
--libdir=/bootstrap/lib32 \
--with-sysroot=/bootstrap \
--host=$ARCH \
--enable-static \
--disable-shared \
CC="$ARCH-gcc -m32" \
CFLAGS="-O2" \
LDFLAGS="-s" \
&& make -j$(nproc) \
&& make install

WORKDIR /x-gcc
RUN make -j$(nproc) \
&& make install
Expand Down Expand Up @@ -417,7 +437,7 @@ RUN /dl/mingw/mingw-w64-crt/configure \
--host=$ARCH \
--with-default-msvcrt=msvcrt-os \
--disable-dependency-tracking \
--disable-lib32 \
--enable-lib32 \
--enable-lib64 \
CFLAGS="-O2" \
LDFLAGS="-s" \
Expand All @@ -428,7 +448,11 @@ COPY src/threads.c $PREFIX/src/
COPY src/threads.h $PREFIX/include/
RUN $ARCH-gcc -c -Oz -I$PREFIX/include/ \
-ffunction-sections -Wa,--no-pad-sections $PREFIX/src/threads.c \
&& $ARCH-ar r $PREFIX/lib/libmingwex.a threads.o
&& $ARCH-ar r $PREFIX/lib/libmingwex.a threads.o \
&& $ARCH-gcc -m32 -c -Oz -I$PREFIX/include/ \
-ffunction-sections -Wa,--no-pad-sections \
-o threads32.o $PREFIX/src/threads.c \
&& $ARCH-ar r $PREFIX/lib32/libmingwex.a threads32.o

WORKDIR /winpthreads
RUN /dl/mingw/mingw-w64-libraries/winpthreads/configure \
Expand All @@ -442,13 +466,28 @@ RUN /dl/mingw/mingw-w64-libraries/winpthreads/configure \
&& make -j$(nproc) \
&& make install

WORKDIR /winpthreads32
RUN /dl/mingw/mingw-w64-libraries/winpthreads/configure \
--prefix=$PREFIX \
--libdir=$PREFIX/lib32 \
--with-sysroot=$PREFIX \
--host=$ARCH \
--enable-static \
--disable-shared \
CC="$ARCH-gcc -m32" \
CFLAGS="-O2" \
LDFLAGS="-s" \
&& make -j$(nproc) \
&& make install

WORKDIR /gcc
COPY src/crossgcc-*.patch $PREFIX/src/
RUN cat $PREFIX/src/crossgcc-*.patch | patch -d/dl/gcc -p1 \
&& /dl/gcc/configure \
--prefix=$PREFIX \
--with-sysroot=$PREFIX \
--with-native-system-header-dir=/include \
--with-arch-32=pentium4 \
--target=$ARCH \
--host=$ARCH \
--enable-static \
Expand All @@ -465,7 +504,6 @@ RUN cat $PREFIX/src/crossgcc-*.patch | patch -d/dl/gcc -p1 \
--disable-libstdcxx-verbose \
--disable-dependency-tracking \
--disable-lto \
--disable-multilib \
--disable-nls \
--disable-win32-registry \
--enable-mingw-wildcard \
Expand Down Expand Up @@ -504,6 +542,46 @@ RUN $ARCH-gcc -DEXE=gcc.exe -DCMD=cc \
-Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/$ARCH-{}.exe $PREFIX/src/alias.c -lkernel32

# Create i686 tool aliases
RUN printf '%s\n' addr2line ar c++filt gcc-ar gcc-nm gcc-ranlib gcov \
gcov-dump gcov-tool gendef nm objcopy objdump ranlib size strings \
strip uuidgen widl windmc \
| xargs -I{} -P$(nproc) \
$ARCH-gcc -DEXE={}.exe -DCMD=i686-w64-mingw32-{} \
-Oz -fno-asynchronous-unwind-tables \
-Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/i686-w64-mingw32-{}.exe \
$PREFIX/src/alias.c -lkernel32 \
&& printf '%s\n' cpp gcc g++ gfortran \
| xargs -I{} -P$(nproc) \
$ARCH-gcc -DEXE={}.exe -DCMD="i686-w64-mingw32-{} -m32" \
-Oz -fno-asynchronous-unwind-tables \
-Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/i686-w64-mingw32-{}.exe \
$PREFIX/src/alias.c -lkernel32 \
&& $ARCH-gcc -DEXE=g++.exe -DCMD="i686-w64-mingw32-c++ -m32" \
-Oz -fno-asynchronous-unwind-tables -Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/i686-w64-mingw32-c++.exe \
$PREFIX/src/alias.c -lkernel32 \
&& $ARCH-gcc -DEXE=as.exe -DCMD="i686-w64-mingw32-as --32" \
-Oz -fno-asynchronous-unwind-tables -Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/i686-w64-mingw32-as.exe \
$PREFIX/src/alias.c -lkernel32 \
&& $ARCH-gcc -DEXE=ld.exe -DCMD="i686-w64-mingw32-ld -m i386pe" \
-Oz -fno-asynchronous-unwind-tables -Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/i686-w64-mingw32-ld.exe \
$PREFIX/src/alias.c -lkernel32 \
&& $ARCH-gcc -DEXE=dlltool.exe \
-DCMD="i686-w64-mingw32-dlltool -m i386 --as-flags=--32" \
-Oz -fno-asynchronous-unwind-tables -Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/i686-w64-mingw32-dlltool.exe \
$PREFIX/src/alias.c -lkernel32 \
&& $ARCH-gcc -DEXE=windres.exe \
-DCMD="i686-w64-mingw32-windres --target=pe-i386" \
-Oz -fno-asynchronous-unwind-tables -Wl,--gc-sections -s -nostdlib \
-o $PREFIX/bin/i686-w64-mingw32-windres.exe \
$PREFIX/src/alias.c -lkernel32

# Build some extra development tools

FROM cross AS build-gendef
Expand Down
19 changes: 19 additions & 0 deletions src/mingw-default-win32-winnt.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
headers: default 32-bit x86 to Windows XP

The x86_64 multilib toolchain shares one header tree between its 64-bit
and 32-bit targets. Keep the configured mingw-w64 default for x86_64 and
other architectures, but preserve w64devkit's Windows XP default when
the compiler targets i686. An explicit user definition still takes
precedence through the existing outer guard.

--- a/mingw-w64-headers/crt/_mingw.h.in
+++ b/mingw-w64-headers/crt/_mingw.h.in
@@ -255,3 +255,7 @@
#ifndef _WIN32_WINNT
-#define _WIN32_WINNT @DEFAULT_WIN32_WINNT@
+# if defined(__i386__)
+# define _WIN32_WINNT 0x0501
+# else
+# define _WIN32_WINNT @DEFAULT_WIN32_WINNT@
+# endif
#endif
Loading