/var/adm/blog
Drizzle in the Snow (how to build Drizzle on OS X 10.6 , aka Snow Leopard)
So these days I do most of my development on my Mac Book Pro and for the most part it works just fine. In fact, things have been so smooth that I've lulled myself into the false sense of complacency that things will "just work". That is until this morning when I pulled down a fresh version of the drizzle trunk and tried to build it. Not more that a few seconds after kicking of the build I noticed the cursor blinking at me below with an error indicating that my build had failed. At this point it dawns on me that I had installed Snow Leopard (OS X 10.6) on the machine over the weekend and most likely this was the culprit.
As it turned out, there were some issues building Drizzle on OS X 10.6, but nothing to difficult to overcome.
ISSUE #1: FDATASYNC
This is issue manifests itself with the following build failure:
libtool: compile: /usr/bin/g++-4.2 -DHAVE_CONFIG_H -I. -I. -isystem ./gnulib -isystem ./gnulib -ggdb3 -I/Users/elambert/dev/drizzle/include -D_THREAD_SAFE -pipe -O3 -Werror -pedantic -Wall -Wextra -Wundef -Wshadow -fdiagnostics-show-option -fvisibility=hidden -Wformat -fno-strict-aliasing -Wno-strict-aliasing -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long -Wno-redundant-decls -std=gnu++98 -MT mysys/my_sync.lo -MD -MP -MF mysys/.deps/my_sync.Tpo -c mysys/my_sync.cc -fno-common -DPIC -o mysys/.libs/my_sync.o
mysys/my_sync.cc: In function ‘int my_sync(File, myf)’:
mysys/my_sync.cc:59: error: ‘fdatasync’ was not declared in this scope
make[2]: *** [mysys/my_sync.lo] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
The problem here is that 'configure' is being fooled into thinking that the fdatasync() system call is available on the system when in reality it should be using fsync instead. Unfortunately, the fix for this problem requires changes to the build system. Fortunately, those changes should already by in drizzle trunk by the time you read this. So if you are seeing this error, do a fresh pull from the trunk. If, for some reason, the changes have not made it to the trunk yet or pulling from the trunk is not option for you, just apply the diff listed at the bottom of this blog.
ISSUE #2: READLINE 'INCOMPATIBILITY'?
This issue manifest itself with the following build failure:
g++ -DHAVE_CONFIG_H -I. -I. -isystem ./gnulib -isystem ./gnulib -ggdb3 -I/Users/elambert/dev/drizzle/include -D_THREAD_SAFE -pipe -O3 -Werror -pedantic -Wall -Wextra -Wundef -Wshadow -fdiagnostics-show-option -fvisibility=hidden -Wformat -fno-strict-aliasing -Wno-strict-aliasing -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long -Wno-redundant-decls -std=gnu++98 -MT client/drizzle.o -MD -MP -MF $depbase.Tpo -c -o client/drizzle.o client/drizzle.cc &&\
mv -f $depbase.Tpo $depbase.Po
client/drizzle.cc:109: error: conflicting declaration ‘typedef int (rl_compentry_func_t)(const char*, int)’
/usr/include/readline/readline.h:44: error: ‘rl_compentry_func_t’ has a previous declaration as ‘typedef char* (rl_compentry_func_t)(const char*, int)’
client/drizzle.cc: In function ‘void initialize_readline(char*)’:
client/drizzle.cc:2348: error: invalid conversion from ‘char* (*)(const char*, int)’ to ‘int (*)(const char*, int)’
make[2]: *** [client/drizzle.o] Error 1
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
The problem here appears to be due to the fact that the readline implementation that ships with SnowLeopard (which I believe is just a wrapper under the editline lib) is 'incompatible' with Drizzle. The readline.h file in /usr/lib/readline defines some functions expected by Drizzle but not all of them, making it difficult to use the header file. To work around this you will need to build your own version of readline and compile Drizzle against it. The steps to do so are listed below:
1 - Download the readline 6.0 source tarball (other versions of readline may work, but I've only tested 6.0)
$ wget ftp://ftp.cwru.edu/pub/bash/readline-6.0.tar.gz
2 - Unarchive the tar ball
$ gtar xfz readline-6.0.tar.gz
3 - configure the readline build scripts. Note, I decided not to install the new version of readline in the default location but instead have it be installed in a specified location of my choosing. My reason for not installing the new version in the default location was that i did not want to upset any dependencies other parts of my system may have on the current version.
$ cd readline-6.0
$ ./configure --prefix=/Users/elambert/dev/readline-6.0
4 - Build and install readline. This step is fairly straight forward
$ make all && make install
5 - Configure Drizzle. If you are reading this blog, you should be fairly familiar with configuring Drizzle by now,but of note here is the fact that I specify the location to find readline with the --with-lib-prefix option. If you installed readline into the default location, you do not need to include this flag.
$ cd <DRIZZLE_HOME>
$ ./config/autorun.sh
$./configure --with-lib-prefix=/Users/elambert/dev/readline-6.0 \
--with-libdrizzle-prefix=/Users/elambert/dev/drizzle \
--prefix=/Users/elambert/dev/drizzle
6 - Build Drizzle
$ make -j2
7 - Test it
$ cd test
$ ./test-run
And thats it .... see not so bad was it.
DIFF FOR FDATASYNC FIX
=== modified file 'configure.ac'
--- configure.ac 2009-08-20 16:14:47 +0000
+++ configure.ac 2009-09-02 02:44:43 +0000
@@ -451,11 +451,27 @@
AC_MSG_ERROR("Drizzle requires fcntl.")
fi
+AC_CACHE_CHECK([working fdatasync],[ac_cv_func_fdatasync],[
+ AC_LANG_PUSH(C++)
+ AC_RUN_IFELSE([AC_LANG_PROGRAM([[
+#include <unistd.h>
+ ]],[[
+fdatasync(4);
+ ]])],
+ [ac_cv_func_fdatasync=yes],
+ [ac_cv_func_fdatasync=no])
+ AC_LANG_POP()
+])
+AS_IF([test "x${ac_cv_func_fdatasync}" = "xyes"],
+ [AC_DEFINE([HAVE_FDATASYNC],[1],[If the system has a working fdatasync])])
+
+
+
AC_CONFIG_LIBOBJ_DIR([gnulib])
AC_CHECK_FUNCS( \
cuserid fchmod \
- fdatasync fpresetsticky fpsetmask fsync \
+ fpresetsticky fpsetmask fsync \
getpassphrase getpwnam \
getpwuid getrlimit getrusage index initgroups isnan \
localtime_r log log2 gethrtime gmtime_r \
=== modified file 'm4/pandora_ensure_gcc_version.m4'
--- m4/pandora_ensure_gcc_version.m4 2009-07-08 07:09:13 +0000
+++ m4/pandora_ensure_gcc_version.m4 2009-09-01 21:21:13 +0000
@@ -8,12 +8,15 @@
AC_DEFUN([PANDORA_MAC_GCC42],
[AS_IF([test "$GCC" = "yes"],[
AS_IF([test "$host_vendor" = "apple" -a "x${ac_cv_env_CC_set}" = "x"],[
- AS_IF([test -f /usr/bin/gcc-4.2],
+ host_os_version=`echo ${host_os} | perl -ple 's/^\D+//g;s,\..*,,'`
+ AS_IF([test "$host_os_version" -lt 10],[
+ AS_IF([test -f /usr/bin/gcc-4.2],
[
CPP="/usr/bin/gcc-4.2 -E"
CC=/usr/bin/gcc-4.2
CXX=/usr/bin/g++-4.2
])
Posted at 09:08PM Sep 01, 2009 by Eric Lambert in Drizzle | Comments[1]
Is fdatasync() actually non-functional on Snow Leopard? While it isn't declared in unistd.h and there's no manpage, there IS an fdatasync system call, and a simple test program that invokes fdatasync() seems to succeed (modulo the expected warning about the lack of a declared prototype for the function).
Posted by Neil Conway on October 19, 2009 at 03:38 PM PDT #