Skip to content

Commit

Permalink
Merge pull request #33 from mpokrywka/xen-support
Browse files Browse the repository at this point in the history
Fix problems on virtualized Xen platforms (i.e. amazon ec2) by compiling with -mno-tls-direct-seg-refs
  • Loading branch information
FooBarWidget committed Nov 26, 2011
2 parents b8aedaf + 0a5f1b0 commit 054d106
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions build/config.rb
Expand Up @@ -35,6 +35,7 @@
# Should be included last in the command string, even after PlatformInfo.portability_cflags.
EXTRA_CXXFLAGS = "-Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-long-long"
EXTRA_CXXFLAGS << " -Wno-missing-field-initializers" if PlatformInfo.compiler_supports_wno_missing_field_initializers_flag?
EXTRA_CXXFLAGS << " -mno-tls-direct-seg-refs" if PlatformInfo.requires_no_tls_direct_seg_refs? && PlatformInfo.compiler_supports_no_tls_direct_seg_refs_option?
EXTRA_CXXFLAGS << " #{OPTIMIZATION_FLAGS}" if !OPTIMIZATION_FLAGS.empty?

# Extra linker flags that should always be passed to the linker.
Expand Down
5 changes: 5 additions & 0 deletions lib/phusion_passenger/platform_info/compiler.rb
Expand Up @@ -66,6 +66,11 @@ def self.compiler_supports_wno_missing_field_initializers_flag?
end
memoize :compiler_supports_wno_missing_field_initializers_flag?

def self.compiler_supports_no_tls_direct_seg_refs_option?
return try_compile(:c, '', '-mno-tls-direct-seg-refs')
end
memoize :compiler_supports_no_tls_direct_seg_refs_option?, true

# Returns whether compiling C++ with -fvisibility=hidden might result
# in tons of useless warnings, like this:
# http://code.google.com/p/phusion-passenger/issues/detail?id=526
Expand Down
5 changes: 5 additions & 0 deletions lib/phusion_passenger/platform_info/operating_system.rb
Expand Up @@ -153,6 +153,11 @@ def self.supports_lfence_instruction?
}))
end
memoize :supports_lfence_instruction?, true

def self.requires_no_tls_direct_seg_refs?
return File.exists?("/proc/xen/capabilities") && cpu_architectures[0] == "x86"
end
memoize :requires_no_tls_direct_seg_refs?, true
end

end # module PhusionPassenger

0 comments on commit 054d106

Please sign in to comment.