Parallel-NetCDF / PnetCDF

Source code repository of PnetCDF library and utilities
https://parallel-netcdf.github.io
Other
80 stars 23 forks source link

configure fail with LTO #88

Closed Alessandro-Barbieri closed 7 months ago

Alessandro-Barbieri commented 2 years ago

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
wkliao commented 2 years ago

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.

Alessandro-Barbieri commented 2 years ago

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.
wkliao commented 2 years ago

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

wkliao commented 7 months ago

Fixed in #89