[cmake-developers] [CMake 0015872]: Programs with Fortran entry point (but calls into C) don't link correctly using Intel or PGI compilers
Mantis Bug Tracker
mantis at public.kitware.com
Sun Dec 6 23:39:31 EST 2015
The following issue has been SUBMITTED.
======================================================================
https://public.kitware.com/Bug/view.php?id=15872
======================================================================
Reported By: Ben Matthews
Assigned To:
======================================================================
Project: CMake
Issue ID: 15872
Category: CMake
Reproducibility: always
Severity: major
Priority: normal
Status: new
======================================================================
Date Submitted: 2015-12-06 21:39 MST
Last Modified: 2015-12-06 21:39 MST
======================================================================
Summary: Programs with Fortran entry point (but calls into C)
don't link correctly using Intel or PGI compilers
Description:
CMake always seems to link mixed language programs using the C++ compiler. Intel
and PGI link libcrt, which wants to have a main(). Programs with a Fortran entry
point typically won't have main(). Setting the linker_language property doesn't
seem to make a difference.
Using the GNU compilers, CMake still uses the C++ compiler, but it gets the
libraries right and everything works as expected.
Steps to Reproduce:
git clone https://github.com/matthb2/cmake_f90_entry_bug.git
cd cmake_f90_entry_bug
mkdir build
cd build
CC=icc CXX=icpc FC=ifort cmake ../
make
####
make
Scanning dependencies of target testprog
[ 50%] Building Fortran object CMakeFiles/testprog.dir/test.f90.o
[100%] Linking CXX executable testprog
/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.3/../../../../lib64/crt1.o: In function
`_start':
(.text+0x20): undefined reference to `main'
CMakeFiles/testprog.dir/build.make:94: recipe for target 'testprog' failed
make[2]: *** [testprog] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/testprog.dir/all' failed
make[1]: *** [CMakeFiles/testprog.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
Additional Information:
Note that the example code is a bit of a simplified/contrived example. It will
work fine if you remove the HAS_CXX property, but real cases also incorporate
C/C++ modules and require that libc/libstdc++ be present.
icc -V
Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64,
Version 13.0.0.079 Build 20120731
Copyright (C) 1985-2012 Intel Corporation. All rights reserved.
FOR NON-COMMERCIAL USE ONLY
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2015-12-06 21:39 Ben Matthews New Issue
======================================================================
More information about the cmake-developers
mailing list