MantisBT - CMake
View Issue Details
0015673CMakeCMakepublic2015-07-30 11:582016-01-04 11:51
Xan López 
Brad King 
normalmajoralways
closedfixed 
CMake 3.2.3 
CMake 3.4CMake 3.4 
0015673: CMAKE_C_COMPILER is used to link a CXX shared library on Solaris
The SunOS.cmake file has the following:

if(CMAKE_COMPILER_IS_GNUCXX)
  if(CMAKE_COMPILER_IS_GNUCC)
    set(CMAKE_CXX_CREATE_SHARED_LIBRARY
        "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")


The end result is that CMAKE_C_COMPILER (gcc) is used to link C++ shared libraries in Solaris. This results in numerous errors. I assume this is just a typo, and the attached patch just fixes things for me.

This can be reproduced 100% of the time trying to compile LLVM/clang from SVN HEAD, LTO and clang libs will fail to compile.
No tags attached.
patch 0001-SunOS-use-CXX-compiler-to-link-CXX-shared-libraries.patch (1,095) 2015-07-30 11:58
https://public.kitware.com/Bug/file/5496/0001-SunOS-use-CXX-compiler-to-link-CXX-shared-libraries.patch
patch 0001-SunOS-drop-special-case-to-link-shared-libraries.patch (1,235) 2015-07-30 14:10
https://public.kitware.com/Bug/file/5498/0001-SunOS-drop-special-case-to-link-shared-libraries.patch
Issue History
2015-07-30 11:58Xan LópezNew Issue
2015-07-30 11:58Xan LópezFile Added: 0001-SunOS-use-CXX-compiler-to-link-CXX-shared-libraries.patch
2015-07-30 13:56Brad KingNote Added: 0039202
2015-07-30 13:56Brad KingAssigned To => Brad King
2015-07-30 13:56Brad KingStatusnew => assigned
2015-07-30 13:56Brad KingTarget Version => CMake 3.4
2015-07-30 13:58Brad KingNote Edited: 0039202bug_revision_view_page.php?bugnote_id=39202#r1854
2015-07-30 14:10Xan LópezNote Added: 0039203
2015-07-30 14:10Xan LópezFile Added: 0001-SunOS-drop-special-case-to-link-shared-libraries.patch
2015-07-30 14:24Brad KingNote Added: 0039206
2015-07-30 14:24Brad KingStatusassigned => resolved
2015-07-30 14:24Brad KingResolutionopen => fixed
2015-07-30 14:24Brad KingFixed in Version => CMake 3.4
2016-01-04 11:51Robert MaynardNote Added: 0040100
2016-01-04 11:51Robert MaynardStatusresolved => closed

Notes
(0039202)
Brad King   
2015-07-30 13:56   
(edited on: 2015-07-30 13:58)
It was not a typo. The change was first made here:

 ... Just use gcc -shared, even for C++ libraries.
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=284071e3 [^]

IIRC at the time g++ did not know how to link shared libraries on Sun. I'm sure that has long since been fixed so we can probably just drop the whole special case. Please try:

diff --git a/Modules/Platform/SunOS.cmake b/Modules/Platform/SunOS.cmake                                                                                                          

index aaa79c4..77946f2 100644                                                                                                                                                           

--- a/Modules/Platform/SunOS.cmake
+++ b/Modules/Platform/SunOS.cmake
@@ -7,14 +7,6 @@ if(CMAKE_SYSTEM MATCHES "SunOS-4")
    set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
 endif()
 
-if(CMAKE_COMPILER_IS_GNUCXX)
-  if(CMAKE_COMPILER_IS_GNUCC)
-    set(CMAKE_CXX_CREATE_SHARED_LIBRARY
-        "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS>  
<SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")

-  else()
-    # Take default rule from CMakeDefaultMakeRuleVariables.cmake.
-  endif()
-endif()
 include(Platform/UnixPaths)
 
 # Add the compiler's implicit link directories.


(0039203)
Xan López   
2015-07-30 14:10   
Yep, you are right, removing the whole thing has the same effect. Updated patch attached.
(0039206)
Brad King   
2015-07-30 14:24   
Thanks for testing. Actually I already had the commit ready on a branch locally. I've now pushed it out:

 SunOS: Drop special case for linking C++ shared libraries with gcc
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=60fe4b54 [^]
(0040100)
Robert Maynard   
2016-01-04 11:51   
Closing resolved issues that have not been updated in more than 4 months.