View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0009985CMakeCMakepublic2009-12-01 14:232015-06-24 08:42
ReporterBrad King 
Assigned ToBrad King 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0009985: Linux.cmake should not hard-code -rdynamic
DescriptionThis 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.
TagsNo tags attached.
Attached Files

related to 0009798closedAlex Neundorf when setting toolchain.cmake, try_compile fails for gcc-fm where -rdynamic fails but -shared works 
related to 0009659closedBrad 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 

Brad King (manager)
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
Brad King (manager)
2009-12-02 09:46

The Linux builds on our dashboard look good after this fix.

I'll schedule it for 2.8.1.
Brad King (manager)
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.
Brad King (manager)
2010-01-12 17:15

It is likely that many projects already use the workaround mentioned in issue 0005833:


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.
Brad King (manager)
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
Brad King (manager)
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.

 Issue History
Date Modified Username Field Change
2009-12-01 14:23 Brad King New Issue
2009-12-01 14:23 Brad King Relationship added parent of 0009798
2009-12-01 14:24 Brad King Relationship replaced related to 0009798
2009-12-01 14:24 Brad King Status new => assigned
2009-12-01 14:24 Brad King Assigned To => Brad King
2009-12-01 14:26 Brad King Note Added: 0018625
2009-12-02 09:46 Brad King Note Added: 0018642
2009-12-02 09:46 Brad King Status assigned => closed
2009-12-02 09:46 Brad King Resolution open => fixed
2010-01-12 17:10 Brad King Note Added: 0019106
2010-01-12 17:10 Brad King Status closed => feedback
2010-01-12 17:10 Brad King Resolution fixed => reopened
2010-01-12 17:10 Brad King Relationship added related to 0009659
2010-01-12 17:11 Brad King Relationship added related to 0005833
2010-01-12 17:15 Brad King Note Added: 0019107
2010-01-13 08:14 Brad King Note Added: 0019113
2010-01-13 08:17 Brad King Note Added: 0019114
2010-01-13 08:17 Brad King Status feedback => closed
2010-01-13 08:17 Brad King Resolution reopened => fixed
2015-06-24 08:42 Brad King Relationship added related to 0015630

Copyright © 2000 - 2018 MantisBT Team