Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
CMake
CMake
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,189
    • Issues 3,189
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 15
    • Merge Requests 15
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • CI / CD
    • Repository
    • Value Stream
  • External Wiki
    • External Wiki
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • CMake
  • CMakeCMake
  • Issues
  • #21454

Closed
Open
Opened Nov 18, 2020 by Ronald Rahaman@RonRahaman

FortranCInterface: Detection fails on macOS 11 with Homebrew GCC 10

A follow-up from Discourse. I've attached a tarball of the CMakeLists/ for a tiny project that demonstrates the problem: CMakeFiles.tar.gz

FortranCInterface_VERIFY isn’t working on my Mac after an OS and compiler updates. I’m running on macOS 11 with gcc-10 from Homebrew and cmake 3.18. Here are some of the relevant errors from stdout:

-- Detecting Fortran/C Interface
Failed to compile
-- Verifying Fortran/C Compiler Compatibility
Failed to compile
CMake Warning (dev) at /usr/local/Cellar/cmake/3.18.4/share/cmake/Modules/FortranCInterface.cmake:309 (message):
  No FortranCInterface mangling known for VerifyFortran
Call Stack (most recent call first):
  /usr/local/Cellar/cmake/3.18.4/share/cmake/Modules/FortranCInterface/Verify/CMakeLists.txt:16 (FortranCInterface_HEADER)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Verifying Fortran/C Compiler Compatibility - Failed
CMake Error at /usr/local/Cellar/cmake/3.18.4/share/cmake/Modules/FortranCInterface.cmake:383 (message):
  The Fortran compiler:

    /usr/local/bin/gfortran-10

  and the C compiler:

    /usr/local/bin/gcc-10

  failed to compile a simple test project using both languages.  The output
  was:

****** A BUNCH OF STUFF ****

    /usr/local/bin/gcc-10 -O3 -DNDEBUG -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names CMakeFiles/VerifyFortranC.dir/main.c.o CMakeFiles/VerifyFortranC.dir/VerifyC.c.o -o VerifyFortranC  libVerifyFortran.a -lgfortran -lquadmath -lm
    ld: warning: ignoring file libVerifyFortran.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
    Undefined symbols for architecture x86_64:
      "_VerifyFortran", referenced from:
          _main in main.c.o
    ld: symbol(s) not found for architecture x86_64
    collect2: error: ld returned 1 exit status

I did some detective work as saw that the name-mangling was indeed wrong.

$ nm CMakeFiles/FortranCInterface/VerifyC/libVerifyFortran.a
VerifyFortran.f.o:
00000000000000d0 r EH_frame1
                 U __gfortran_st_write
                 U __gfortran_st_write_done
                 U __gfortran_transfer_character_write
0000000000000000 T _verifyfortran_
0000000000000058 r lC0
00000000000000c8 r lC1
00000000000000b8 r lC2

$ nm CMakeFiles/FortranCInterface/VerifyC/CMakeFiles/VerifyFortranC.dir/main.c.o
0000000000000018 r EH_frame1
                 U _VerifyC
                 U _VerifyFortran
0000000000000000 T _main

$ cat ./CMakeFiles/FortranCInterface/VerifyC/VerifyFortran.h
#ifndef FortranCInterface_HEADER_INCLUDED
#define FortranCInterface_HEADER_INCLUDED

/*--------------------------------------------------------------------------*/
/* Mangle some symbols automatically.                                       */

#endif
Edited Nov 18, 2020 by Brad King
To upload designs, you'll need to enable LFS and have admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None
Reference: cmake/cmake#21454