diff options
author | Brad King <brad.king@kitware.com> | 2010-01-13 13:13:46 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2010-01-13 13:13:46 (GMT) |
commit | 9ef3f8e82036a28c4f0375ec65eb25864a5240ca (patch) | |
tree | 89c769bbe521c239947893501bf43d7bab6545a6 | |
parent | 7b106a6fb3431774fb38e39e90a1147118f811a0 (diff) | |
download | CMake-9ef3f8e82036a28c4f0375ec65eb25864a5240ca.zip CMake-9ef3f8e82036a28c4f0375ec65eb25864a5240ca.tar.gz CMake-9ef3f8e82036a28c4f0375ec65eb25864a5240ca.tar.bz2 |
Restore -rdynamic in Linux build rules
The commit "Drop -rdynamic from Linux build rules" removed default use
of the flag on Linux. It was expected to be compatible because any
project using plugins should set ENABLE_EXPORTS on its executables to
export their symbols for use by the plugins in a cross-platform way.
However, it is possible to build without ENABLE_EXPORTS and load plugins
that do not link to any symbols from the executable explicitly. These
plugins may need to see RTTI and other executable symbols needed by the
language implementation. Executables using such plugins were broken by
the change.
If we want to remove the -rdynamic flag in the future we should do so in
a compatible way. At that time we should also remove equivalent flags
on other platforms (like -bexpall on AIX). We will either need a policy
or an explicit API to disable symbol exports on executables.
The primary purpose of the above-mentioned commit was to avoid passing
the -rdynamic flag to compilers on Linux that do not support it. In
this commit we restore the flag but only on GNU and Intel compilers
which are known to support it.
See issue #9985.
-rw-r--r-- | Modules/Platform/Linux-GNU.cmake | 3 | ||||
-rw-r--r-- | Modules/Platform/Linux-Intel.cmake | 4 |
2 files changed, 7 insertions, 0 deletions
diff --git a/Modules/Platform/Linux-GNU.cmake b/Modules/Platform/Linux-GNU.cmake index df6295b..d257f34 100644 --- a/Modules/Platform/Linux-GNU.cmake +++ b/Modules/Platform/Linux-GNU.cmake @@ -19,4 +19,7 @@ endif() set(__LINUX_COMPILER_GNU 1) macro(__linux_compiler_gnu lang) + # We pass this for historical reasons. Projects may have + # executables that use dlopen but do not set ENABLE_EXPORTS. + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic") endmacro() diff --git a/Modules/Platform/Linux-Intel.cmake b/Modules/Platform/Linux-Intel.cmake index 1474051..dff90e9 100644 --- a/Modules/Platform/Linux-Intel.cmake +++ b/Modules/Platform/Linux-Intel.cmake @@ -34,6 +34,10 @@ macro(__linux_compiler_intel lang) set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "-fPIC") set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-shared") + # We pass this for historical reasons. Projects may have + # executables that use dlopen but do not set ENABLE_EXPORTS. + set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic") + if(XIAR) # INTERPROCEDURAL_OPTIMIZATION set(CMAKE_${lang}_COMPILE_OPTIONS_IPO -ipo) |