Bug #72352 Provide option to link against libCstd instead of stlport4 on Solaris 10+
Submitted: 15 Apr 2014 17:29 Modified: 18 Jun 2014 12:45
Reporter: Valeriy Kravchuk Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.6.14+, 5.6.18, 5.7.4 OS:Solaris
Assigned to: Tor Didriksen CPU Architecture:Any
Tags: cmake, libCstd, MySQL, regression, stlport4

[15 Apr 2014 17:29] Valeriy Kravchuk
Description:
It seems MySQL 5.6 does not provide any easy way to link against libCstd even for mysql client. This is what I see in cmake/build_configurations/compiler_options.cmake:

  # Solaris flags
  IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
    IF(CMAKE_SYSTEM_VERSION VERSION_GREATER "5.9")
      # Link mysqld with mtmalloc on Solaris 10 and later
      SET(WITH_MYSQLD_LDFLAGS "-lmtmalloc" CACHE STRING "")
    ENDIF()
    IF(CMAKE_C_COMPILER_ID MATCHES "SunPro")
      IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i386")
        SET(COMMON_C_FLAGS                   "-g -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -xlibmil -xlibmopt -xtarget=generic")
        SET(COMMON_CXX_FLAGS                 "-g0 -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -xlibmil -xlibmopt -xtarget=generic -library=stlport4")
        # We have to specify "-xO1" for DEBUG flags here,
        # see http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6879978
        SET(CMAKE_C_FLAGS_DEBUG              "-xO1 ${COMMON_C_FLAGS}")
        SET(CMAKE_CXX_FLAGS_DEBUG            "-xO1 ${COMMON_CXX_FLAGS}")
        IF(32BIT)
          SET(CMAKE_C_FLAGS_RELWITHDEBINFO   "-xO2 ${COMMON_C_FLAGS}")
          SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO2 ${COMMON_CXX_FLAGS}")
        ELSEIF(64BIT)
          SET(CMAKE_C_FLAGS_RELWITHDEBINFO   "-xO3 ${COMMON_C_FLAGS}")
          SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_CXX_FLAGS}")
        ENDIF()
      ELSE()
        # Assume !x86 is SPARC
        SET(COMMON_C_FLAGS                 "-g -Xa -xstrconst -mt")
        SET(COMMON_CXX_FLAGS               "-g0 -mt -library=stlport4")
        IF(32BIT)
          SET(COMMON_C_FLAGS               "${COMMON_C_FLAGS} -xarch=sparc")
          SET(COMMON_CXX_FLAGS             "${COMMON_CXX_FLAGS} -xarch=sparc")
        ENDIF()
        SET(CMAKE_C_FLAGS_DEBUG            "${COMMON_C_FLAGS}")
        SET(CMAKE_CXX_FLAGS_DEBUG          "${COMMON_CXX_FLAGS}")
        SET(CMAKE_C_FLAGS_RELWITHDEBINFO   "-xO3 ${COMMON_C_FLAGS}")
        SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_CXX_FLAGS}")
      ENDIF()
    ENDIF()
  ENDIF()

stlport4 seems to be "hardcoded" in some other places in the source code as well:

openxs@ao756:~/bzr/mysql-5.6$ grep -rn stlport4 *
cmake/readline.cmake:103: # /opt/studio12u2/lib/stlport4/v9/libstlport.so.1
cmake/build_configurations/compiler_options.cmake:98: SET(COMMON_CXX_FLAGS "-g0 -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -xlibmil -xlibmopt -xtarget=generic -library=stlport4")
cmake/build_configurations/compiler_options.cmake:113: SET(COMMON_CXX_FLAGS "-g0 -mt -library=stlport4")
configure.cmake:85: "${CMAKE_CXX_FLAGS} -library=stlport4")
configure.cmake:95: SET(STLPORT_SUFFIX "lib/stlport4")
configure.cmake:97: SET(STLPORT_SUFFIX "lib/stlport4/v9")
configure.cmake:100: SET(STLPORT_SUFFIX "lib/stlport4/amd64")
mysql-test/lib/My/SafeProcess/CMakeLists.txt:29: STRING(REPLACE " -library=stlport4" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
mysql-test/lib/My/SafeProcess/CMakeLists.txt:30: STRING(REPLACE " -library=stlport4" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
mysql-test/lib/My/SafeProcess/CMakeLists.txt:31: STRING(REPLACE " -library=stlport4" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
openxs@ao756:~/bzr/mysql-5.6$

Users may have some reasons to want to link at least mysql client with libCstd. I do not see stlport4 hardcoded in MySQL 5.5, for example. 

Please, provide some easy way to configure cmake to do this kind of a build.

How to repeat:
Try to build only mysql client from MySQL 5.6.x linked with libCstd instead of stlport4 on Solaris.

Suggested fix:
Either provide a way to select libCstd via cmake settings/options or document in the manual (http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html maybe) why all/some binaries from MySQL 5.6 can not be built with libCstd on Solaris and how to built this way those binaries that can work with this library.
[16 Apr 2014 7:18] Umesh Shastry
Hello Valeriy,

Thank you for the report.
Verified as described.

Thanks,
Umesh
[18 Jun 2014 12:45] Paul Dubois
Noted in 5.6.20, 5.7.5 changelogs.

A new CMake option, SUNPRO_CXX_LIBRARY, enables linking against
libCstd instead of stlport4 on Solaris 10 or later. This works only
for client code because the server depends on C++98. Example usage:

cmake -DWITHOUT_SERVER=1 -DSUNPRO_CXX_LIBRARY=Cstd
[7 Aug 2014 5:13] Laurynas Biveinis
$ bzr log -n0 -r 5960
------------------------------------------------------------
revno: 5960
committer: Tor Didriksen <tor.didriksen@oracle.com>
branch nick: 5.6-cmake
timestamp: Fri 2014-05-23 12:50:24 +0200
message:
  Bug#18605389 PROVIDE OPTION TO LINK AGAINST LIBCSTD INSTEAD OF STLPORT4 ON SOLARIS 10+
  Bug#72352    Provide option to link against libCstd instead of stlport4 on Solaris 10+
  
  Patch for 5.6
  This patch enables the use of Cstd when building with SunStudio.
  It only works for client code, as the server depends on C++98
  Usage:
  cmake -DWITHOUT_SERVER=1 -DSUNPRO_CXX_LIBRARY=Cstd
  
  Also backport:
  Bug#14367046: PROBLEM BUILDING CLIENT ONLY