Monday, March 28, 2011

[solved] installing passenger 3.0.5 apache2 module on OS X gives 'missing required architecture ppc64 in file'

I was getting odd compilation errors trying to install the Passenger 3.0.5 apache2 module on my Mac running OS X. I worked through the problems and you just need to edit a couple of files to solve the problem.
gem install passenger rvmsudo passenger-install-apache2-module
mkdir -p ext/apache2/module_libboost_oxt
g++ -Iext -fPIC -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -I/usr/include/apr-1 -I/usr/include/apr-1 -I/usr/include/apache2 -arch i386 -arch ppc -arch x86_64 -arch ppc64 -D_REENTRANT -I/usr/local/include -DHASH_NAMESPACE="__gnu_cxx" -DHASH_FUN_H="" -DHAS_SFENCE -DHAS_LFENCE -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/module_libboost_oxt/aggregate.o -c ext/apache2/module_libboost_oxt/aggregate.cpp
mkdir -p ext/apache2/module_libboost_oxt
rm -rf ext/apache2/module_libboost_oxt.a
ar cru ext/apache2/module_libboost_oxt.a ext/apache2/module_libboost_oxt/aggregate.o
ranlib ext/apache2/module_libboost_oxt.a
gcc -Iext -Iext/common -fPIC -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -I/usr/include/apr-1 -I/usr/include/apr-1 -I/usr/include/apache2 -arch i386 -arch ppc -arch x86_64 -arch ppc64 -D_REENTRANT -I/usr/local/include -DHASH_NAMESPACE="__gnu_cxx" -DHASH_FUN_H="" -DHAS_SFENCE -DHAS_LFENCE -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/mod_passenger.o -c ext/apache2/mod_passenger.c
g++ -Iext -Iext/common -fPIC -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -I/usr/include/apr-1 -I/usr/include/apr-1 -I/usr/include/apache2 -arch i386 -arch ppc -arch x86_64 -arch ppc64 -D_REENTRANT -I/usr/local/include -DHASH_NAMESPACE="__gnu_cxx" -DHASH_FUN_H="" -DHAS_SFENCE -DHAS_LFENCE -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/Configuration.o -c ext/apache2/Configuration.cpp
g++ -Iext -Iext/common -fPIC -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -I/usr/include/apr-1 -I/usr/include/apr-1 -I/usr/include/apache2 -arch i386 -arch ppc -arch x86_64 -arch ppc64 -D_REENTRANT -I/usr/local/include -DHASH_NAMESPACE="__gnu_cxx" -DHASH_FUN_H="" -DHAS_SFENCE -DHAS_LFENCE -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/Bucket.o -c ext/apache2/Bucket.cpp
g++ -Iext -Iext/common -fPIC -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -I/usr/include/apr-1 -I/usr/include/apr-1 -I/usr/include/apache2 -arch i386 -arch ppc -arch x86_64 -arch ppc64 -D_REENTRANT -I/usr/local/include -DHASH_NAMESPACE="__gnu_cxx" -DHASH_FUN_H="" -DHAS_SFENCE -DHAS_LFENCE -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS -o ext/apache2/Hooks.o -c ext/apache2/Hooks.cpp
g++ -flat_namespace -bundle -undefined dynamic_lookup ext/apache2/Configuration.o ext/apache2/Bucket.o ext/apache2/Hooks.o ext/apache2/mod_passenger.o -fPIC -o ext/apache2/mod_passenger.so -fPIC -fvisibility=hidden -DVISIBILITY_ATTRIBUTE_SUPPORTED -DDARWIN -DSIGPROCMASK_SETS_THREAD_MASK -I/usr/include/apr-1 -I/usr/include/apr-1 -I/usr/include/apache2 -arch i386 -arch ppc -arch x86_64 -arch ppc64 -D_REENTRANT -I/usr/local/include -DHASH_NAMESPACE="__gnu_cxx" -DHASH_FUN_H="" -DHAS_SFENCE -DHAS_LFENCE -Wall -g -DPASSENGER_DEBUG -DBOOST_DISABLE_ASSERTS ext/apache2/module_libpassenger_common.a ext/apache2/module_libboost_oxt.a -fPIC -L/usr/lib -lapr-1 -L/usr/lib -laprutil-1 -lpthread  
ld: warning: in /usr/lib/bundle1.o, missing required architecture ppc64 in file
ld: warning: in /usr/lib/libapr-1.dylib, missing required architecture ppc64 in file
ld: warning: in /usr/lib/libaprutil-1.dylib, missing required architecture ppc64 in file
ld: warning: in /usr/lib/libpthread.dylib, missing required architecture ppc64 in file
ld: warning: in /usr/lib/gcc/powerpc-apple-darwin10/4.2.1/libstdc++.dylib, missing required architecture ppc64 in file
ld: warning: in /usr/lib/libSystemStubs.a, missing required architecture ppc64 in file
ld: warning: in /usr/lib/libSystem.dylib, missing required architecture ppc64 in file
ld: symbol dyld_stub_binding_helper not defined (usually in crt1.o/dylib1.o/bundle1.o) for architecture ppc64
collect2: ld returned 1 exit status
lipo: can't open input file: /var/tmp//ccPTqixF.out (No such file or directory)
rake aborted!
Command failed with status (1): [g++ -flat_namespace -bundle -undefined dyn...]

Fix the compilation errror

cd /Users/karl/.rvm/gems/ree-1.8.7-2010.02/gems/passenger-3.0.5 vi ./lib/phusion_passenger/platform_info/apache.rb
Change line 215 to: architectures = ["-arch i386 -arch x86_64"] Then restart Apache. Now in your apache logs you might see the following error:
/Users/karl/.rvm/gems/ree-1.8.7-2010.02/gems/passenger-3.0.5/lib/phusion_passenger/platform_info/ruby.rb:166:in `expand_path': couldn't find HOME environment -- expanding `~/.rvm' (ArgumentError)
 from /Users/karl/.rvm/gems/ree-1.8.7-2010.02/gems/passenger-3.0.5/lib/phusion_passenger/platform_info/ruby.rb:166:in `_unmemoized_rvm_path'
 from /Users/karl/.rvm/gems/ree-1.8.7-2010.02/gems/passenger-3.0.5/lib/phusion_passenge

Fix the missing HOME env variable

Hard-code the path to your HOME directory.
vi /Users/karl/.rvm/gems/ree-1.8.7-2010.02/gems/passenger-3.0.5/lib/phusion_passenger/platform_info/ruby.rb
Edit #164 to [ENV['rvm_path'], "/Users/karl/.rvm", "/usr/local/rvm"].each do |path| Now restart Apache with sudo apachectl -k restart and everything should be working fine!

To find the location of your gem files you can echo $GEM_HOME. Keep in mind you will need to substitute your own HOME path in the above command.