From: kledzik Date: October 3 2000 12:09am Subject: compiling mySQL on Mac OS X List-Archive: http://lists.mysql.com/internals/19 Message-Id: <200010030009.RAA05352@scv1.apple.com> MIME-Version: 1.0 (Apple Message framework v351) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable 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. -Nick --------------------------------------- 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. =20 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 to: #ifdef __APPLE_CC__ #define function longtype strtolXXX #else #define function longtype strtol #endif 2) The file sql_cache.cc 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 sql_cache.cc from: #define SQL_CACHE_LENGTH 300 to: #ifdef __APPLE_CC__ #define SQL_CACHE_LENGTH 30 #else #define SQL_CACHE_LENGTH 300 #endif 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 = mysql-3.23.24-beta.my/include/my_pthread.h 381a382,397 > #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=3Dpthread_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. =20= if test "$ac_cv_prog_gcc" =3D "yes" then DEBUG_CFLAGS=3D"-g" DEBUG_OPTIMIZE_CC=3D"-O" OPTIMIZE_CFLAGS=3D"-O6" ## <-- does not work on Mac OS X, change to = -O else DEBUG_CFLAGS=3D"-g" DEBUG_OPTIMIZE_CC=3D"" OPTIMIZE_CFLAGS=3D"-O" fi 5) To distingush between Mac OS X and Mac OS X Server in config.guess, = the uname values are: uname option Mac OS X Mac OS X Server = ----------------------+--------------------------+------------------------= --------+ -s Darwin Rhapsody -r 1.2 5.6 -m Power Macintosh Power Macintosh =20 config.guess should be updated to recognize Mac OS X as a target. -Nick