MantisBT - CMake
View Issue Details
0009071CMakeCMakepublic2009-05-26 17:562009-06-01 11:08
Torsten Rohlfing 
Brad King 
normalmajoralways
closedfixed 
CMake-2-6 
 
0009071: gcc4 on cygwin may need extra link options, otherwise exception
When building under Cygwin using gcc4 (tested using gcc-4.3.2beta), some applications require an additional linker flag to work:

CMAKE_EXE_LINKER_FLAGS=-Wl,--enable-auto-import

It would be nice if CMake could auto-detect this combination of OS/compiler and pre-set this flag.

Some generated binaries run without using this flag during the build, but others generate "exception c0000005" (as displayed when running binary through "strace") before even entering main().

Sorry, but I can't provide a small test example. The technical background seems to be related to this issue though:

http://www.cygwin.com/ml/cygwin/2004-09/msg01101.html [^]

Noteworthy also:

- No problems using gcc-3.x.x, but eventually gcc-4 will probably supersede gcc-3 on cygwin (plus, gcc-4 provides OpenMP).

- The linker using gcc-4 actually provides a warning message saying that it auto-enabled "auto-importing", and it says under what circumstances that doesn't work. Probably applies here.
No tags attached.
Issue History
2009-05-26 17:56Torsten RohlfingNew Issue
2009-05-27 09:00Bill HoffmanStatusnew => assigned
2009-05-27 09:00Bill HoffmanAssigned To => Brad King
2009-05-27 11:34Brad KingNote Added: 0016581
2009-06-01 11:08Brad KingNote Added: 0016599
2009-06-01 11:08Brad KingStatusassigned => closed
2009-06-01 11:08Brad KingResolutionopen => fixed

Notes
(0016581)
Brad King   
2009-05-27 11:34   
It should be safe to just always put --enable-auto-import on exe link lines for Cygwin. It works with the older compiler too. We already do it when linking shared libraries.

ENH: Auto-import symbols for cygwin executables
/cvsroot/CMake/CMake/Modules/Platform/CYGWIN.cmake,v <-- Modules/Platform/CYGWIN.cmake
new revision: 1.21; previous revision: 1.20
/cvsroot/CMake/CMake/bootstrap,v <-- bootstrap
new revision: 1.118; previous revision: 1.117
(0016599)
Brad King   
2009-06-01 11:08   
I've scheduled this for inclusion in CMake 2.6.5.