Skip to content

Commit 608c0e1

Browse files
committed
MDEV-5982 make fail @ ".../libmysql_versions.ld:155:9: invalid use of VERSION in input file"
add a workaround for gold
1 parent ce35530 commit 608c0e1

File tree

2 files changed

+44
-18
lines changed

2 files changed

+44
-18
lines changed

libmysql/CMakeLists.txt

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,25 @@ SET(CLIENT_API_FUNCTIONS
251251
)
252252

253253
IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
254+
IF (NOT DISABLE_LIBMYSQLCLIENT_SYMBOL_VERSIONING)
255+
256+
INCLUDE (CheckCSourceCompiles)
257+
FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.ld"
258+
"VERSION {\nlibmysqlclient_18 {\nglobal: *;\n};\n}\n")
259+
SET(CMAKE_REQUIRED_LIBRARIES "-Wl,src.ld")
260+
CHECK_C_SOURCE_COMPILES("int main() { return 0; }"
261+
SUPPORTS_VERSION_IN_LINK_SCRIPT)
262+
SET(CMAKE_REQUIRED_LIBRARIES)
263+
264+
IF (NOT SUPPORTS_VERSION_IN_LINK_SCRIPT)
265+
# https://sourceware.org/bugzilla/show_bug.cgi?id=16895
266+
MESSAGE(SEND_ERROR "Your current linker does not support VERSION "
267+
"command in linker scripts like a GNU ld or any compatible linker "
268+
"should. Perhaps you're using gold? Either switch to GNU ld compatible "
269+
"linker or run cmake with -DDISABLE_LIBMYSQLCLIENT_SYMBOL_VERSIONING=TRUE "
270+
"to be able to complete the build")
271+
ENDIF (NOT SUPPORTS_VERSION_IN_LINK_SCRIPT)
272+
254273
# When building RPM, or DEB package on Debian, use ELF symbol versioning
255274
# for compatibility with distribution packages, so client shared library can
256275
# painlessly replace the one supplied by the distribution.
@@ -335,14 +354,26 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
335354
make_scrambled_password_323
336355
)
337356

338-
# Linker script to version symbols in Fedora- and Debian- compatible way, MDEV-5529
339-
SET(VERSION_SCRIPT_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/libmysql_versions.ld.in)
340-
341357
# Generate version script.
342358
# Create semicolon separated lists of functions to export from
343359
# Since RPM packages use separate versioning for 5.1 API
344360
# and 5.5 API (libmysqlclient_16 vs libmysqlclient_18),
345361
# we need 2 lists.
362+
SET (VERSION_HEADER
363+
"VERSION {
364+
libmysqlclient_18 {
365+
global:")
366+
SET (VERSION_FOOTER
367+
" local:
368+
*;
369+
};
370+
371+
libmysqlclient_16 {
372+
/* empty here. aliases are added above */
373+
};
374+
}
375+
")
376+
346377
SET (CLIENT_API_5_1_LIST)
347378
SET (CLIENT_API_5_1_ALIASES)
348379
FOREACH (f ${CLIENT_API_FUNCTIONS_5_1} ${CLIENT_API_5_1_EXTRA})
@@ -355,6 +386,13 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
355386
SET(CLIENT_API_5_5_LIST "${CLIENT_API_5_5_LIST}\t${f};\n")
356387
ENDFOREACH()
357388

389+
ELSE (NOT DISABLE_LIBMYSQLCLIENT_SYMBOL_VERSIONING)
390+
SET (CLIENT_API_5_1_ALIASES "/* Versioning disabled per user request. MDEV-5982 */")
391+
ENDIF (NOT DISABLE_LIBMYSQLCLIENT_SYMBOL_VERSIONING)
392+
393+
# Linker script to version symbols in Fedora- and Debian- compatible way, MDEV-5529
394+
SET(VERSION_SCRIPT_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/libmysql_versions.ld.in)
395+
358396
CONFIGURE_FILE(
359397
${VERSION_SCRIPT_TEMPLATE}
360398
${CMAKE_CURRENT_BINARY_DIR}/libmysql_versions.ld
@@ -363,7 +401,7 @@ IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
363401
SET(VERSION_SCRIPT_LINK_FLAGS
364402
"-Wl,${CMAKE_CURRENT_BINARY_DIR}/libmysql_versions.ld")
365403

366-
ENDIF()
404+
ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
367405

368406

369407
SET(CLIENT_SOURCES

libmysql/libmysql_versions.ld.in

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,7 @@ mysql_get_charset_by_csname = get_charset_by_csname;
2727
mysql_net_realloc = net_realloc;
2828
mysql_client_errors = client_errors;
2929

30-
VERSION {
31-
32-
libmysqlclient_18 {
33-
global:
30+
@VERSION_HEADER@
3431
@CLIENT_API_5_1_LIST@
3532
@CLIENT_API_5_5_LIST@
36-
37-
local:
38-
*;
39-
};
40-
41-
libmysqlclient_16 {
42-
/* empty here. aliases are added above */
43-
};
44-
45-
}
33+
@VERSION_FOOTER@

0 commit comments

Comments
 (0)