tags:

views:

687

answers:

4

Last Thursday I built SVN from source on my Mac running Leopard 10.5.7 so that I could get svn+ssh capability. (For some reason that functionality wasn't available using the binary from Collabnet.)

The build was successful and I was able to use SVN afterwords, but apache stopped launching.

When I tracked down the error, this is what I'm getting:

Syntax error on line 117 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec
/apache2/mod_dav_svn.so into server: dlopen(/usr/libexec/apache2/mod_dav_svn.so, 10): no
suitable image found.  Did find:\n\t/usr/libexec/apache2/mod_dav_svn.so: mach-o, but
wrong architecture

I suspect that doing the build mucked something up but I'm not sure where to go from here.

A: 

It looks like it was compiled for the wrong architecture. Mayhaps 64-bit?

Andrew Noyes
+3  A: 

The problem is that Apple built Apache as a fat binary so it supports four architectures so it will only load modules which are built as fat binaries. You can use the lipo utility to figure out how something was built:

lorien$ lipo -info /usr/sbin/httpd
Architectures in the fat file: /usr/sbin/httpd are: ppc7400 ppc64 i386 x86_64

Chances are that you will see something like this:

lorien$ lipo -info /usr/libexec/apache2/modules/mod_dav_svn.so
Non-fat file: /usr/libexec/apache2/modules/mod_dav_svn.so is architecture: i386

You can use arch to force a command to run in one mode or another or the lipo utility to modify the binary and strip out certain variants. Overall, it is quite a pain to deal with on a case by case basis.

The other option is to compile everything into fat binaries which is what I have been doing lately. With autoconf based things (just about anything with a configure script), you can usually control much of the process with environment variables. I have a bunch of scripts that wrap the build process to make sure that they get set up correctly. Use the following commands to rebuild svn:

lorien$ cd ~/src/svn-1.6.2
lorien$ cat env-sh
ARCHFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64"
DEVPATH='/Developer/SDKs/MacOSX10.5.sdk'
CPPFLAGS="-isysroot $DEVPATH"
CFLAGS="$ARCHFLAGS $CPPFLAGS"
CXXFLAGS="$CFLAGS"
LDFLAGS="-Wl,-syslibroot,$DEVPATH $ARCHFLAGS"
MACOS_DEPLOYMENT_TARGET=10.5
export CFLAGS CXXFLAGS LDFLAGS MACOS_DEPLOYMENT_TARGET
lorien$ . env-sh
lorien$ ./configure ... 
lorien$ make -j2
lorien$ lipo -info subversion/mod_dav_svn/.libs/mod_dav_svn.so
Architectures in the fat file: subversion/mod_dav_svn/.libs/mod_dav_svn.so are: ppc7400 ppc64 i386 x86_64

I keep a copy of the environment in my home directory. Whenever I build something, I copy env-sh, edit it as needed, source it, then build away. There is a lot more information hidden in the depths of developer.apple.com like Tech Note 2137 and the Universal Binary Programming Guidelines as well.

Good luck. I know that I am still navigating my way through this morass of fun.

D.Shawley
I tried running your steps above, but the resulting mod_dav_svn.so is still i386 when I do lipo. I have the latest SDK installed(the one that comes with the iPhone 3.0 kit).Everything you say makes a lot of sense. Just not getting it to build as anything but i386.
Geuis
I did run into problems with some packages that were not using CFLAGS and LDFLAGS in the proper places but subversion gets that one right. Make sure that you do a `make distclean' at the top-level before you run the configure script. I tried this with a clean fetch of svn-1.6.2 and it worked on my MacBook Pro. You are looking at the built one and not the installed one right?
D.Shawley
This was super helpful, thanks. As a side note, I had to do the envvars / DYLD_LIBRARY_PATH trick mentioned here afterwards: http://www.thoughtspark.org/node/19
leander
A: 

Mine were built as fat, but it still doesn't work:

lipo -info /usr/libexec/apache2/mod_dav_svn.so Architectures in the fat file: /usr/libexec/apache2/mod_dav_svn.so are: ppc7400 ppc64 i386 x86_64

A: 

The answer of D.Shawley didn't work for me (I get an error during make) but maybe I didn't do it right. But... since I don't use svn in my http-server I managed to "solve" the problem by commenting all SVN modules in httpd.conf. In my case:

file: /etc/apache2/httpd.conf

#LoadModule dav_svn_module libexec/apache2/mod_dav_svn.so

#LoadModule authz_svn_module libexec/apache2/mod_authz_svn.so

And after commenting those lines, I was able to start apache again.

Vincent