docker: Build MinGW with -mcmodel=small.

(cherry picked from commit c90d4c34d8)
This commit is contained in:
Rémi Bernon 2022-12-11 15:06:06 +01:00 committed by Arkadiusz Hiler
parent e1d797fd97
commit 470f3084eb
4 changed files with 18 additions and 1 deletions

View file

@ -61,19 +61,23 @@ DOCKER = docker
%-i686.Dockerfile.in: %.Dockerfile.in
sed -re 's!@ARCH@!i686!g' \
-re 's!@ARCH_FLAGS@!$(ARCH_FLAGS)!g' \
$< >$@
%-x86_64.Dockerfile.in: %.Dockerfile.in
sed -re 's!@ARCH@!x86_64!g' \
-re 's!@ARCH_FLAGS@!$(ARCH_FLAGS)!g' \
$< >$@
%-linux-gnu.Dockerfile.in: %.Dockerfile.in
sed -re 's!@TARGET@!linux-gnu!g' \
-re 's!@ARCH_FLAGS@!$(ARCH_FLAGS)!g' \
-re 's!@TARGET_FLAGS@!$(TARGET_FLAGS)!g' \
$< >$@
%-w64-mingw32.Dockerfile.in: %.Dockerfile.in
sed -re 's!@TARGET@!w64-mingw32!g' \
-re 's!@ARCH_FLAGS@!$(ARCH_FLAGS)!g' \
-re 's!@TARGET_FLAGS@!$(TARGET_FLAGS)!g' \
$< >$@
@ -118,9 +122,15 @@ $(eval $(call create-binutils-rules,i686,linux-gnu))
$(eval $(call create-binutils-rules,x86_64,w64-mingw32))
$(eval $(call create-binutils-rules,x86_64,linux-gnu))
MINGW_ARCH_FLAGS_crt-x86_64 = --disable-lib32 CFLAGS="-mcmodel=small"
MINGW_ARCH_FLAGS_crt-i686 = --disable-lib64
MINGW_ARCH_FLAGS_pthread-x86_64 = CFLAGS="-mcmodel=small"
MINGW_ARCH_FLAGS_pthread-i686 =
define create-mingw-rules
.PHONY: mingw-$(2)-$(1)
all mingw: mingw-$(2)-$(1)
mingw-$(2)-$(1): ARCH_FLAGS = $(MINGW_ARCH_FLAGS_$(2)-$(1))
mingw-$(2)-$(1): mingw-$(2)-$(1).Dockerfile | binutils
rm -rf build; mkdir -p build
$(DOCKER) build -f $$< \
@ -146,12 +156,16 @@ $(eval $(call create-mingw-rules,x86_64,crt))
$(eval $(call create-mingw-rules,x86_64,pthreads))
$(eval $(call create-mingw-rules,x86_64,widl))
GCC_ARCH_FLAGS_x86_64 = CFLAGS_FOR_TARGET="-mcmodel=small" CXXFLAGS_FOR_TARGET="-mcmodel=small"
GCC_ARCH_FLAGS_i686 =
GCC_TARGET_FLAGS_w64-mingw32 = --disable-shared
GCC_TARGET_FLAGS_linux-gnu =
define create-gcc-rules
.PHONY: gcc-$(1)-$(2)
all gcc: gcc-$(1)-$(2)
gcc-$(1)-$(2): ARCH_FLAGS = $(GCC_ARCH_FLAGS_$(1))
gcc-$(1)-$(2): TARGET_FLAGS = $(GCC_TARGET_FLAGS_$(2))
gcc-$(1)-$(2): gcc-$(1)-$(2).Dockerfile | mingw
rm -rf build; mkdir -p build

View file

@ -40,6 +40,7 @@ RUN wget -q @GCC_URLBASE@/@GCC_SOURCE@ \
--with-system-mpfr \
--with-system-zlib \
--with-tune=core-avx2 \
@ARCH_FLAGS@ \
MAKEINFO=true \
&& make --quiet -j@J@ MAKEINFO=true CFLAGS="-static --static" LDFLAGS="-s -static --static" \
&& make --quiet -j@J@ MAKEINFO=true CFLAGS="-static --static" LDFLAGS="-s -static --static" install-strip DESTDIR=/opt \

View file

@ -13,7 +13,8 @@ RUN wget -q @MINGW_URLBASE@/@MINGW_SOURCE@ \
--prefix=/usr/@ARCH@-w64-mingw32/ \
--host=@ARCH@-w64-mingw32 \
--enable-wildcard \
MAKEINFO=true || cat config.log \
@ARCH_FLAGS@ \
MAKEINFO=true \
&& make --quiet -j@J@ MAKEINFO=true \
&& make --quiet -j@J@ MAKEINFO=true install-strip DESTDIR=/opt \
&& rm -rf /opt/usr/share/doc /opt/usr/share/info /opt/usr/share/man \

View file

@ -15,6 +15,7 @@ RUN wget -q @MINGW_URLBASE@/@MINGW_SOURCE@ \
--prefix=/usr/@ARCH@-w64-mingw32/ \
--host=@ARCH@-w64-mingw32 \
--disable-shared \
@ARCH_FLAGS@ \
MAKEINFO=true \
&& make --quiet -j@J@ MAKEINFO=true \
&& make --quiet -j@J@ MAKEINFO=true install-strip DESTDIR=/opt \