# File lib/phusion_passenger/platform_info/compiler.rb, line 102
        def self.portability_cflags
                flags = ["-D_REENTRANT -I/usr/local/include"]
                
                # Google SparseHash flags.
                # Figure out header for hash function object and its namespace.
                # Based on stl_hash.m4 and stl_hash_fun.m4 in the Google SparseHash sources.
                hash_namespace = nil
                ok = false
                ['__gnu_cxx', '', 'std', 'stdext'].each do |namespace|
                        ['ext/hash_map', 'hash_map'].each do |hash_map_header|
                                ok = try_compile(:cxx, %Q{
                                        #include <#{hash_map_header}>
                                        int
                                        main() {
                                                #{namespace}::hash_map<int, int> m;
                                                return 0;
                                        }
                                })
                                if ok
                                        hash_namespace = namespace
                                        flags << "-DHASH_NAMESPACE=\"#{namespace}\""
                                end
                        end
                        break if ok
                end
                ['ext/hash_fun.h', 'functional', 'tr1/functional',
                 'ext/stl_hash_fun.h', 'hash_fun.h', 'stl_hash_fun.h',
                 'stl/_hash_fun.h'].each do |hash_function_header|
                        ok = try_compile(:cxx, %Q{
                                #include <#{hash_function_header}>
                                int
                                main() {
                                        #{hash_namespace}::hash<int>()(5);
                                        return 0;
                                }
                        })
                        if ok
                                flags << "-DHASH_FUN_H=\"<#{hash_function_header}>\""
                                break
                        end
                end
                
                if RUBY_PLATFORM =~ /solaris/
                        flags << '-pthreads'
                        if RUBY_PLATFORM =~ /solaris2.11/
                                # skip the _XOPEN_SOURCE and _XPG4_2 definitions in later versions of Solaris / OpenIndiana
                                flags << '-D__EXTENSIONS__ -D__SOLARIS__ -D_FILE_OFFSET_BITS=64'
                        else
                                flags << '-D_XOPEN_SOURCE=500 -D_XPG4_2 -D__EXTENSIONS__ -D__SOLARIS__ -D_FILE_OFFSET_BITS=64'
                                flags << '-D__SOLARIS9__ -DBOOST__STDC_CONSTANT_MACROS_DEFINED' if RUBY_PLATFORM =~ /solaris2.9/
                        end
                        flags << '-D_XOPEN_SOURCE=500 -D_XPG4_2 -D__EXTENSIONS__ -D__SOLARIS__ -D_FILE_OFFSET_BITS=64'
                        flags << '-DBOOST_HAS_STDINT_H' unless RUBY_PLATFORM =~ /solaris2.9/
                        flags << '-mcpu=ultrasparc' if RUBY_PLATFORM =~ /sparc/
                elsif RUBY_PLATFORM =~ /openbsd/
                        flags << '-DBOOST_HAS_STDINT_H -D_GLIBCPP__PTHREADS'
                elsif RUBY_PLATFORM =~ /aix/
                        flags << '-DOXT_DISABLE_BACKTRACES'
                elsif RUBY_PLATFORM =~ /(sparc-linux|arm-linux|^arm.*-linux|sh4-linux)/
                        # http://code.google.com/p/phusion-passenger/issues/detail?id=200
                        # http://groups.google.com/group/phusion-passenger/t/6b904a962ee28e5c
                        # http://groups.google.com/group/phusion-passenger/browse_thread/thread/aad4bd9d8d200561
                        flags << '-DBOOST_SP_USE_PTHREADS'
                end
                
                flags << '-DHAS_ALLOCA_H' if has_alloca_h?
                flags << '-DHAS_SFENCE' if supports_sfence_instruction?
                flags << '-DHAS_LFENCE' if supports_lfence_instruction?
                
                return flags.compact.join(" ").strip
        end