[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Do not remove MinGW libraries from Fortran default linker flags
From: |
Markus Mützel |
Subject: |
Do not remove MinGW libraries from Fortran default linker flags |
Date: |
Thu, 12 Dec 2024 12:42:48 +0000 |
Stripping `-lmingwex` from the Fortran default linker flags can lead to
a situation where the first `-lmsvcrt` appears before the first
`-lmingwex` for a library that consists of Fortran and C++ sources.
That means that the linker picks some functions from the Windows CRT that
should instead be picked from `libmingwex.a`.
It took quite some time to figure out an odd behavior when calling
`std::asin` with a complex double precision value with a real part larger
than 1.0 and an imaginary part of 0.0 in such a library.
See also: https://octave.discourse.group/t/6026/75
Also don't strip `-lmoldname` from these flags because omitting that
library could result in issues when Fortran code tries to call POSIX-like
C functions without a `_` prefix when targeting MinGW.
The following change fixes these issues by essentially reverting the
changes from:
https://lists.gnu.org/r/autoconf-patches/2021-09/msg00000.html
I'm not sure why `-lkernel32` needs to be removed from the linker flags
when targeting MinGW. But we didn't observe an issue with that, so I left
that as applied in that changeset.
diff -urN autoconf-2.72/lib/autoconf/fortran.m4.orig
autoconf-2.72/lib/autoconf/fortran.m4
--- autoconf-2.72/lib/autoconf/fortran.m4.orig 2024-10-30 13:31:24.456674400
+0100
+++ autoconf-2.72/lib/autoconf/fortran.m4 2024-12-11 16:08:46.415095400
+0100
@@ -705,7 +705,7 @@
-lang* | -lcrt*.o | -lc | -lgcc* | -lSystem | -libmil | -little \
|-LANG:=* | -LIST:* | -LNO:* | -link)
;;
- -lkernel32 | -lmingw* | -lmoldname)
+ -lkernel32)
# Ignore this library only on Windows-like systems.
case $host_os in
cygwin* | msys* | mingw* | windows*) ;;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Do not remove MinGW libraries from Fortran default linker flags,
Markus Mützel <=