PnetCDF icon indicating copy to clipboard operation
PnetCDF copied to clipboard

configure fail with LTO

Open Alessandro-Barbieri opened this issue 3 years ago • 3 comments

Gentoo CI had a failure while trying to build with LTO log https://860768.bugs.gentoo.org/attachment.cgi?id=794060 see https://bugs.gentoo.org/860768

configure:35368: /usr/bin/mpif90 -o conftest -O2 -pipe -march=x86-64 -frecord-gcc-switches -fno-diagnostics-color -fmessage-length=0 -flto -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing  conftestf.o conftest.o -Wl,-O1 -Wl,--as-needed -Wl,--defsym=__gentoo_check_ldflags__=0 
conftestf.f:4:72: error: type of 'sub' does not match original declaration [-Werror=lto-type-mismatch]
    4 |            status = sub(values)
      |                                                                        ^
conftest.c:1:17: note: 'sub_' was previously declared here
    1 |             int sub_(int values[4])
      |                 ^
conftest.c:1:17: note: code may be misoptimized unless '-fno-strict-aliasing' is used
lto1: some warnings being treated as errors
lto-wrapper: fatal error: /usr/bin/x86_64-pc-linux-gnu-gfortran returned 1 exit status
compilation terminated.
/usr/lib/gcc/x86_64-pc-linux-gnu/12.1.1/../../../../x86_64-pc-linux-gnu/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
configure:35371: $? = 1
configure:35389: error: Could not link conftestf.o and conftest.o

Alessandro-Barbieri avatar Jul 24 '22 20:07 Alessandro-Barbieri

Thanks. #89 should fix it.

However, I would like to point out that using flag -Werror=lto-type-mismatch can be a problem for Fortran programs that make MPI calls. It turns the warning message of mismatched type into an error.

wkliao avatar Jul 25 '22 22:07 wkliao

This is the explanation on why we are doing this

-Werror=lto-type-mismatch:
User to find possible runtime issues in packages. It likely means the package
is unsafe to build & use with LTO.
For projects using the same identifier but with different types across
different files, they must be fixed to be consistent across the codebase.

Alessandro-Barbieri avatar Jul 26 '22 09:07 Alessandro-Barbieri

The problem with Fortran binding has been mentioned in MPI 4.0, Section 19.1.11 Problems Due to Strong Typing

wkliao avatar Jul 26 '22 20:07 wkliao

Fixed in #89

wkliao avatar Feb 11 '24 02:02 wkliao