List:Internals« Previous MessageNext Message »
From:kledzik Date:October 3 2000 12:09am
Subject:compiling mySQL on Mac OS X
View as plain text  
I posted this to the 'internals' list a few weeks ago, but looks like the listserv was not
working then.  Just a little more info on Darwin and Mac OS X.


Although I work at Apple, I've been interested in trying to use mySQL for a personal
project.  I download the sources for 3.23.24-beta, and after a lot of wrestling and got it
running on Mac OS X (public beta).  I'd like to feed back my changes, so no one else will
need to go through the porting pain.  

First off, to clarify:  "Mac OS X" and "Mac OS X Server" and very different platforms.  
mySQL currently does compile on Mac OS X Server (previously known as Rhapsody).  What I
did was get it building on Mac OS X, which Apple recently had a public beta release. 
There have been a few posts to this list in the past that have helped out.

1) strtol is built-in in Mac OS X.  mySQL builds its own implementation of the function
into libmysqlclient.a.  The result is any client software fails on launch because strtol
is defined twice.  Simply conditionalizing strtol.c did not work.  For some reason strto.c
(which is included by strtol.c and strtoll.c etc) was compiled on its own and since if
LONGLONG and UNSIGNED are undefined it compiles into strtol.  It seems like the correct
fix is somewhere in the makefiles (strto.c should never be compiled on its own).  My fix
was to change strto.c from:

 #define function longtype strtolXXX


 #ifdef __APPLE_CC__
    #define function longtype strtolXXX
    #define function longtype strtol

2) The file does not compile with Apple's gcc on Mac OS X.  I tracked this
down to a compiler bug and reported it.  The compiler problem is a codegen problem with
>32K static array initialization when the array contains C++ classes that use
templates...  Since the cache array does not seem to be used, I changed

  #define SQL_CACHE_LENGTH 300

 #ifdef __APPLE_CC__
   #define SQL_CACHE_LENGTH 30
   #define SQL_CACHE_LENGTH 300

3) Unlike Mac OS X Server, Mac OS X does support pthreads, but not the full set that mySQL
expects.  I added the following to my_pthread.h. (based on another posting to this list).
Note: __APPLE_CC__ is a conditional built in to the gcc compiler on Mac OS X.

diff -r mysql-3.23.24-beta/include/my_pthread.h
> #if __APPLE_CC__
>  #define pthread_condattr_init(A) pthread_dummy(0)
>  #define pthread_condattr_destroy(A) pthread_dummy(0)
>  #define pthread_cond_init( A, B ) pthread_cond_init( (A), 0 )
>  #define pthread_kill(A,B) pthread_dummy(0)
>  #define pthread_sigmask(A,B,C) sigprocmask((A),(B),(C))
>  #undef  pthread_detach_this_thread
>  #define pthread_detach_this_thread() { pthread_t tmp=pthread_self() ;
> pthread_detach(tmp); }
>  #ifdef sigset
>   #undef sigset
>   #define sigset(A,B) signal((A),(B))
>  #endif
> #endif

4) In the configuration script, it's not clear to me how $ac_cv_prog_gcc is set up.  But
Apple's gcc on Mac OS X does not support -O6 only -O.  

if test "$ac_cv_prog_gcc" = "yes"
  OPTIMIZE_CFLAGS="-O6"   ## <-- does not work on Mac OS X, change to -O

5) To distingush between Mac OS X and Mac OS X Server in config.guess, the uname values

uname option         Mac OS X                  Mac OS X Server
-s                             Darwin                         Rhapsody
-r                             1.2                                 5.6
-m                           Power Macintosh       Power Macintosh
config.guess should be updated to recognize Mac OS X as a target.


compiling mySQL on Mac OS Xkledzik3 Oct
  • Re: compiling mySQL on Mac OS XBeotel3 Oct