Bug #61816 MySQL fails to compile on Mac OS X (Lion 10.7) & Xcode 4.2 DP7
Submitted: 11 Jul 2011 0:35 Modified: 22 Jul 2011 7:23
Reporter: Rob Lowe Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server: Compiling Severity:S2 (Serious)
Version:5.5.x OS:MacOS (10.7)
Assigned to: Jon Olav Hauglid CPU Architecture:Any
Tags: xcode xcode4 lion

[11 Jul 2011 0:35] Rob Lowe
Description:
mysql 5.5.12 segfaults during install (Lion GM, clean install so no SL upgrade, Xcode 4.2 beta2 for Lion)

[ 31%] [ 31%] Building CXX object sql/CMakeFiles/mysql_tzinfo_to_sql.dir/tztime.cc.o
Generating ../include/mysqld_error.h, ../sql/share/english/errmsg.sys
Linking C executable resolveip
Linking C executable replace
[ 31%] Built target resolveip
[ 31%] Built target replace
/bin/sh: line 1: 36621 Segmentation fault: 11 ./comp_err --charset=/tmp/homebrew-mysql-5.5.12-qakN/mysql-5.5.12/sql/share/charsets --out-dir=/tmp/homebrew-mysql-5.5.12-qakN/mysql-5.5.12/sql/share/ --header_file=/tmp/homebrew-mysql-5.5.12-qakN/mysql-5.5.12/include/mysqld_error.h --name_file=/tmp/homebrew-mysql-5.5.12-qakN/mysql-5.5.12/include/mysqld_ername.h --state_file=/tmp/homebrew-mysql-5.5.12-qakN/mysql-5.5.12/include/sql_state.h --in_file=/tmp/homebrew-mysql-5.5.12-qakN/mysql-5.5.12/sql/share/errmsg-utf8.txt
make[2]: *** [include/mysqld_error.h] Error 139
make[1]: *** [extra/CMakeFiles/GenError.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Linking CXX executable mysql_tzinfo_to_sql
[ 31%] Built target mysql_tzinfo_to_sql
make: *** [all] Error 2
==> Exit Status: 2

More information here:
https://github.com/mxcl/homebrew/issues/6277

How to repeat:
1. Get Lion
2. Install Xcode
3. Compile

Suggested fix:
Patch
[11 Jul 2011 5:57] Dmitry Remesov
The problem is with pthread_getspecific call
Suddenly it returns NULL although key is correct and pthread_setspecific on this key is called just once in the beginning
So even if i patch the place where comp_err fails ( in ./mysys/my_lib.c function my_stat at "my_errno = errno" )
the mysqld itself fails in another place like this ( in my_delete )
[16 Jul 2011 6:20] Quanah Gibson-Mount
Broken in mysql 5.5.14 and mysql 5.6.2 as well.
[17 Jul 2011 20:55] Rob Lowe
From 

https://github.com/mxcl/homebrew/issues/6277#issuecomment-1591434

@coondog0630 notes:

Here's the build number I'm on, Software Mac OS X Lion 10.7 (11A511)
g++ and gcc are just symlinks to llvm-g++ and llvm-gcc, check it

:]gcc -version
i686-apple-darwin11-llvm-gcc-4.2: no input files
:]g++ -version
i686-apple-darwin11-llvm-g++-4.2: no input files

It's not just the standard GNU gcc compiler but rather a hybrid of gcc and llvm.
http://gcc.gnu.org/ml/gcc/2005-11/msg00888.html

all in all a fresh compiler build out of apple's house

--------------------------------------------

▸▸▸▸▸ bin viral$ ls -la /usr/bin/ | grep gcc
lrwxr-xr-x     1 root   wheel        12  3 Jul 06:06 cc -> llvm-gcc-4.2
lrwxr-xr-x     1 root   wheel        12  3 Jul 06:06 gcc -> llvm-gcc-4.2
-rwxr-xr-x     1 root   wheel    113024 16 May 00:37 gcc-4.2
-rwxr-xr-x     1 root   wheel    562992 16 May 00:37 i686-apple-darwin11-gcc-4.2.1
lrwxr-xr-x     1 root   admin        52  3 Jul 06:06 i686-apple-darwin11-llvm-g++-4.2 -> ../llvm-gcc-4.2/bin/i686-apple-darwin11-llvm-g++-4.2
lrwxr-xr-x     1 root   admin        52  3 Jul 06:06 i686-apple-darwin11-llvm-gcc-4.2 -> ../llvm-gcc-4.2/bin/i686-apple-darwin11-llvm-gcc-4.2
lrwxr-xr-x     1 root   admin        32  3 Jul 06:06 llvm-cpp-4.2 -> ../llvm-gcc-4.2/bin/llvm-cpp-4.2
lrwxr-xr-x     1 root   admin        32  3 Jul 06:06 llvm-g++ -> ../llvm-gcc-4.2/bin/llvm-g++-4.2
lrwxr-xr-x     1 root   admin        32  3 Jul 06:06 llvm-g++-4.2 -> ../llvm-gcc-4.2/bin/llvm-g++-4.2
lrwxr-xr-x     1 root   admin        32  3 Jul 06:06 llvm-gcc -> ../llvm-gcc-4.2/bin/llvm-gcc-4.2
lrwxr-xr-x     1 root   admin        32  3 Jul 06:06 llvm-gcc-4.2 -> ../llvm-gcc-4.2/bin/llvm-gcc-4.2

▸▸▸▸▸ bin viral$ gcc --version
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

▸▸▸▸▸ bin viral$ gcc-4.2 --version
i686-apple-darwin11-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[22 Jul 2011 7:23] Jon Olav Hauglid
Hello!

Thank you for the bug report.

I cannot repeat this segfault using the release version of OS X 10.7 (Lion):
i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)

So I'm closing this bug as "Can't repeat".

However, compilation will instead fail with:
/mysys/my_init.c:103: warning: implicit declaration of function ‘pthread_init’

Technically, it can be debated if this is really a MySQL issue, however we
have implemented a fix which avoids the problem. It is scheduled to be a part
of MySQL 5.5.16.

The changeset can be seen here: http://lists.mysql.com/commits/140413