Thanks for looking into this, however, the fix doesn't work to me. I was using passenger-install-apache2-module to install passenger, and saw those error, and checking source code, I changed something in 2 places, see below, basically it's removing wrong checking for cxx compiler in compiler.rb and adding apache2_module_cxxflags in apache.rb, then let compiler use apache2_module_cxxflags in apache2.rb.
root@dtcd-absnda1 # diff ./lib/phusion_passenger/platform_info/compiler.rb.bak ./lib/phusion_passenger/platform_info/compiler.rb
206c206
< `#{cxx} -V 2>&1` =~ /Sun C/ || `#{cc} -flags 2>&1` =~ /Sun C/
---
> `#{cxx} -V 2>&1` =~ /Sun C/
##add a apache2_module_cxxflags part into apache.rb, to allow c++ use -fPIC, as in our solaris, cc is for Sun sparc, but c++ is gcc
root@dtcd-absnda1 # diff ./lib/phusion_passenger/platform_info/apache.rb.bak ./lib/phusion_passenger/platform_info/apache.rb
601a602,690
>
> ################ CXX Compiler and linker flags ################
>
> # The C compiler flags that are necessary to compile an Apache module.
> # Also includes APR and APU compiler flags if with_apr_flags is true.
> def self.apache2_module_cxxflags(with_apr_flags = true)
> flags = [""]
> if cxx_is_sun_studio?
> flags << "-fPIC"
> else
> flags << "-fPIC"
> end
> if with_apr_flags
> flags << apr_flags
> flags << apu_flags
> end
> if !apxs2.nil?
> apxs2_flags = `#{apxs2} -q CFLAGS`.strip << " -I" << `#{apxs2} -q INCLUDEDIR`.strip
> apxs2_flags.gsub!(/-O\d? /, '')
>
> # Remove flags not supported by GCC
> if os_name =~ /solaris/ # TODO: Add support for people using SunStudio
> # The big problem is Coolstack apxs includes a bunch of solaris -x directives.
> options = apxs2_flags.split
> options.reject! { |f| f =~ /^\-x/ }
> options.reject! { |f| f =~ /^\-Xa/ }
> options.reject! { |f| f =~ /^\-fast/ }
> options.reject! { |f| f =~ /^\-mt/ }
> apxs2_flags = options.join(' ')
> end
>
> if os_name == "linux" &&
> linux_distro_tags.include?(:redhat) &&
> apxs2 == "/usr/sbin/apxs" &&
> httpd_architecture_bits == 64
> # The Apache package in CentOS 5 x86_64 is broken.
> # 'apxs -q CFLAGS' contains directives for compiling
> # the module as 32-bit, even though httpd itself
> # is 64-bit. Fix this.
> apxs2_flags.gsub!('-m32 -march=i386 -mtune=generic', '')
> end
>
> apxs2_flags.strip!
> flags << apxs2_flags
> end
> if !httpd.nil? && os_name == "macosx"
> # The default Apache install on OS X is a universal binary.
> # Figure out which architectures it's compiled for and do the same
> # thing for mod_passenger. We use the 'file' utility to do this.
> #
> # Running 'file' on the Apache executable usually outputs something
> # like this:
> #
> # /usr/sbin/httpd: Mach-O universal binary with 4 architectures
> # /usr/sbin/httpd (for architecture ppc7400): Mach-O executable ppc
> # /usr/sbin/httpd (for architecture ppc64): Mach-O 64-bit executable ppc64
> # /usr/sbin/httpd (for architecture i386): Mach-O executable i386
> # /usr/sbin/httpd (for architecture x86_64): Mach-O 64-bit executable x86_64
> #
> # But on some machines, it may output just:
> #
> # /usr/sbin/httpd: Mach-O fat file with 4 architectures
> #
> output = `file "#{httpd}"`.strip
> if output =~ /Mach-O fat file/ && output !~ /for architecture/
> architectures = ["i386", "ppc", "x86_64", "ppc64"]
> else
> architectures = []
> output.split("\n").grep(/for architecture/).each do |line|
> line =~ /for architecture (.*?)\)/
> architectures << $1
> end
> end
> # The compiler may not support all architectures in the binary.
> # XCode 4 seems to have removed support for the PPC architecture
> # even though there are still plenty of Apache binaries around
> # containing PPC components.
> architectures.reject! do |arch|
> !compiler_supports_architecture?(arch)
> end
> architectures.map! do |arch|
> "-arch #{arch}"
> end
> flags << architectures.compact.join(' ')
> end
> return flags.compact.join(' ').strip
> end
> memoize :apache2_module_cxxflags, true
603c692,693
< # Linker flags that are necessary for linking an Apache module.
---
>
> # Linker flags that are necessary for linking an Apache module.
flags << "-fPIC"
##To allow complier actually use the apache2_module_cxxflags.
root@dtcd-absnda1 # diff ./build/apache2.rb.bak ./build/apache2.rb
66c66
< "-Iext -Iext/common #{PlatformInfo.apache2_module_cflags} " <<
---
> "-Iext -Iext/common #{PlatformInfo.apache2_module_cxxflags} " <<
71c71
< PlatformInfo.apache2_module_cflags)
---
> PlatformInfo.apache2_module_cxxflags)
77c77
< define_tasks(PlatformInfo.apache2_module_cflags).
---
> define_tasks(PlatformInfo.apache2_module_cxxflags).