Bug 2041904 - Broken Fortran/C interface detection with gcc12
Summary: Broken Fortran/C interface detection with gcc12
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: cmake
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
high
Target Milestone: ---
Assignee: Björn 'besser82' Esser
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-01-18 13:49 UTC by Iñaki Ucar
Modified: 2022-01-19 22:05 UTC (History)
5 users (show)

Fixed In Version: cmake-3.22.1-6.fc36
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-01-19 22:05:25 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Iñaki Ucar 2022-01-18 13:49:48 UTC
Description of problem:

Fortran/C interface detection is broken when LTO is enabled under gcc12, which is in rawhide. cmake-based packages using this interface are currently FTBFS in rawhide (e.g.: https://koschei.fedoraproject.org/package/flexiblas?collection=f36).


How reproducible:

    $ cat << EOL > CMakeLists.txt
    PROJECT(F-C-MWE LANGUAGES C Fortran) 
    include(FortranCInterface)
    FortranCInterface_HEADER(FCMangle.h
                            MACRO_NAMESPACE "FC_"
                            SYMBOL_NAMESPACE "FC_"
                            SYMBOLS mysub mymod:my_sub)
    FortranCInterface_VERIFY()
    EOL

    $ mkdir -p build && cd build
    $ export FFLAGS='-flto'
    $ cmake ..


Actual results (some lines suppressed for legibility):

    -- Detecting Fortran/C Interface - Failed to recognize symbols
    CMake Warning (dev) at /usr/share/cmake/Modules/FortranCInterface.cmake:309 (message):
    No FortranCInterface mangling known for mysub

    CMake Warning (dev) at /usr/share/cmake/Modules/FortranCInterface.cmake:295 (message):
    No FortranCInterface mangling known for mymod:my_sub

    -- Verifying Fortran/C Compiler Compatibility
    CMake Warning (dev) at /usr/share/cmake/Modules/FortranCInterface.cmake:309 (message):
    No FortranCInterface mangling known for VerifyFortran

    -- Verifying Fortran/C Compiler Compatibility - Failed
    CMake Error at /usr/share/cmake/Modules/FortranCInterface.cmake:391 (message):

        /usr/bin/ld: /tmp/cclMYidY.ltrans0.ltrans.o: in function `main':
        /usr/share/cmake/Modules/FortranCInterface/Verify/main.c:14: undefined reference to `VerifyFortran'
        collect2: error: ld returned 1 exit status


Expected results: Detection succeeds.

Comment 1 Björn 'besser82' Esser 2022-01-19 16:50:48 UTC
Forwarded to upstream:  https://gitlab.kitware.com/cmake/cmake/-/issues/23123
Proposed PR to fix:     https://gitlab.kitware.com/cmake/cmake/-/merge_requests/6879

***

Update with temporary fix for Rawhide is on its way.

Comment 3 Fedora Update System 2022-01-19 21:25:01 UTC
FEDORA-2022-c4e3921010 has been submitted as an update to Fedora 36. https://bodhi.fedoraproject.org/updates/FEDORA-2022-c4e3921010

Comment 4 Fedora Update System 2022-01-19 22:05:25 UTC
FEDORA-2022-c4e3921010 has been pushed to the Fedora 36 stable repository.
If problem still persists, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.