Bug #67897 Fast mutex is not enabled without -DCMAKE_BUILD_TYPE=RelWithDebInfo
Submitted: 13 Dec 2012 15:32 Modified: 15 Feb 2013 12:17
Reporter: Mikiya Okuno Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Compiling Severity:S3 (Non-critical)
Version:5.5+ OS:Linux
Assigned to: CPU Architecture:Any

[13 Dec 2012 15:32] Mikiya Okuno
Description:
From MySQL 5.5 series, fastmutex is available for Linux systems. cmake does not handle compiler option for fastmutex correctly.

fastmutex is enabled when both -DBUILD_CONFIG=mysql_release and -DCMAKE_BUILD_TYPE=RelWithDebInfo are specified. Without -DCMAKE_BUILD_TYPE=RelWithDebInfo, fastmutex is not enabled.

How to repeat:
Configure 

shell> cd src_top_dir
shell> mkdir bld && cd bld
shell> cmake .. -DBUILD_CONFIG=mysql_release

Then, you'll see mysql_config does include -DMY_PTHREAD_FASTMUTEX=1 option like below:

shell> scripts/mysql_config --cflags
-I/usr/local/mysql/include -m64 -g -fPIC -g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing -DMY_PTHREAD_FASTMUTEX=1

However, C_FLAGS in strings/CMakeFiles/strings.dir/flags.make does not include -DMY_PTHREAD_FASTMUTEX=1 like below:

shell> cat strings/CMakeFiles/strings.dir/flags.make 
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 2.8

# compile C with /usr/bin/gcc
C_FLAGS = -m64 -O4 -g -march=native  -fPIC -Wall -I/home/mikiya/src/mysql/5.5.28/bld3/include -I/home/mikiya/src/mysql/5.5.28/include   

C_DEFINES = -DDBUG_OFF -DHAVE_CONFIG_H -DDISABLE_MYSQL_THREAD_H

-DMY_PTHREAD_FASTMUTEX=1 is included when -DCMAKE_BUILD_TYPE=RelWithDebInfo is specified on cmake option like below:

shell> cd src_top_dir
shell> mkdir bld && cd bld
shell> cmake .. -DBUILD_CONFIG=mysql_release -DCMAKE_BUILD_TYPE=RelWithDebInfo

Suggested fix:
Mr.Kohei Sutou has written a patch for this problem:

http://packages.groonga.org/tmp/mysql-5.5.27-fix-wrong-mysql_config-cflags-for-non-relwith...
[14 Dec 2012 0:10] Vladislav Vaintroub
This issue is understood backwards. 
mysql_config should *not* have any MY_PTHREAD_WHATEVER flags, it should have the necessary stuff to compile *other peoples* code that uses mysql client library.

The less it exposes our own macro definitions the better. mysql_config should actually just spit out the libraries to link with, and I think that's it
[19 Dec 2012 4:19] 功平 須藤
This patch enables fast mutex with not only RelWithDebInfo CMAK_BUILD_TYPE but also all CMAKE_BUILD_TYPEs

(*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: mysql-5.5.27-fix-wrong-mysql_config-cflags-for-non-relwithdebinfo-build-type.diff (text/x-diff), 1.01 KiB.

[19 Dec 2012 4:23] 功平 須藤
This bug report cares about only CMake. mysql_config isn't cared on this bug report.
If mysql_config has a problem, I think that we discuss about it on other bug report.

I hope that this bug report cares about only "cmake does not handle compiler option for fastmutex correctly".
[15 Feb 2013 11:58] Tor Didriksen
I agree with Vlad on this one.
The proposed patch tries to change the generation of various scripts.
Those scripts are not used when building MySQL.