[MDEV-9388] mysql_config --libs output contains invalid -l-pthread Created: 2016-01-10  Updated: 2016-02-22  Resolved: 2016-02-22

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients
Affects Version/s: 10.1.10
Fix Version/s: 10.1.12

Type: Bug Priority: Major
Reporter: Bernard Spil Assignee: Vladislav Vaintroub
Resolution: Fixed Votes: 0
Labels: None
Environment:

FreeBSD meterkast.example.org 10.2-RELEASE-p8 FreeBSD 10.2-RELEASE-p8 #2: Sun Dec 13 15:21:37 CET 2015 root@meterkast.brnrd.eu:/usr/obj/usr/src/sys/BEASTIE102 amd64
FreeBSD clang version 3.4.1 (tags/RELEASE_34/dot1-final 208032) 20140512


Attachments: Text File CMakeCache.txt    

 Description   

After building MariaDB 10.1 the mysql_config script contains -l-pthread in the libs output.

This introduces build-errors for configure scripts that use mysql_config to retrieve build flags.

For now worked around it by applying 's/-l-pthread/-lpthread/' to mysql_config before packaging.



 Comments   
Comment by Vladislav Vaintroub [ 2016-01-12 ]

Could you please attach CMakeCache.txt from the server build, just to to understand where -l-pthread comes from?
Thank you!

Comment by Vladislav Vaintroub [ 2016-01-12 ]

seems to work for me on my PCBSD VM

[wlad@pcbsd ~/server/10.1]$ uname -a
FreeBSD pcbsd.local 10.2-RELEASE-p10 FreeBSD 10.2-RELEASE-p10 #0: Thu Dec 10 15:29:43 UTC 2015 root@amd64-builder.pcbsd.org:/usr/obj/usr/src/sys/GENERIC amd64
[wlad@pcbsd ~/server/10.1]$ cmake --version
cmake version 3.4.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).
[wlad@pcbsd ~/server/10.1]$ scripts/mysql_config
Usage: scripts/mysql_config [OPTIONS]
Options:
--cflags [-I/usr/local/mysql/include/mysql -I/usr/local/mysql/include/mysql/.. ]
--include [-I/usr/local/mysql/include/mysql -I/usr/local/mysql/include/mysql/..]
--libs [-L/usr/local/mysql/lib -lmysqlclient -lpthread -lz -lm -lexecinfo -lssl -lcrypto]
--libs_r [-L/usr/local/mysql/lib -lmysqlclient -lpthread -lz -lm -lexecinfo -lssl -lcrypto]
--plugindir [/usr/local/mysql/lib/plugin]
--socket [/tmp/mysql.sock]
--port [0]
--version [10.1.10]
--libmysqld-libs [-L/usr/local/mysql/lib -lmysqld]
--variable=VAR VAR is one of:
pkgincludedir [/usr/local/mysql/include/mysql]
pkglibdir [/usr/local/mysql/lib]
plugindir [/usr/local/mysql/lib/plugin]
[wlad@pcbsd ~/server/10.1]$

Comment by Bernard Spil [ 2016-01-12 ]

The only thing I can find related to pthreads that we are passing to the build is from the cmake wrapper

CMAKE_ARGS+= -DCMAKE_C_COMPILER:STRING="${CC}" \
-DCMAKE_CXX_COMPILER:STRING="${CXX}" \
-DCMAKE_C_FLAGS:STRING="${CFLAGS}" \
-DCMAKE_C_FLAGS_DEBUG:STRING="${CFLAGS}" \
-DCMAKE_C_FLAGS_RELEASE:STRING="${CFLAGS}" \
-DCMAKE_CXX_FLAGS:STRING="${CXXFLAGS}" \
-DCMAKE_CXX_FLAGS_DEBUG:STRING="${CXXFLAGS}" \
-DCMAKE_CXX_FLAGS_RELEASE:STRING="${CXXFLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS:STRING="${LDFLAGS}" \
-DCMAKE_MODULE_LINKER_FLAGS:STRING="${LDFLAGS}" \
-DCMAKE_SHARED_LINKER_FLAGS:STRING="${LDFLAGS}" \
-DCMAKE_INSTALL_PREFIX:PATH="${CMAKE_INSTALL_PREFIX}" \
-DCMAKE_BUILD_TYPE:STRING="${CMAKE_BUILD_TYPE}" \
-DTHREADS_HAVE_PTHREAD_ARG:BOOL=YES \
-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=YES

Comment by Vladislav Vaintroub [ 2016-01-12 ]

Out of curiosity, what is the cmake version on the machine?
I see that in CMakeCache.txt
mysqlclient_LIB_DEPENDS contains -pthread, whereas mine contains -lpthread.

While both are OK to pass to gcc for linking , only the -lpthread refernces a library, strictly speaking.

Comment by Vladislav Vaintroub [ 2016-01-12 ]

Ok, this option -DTHREADS_HAVE_PTHREAD_ARG=YES makes a difference indeed. But you should not be setting it, it is internal to FindThreads module

Comment by Vladislav Vaintroub [ 2016-01-28 ]

spil, could you provide more info on why -DTHREADS_HAVE_PTHREAD_ARG=YES is used? This is an internal variable inside FindThreads module, that in my understanding should not be manipulated

Generated at Thu Feb 08 07:34:17 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.