2022-01-19 19:51:21 +00:00
|
|
|
From 6a0ce19ce1cb594cdec19bacc9fc7a38156e38da Mon Sep 17 00:00:00 2001
|
2022-01-19 17:14:46 +00:00
|
|
|
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <besser82@fedoraproject.org>
|
|
|
|
Date: Wed, 19 Jan 2022 17:26:14 +0100
|
|
|
|
Subject: [PATCH] FortranCInterface: Fix compatibility with GCC gfortran 12 LTO
|
|
|
|
MIME-Version: 1.0
|
|
|
|
Content-Type: text/plain; charset=UTF-8
|
|
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
|
|
|
|
Since version 12.0 the GCC Fortran compiler has implemented "WG5/N1942",
|
|
|
|
which causes, if link-time opmization is enabled, obfuscation of hard-coded
|
|
|
|
string values in the compiler objects and its resulting ELF-binaries.
|
|
|
|
|
|
|
|
This causes the CMake-internal detection of the mangling scheme for the
|
|
|
|
naming of subroutines to fail. Thus we must ensure to have any link-time
|
|
|
|
optimization features to be disabled on the executable file we perform the
|
|
|
|
detection on.
|
|
|
|
|
2022-01-19 19:51:21 +00:00
|
|
|
The static libraries, however, must be build with LTO and non-LTO objects,
|
|
|
|
as that will ensure the verify step will operate on IPO objects, if building
|
|
|
|
those is requested by the system compiler flags.
|
|
|
|
|
2022-01-19 17:14:46 +00:00
|
|
|
Fixes: #23123
|
|
|
|
|
|
|
|
Signed-off-by: Björn Esser <besser82@fedoraproject.org>
|
|
|
|
---
|
2022-01-19 19:51:21 +00:00
|
|
|
Modules/FortranCInterface/CMakeLists.txt | 13 +++++++++++++
|
|
|
|
1 file changed, 13 insertions(+)
|
2022-01-19 17:14:46 +00:00
|
|
|
|
|
|
|
diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt
|
2022-01-19 19:51:21 +00:00
|
|
|
index 13e4498ad9..ce0bc10c8e 100644
|
2022-01-19 17:14:46 +00:00
|
|
|
--- a/Modules/FortranCInterface/CMakeLists.txt
|
|
|
|
+++ b/Modules/FortranCInterface/CMakeLists.txt
|
2022-01-19 19:51:21 +00:00
|
|
|
@@ -102,6 +102,19 @@ set_property(TARGET symbols PROPERTY POSITION_INDEPENDENT_CODE 1)
|
|
|
|
add_executable(FortranCInterface main.F call_sub.f ${call_mod})
|
|
|
|
target_link_libraries(FortranCInterface PUBLIC symbols)
|
2022-01-19 17:14:46 +00:00
|
|
|
|
|
|
|
+# If IPO is enabled here, GCC gfortran >= 12.0 will obfuscate
|
|
|
|
+# the strings of the return values in the compiled executable,
|
|
|
|
+# which we use to regex match against later.
|
2022-01-19 19:51:21 +00:00
|
|
|
+# The static libraries must be build with IPO and non-IPO objects,
|
|
|
|
+# as that will ensure the verify step will operate on IPO objects,
|
|
|
|
+# if requested by the system compiler flags.
|
2022-01-19 17:14:46 +00:00
|
|
|
+if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" AND
|
|
|
|
+ CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 12)
|
2022-01-19 19:51:21 +00:00
|
|
|
+ target_compile_options(FortranCInterface PRIVATE "-fno-lto")
|
|
|
|
+ target_compile_options(myfort PRIVATE "-flto=auto" "-ffat-lto-objects")
|
|
|
|
+ target_compile_options(symbols PRIVATE "-flto=auto" "-ffat-lto-objects")
|
2022-01-19 17:14:46 +00:00
|
|
|
+endif()
|
|
|
|
+
|
2022-01-19 19:51:21 +00:00
|
|
|
file(GENERATE OUTPUT exe-$<CONFIG>.cmake CONTENT [[
|
|
|
|
set(FortranCInterface_EXE "$<TARGET_FILE:FortranCInterface>")
|
|
|
|
]])
|
2022-01-19 17:14:46 +00:00
|
|
|
--
|
|
|
|
2.34.1
|
|
|
|
|