#1148558 the mingw build deduces the mingw target build flags wrongly from the host build flags #1148558
- Package:
- src:gcc-mingw-w64
- Source:
- src:gcc-mingw-w64
- Submitter:
- Matthias Klose
- Date:
- 2026-10-11 19:11:01 UTC
- Severity:
- normal
- Tags:
d/rules reads: $(foreach flag,$(BUILDFLAGS),$(eval $(flag)_FOR_TARGET := $(shell $(dpkg_buildflags_target) --get $(flag)))) and the good thing at least, that this fails in the Ubuntu builds at least, because the build flags include some host specific non-generic flags (-mbranch-protection=none on arm64, -mbackchain on s390x). These builds fail at the first place building the libgcc target library after the compiler is built. This is plain wrong. These flags are for the host, not for any of your mingw targets, and I wouldn't be surprised, that different code for the target is generated depending on the host. You need to set these on your own, independent of the host that you are building on.
patch at https://launchpadlibrarian.net/877713484/gcc-mingw-w64_29ubuntu1_29ubuntu2.diff.gz the libgcc build and various other target builds succeed, but the libgfortran build still fails with: checking whether the GNU Fortran compiler is working... no configure: error: GNU Fortran is not working; please report a bug in http://gcc.gnu.org/bugzilla, attaching /<<P KGBUILDDIR>>/build/i686-w64-mingw32-posix/i686-w64-mingw32/libgfortran/config.log ... because of an invalid host flag.
the packaging apparently knows about the libgfortran issue: # libgfortran doesn't handle FCFLAGS_FOR_TARGET, override FCFLAGS FCFLAGS := $(shell $(dpkg_buildflags_target) --get FCFLAGS) but the work-around is wrong. the build log shows checking whether the GNU Fortran compiler is working... no configure: error: GNU Fortran is not working; please report a bug in http://gcc.gnu.org/bugzilla, attaching /<<P KGBUILDDIR>>/build/i686-w64-mingw32-posix/i686-w64-mingw32/libgfortran/config.log but I couldn't find anything in the GCC bug tracker. Now submitted https://gcc.gnu.org/PR127539
and the patch to remove the host flags from the FCFLAGS settings ... https://launchpadlibrarian.net/877725807/gcc-mingw-w64_29ubuntu2_29ubuntu3.diff.gz