https://gcc.gnu.org/bugzilla/show_bug.cgi?id=41418
LIU Hao <lh_mouse at 126 dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |lh_mouse at 126 dot com
--- Comment #26 from LIU Hao <lh_mouse at 126 dot com> ---
(In reply to Thomas Schwinge from comment #25)
> Now hopefully fixed for good. ;-)
This breaks bootstrapping fortran on x86_64-w64-mingw32. For some reason, the
build system attempts to create a static library with MSVC suffix (.lib)
instead of GNU suffix (.a), and fails with
.../x86_64-w64-mingw32/bin/ar.exe: .libs/libgomp.lib: file format not
recognized
Here is a patch created by AI which seems to work somehow, but I don't know
whether it's correct:
During a bootstrap build, stage 1 by default only builds the languages
selected by '--enable-stage1-languages' ('c,c++'), so the '$GFORTRAN' that
the top-level build system passes to the libgomp build does not exist yet.
With such a non-functional '$FC', libtool configures its Fortran language
tag, and the per-host library naming of that tag then overwrites the one
established for the C language tag: on Windows hosts, 'library_names_spec'
becomes '${libname}${release}${versuffix}${shared_ext} $libname.lib' (the
naming used for MSVC) and 'libext' becomes 'lib'. The libgomp link then
creates a 'libgomp.lib' copy of the DLL, and subsequently fails when trying
to create the static archive of the same name:
.../x86_64-w64-mingw32/bin/ar.exe: .libs/libgomp.lib: file format not
recognized
This is a regression from commit e5efa9eff99d ("libgomp: Revise
libgomp/Fortran support conditionals"), which assumed that with
'--enable-languages=fortran' in effect '$GFORTRAN' is functional.
---
libgomp/configure | 15 ++++++++++++++-
libgomp/configure.ac | 15 ++++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/libgomp/configure.ac b/libgomp/configure.ac
index d8ab719..765b6e8 100644
--- a/libgomp/configure.ac
+++ b/libgomp/configure.ac
@@ -159,7 +159,20 @@ FCFLAGS="$FCFLAGS -L."
# We need gfortran to compile parts of the library
# We can't use AC_PROG_FC because it expects a fully working gfortran.
#AC_PROG_FC(gfortran)
-FC="$GFORTRAN"
+# 'GFORTRAN' may refer to a compiler that is not available yet: during a
+# bootstrap build, stage 1 by default only builds 'c,c++' (see
+# '--enable-stage1-languages'). Set 'FC' to 'no' then, to keep libtool's
+# Fortran language tag disabled; it would otherwise be configured with a
+# non-working compiler, overwriting the per-host library naming established
+# for the C language tag (with MSVC-style names on Windows hosts).
+case ,${enable_languages}, in
+ *,fortran,* )
+ FC="$GFORTRAN"
+ ;;
+ * )
+ FC=no
+ ;;
+esac
AC_PROG_FC(gfortran)
FCFLAGS="$FCFLAGS -Wall -L../libgfortran"