Bug 2216808

Summary: cmake: FortranC.Flags test fails under GCC Toolset 12
Product: Red Hat Enterprise Linux 9 Reporter: Florian Weimer <fweimer>
Component: cmakeAssignee: Tom Stellard <tstellar>
Status: NEW --- QA Contact: qe-baseos-tools-bugs
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.3CC: sipoyare
Target Milestone: rcKeywords: Bugfix, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Florian Weimer 2023-06-22 17:06:04 UTC
Manually runnign the upstream testsuite from cmake-3.20.2-8.el9 under GCC Toolset 12

gcc-toolset-12-12.0-6.el9.x86_64
gcc-toolset-12-annobin-docs-11.08-2.el9.noarch
gcc-toolset-12-annobin-plugin-gcc-11.08-2.el9.x86_64
gcc-toolset-12-binutils-2.38-16.el9.x86_64
gcc-toolset-12-binutils-gold-2.38-16.el9.x86_64
gcc-toolset-12-dwz-0.14-4.el9.x86_64
gcc-toolset-12-gcc-12.2.1-7.4.el9.x86_64
gcc-toolset-12-gcc-c++-12.2.1-7.4.el9.x86_64
gcc-toolset-12-gcc-gfortran-12.2.1-7.4.el9.x86_64
gcc-toolset-12-gdb-11.2-4.el9.x86_64
gcc-toolset-12-libquadmath-devel-12.2.1-7.4.el9.x86_64
gcc-toolset-12-libstdc++-devel-12.2.1-7.4.el9.x86_64
gcc-toolset-12-runtime-12.0-6.el9.x86_64

results in a FortranC.Flags failure.  This happens with GCC 12 proper, too, and the following upstream patches are relevant:

commit 6a0ce19ce1cb594cdec19bacc9fc7a38156e38da
Author: Björn Esser <besser82>
Date:   Wed Jan 19 17:26:14 2022 +0100

    FortranCInterface: Fix compatibility with GCC gfortran 12 LTO
    
    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.
    
    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.
    
    Fixes: #23123
    
    Signed-off-by: Björn Esser <besser82>

commit cb616d43d6f0912f3b4ab61d210cebe42dbfffb3
Author: Brad King <brad.king>
Date:   Mon May 16 11:15:34 2022 -0400

    FortranCInterface: Fix failure with gfortran 12 and Clang
    
    The C flags added by commit 6a0ce19ce1 (FortranCInterface: Fix
    compatibility with GCC gfortran 12 LTO, 2022-01-19, v3.22.2~5^2)
    should only be added for the GNU C compiler.
    
    Fixes: #23500
    Issue: #23123

There are a bunch of other failures as well:

The following tests FAILED:
         39 - VSGNUFortran (Failed)
        121 - CustomCommand (Failed)
        135 - CPackComponentsForAll-RPM-IgnoreGroup (Failed)
        267 - Fortran (Failed)
        269 - FortranC.Flags (Failed)
        415 - RunCMake.PositionIndependentCode (Failed)
        542 - RunCMake.CPack_RPM.DEBUGINFO (Failed)
Errors while running CTest

I have not reproduced those under GCC 12 proper, so maybe they happen because “scl enable gcc-toolset-12 -- bash” results in some incompatibilities. Some of the failures are suppressed during the RPM build; I skipped that part.

(NB: gcc is not installed on this system.)