[MDEV-19603] MariaDB 10.4 does not build on OpenBSD due to the use of libdl Created: 2019-05-26  Updated: 2020-07-31  Resolved: 2020-07-31

Status: Closed
Project: MariaDB Server
Component/s: Compiling, Galera
Affects Version/s: 10.4.5, 10.5.0, 10.5.4
Fix Version/s: 10.4.14, 10.5.5

Type: Bug Priority: Blocker
Reporter: Brad Smith Assignee: Sergei Golubchik
Resolution: Fixed Votes: 2
Labels: None
Environment:

OpenBSD


Attachments: File patch-plugin_auth__pam_CMakeLists.txt2     File patch-wsrep-lib_src_CMakeLists.txt2    

 Description   

MariaDB 10.4 does not build on OpenBSD due to the use of libdl

[1/127] : && /home/ports/pobj/mariadb-10.4.5/bin/c++  -O2 -pipe  -I/usr/local/include -Wl,-z,relro,-z,now -fstack-protector --param=ssp-buffer-size=4 -DNDEBUG -D_FORTIFY_SOURCE=2 -DDBUG_OFF  -L/usr/local/lib   -Wl,--export-dynamic extra/mariabackup/CMakeFiles/mariabackup.dir/xtrabackup.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/innobackupex.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/changed_page_bitmap.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/datasink.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/ds_buffer.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/ds_compress.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/ds_local.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/ds_stdout.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/ds_tmpfile.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/ds_xbstream.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/fil_cur.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/quicklz/quicklz.c.o extra/mariabackup/CMakeFiles/mariabackup.dir/read_filt.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/write_filt.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/wsrep.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/xbstream_write.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/backup_mysql.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/backup_copy.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/encryption_plugin.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/__/__/sql/net_serv.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/__/__/libmysqld/libmysql.c.o  -o extra/mariabackup/mariabackup -L/usr/local/lib -lpthread -llz4 -llzo2 -llzma -lbz2 -lsnappy sql/libsql.a extra/mariabackup/crc/libcrc.a storage/csv/libcsv.a storage/heap/libheap.a storage/innobase/libinnobase.a storage/maria/libaria.a storage/myisam/libmyisam.a storage/myisammrg/libmyisammrg.a storage/perfschema/libperfschema.a storage/sequence/libsequence.a plugin/auth_socket/libauth_socket.a plugin/feedback/libfeedback.a plugin/user_variables/libuser_variables.a plugin/userstat/libuserstat.a sql/libpartition.a sql/libsql_sequence.a mysys/libmysys.a mysys_ssl/libmysys_ssl.a dbug/libdbug.a mysys/libmysys.a mysys_ssl/libmysy
s_ssl.a dbug/libdbug.a -lz -lm strings/libstrings.a vio/libvio.a -lpcre -lssl -lcrypto wsrep-lib/src/libwsrep-lib.a -lpthread -ldl wsrep-lib/wsrep-API/libwsrep_api_v26.
a -lpthread -llz4 -llzo2 -llzma -lbz2 -lsnappy -Wl,-rpath-link,/usr/X11R6/lib && :
FAILED: extra/mariabackup/mariabackup
: && /home/ports/pobj/mariadb-10.4.5/bin/c++  -O2 -pipe  -I/usr/local/include -Wl,-z,relro,-z,now -fstack-protector --param=ssp-buffer-size=4 -DNDEBUG -D_FORTIFY_SOURCE
=2 -DDBUG_OFF  -L/usr/local/lib   -Wl,--export-dynamic extra/mariabackup/CMakeFiles/mariabackup.dir/xtrabackup.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/innobac
kupex.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/changed_page_bitmap.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/datasink.cc.o extra/mariabackup/CMakeFiles
/mariabackup.dir/ds_buffer.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/ds_compress.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/ds_local.cc.o extra/mariaback
up/CMakeFiles/mariabackup.dir/ds_stdout.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/ds_tmpfile.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/ds_xbstream.cc.o
extra/mariabackup/CMakeFiles/mariabackup.dir/fil_cur.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/quicklz/quicklz.c.o extra/mariabackup/CMakeFiles/mariabackup.dir/
read_filt.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/write_filt.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/wsrep.cc.o extra/mariabackup/CMakeFiles/mariaba
ckup.dir/xbstream_write.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/backup_mysql.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/backup_copy.cc.o extra/mariabac
kup/CMakeFiles/mariabackup.dir/encryption_plugin.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/__/__/sql/net_serv.cc.o extra/mariabackup/CMakeFiles/mariabackup.dir/
__/__/libmysqld/libmysql.c.o  -o extra/mariabackup/mariabackup -L/usr/local/lib -lpthread -llz4 -llzo2 -llzma -lbz2 -lsnappy sql/libsql.a extra/mariabackup/crc/libcrc.a
 storage/csv/libcsv.a storage/heap/libheap.a storage/innobase/libinnobase.a storage/maria/libaria.a storage/myisam/libmyisam.a storage/myisammrg/libmyisammrg.a storage/
perfschema/libperfschema.a storage/sequence/libsequence.a plugin/auth_socket/libauth_socket.a plugin/feedback/libfeedback.a plugin/user_variables/libuser_variables.a pl
ugin/userstat/libuserstat.a sql/libpartition.a sql/libsql_sequence.a mysys/libmysys.a mysys_ssl/libmysys_ssl.a dbug/libdbug.a mysys/libmysys.a mysys_ssl/libmysys_ssl.a
dbug/libdbug.a -lz -lm strings/libstrings.a vio/libvio.a -lpcre -lssl -lcrypto wsrep-lib/src/libwsrep-lib.a -lpthread -ldl wsrep-lib/wsrep-API/libwsrep_api_v26.a -lpthr
ead -llz4 -llzo2 -llzma -lbz2 -lsnappy -Wl,-rpath-link,/usr/X11R6/lib && :
ld: error: unable to find library -ldl



 Comments   
Comment by Brad Smith [ 2019-06-15 ]

There were 3 spots I saw linking fail due to the use of libdl.

unittest/sql/explain_filename-t
extra/mariabackup/mariabackup
sql/mysqld

Comment by Brad Smith [ 2019-08-03 ]

Still affects 10.4.7.

Comment by Laurent Frigault [ 2019-08-06 ]

I successfully work around this bug and compile mariadb 10.4.6 in a jail running freebsd 10.4 .

1/
Remove all ${LIBDL] from CMakeLists.txt files and replace them with ${CMAKE_DL_LIBS}

I'm not a cmake specialist, but any portable code should use CMAKE_DL_LIBS instead of LIBDL
I ran this to make the changes ( ${WRKSRC} is the source directory).

find ${WRKSRC} -type f -name CMakeLists.txt | fgrep -l '

{LIBDL}' | xargs -n 1 sed -i .orig -e 's|{LIBDL}

|

{CMAKE_DL_LIBS}

|'

2/
then, fix 2 CMakeLists.txt files to remove dl library references :

— plugin/auth_pam/CMakeLists.txt.orig 2019-06-18 00:00:32.000000000 +0200
+++ plugin/auth_pam/CMakeLists.txt 2019-08-06 11:35:08.348276000 +0200
@@ -11,7 +11,7 @@
FIND_LIBRARY(PAM_LIBRARY pam)
ADD_DEFINITIONS(-D_GNU_SOURCE)
MYSQL_ADD_PLUGIN(auth_pam_v1 auth_pam_v1.c LINK_LIBRARIES pam MODULE_ONLY)

  • MYSQL_ADD_PLUGIN(auth_pam auth_pam.c LINK_LIBRARIES pam dl MODULE_ONLY)
    + MYSQL_ADD_PLUGIN(auth_pam auth_pam.c LINK_LIBRARIES pam MODULE_ONLY)
    MYSQL_ADD_EXECUTABLE(auth_pam_tool auth_pam_tool.c DESTINATION ${INSTALL_PLUGINDIR}/auth_pam_tool_dir COMPONENT Server)
    TARGET_LINK_LIBRARIES(auth_pam_tool pam)
    INSTALL(CODE "EXECUTE_PROCESS(

— wsrep-lib/src/CMakeLists.txt.orig 2019-06-18 00:00:31.000000000 +0200
+++ wsrep-lib/src/CMakeLists.txt 2019-08-06 11:48:38.866902000 +0200
@@ -16,4 +16,4 @@
thread.cpp
transaction.cpp
wsrep_provider_v26.cpp)
-target_link_libraries(wsrep-lib wsrep_api_v26 pthread dl)
+target_link_libraries(wsrep-lib wsrep_api_v26 pthread)

After this, mariadb 10.4.6 build successfully and starts.

Comment by Brad Smith [ 2019-08-10 ]

Comparing the CMake files between 10.3 and 10.4 they both have the same use of ${LIBDL}. So something must have changed elsewhere in the MariaDB codebase. All releases prior to 10.4 have always built Ok.

Comment by Brad Smith [ 2019-12-19 ]

This is (not surprisingly) an issue with 10.5 as well.

Comment by Brad Smith [ 2019-12-28 ]

So doing a bit more testing, if I patch just wsrep-lib/src/CMakeLists.txt, which seems to be the root of where this bogus libdl is being added, then MariaDB 10.4 and 10.5 build Ok.

Comment by Brad Smith [ 2019-12-30 ]

It looks as if substituting dl for ${LIBDL} should work in wsrep-lib/src/CMakeLists.txt, but I don't know CMake well.

Comment by Brad Smith [ 2020-01-02 ]

I have used just the wsrep-lib/src/CMakeLists.txt modification to use ${LIBDL} for the 10.4.11 update I have commited to the OpenBSD port / package.

Comment by Brad Smith [ 2020-01-28 ]

We're using 10.4.11 in our MariaDB port /package. Could this one patch please go in for 10.4.12 and 10.5.1 to fix the build?

Comment by Brad Smith [ 2020-06-28 ]

So we've upgraded from 10.4 to 10.5 and this is still a build issue with 10.4 / 10.5.

Comment by Brad Smith [ 2020-07-04 ]

http://cvsweb.openbsd.org/cgi-bin/cvsweb/~checkout~/ports/databases/mariadb/patches/patch-wsrep-lib_src_CMakeLists_txt?rev=1.1&hideattic=1

Our current patch from our ports tree.

Comment by Sergei Golubchik [ 2020-07-31 ]

https://github.com/mariadb/server/commit/a773d932678

Generated at Thu Feb 08 08:52:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.