FortranCInterface_VERIFY fails when LTO is used
Whole thread related to that issu is on https://sourceforge.net/p/wsjt/mailman/wsjt-devel/thread/CABB28Cz7Hd-X_E%3DLmakBOscaungvM7mE0db_wotey_LyOZW7WQ%40mail.gmail.com/#msg37306025
In wsjtx project uses FortranCInterface_VERIFY () macro and it fails when LTO is used
+ cd wsjtx-2.5.0-rc1
+ CFLAGS='-O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none'
+ CXXFLAGS='-O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none'
+ FFLAGS='-O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -I/usr/lib64/gfortran/modules'
+ FCFLAGS='-O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -I/usr/lib64/gfortran/modules'
+ LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,--gc-sections -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -flto=auto -flto-partition=none -fuse-linker-plugin'
+ CC=/usr/bin/gcc
+ CXX=/usr/bin/g++
+ FC=/usr/bin/gfortran
+ AR=/usr/bin/gcc-ar
+ NM=/usr/bin/gcc-nm
+ RANLIB=/usr/bin/gcc-ranlib
+ export CFLAGS CXXFLAGS FFLAGS FCFLAGS LDFLAGS CC CXX FC AR NM RANLIB
+ /usr/bin/cmake -B x86_64-redhat-linux-gnu -D BUILD_SHARED_LIBS=ON -D CMAKE_AR=/usr/bin/gcc-ar -D CMAKE_BUILD_TYPE=RelWithDebInfo -D CMAKE_C_FLAGS_RELEASE=-DNDEBUG -D CMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -D CMAKE_Fortran_FLAGS_RELEASE=-DNDEBUG -D CMAKE_INSTALL_PREFIX=/usr -D CMAKE_NM=/usr/bin/gcc-nm -D CMAKE_RANLIB=/usr/bin/gcc-ranlib -D CMAKE_VERBOSE_MAKEFILE=ON -D DBUILD_SHARED_LIBS=ON -D INCLUDE_INSTALL_DIR=/usr/include -D LIB_INSTALL_DIR=/usr/lib64 -D LIB_SUFFIX=64 -D SHARE_INSTALL_PREFIX=/usr/share -D SYSCONF_INSTALL_DIR=/etc -S . wsjtx -D hamlib_STATIC=FALSE -D Boost_NO_SYSTEM_PATHS=FALSE
-- The C compiler identification is GNU 11.1.1
-- The CXX compiler identification is GNU 11.1.1
-- The Fortran compiler identification is GNU 11.1.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/gcc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Check for working Fortran compiler: /usr/bin/gfortran - skipped
-- Checking whether /usr/bin/gfortran supports Fortran 90
-- Checking whether /usr/bin/gfortran supports Fortran 90 - yes
-- ******************************************************
-- Building for for: Linux-x86_64
-- ******************************************************
-- Building wsjtx v2.5.0.0-rc1
-- Looking for 4 include files stdlib.h, ..., float.h
-- Looking for 4 include files stdlib.h, ..., float.h - found
-- Looking for include file stdio.h
-- Looking for include file stdio.h - found
-- Looking for include file stdlib.h
-- Looking for include file stdlib.h - found
-- Looking for include file unistd.h
-- Looking for include file unistd.h - found
-- Looking for include file sys/ioctl.h
-- Looking for include file sys/ioctl.h - found
-- Looking for include file sys/types.h
-- Looking for include file sys/types.h - found
-- Looking for include file fcntl.h
-- Looking for include file fcntl.h - found
-- Looking for include file sys/stat.h
-- Looking for include file sys/stat.h - found
-- Looking for include files linux/ppdev.h, linux/parport.h
-- Looking for include files linux/ppdev.h, linux/parport.h - found
-- Looking for include files dev/ppbus/ppi.h, dev/ppbus/ppbconf.h
-- Looking for include files dev/ppbus/ppi.h, dev/ppbus/ppbconf.h - not found
-- Performing Test HAVE_MATH
-- Performing Test HAVE_MATH - Success
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found Boost: /usr/include (found suitable version "1.75.0", minimum required is "1.62") found components: log_setup log date_time filesystem thread regex chrono atomic
-- Found OpenMP_C: -fopenmp (found version "4.5")
-- Found OpenMP_CXX: -fopenmp (found version "4.5")
-- Found OpenMP_Fortran: -fopenmp (found version "4.5")
-- Found OpenMP: TRUE (found version "4.5")
-- Found FFTW3: /usr/lib64/libfftw3f_threads.so
-- Found Usb
-- Found Hamlib 4.2
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of CACHE_ALL
-- Check size of CACHE_ALL - failed
-- Looking for rig_set_cache_timeout_ms
-- Looking for rig_set_cache_timeout_ms - not found
-- Found Portaudio 19
-- Detecting Fortran/C Interface
-- Detecting Fortran/C Interface - Failed to recognize symbols
-- Verifying Fortran/CXX Compiler Compatibility
CMake Warning (dev) at /usr/share/cmake/Modules/FortranCInterface.cmake:309 (message):
No FortranCInterface mangling known for VerifyFortran
Call Stack (most recent call first):
/usr/share/cmake/Modules/FortranCInterface/Verify/CMakeLists.txt:16 (FortranCInterface_HEADER)
This warning is for project developers. Use -Wno-dev to suppress it.
-- Verifying Fortran/CXX Compiler Compatibility - Failed
CMake Error at /usr/share/cmake/Modules/FortranCInterface.cmake:391 (message):
The Fortran compiler:
/usr/bin/gfortran
and the CXX compiler:
/usr/bin/g++
failed to compile a simple test project using both languages. The output
was:
Change Dir: /home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX
Run Build Command(s):/usr/bin/gmake -f Makefile VerifyFortranC && /usr/bin/cmake -S/usr/share/cmake/Modules/FortranCInterface/Verify -B/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/gmake -f CMakeFiles/Makefile2 VerifyFortranC
gmake[1]: Entering directory '/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX'
/usr/bin/cmake -S/usr/share/cmake/Modules/FortranCInterface/Verify -B/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX/CMakeFiles 6
/usr/bin/gmake -f CMakeFiles/Makefile2 CMakeFiles/VerifyFortranC.dir/all
gmake[2]: Entering directory '/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX'
/usr/bin/gmake -f CMakeFiles/VerifyFortran.dir/build.make CMakeFiles/VerifyFortran.dir/depend
gmake[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX'
cd /home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /usr/share/cmake/Modules/FortranCInterface/Verify /usr/share/cmake/Modules/FortranCInterface/Verify /home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX /home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX /home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX/CMakeFiles/VerifyFortran.dir/DependInfo.cmake
Scanning dependencies of target VerifyFortran
gmake[3]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX'
/usr/bin/gmake -f CMakeFiles/VerifyFortran.dir/build.make CMakeFiles/VerifyFortran.dir/build
gmake[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX'
[ 16%] Building Fortran object CMakeFiles/VerifyFortran.dir/VerifyFortran.f.o
/usr/bin/gfortran -DVERIFY_CXX -I/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -I/usr/lib64/gfortran/modules -DNDEBUG -fbounds-check -funroll-all-loops -fno-f2c -ffpe-summary=invalid,zero,overflow,underflow -Wall -Wno-conversion -fno-second-underscore -c /usr/share/cmake/Modules/FortranCInterface/Verify/VerifyFortran.f -o CMakeFiles/VerifyFortran.dir/VerifyFortran.f.o
f951: Warning: '-Werror=' argument '-Werror=format-security' is not valid for Fortran
[ 33%] Linking Fortran static library libVerifyFortran.a
/usr/bin/cmake -P CMakeFiles/VerifyFortran.dir/cmake_clean_target.cmake
/usr/bin/cmake -E cmake_link_script CMakeFiles/VerifyFortran.dir/link.txt --verbose=1
/usr/bin/gcc-ar qc libVerifyFortran.a CMakeFiles/VerifyFortran.dir/VerifyFortran.f.o
/usr/bin/gcc-ranlib libVerifyFortran.a
gmake[3]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX'
[ 33%] Built target VerifyFortran
/usr/bin/gmake -f CMakeFiles/VerifyFortranC.dir/build.make CMakeFiles/VerifyFortranC.dir/depend
gmake[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX'
cd /home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /usr/share/cmake/Modules/FortranCInterface/Verify /usr/share/cmake/Modules/FortranCInterface/Verify /home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX /home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX /home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX/CMakeFiles/VerifyFortranC.dir/DependInfo.cmake
Scanning dependencies of target VerifyFortranC
gmake[3]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX'
/usr/bin/gmake -f CMakeFiles/VerifyFortranC.dir/build.make CMakeFiles/VerifyFortranC.dir/build
gmake[3]: Entering directory '/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX'
[ 50%] Building C object CMakeFiles/VerifyFortranC.dir/main.c.o
/usr/bin/gcc -DVERIFY_CXX -I/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -Wall -Wextra -fopenmp -pthread -DNDEBUG -fdata-sections -ffunction-sections -o CMakeFiles/VerifyFortranC.dir/main.c.o -c /usr/share/cmake/Modules/FortranCInterface/Verify/main.c
[ 66%] Building C object CMakeFiles/VerifyFortranC.dir/VerifyC.c.o
/usr/bin/gcc -DVERIFY_CXX -I/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -Wall -Wextra -fopenmp -pthread -DNDEBUG -fdata-sections -ffunction-sections -o CMakeFiles/VerifyFortranC.dir/VerifyC.c.o -c /usr/share/cmake/Modules/FortranCInterface/Verify/VerifyC.c
[ 83%] Building CXX object CMakeFiles/VerifyFortranC.dir/VerifyCXX.cxx.o
/usr/bin/g++ -DVERIFY_CXX -I/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -Werror -Wall -Wextra -fexceptions -frtti -Wno-pragmas -fopenmp --std=gnu++11 -pthread -DNDEBUG -fdata-sections -ffunction-sections -o CMakeFiles/VerifyFortranC.dir/VerifyCXX.cxx.o -c /usr/share/cmake/Modules/FortranCInterface/Verify/VerifyCXX.cxx
[100%] Linking CXX executable VerifyFortranC
/usr/bin/cmake -E cmake_link_script CMakeFiles/VerifyFortranC.dir/link.txt --verbose=1
/usr/bin/g++ -O2 -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fdata-sections -ffunction-sections -flto=auto -flto-partition=none -Werror -Wall -Wextra -fexceptions -frtti -Wno-pragmas -fopenmp --std=gnu++11 -pthread -DNDEBUG -fdata-sections -ffunction-sections -Wl,-z,relro -Wl,--as-needed -Wl,--gc-sections -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -flto=auto -flto-partition=none -fuse-linker-plugin CMakeFiles/VerifyFortranC.dir/main.c.o CMakeFiles/VerifyFortranC.dir/VerifyC.c.o CMakeFiles/VerifyFortranC.dir/VerifyCXX.cxx.o -o VerifyFortranC libVerifyFortran.a -lgfortran -lquadmath
/usr/bin/ld: /usr/bin/ld: DWARF error: invalid abstract instance DIE ref
/tmp/ccWzjZCF.lto.o: in function `main':
<artificial>:(.text.startup.main[.text.startup.main.group]+0x15): undefined reference to `VerifyFortran'
collect2: error: ld returned 1 exit status
gmake[3]: *** [CMakeFiles/VerifyFortranC.dir/build.make:130: VerifyFortranC] Error 1
gmake[3]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX'
gmake[2]: *** [CMakeFiles/Makefile2:88: CMakeFiles/VerifyFortranC.dir/all] Error 2
gmake[2]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX'
gmake[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/VerifyFortranC.dir/rule] Error 2
gmake[1]: Leaving directory '/home/tkloczko/rpmbuild/BUILD/wsjtx-2.5.0-rc1/x86_64-redhat-linux-gnu/CMakeFiles/FortranCInterface/VerifyCXX'
gmake: *** [Makefile:127: VerifyFortranC] Error 2
Call Stack (most recent call first):
CMakeLists.txt:1003 (FortranCInterface_VERIFY)