Skip to content

Commit

Permalink
Bug#23344916 ADAPT TO GCC 5.3 ON SOLARIS
Browse files Browse the repository at this point in the history
Our cmake scripts tries to hide (visibility=hidden) certain symbols.
The current approach is wrong, and gives link problems with gcc 5.3 on
Solaris.

Fix:
Do not compile entire source files with visibility hidden,
that makes *all* symbols in the compilation unit hidden.

Rather: tag the desired symbols with __attribute__((visibility("hidden")))
  • Loading branch information
Tor Didriksen committed May 30, 2016
1 parent 8e654a0 commit 557f95e
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 21 deletions.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Expand Up @@ -248,6 +248,8 @@ MACRO (MY_CHECK_C_COMPILER_FLAG FLAG RESULT)
FAIL_REGEX "unrecognized .*option"
FAIL_REGEX "ignoring unknown option"
FAIL_REGEX "[Ww]arning: [Oo]ption"
FAIL_REGEX "error: visibility"
FAIL_REGEX "warning: visibility"
)
SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
ENDMACRO()
Expand All @@ -262,6 +264,8 @@ MACRO (MY_CHECK_CXX_COMPILER_FLAG FLAG RESULT)
FAIL_REGEX "unrecognized .*option"
FAIL_REGEX "ignoring unknown option"
FAIL_REGEX "[Ww]arning: [Oo]ption"
FAIL_REGEX "error: visibility"
FAIL_REGEX "warning: visibility"
)
SET(CMAKE_REQUIRED_FLAGS "${SAVE_CMAKE_REQUIRED_FLAGS}")
ENDMACRO()
Expand Down
12 changes: 0 additions & 12 deletions cmake/libutils.cmake
Expand Up @@ -291,15 +291,3 @@ FUNCTION(GET_DEPENDEND_OS_LIBS target result)
ENDIF()
SET(${result} ${ret} PARENT_SCOPE)
ENDFUNCTION()

INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake)

FUNCTION(RESTRICT_SYMBOL_SOURCE target)
IF(CMAKE_COMPILER_IS_GNUCXX AND UNIX)
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror")
CHECK_C_COMPILER_FLAG("-fvisibility=hidden" HAVE_VISIBILITY_HIDDEN)
IF(HAVE_VISIBILITY_HIDDEN)
ADD_COMPILE_FLAGS(${target} COMPILE_FLAGS "-fvisibility=hidden")
ENDIF()
ENDIF()
ENDFUNCTION()
3 changes: 3 additions & 0 deletions config.h.cmake
Expand Up @@ -182,6 +182,9 @@
#cmakedefine HAVE_U_INT32_T 1
#cmakedefine HAVE_STRUCT_TIMESPEC

/* Support for tagging symbols with __attribute__((visibility("hidden"))) */
#cmakedefine HAVE_VISIBILITY_HIDDEN 1

/* Code tests*/
#cmakedefine STACK_DIRECTION @STACK_DIRECTION@
#cmakedefine TIME_WITH_SYS_TIME 1
Expand Down
3 changes: 3 additions & 0 deletions configure.cmake
Expand Up @@ -620,6 +620,9 @@ ENDIF()

SET(CMAKE_EXTRA_INCLUDE_FILES)

# Support for tagging symbols with __attribute__((visibility("hidden")))
MY_CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" HAVE_VISIBILITY_HIDDEN)

#
# Code tests
#
Expand Down
14 changes: 11 additions & 3 deletions include/sha1.h
@@ -1,7 +1,7 @@
#ifndef SHA1_INCLUDED
#define SHA1_INCLUDED

/* Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
/* Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand All @@ -21,9 +21,17 @@

C_MODE_START

void compute_sha1_hash(uint8 *digest, const char *buf, size_t len);
void compute_sha1_hash(uint8 *digest, const char *buf, size_t len)
#if defined(HAVE_VISIBILITY_HIDDEN)
MY_ATTRIBUTE((visibility("hidden")))
#endif
;
void compute_sha1_hash_multi(uint8 *digest, const char *buf1, int len1,
const char *buf2, int len2);
const char *buf2, int len2)
#if defined(HAVE_VISIBILITY_HIDDEN)
MY_ATTRIBUTE((visibility("hidden")))
#endif
;

C_MODE_END

Expand Down
2 changes: 2 additions & 0 deletions libevent/CMakeLists.txt
Expand Up @@ -19,6 +19,8 @@ ADD_DEFINITIONS(-DHAVE_CONFIG_H)
INCLUDE_DIRECTORIES(${LIBEVENT_INCLUDE_DIR}/compat/sys
${LIBEVENT_INCLUDE_DIR})

INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/compile_flags.cmake)

IF ( WIN32 )
INCLUDE_DIRECTORIES(${LIBEVENT_INCLUDE_DIR}/WIN32-Code
${LIBEVENT_INCLUDE_DIR}/compat)
Expand Down
2 changes: 0 additions & 2 deletions mysys_ssl/CMakeLists.txt
Expand Up @@ -50,8 +50,6 @@ IF(WIN32 AND NOT WITH_SSL STREQUAL "bundled")
ENDIF()
DTRACE_INSTRUMENT(mysys_ssl)

RESTRICT_SYMBOL_SOURCE("my_sha1.cc")

IF(MSVC)
INSTALL_DEBUG_TARGET(mysys_ssl DESTINATION ${INSTALL_LIBDIR}/debug)
ENDIF()
Expand Down
2 changes: 0 additions & 2 deletions rapid/plugin/x/CMakeLists.txt
Expand Up @@ -143,8 +143,6 @@ ELSE()
LINK_LIBRARIES xplugin ${xplugin_PROTOBUF_LIB}
MODULE_ONLY MODULE_OUTPUT_NAME "mysqlx")

RESTRICT_SYMBOL_SOURCE("${MYSQLX_PROJECT_DIR}/ngs/src/mysql41_hash.cc")

ADD_DEPENDENCIES(xplugin GenError)
IF (WITH_LIBEVENT STREQUAL "bundled")
ADD_DEPENDENCIES(xplugin ${LIBEVENT_LIBRARY})
Expand Down
12 changes: 10 additions & 2 deletions rapid/plugin/x/mysqlxtest_src/mysql41_hash.h
Expand Up @@ -24,9 +24,17 @@

#define MYSQL41_HASH_SIZE 20 /* Hash size in bytes */

void compute_mysql41_hash(uint8 *digest, const char *buf, size_t len);
void compute_mysql41_hash(uint8 *digest, const char *buf, size_t len)
#if defined(HAVE_VISIBILITY_HIDDEN)
MY_ATTRIBUTE((visibility("hidden")))
#endif
;
void compute_mysql41_hash_multi(uint8 *digest, const char *buf1, int len1,
const char *buf2, int len2);
const char *buf2, int len2)
#if defined(HAVE_VISIBILITY_HIDDEN)
MY_ATTRIBUTE((visibility("hidden")))
#endif
;


#endif /* MYSQL41_HASH_INCLUDED */

0 comments on commit 557f95e

Please sign in to comment.