MantisBT - CMake
View Issue Details
0009985CMakeCMakepublic2009-12-01 14:232015-06-24 08:42
Brad King 
Brad King 
normalmajoralways
closedfixed 
 
 
0009985: Linux.cmake should not hard-code -rdynamic
This GNU-specific flag breaks non-GNU compilers on Linux. Several compiler-specific Linux platform files already erase the flag setting, but it always creates trouble for folks trying new compilers.
No tags attached.
related to 0009798closed Alex Neundorf when setting toolchain.cmake, try_compile fails for gcc-fm where -rdynamic fails but -shared works 
related to 0009659closed Brad King Executables should not be linked with shared library compilation flags 
related to 0005833closed  Executables are created with -rdynamic by default on Linux 
related to 0015630closed  ENABLE_EXPORTS value is not used for gcc makefile -rdynamic option 
Issue History
2009-12-01 14:23Brad KingNew Issue
2009-12-01 14:23Brad KingRelationship addedparent of 0009798
2009-12-01 14:24Brad KingRelationship replacedrelated to 0009798
2009-12-01 14:24Brad KingStatusnew => assigned
2009-12-01 14:24Brad KingAssigned To => Brad King
2009-12-01 14:26Brad KingNote Added: 0018625
2009-12-02 09:46Brad KingNote Added: 0018642
2009-12-02 09:46Brad KingStatusassigned => closed
2009-12-02 09:46Brad KingResolutionopen => fixed
2010-01-12 17:10Brad KingNote Added: 0019106
2010-01-12 17:10Brad KingStatusclosed => feedback
2010-01-12 17:10Brad KingResolutionfixed => reopened
2010-01-12 17:10Brad KingRelationship addedrelated to 0009659
2010-01-12 17:11Brad KingRelationship addedrelated to 0005833
2010-01-12 17:15Brad KingNote Added: 0019107
2010-01-13 08:14Brad KingNote Added: 0019113
2010-01-13 08:17Brad KingNote Added: 0019114
2010-01-13 08:17Brad KingStatusfeedback => closed
2010-01-13 08:17Brad KingResolutionreopened => fixed
2015-06-24 08:42Brad KingRelationship addedrelated to 0015630

Notes
(0018625)
Brad King   
2009-12-01 14:26   
The following commit addresses this issue:

---------------------------------------------------------------------------
Drop -rdynamic from Linux build rules

This is a GNU-specific option that should not be specified for all
compilers on Linux. It tells the GNU compiler to pass -export-dynamic
to the linker to export symbols from executables for use by plugins.
Since we provide the ENABLE_EXPORTS target property to do the same thing
in a cross-platform way, there is no need to pass -rdynamic always.

Since the option is not useful for GNU tools and breaks other tools on
Linux we simply remove it from CMAKE_SHARED_LIBRARY_LINK_<lang>_FLAGS.
This also allows us to stop setting the variable in other Linux compiler
files just to erase the bad flag.
---------------------------------------------------------------------------

/cvsroot/CMake/CMake/Modules/Compiler/SunPro-C.cmake,v <-- Modules/Compiler/SunPro-C.cmake
new revision: 1.3; previous revision: 1.2
/cvsroot/CMake/CMake/Modules/Compiler/SunPro-CXX.cmake,v <-- Modules/Compiler/SunPro-CXX.cmake
new revision: 1.3; previous revision: 1.2
/cvsroot/CMake/CMake/Modules/Compiler/SunPro-Fortran.cmake,v <-- Modules/Compiler/SunPro-Fortran.cmake
new revision: 1.3; previous revision: 1.2
/cvsroot/CMake/CMake/Modules/Platform/GNU.cmake,v <-- Modules/Platform/GNU.cmake
new revision: 1.2; previous revision: 1.1
/cvsroot/CMake/CMake/Modules/Platform/Linux-PGI-C.cmake,v <-- Modules/Platform/Linux-PGI-C.cmake
new revision: 1.3; previous revision: 1.2
/cvsroot/CMake/CMake/Modules/Platform/Linux-PGI-CXX.cmake,v <-- Modules/Platform/Linux-PGI-CXX.cmake
new revision: 1.3; previous revision: 1.2
/cvsroot/CMake/CMake/Modules/Platform/Linux-PGI-Fortran.cmake,v <-- Modules/Platform/Linux-PGI-Fortran.cmake
new revision: 1.3; previous revision: 1.2
/cvsroot/CMake/CMake/Modules/Platform/Linux-XL-C.cmake,v <-- Modules/Platform/Linux-XL-C.cmake
new revision: 1.3; previous revision: 1.2
/cvsroot/CMake/CMake/Modules/Platform/Linux-XL-CXX.cmake,v <-- Modules/Platform/Linux-XL-CXX.cmake
new revision: 1.3; previous revision: 1.2
/cvsroot/CMake/CMake/Modules/Platform/Linux-XL-Fortran.cmake,v <-- Modules/Platform/Linux-XL-Fortran.cmake
new revision: 1.3; previous revision: 1.2
/cvsroot/CMake/CMake/Modules/Platform/Linux-como.cmake,v <-- Modules/Platform/Linux-como.cmake
new revision: 1.6; previous revision: 1.5
/cvsroot/CMake/CMake/Modules/Platform/Linux.cmake,v <-- Modules/Platform/Linux.cmake
new revision: 1.20; previous revision: 1.19
(0018642)
Brad King   
2009-12-02 09:46   
The Linux builds on our dashboard look good after this fix.

I'll schedule it for 2.8.1.
(0019106)
Brad King   
2010-01-12 17:10   
We need to export symbols from any executable on Linux that uses dlopen() even if we do not export an API explicitly. The compiler may need RTTI symbols as an implementation detail. Furthermore, we still pass export flags when linking executables on other platforms. If we want to do change behavior on Linux we should do it on all platforms at once.
(0019107)
Brad King   
2010-01-12 17:15   
It is likely that many projects already use the workaround mentioned in issue 0005833:

  SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
  SET(CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")

to erase -rdynamic. Restoring the flag to match 2.8.0 behavior will have to be done in this variable, but only on compilers known to support it.
(0019113)
Brad King   
2010-01-13 08:14   
I've committed changes to restore -rdynamic.

Create Linux GNU compiler flag consolidation macro
/cvsroot/CMake/CMake/Modules/Platform/Linux-GNU-C.cmake,v <-- Modules/Platform/Linux-GNU-C.cmake
initial revision: 1.1
/cvsroot/CMake/CMake/Modules/Platform/Linux-GNU-CXX.cmake,v <-- Modules/Platform/Linux-GNU-CXX.cmake
initial revision: 1.1
/cvsroot/CMake/CMake/Modules/Platform/Linux-GNU-Fortran.cmake,v <-- Modules/Platform/Linux-GNU-Fortran.cmake
new revision: 1.4; previous revision: 1.3
/cvsroot/CMake/CMake/Modules/Platform/Linux-GNU.cmake,v <-- Modules/Platform/Linux-GNU.cmake
initial revision: 1.1

Restore -rdynamic in Linux build rules
/cvsroot/CMake/CMake/Modules/Platform/Linux-GNU.cmake,v <-- Modules/Platform/Linux-GNU.cmake
new revision: 1.2; previous revision: 1.1
/cvsroot/CMake/CMake/Modules/Platform/Linux-Intel.cmake,v <-- Modules/Platform/Linux-Intel.cmake
new revision: 1.4; previous revision: 1.3
(0019114)
Brad King   
2010-01-13 08:17   
I'm closing this because Linux.cmake no longer hard-codes -rdynamic and prior behavior for compilers that support it is preserved. If we want to avoid exporting symbols from executables that is a separate issue that should be tackled on all platforms at once.