passenger 3.9.2.beta → 4.0.0.rc4
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of passenger might be problematic. Click here for more details.
- data/.travis.yml +3 -0
- data/NEWS +77 -7
- data/README.md +3 -11
- data/bin/passenger-install-apache2-module +24 -20
- data/bin/passenger-install-nginx-module +25 -23
- data/build/agents.rb +11 -0
- data/build/apache2.rb +9 -5
- data/build/basics.rb +37 -30
- data/build/common_library.rb +4 -1
- data/build/cplusplus_support.rb +5 -5
- data/build/cxx_tests.rb +28 -8
- data/build/integration_tests.rb +6 -3
- data/build/nginx.rb +3 -3
- data/build/packaging.rb +95 -57
- data/build/ruby_extension.rb +34 -21
- data/build/ruby_tests.rb +4 -2
- data/build/test_basics.rb +1 -1
- data/dev/run_travis.sh +36 -1
- data/doc/Users guide Apache.html +425 -308
- data/doc/Users guide Apache.idmap.txt +78 -70
- data/doc/Users guide Apache.index.sqlite3 +0 -0
- data/doc/Users guide Apache.txt +33 -92
- data/doc/Users guide Nginx.html +519 -220
- data/doc/Users guide Nginx.idmap.txt +78 -60
- data/doc/Users guide Nginx.txt +115 -26
- data/doc/Users guide Standalone.html +8 -2
- data/doc/users_guide_snippets/analysis_and_system_maintenance.txt +1 -7
- data/doc/users_guide_snippets/installation.txt +167 -22
- data/doc/users_guide_snippets/rackup_specifications.txt +4 -0
- data/doc/users_guide_snippets/since_version.txt +1 -0
- data/doc/users_guide_snippets/support_information.txt +3 -7
- data/doc/users_guide_snippets/tips.txt +0 -24
- data/ext/apache2/Configuration.cpp +11 -33
- data/ext/apache2/Configuration.hpp +3 -18
- data/ext/apache2/DirectoryMapper.h +20 -70
- data/ext/apache2/Hooks.cpp +2 -2
- data/ext/common/AgentsStarter.cpp +0 -2
- data/ext/common/AgentsStarter.h +0 -1
- data/ext/common/AgentsStarter.hpp +1 -3
- data/ext/common/ApplicationPool2/AppTypes.cpp +74 -0
- data/ext/common/ApplicationPool2/AppTypes.h +202 -0
- data/ext/common/ApplicationPool2/Common.h +12 -10
- data/ext/common/ApplicationPool2/DirectSpawner.h +256 -0
- data/ext/common/ApplicationPool2/DummySpawner.h +90 -0
- data/ext/common/ApplicationPool2/Group.h +311 -94
- data/ext/common/ApplicationPool2/Implementation.cpp +405 -145
- data/ext/common/ApplicationPool2/Options.h +24 -26
- data/ext/common/ApplicationPool2/PipeWatcher.h +20 -13
- data/ext/common/ApplicationPool2/Pool.h +326 -183
- data/ext/common/ApplicationPool2/Process.h +205 -55
- data/ext/common/ApplicationPool2/README.md +1 -1
- data/ext/common/ApplicationPool2/Session.h +21 -10
- data/ext/common/ApplicationPool2/SmartSpawner.h +801 -0
- data/ext/common/ApplicationPool2/Spawner.h +141 -1149
- data/ext/common/ApplicationPool2/SpawnerFactory.h +132 -0
- data/ext/common/ApplicationPool2/SuperGroup.h +146 -223
- data/ext/common/Constants.h +4 -2
- data/ext/common/Exceptions.h +23 -1
- data/ext/common/Logging.cpp +17 -6
- data/ext/common/Logging.h +37 -7
- data/ext/common/ResourceLocator.h +1 -1
- data/ext/common/Utils.cpp +49 -1
- data/ext/common/Utils.h +13 -4
- data/ext/common/{AnsiColorConstants.h → Utils/AnsiColorConstants.h} +0 -0
- data/ext/common/{BCrypt.cpp → Utils/BCrypt.cpp} +0 -0
- data/ext/common/{BCrypt.h → Utils/BCrypt.h} +0 -0
- data/ext/common/{Blowfish.c → Utils/Blowfish.c} +0 -0
- data/ext/common/{Blowfish.h → Utils/Blowfish.h} +0 -0
- data/ext/common/Utils/CachedFileStat.hpp +27 -25
- data/ext/common/Utils/Curl.h +184 -0
- data/ext/common/{HttpConstants.h → Utils/HttpConstants.h} +3 -0
- data/ext/common/Utils/IOUtils.cpp +6 -2
- data/ext/common/{IniFile.h → Utils/IniFile.h} +0 -0
- data/ext/common/Utils/LargeFiles.cpp +30 -0
- data/ext/common/Utils/LargeFiles.h +40 -0
- data/ext/common/Utils/StrIntUtils.cpp +72 -8
- data/ext/common/Utils/StrIntUtils.h +24 -2
- data/ext/common/Utils/StringMap.h +12 -2
- data/ext/common/Utils/VariantMap.h +51 -2
- data/ext/common/Utils/jsoncpp.cpp +1 -1
- data/ext/common/agents/Base.cpp +147 -11
- data/ext/common/agents/HelperAgent/AgentOptions.h +14 -6
- data/ext/common/agents/HelperAgent/Main.cpp +79 -19
- data/ext/common/agents/HelperAgent/RequestHandler.h +36 -16
- data/ext/common/agents/LoggingAgent/LoggingServer.h +3 -5
- data/ext/common/agents/LoggingAgent/Main.cpp +2 -4
- data/ext/common/agents/LoggingAgent/RemoteSender.h +18 -24
- data/ext/common/agents/SpawnPreparer.cpp +7 -0
- data/ext/common/agents/Watchdog/Main.cpp +96 -38
- data/ext/nginx/Configuration.c +26 -22
- data/ext/nginx/Configuration.h +4 -2
- data/ext/nginx/ContentHandler.c +23 -52
- data/ext/nginx/ContentHandler.h +5 -11
- data/ext/nginx/config +10 -3
- data/ext/nginx/ngx_http_passenger_module.c +21 -6
- data/ext/nginx/ngx_http_passenger_module.h +4 -1
- data/ext/oxt/dynamic_thread_group.hpp +9 -1
- data/ext/oxt/system_calls.cpp +2 -2
- data/ext/ruby/extconf.rb +2 -1
- data/helper-scripts/backtrace-sanitizer.rb +2 -0
- data/helper-scripts/wsgi-loader.py +54 -21
- data/lib/phusion_passenger.rb +5 -3
- data/lib/phusion_passenger/abstract_installer.rb +18 -41
- data/lib/phusion_passenger/admin_tools/memory_stats.rb +2 -2
- data/lib/phusion_passenger/admin_tools/server_instance.rb +2 -2
- data/lib/phusion_passenger/common_library.rb +23 -3
- data/lib/phusion_passenger/debug_logging.rb +10 -3
- data/lib/phusion_passenger/packaging.rb +1 -0
- data/lib/phusion_passenger/platform_info.rb +113 -115
- data/lib/phusion_passenger/platform_info/compiler.rb +224 -134
- data/lib/phusion_passenger/platform_info/cxx_portability.rb +143 -0
- data/lib/phusion_passenger/platform_info/depcheck.rb +371 -0
- data/lib/phusion_passenger/platform_info/depcheck_specs/apache2.rb +124 -0
- data/lib/phusion_passenger/platform_info/depcheck_specs/compiler_toolchain.rb +97 -0
- data/lib/phusion_passenger/platform_info/depcheck_specs/gems.rb +39 -0
- data/lib/phusion_passenger/platform_info/depcheck_specs/libs.rb +118 -0
- data/lib/phusion_passenger/platform_info/depcheck_specs/ruby.rb +137 -0
- data/lib/phusion_passenger/platform_info/depcheck_specs/utilities.rb +15 -0
- data/lib/phusion_passenger/platform_info/operating_system.rb +6 -5
- data/lib/phusion_passenger/platform_info/ruby.rb +45 -34
- data/lib/phusion_passenger/request_handler.rb +35 -22
- data/lib/phusion_passenger/request_handler/thread_handler.rb +5 -6
- data/lib/phusion_passenger/ruby_core_enhancements.rb +7 -1
- data/lib/phusion_passenger/standalone/runtime_installer.rb +43 -34
- data/lib/phusion_passenger/utils/robust_interruption.rb +34 -18
- data/passenger.gemspec +25 -0
- data/resources/templates/standalone/config.erb +3 -1
- data/test/config.json.travis +2 -2
- data/test/cxx/ApplicationPool2/DirectSpawnerTest.cpp +37 -5
- data/test/cxx/ApplicationPool2/PoolTest.cpp +143 -50
- data/test/cxx/ApplicationPool2/ProcessTest.cpp +8 -0
- data/test/cxx/ApplicationPool2/SmartSpawnerTest.cpp +28 -17
- data/test/cxx/ApplicationPool2/SpawnerTestCases.cpp +31 -26
- data/test/cxx/RequestHandlerTest.cpp +17 -1
- data/test/cxx/UtilsTest.cpp +84 -10
- data/test/integration_tests/apache2_tests.rb +49 -163
- data/test/integration_tests/hello_world_wsgi_spec.rb +2 -2
- data/test/integration_tests/mycook_spec.rb +1 -1
- data/test/integration_tests/nginx_tests.rb +37 -19
- data/test/ruby/request_handler_spec.rb +1 -0
- data/test/ruby/spec_helper.rb +52 -1
- data/test/stub/nginx/nginx.conf.erb +2 -0
- data/test/stub/rack/start.rb +5 -0
- data/test/stub/rails3.0/Gemfile.lock +30 -30
- data/test/stub/rails3.1/Gemfile +1 -1
- data/test/stub/rails3.1/Gemfile.lock +3 -3
- data/test/stub/rails3.2/Gemfile +1 -1
- data/test/stub/rails3.2/Gemfile.lock +4 -4
- data/test/stub/rails_apps/2.3/mycook/app/controllers/welcome_controller.rb +1 -1
- data/test/stub/rails_apps/2.3/mycook/app/helpers/recipes_helper.rb +2 -0
- data/test/stub/rails_apps/2.3/mycook/app/helpers/test_helper.rb +2 -0
- data/test/stub/rails_apps/2.3/mycook/app/helpers/uploads_helper.rb +2 -0
- data/test/stub/rails_apps/2.3/mycook/app/helpers/welcome_helper.rb +2 -0
- data/test/support/nginx_controller.rb +2 -1
- metadata +160 -156
- data/build/gempackagetask.rb +0 -99
- data/build/packagetask.rb +0 -186
- data/ext/common/StringListCreator.h +0 -83
- data/lib/phusion_passenger/dependencies.rb +0 -657
@@ -1,5 +1,5 @@
|
|
1
1
|
# Phusion Passenger - https://www.phusionpassenger.com/
|
2
|
-
# Copyright (c) 2010
|
2
|
+
# Copyright (c) 2010-2013 Phusion
|
3
3
|
#
|
4
4
|
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
5
5
|
#
|
@@ -22,30 +22,97 @@
|
|
22
22
|
# THE SOFTWARE.
|
23
23
|
|
24
24
|
require 'phusion_passenger/platform_info'
|
25
|
-
require 'phusion_passenger/platform_info/operating_system'
|
26
25
|
|
27
26
|
module PhusionPassenger
|
28
27
|
|
29
28
|
module PlatformInfo
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
29
|
+
private
|
30
|
+
def self.detect_language_extension(language)
|
31
|
+
case language
|
32
|
+
when :c
|
33
|
+
return "c"
|
34
|
+
when :cxx
|
35
|
+
return "cpp"
|
36
|
+
else
|
37
|
+
raise ArgumentError, "Unsupported language #{language.inspect}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
private_class_method :detect_language_extension
|
41
|
+
|
42
|
+
def self.create_compiler_command(language, flags1, flags2, link = false)
|
43
|
+
case language
|
44
|
+
when :c
|
45
|
+
result = [cc, link ? ENV['EXTRA_PRE_LDFLAGS'] : nil,
|
46
|
+
ENV['EXTRA_PRE_CFLAGS'], flags1, flags2, ENV['EXTRA_CFLAGS'],
|
47
|
+
ENV['EXTRA_LDFLAGS']]
|
48
|
+
when :cxx
|
49
|
+
result = [cxx, link ? ENV['EXTRA_PRE_LDFLAGS'] : nil,
|
50
|
+
ENV['EXTRA_PRE_CXXFLAGS'], flags1, flags2, ENV['EXTRA_CXXFLAGS'],
|
51
|
+
ENV['EXTRA_LDFLAGS']]
|
52
|
+
else
|
53
|
+
raise ArgumentError, "Unsupported language #{language.inspect}"
|
54
|
+
end
|
55
|
+
return result.compact.join(" ").strip
|
56
|
+
end
|
57
|
+
private_class_method :create_compiler_command
|
58
|
+
|
59
|
+
def self.run_compiler(description, command, source_file, source, capture_output = false)
|
60
|
+
if verbose?
|
61
|
+
message = "#{description}\n" <<
|
62
|
+
"Running: #{command}\n"
|
63
|
+
if source.strip.empty?
|
64
|
+
message << "Source file is empty."
|
65
|
+
else
|
66
|
+
message << "Source file contains:\n" <<
|
67
|
+
"-------------------------\n" <<
|
68
|
+
unindent(source) <<
|
69
|
+
"\n-------------------------"
|
70
|
+
end
|
71
|
+
log(message)
|
72
|
+
end
|
73
|
+
if capture_output
|
74
|
+
begin
|
75
|
+
output = `#{command} 2>&1`
|
76
|
+
result = $?.exitstatus == 0
|
77
|
+
rescue SystemCallError => e
|
78
|
+
result = false
|
79
|
+
exec_error_reason = e.message
|
80
|
+
end
|
81
|
+
log("Output:\n" <<
|
82
|
+
"-------------------------\n" <<
|
83
|
+
output <<
|
84
|
+
"\n-------------------------")
|
85
|
+
elsif verbose?
|
86
|
+
result = system(command)
|
87
|
+
else
|
88
|
+
result = system("(#{command}) >/dev/null 2>/dev/null")
|
89
|
+
end
|
90
|
+
if result.nil?
|
91
|
+
log("Command could not be executed! #{exec_error_reason}".strip)
|
92
|
+
return false
|
93
|
+
elsif result
|
94
|
+
log("Check suceeded")
|
95
|
+
if capture_output
|
96
|
+
return { :output => output }
|
40
97
|
else
|
41
|
-
return
|
98
|
+
return true
|
42
99
|
end
|
43
100
|
else
|
44
|
-
|
101
|
+
log("Check failed with exit status #{$?.exitstatus}")
|
102
|
+
return false
|
45
103
|
end
|
46
104
|
end
|
47
|
-
|
105
|
+
private_class_method :run_compiler
|
106
|
+
|
107
|
+
public
|
108
|
+
def self.cc
|
109
|
+
return string_env('CC', 'gcc')
|
110
|
+
end
|
48
111
|
|
112
|
+
def self.cxx
|
113
|
+
return string_env('CXX', 'g++')
|
114
|
+
end
|
115
|
+
|
49
116
|
def self.cc_is_clang?
|
50
117
|
`#{cc} --version 2>&1` =~ /clang version/
|
51
118
|
end
|
@@ -56,29 +123,132 @@ module PlatformInfo
|
|
56
123
|
end
|
57
124
|
memoize :cxx_is_clang?
|
58
125
|
|
126
|
+
|
127
|
+
# Looks for the given C or C++ header. This works by invoking the compiler and
|
128
|
+
# searching in the compiler's header search path. Returns its full filename,
|
129
|
+
# or true if this function knows that the header exists but can't find it (e.g.
|
130
|
+
# because the compiler cannot tell us what its header search path is).
|
131
|
+
# Returns nil if the header cannot be found.
|
132
|
+
def self.find_header(header_name, language, flags = nil)
|
133
|
+
extension = detect_language_extension(language)
|
134
|
+
create_temp_file("passenger-compile-check.#{extension}") do |filename, f|
|
135
|
+
source = %Q{
|
136
|
+
#include <#{header_name}>
|
137
|
+
}
|
138
|
+
f.puts(source)
|
139
|
+
f.close
|
140
|
+
begin
|
141
|
+
command = create_compiler_command(language,
|
142
|
+
"-v -c '#{filename}' -o '#{filename}.o'",
|
143
|
+
flags)
|
144
|
+
if result = run_compiler("Checking for #{header_name}", command, filename, source, true)
|
145
|
+
result[:output] =~ /^#include <...> search starts here:$(.+?)^End of search list\.$/m
|
146
|
+
search_paths = $1.to_s.strip.split("\n").map{ |line| line.strip }
|
147
|
+
search_paths.each do |dir|
|
148
|
+
if File.file?("#{dir}/#{header_name}")
|
149
|
+
return "#{dir}/#{header_name}"
|
150
|
+
end
|
151
|
+
end
|
152
|
+
return true
|
153
|
+
else
|
154
|
+
return nil
|
155
|
+
end
|
156
|
+
ensure
|
157
|
+
File.unlink("#{filename}.o") rescue nil
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def self.try_compile(description, language, source, flags = nil)
|
163
|
+
extension = detect_language_extension(language)
|
164
|
+
create_temp_file("passenger-compile-check.#{extension}") do |filename, f|
|
165
|
+
f.puts(source)
|
166
|
+
f.close
|
167
|
+
begin
|
168
|
+
command = create_compiler_command(language,
|
169
|
+
"-c '#{filename}' -o '#{filename}.o'",
|
170
|
+
flags)
|
171
|
+
return run_compiler(description, command, filename, source)
|
172
|
+
ensure
|
173
|
+
File.unlink("#{filename}.o") rescue nil
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def self.try_link(description, language, source, flags = nil)
|
179
|
+
extension = detect_language_extension(language)
|
180
|
+
create_temp_file("passenger-link-check.#{extension}") do |filename, f|
|
181
|
+
f.puts(source)
|
182
|
+
f.close
|
183
|
+
begin
|
184
|
+
command = create_compiler_command(language,
|
185
|
+
"'#{filename}' -o '#{filename}.out'",
|
186
|
+
flags, true)
|
187
|
+
return run_compiler(description, command, filename, source)
|
188
|
+
ensure
|
189
|
+
File.unlink("#{filename}.out") rescue nil
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
def self.try_compile_and_run(description, language, source, flags = nil)
|
195
|
+
extension = detect_language_extension(language)
|
196
|
+
create_temp_file("passenger-run-check.#{extension}", tmpexedir) do |filename, f|
|
197
|
+
f.puts(source)
|
198
|
+
f.close
|
199
|
+
begin
|
200
|
+
command = create_compiler_command(language,
|
201
|
+
"'#{filename}' -o '#{filename}.out'",
|
202
|
+
flags, true)
|
203
|
+
if run_compiler(description, command, filename, source)
|
204
|
+
log("Running #{filename}.out")
|
205
|
+
begin
|
206
|
+
output = `'#{filename}.out' 2>&1`
|
207
|
+
rescue SystemCallError => e
|
208
|
+
log("Command failed: #{e}")
|
209
|
+
return false
|
210
|
+
end
|
211
|
+
status = $?.exitstatus
|
212
|
+
log("Command exited with status #{status}. Output:\n--------------\n#{output}\n--------------")
|
213
|
+
return status == 0
|
214
|
+
else
|
215
|
+
return false
|
216
|
+
end
|
217
|
+
ensure
|
218
|
+
File.unlink("#{filename}.out") rescue nil
|
219
|
+
end
|
220
|
+
end
|
221
|
+
end
|
222
|
+
|
223
|
+
|
59
224
|
# Checks whether the compiler supports "-arch #{arch}".
|
60
225
|
def self.compiler_supports_architecture?(arch)
|
61
|
-
return try_compile(
|
226
|
+
return try_compile("Checking for C compiler '-arch' support",
|
227
|
+
:c, '', "-arch #{arch}")
|
62
228
|
end
|
63
229
|
|
64
230
|
def self.compiler_supports_visibility_flag?
|
65
231
|
return false if RUBY_PLATFORM =~ /aix/
|
66
|
-
return try_compile(
|
232
|
+
return try_compile("Checking for C compiler '-fvisibility' support",
|
233
|
+
:c, '', '-fvisibility=hidden')
|
67
234
|
end
|
68
235
|
memoize :compiler_supports_visibility_flag?, true
|
69
236
|
|
70
237
|
def self.compiler_supports_wno_attributes_flag?
|
71
|
-
return try_compile(
|
238
|
+
return try_compile("Checking for C compiler '-Wno-attributes' support",
|
239
|
+
:c, '', '-Wno-attributes')
|
72
240
|
end
|
73
241
|
memoize :compiler_supports_wno_attributes_flag?, true
|
74
242
|
|
75
243
|
def self.compiler_supports_wno_missing_field_initializers_flag?
|
76
|
-
return try_compile(
|
244
|
+
return try_compile("Checking for C compiler '-Wno-missing-field-initializers' support",
|
245
|
+
:c, '', '-Wno-missing-field-initializers')
|
77
246
|
end
|
78
|
-
memoize :compiler_supports_wno_missing_field_initializers_flag
|
247
|
+
memoize :compiler_supports_wno_missing_field_initializers_flag?, true
|
79
248
|
|
80
249
|
def self.compiler_supports_no_tls_direct_seg_refs_option?
|
81
|
-
return try_compile(
|
250
|
+
return try_compile("Checking for C compiler '-mno-tls-direct-seg-refs' support",
|
251
|
+
:c, '', '-mno-tls-direct-seg-refs')
|
82
252
|
end
|
83
253
|
memoize :compiler_supports_no_tls_direct_seg_refs_option?, true
|
84
254
|
|
@@ -98,125 +268,16 @@ module PlatformInfo
|
|
98
268
|
memoize :compiler_visibility_flag_generates_warnings?, true
|
99
269
|
|
100
270
|
def self.has_math_library?
|
101
|
-
return try_link(
|
271
|
+
return try_link("Checking for -lmath support",
|
272
|
+
:c, "int main() { return 0; }\n", '-lmath')
|
102
273
|
end
|
103
274
|
memoize :has_math_library?, true
|
104
275
|
|
105
276
|
def self.has_alloca_h?
|
106
|
-
return try_compile(
|
277
|
+
return try_compile("Checking for alloca.h",
|
278
|
+
:c, '#include <alloca.h>')
|
107
279
|
end
|
108
280
|
memoize :has_alloca_h?, true
|
109
|
-
|
110
|
-
# Compiler flags that should be used for compiling every C/C++ program,
|
111
|
-
# for portability reasons. These flags should be specified as last
|
112
|
-
# when invoking the compiler.
|
113
|
-
def self.portability_cflags
|
114
|
-
flags = ["-D_REENTRANT -I/usr/local/include"]
|
115
|
-
|
116
|
-
# There are too many implementations of of the hash map!
|
117
|
-
# Figure out the right one.
|
118
|
-
ok = try_compile(:cxx, %Q{
|
119
|
-
#include <tr1/unordered_map>
|
120
|
-
int
|
121
|
-
main() {
|
122
|
-
std::tr1::unordered_map<int, int> m;
|
123
|
-
return 0;
|
124
|
-
}
|
125
|
-
})
|
126
|
-
if ok
|
127
|
-
flags << "-DHAS_TR1_UNORDERED_MAP"
|
128
|
-
else
|
129
|
-
hash_namespace = nil
|
130
|
-
ok = false
|
131
|
-
['__gnu_cxx', '', 'std', 'stdext'].each do |namespace|
|
132
|
-
['hash_map', 'ext/hash_map'].each do |hash_map_header|
|
133
|
-
ok = try_compile(:cxx, %Q{
|
134
|
-
#include <#{hash_map_header}>
|
135
|
-
int
|
136
|
-
main() {
|
137
|
-
#{namespace}::hash_map<int, int> m;
|
138
|
-
return 0;
|
139
|
-
}
|
140
|
-
})
|
141
|
-
if ok
|
142
|
-
hash_namespace = namespace
|
143
|
-
flags << "-DHASH_NAMESPACE=\"#{namespace}\""
|
144
|
-
flags << "-DHASH_MAP_HEADER=\"<#{hash_map_header}>\""
|
145
|
-
flags << "-DHASH_MAP_CLASS=\"hash_map\""
|
146
|
-
end
|
147
|
-
break if ok
|
148
|
-
end
|
149
|
-
break if ok
|
150
|
-
end
|
151
|
-
['ext/hash_fun.h', 'functional', 'tr1/functional',
|
152
|
-
'ext/stl_hash_fun.h', 'hash_fun.h', 'stl_hash_fun.h',
|
153
|
-
'stl/_hash_fun.h'].each do |hash_function_header|
|
154
|
-
ok = try_compile(:cxx, %Q{
|
155
|
-
#include <#{hash_function_header}>
|
156
|
-
int
|
157
|
-
main() {
|
158
|
-
#{hash_namespace}::hash<int>()(5);
|
159
|
-
return 0;
|
160
|
-
}
|
161
|
-
})
|
162
|
-
if ok
|
163
|
-
flags << "-DHASH_FUN_H=\"<#{hash_function_header}>\""
|
164
|
-
break
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
ok = try_compile(:c, %Q{
|
170
|
-
#define _GNU_SOURCE
|
171
|
-
#include <sys/socket.h>
|
172
|
-
static void *foo = accept4;
|
173
|
-
})
|
174
|
-
flags << '-DHAVE_ACCEPT4' if ok
|
175
|
-
|
176
|
-
if RUBY_PLATFORM =~ /solaris/
|
177
|
-
flags << '-pthreads'
|
178
|
-
if RUBY_PLATFORM =~ /solaris2.11/
|
179
|
-
# skip the _XOPEN_SOURCE and _XPG4_2 definitions in later versions of Solaris / OpenIndiana
|
180
|
-
flags << '-D__EXTENSIONS__ -D__SOLARIS__ -D_FILE_OFFSET_BITS=64'
|
181
|
-
else
|
182
|
-
flags << '-D_XOPEN_SOURCE=500 -D_XPG4_2 -D__EXTENSIONS__ -D__SOLARIS__ -D_FILE_OFFSET_BITS=64'
|
183
|
-
flags << '-D__SOLARIS9__ -DBOOST__STDC_CONSTANT_MACROS_DEFINED' if RUBY_PLATFORM =~ /solaris2.9/
|
184
|
-
end
|
185
|
-
flags << '-DBOOST_HAS_STDINT_H' unless RUBY_PLATFORM =~ /solaris2.9/
|
186
|
-
flags << '-mcpu=ultrasparc' if RUBY_PLATFORM =~ /sparc/
|
187
|
-
elsif RUBY_PLATFORM =~ /openbsd/
|
188
|
-
flags << '-DBOOST_HAS_STDINT_H -D_GLIBCPP__PTHREADS'
|
189
|
-
elsif RUBY_PLATFORM =~ /aix/
|
190
|
-
flags << '-pthread'
|
191
|
-
flags << '-DOXT_DISABLE_BACKTRACES'
|
192
|
-
elsif RUBY_PLATFORM =~ /(sparc-linux|arm-linux|^arm.*-linux|sh4-linux)/
|
193
|
-
# http://code.google.com/p/phusion-passenger/issues/detail?id=200
|
194
|
-
# http://groups.google.com/group/phusion-passenger/t/6b904a962ee28e5c
|
195
|
-
# http://groups.google.com/group/phusion-passenger/browse_thread/thread/aad4bd9d8d200561
|
196
|
-
flags << '-DBOOST_SP_USE_PTHREADS'
|
197
|
-
end
|
198
|
-
|
199
|
-
flags << '-DHAS_ALLOCA_H' if has_alloca_h?
|
200
|
-
flags << '-DHAS_SFENCE' if supports_sfence_instruction?
|
201
|
-
flags << '-DHAS_LFENCE' if supports_lfence_instruction?
|
202
|
-
|
203
|
-
return flags.compact.join(" ").strip
|
204
|
-
end
|
205
|
-
memoize :portability_cflags, true
|
206
|
-
|
207
|
-
# Linker flags that should be used for linking every C/C++ program,
|
208
|
-
# for portability reasons. These flags should be specified as last
|
209
|
-
# when invoking the linker.
|
210
|
-
def self.portability_ldflags
|
211
|
-
if RUBY_PLATFORM =~ /solaris/
|
212
|
-
result = '-lxnet -lrt -lsocket -lnsl -lpthread'
|
213
|
-
else
|
214
|
-
result = '-lpthread'
|
215
|
-
end
|
216
|
-
flags << ' -lmath' if has_math_library?
|
217
|
-
return result
|
218
|
-
end
|
219
|
-
memoize :portability_ldflags
|
220
281
|
|
221
282
|
# C compiler flags that should be passed in order to enable debugging information.
|
222
283
|
def self.debugging_cflags
|
@@ -272,6 +333,35 @@ module PlatformInfo
|
|
272
333
|
return nil
|
273
334
|
end
|
274
335
|
end
|
336
|
+
|
337
|
+
|
338
|
+
def self.make
|
339
|
+
return string_env('MAKE', find_command('make'))
|
340
|
+
end
|
341
|
+
memoize :make, true
|
342
|
+
|
343
|
+
def self.gnu_make
|
344
|
+
if result = string_env('GMAKE')
|
345
|
+
return result
|
346
|
+
else
|
347
|
+
result = find_command('gmake')
|
348
|
+
if !result
|
349
|
+
result = find_command('make')
|
350
|
+
if result
|
351
|
+
if `#{result} --version 2>&1` =~ /GNU/
|
352
|
+
return result
|
353
|
+
else
|
354
|
+
return nil
|
355
|
+
end
|
356
|
+
else
|
357
|
+
return nil
|
358
|
+
end
|
359
|
+
else
|
360
|
+
return result
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|
364
|
+
memoize :gnu_make, true
|
275
365
|
end
|
276
366
|
|
277
367
|
end # module PhusionPassenger
|
@@ -0,0 +1,143 @@
|
|
1
|
+
# Phusion Passenger - https://www.phusionpassenger.com/
|
2
|
+
# Copyright (c) 2010-2013 Phusion
|
3
|
+
#
|
4
|
+
# "Phusion Passenger" is a trademark of Hongli Lai & Ninh Bui.
|
5
|
+
#
|
6
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
7
|
+
# of this software and associated documentation files (the "Software"), to deal
|
8
|
+
# in the Software without restriction, including without limitation the rights
|
9
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10
|
+
# copies of the Software, and to permit persons to whom the Software is
|
11
|
+
# furnished to do so, subject to the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be included in
|
14
|
+
# all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
19
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22
|
+
# THE SOFTWARE.
|
23
|
+
|
24
|
+
require 'phusion_passenger/platform_info'
|
25
|
+
require 'phusion_passenger/platform_info/compiler'
|
26
|
+
require 'phusion_passenger/platform_info/operating_system'
|
27
|
+
|
28
|
+
module PhusionPassenger
|
29
|
+
|
30
|
+
module PlatformInfo
|
31
|
+
# Compiler flags that should be used for compiling every C/C++ program,
|
32
|
+
# for portability reasons. These flags should be specified as last
|
33
|
+
# when invoking the compiler.
|
34
|
+
def self.portability_cflags
|
35
|
+
flags = ["-D_REENTRANT -I/usr/local/include"]
|
36
|
+
|
37
|
+
# There are too many implementations of of the hash map!
|
38
|
+
# Figure out the right one.
|
39
|
+
ok = try_compile("Checking for tr1/unordered_map", :cxx, %Q{
|
40
|
+
#include <tr1/unordered_map>
|
41
|
+
int
|
42
|
+
main() {
|
43
|
+
std::tr1::unordered_map<int, int> m;
|
44
|
+
return 0;
|
45
|
+
}
|
46
|
+
})
|
47
|
+
if ok
|
48
|
+
flags << "-DHAS_TR1_UNORDERED_MAP"
|
49
|
+
else
|
50
|
+
hash_namespace = nil
|
51
|
+
ok = false
|
52
|
+
['__gnu_cxx', '', 'std', 'stdext'].each do |namespace|
|
53
|
+
['hash_map', 'ext/hash_map'].each do |hash_map_header|
|
54
|
+
ok = try_compile("Checking for #{hash_map_header}", :cxx, %Q{
|
55
|
+
#include <#{hash_map_header}>
|
56
|
+
int
|
57
|
+
main() {
|
58
|
+
#{namespace}::hash_map<int, int> m;
|
59
|
+
return 0;
|
60
|
+
}
|
61
|
+
})
|
62
|
+
if ok
|
63
|
+
hash_namespace = namespace
|
64
|
+
flags << "-DHASH_NAMESPACE=\"#{namespace}\""
|
65
|
+
flags << "-DHASH_MAP_HEADER=\"<#{hash_map_header}>\""
|
66
|
+
flags << "-DHASH_MAP_CLASS=\"hash_map\""
|
67
|
+
end
|
68
|
+
break if ok
|
69
|
+
end
|
70
|
+
break if ok
|
71
|
+
end
|
72
|
+
['ext/hash_fun.h', 'functional', 'tr1/functional',
|
73
|
+
'ext/stl_hash_fun.h', 'hash_fun.h', 'stl_hash_fun.h',
|
74
|
+
'stl/_hash_fun.h'].each do |hash_function_header|
|
75
|
+
ok = try_compile("Checking for #{hash_function_header}", :cxx, %Q{
|
76
|
+
#include <#{hash_function_header}>
|
77
|
+
int
|
78
|
+
main() {
|
79
|
+
#{hash_namespace}::hash<int>()(5);
|
80
|
+
return 0;
|
81
|
+
}
|
82
|
+
})
|
83
|
+
if ok
|
84
|
+
flags << "-DHASH_FUN_H=\"<#{hash_function_header}>\""
|
85
|
+
break
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
ok = try_compile("Checking for accept4()", :c, %Q{
|
91
|
+
#define _GNU_SOURCE
|
92
|
+
#include <sys/socket.h>
|
93
|
+
static void *foo = accept4;
|
94
|
+
})
|
95
|
+
flags << '-DHAVE_ACCEPT4' if ok
|
96
|
+
|
97
|
+
if RUBY_PLATFORM =~ /solaris/
|
98
|
+
flags << '-pthreads'
|
99
|
+
if RUBY_PLATFORM =~ /solaris2.11/
|
100
|
+
# skip the _XOPEN_SOURCE and _XPG4_2 definitions in later versions of Solaris / OpenIndiana
|
101
|
+
flags << '-D__EXTENSIONS__ -D__SOLARIS__ -D_FILE_OFFSET_BITS=64'
|
102
|
+
else
|
103
|
+
flags << '-D_XOPEN_SOURCE=500 -D_XPG4_2 -D__EXTENSIONS__ -D__SOLARIS__ -D_FILE_OFFSET_BITS=64'
|
104
|
+
flags << '-D__SOLARIS9__ -DBOOST__STDC_CONSTANT_MACROS_DEFINED' if RUBY_PLATFORM =~ /solaris2.9/
|
105
|
+
end
|
106
|
+
flags << '-DBOOST_HAS_STDINT_H' unless RUBY_PLATFORM =~ /solaris2.9/
|
107
|
+
flags << '-mcpu=ultrasparc' if RUBY_PLATFORM =~ /sparc/
|
108
|
+
elsif RUBY_PLATFORM =~ /openbsd/
|
109
|
+
flags << '-DBOOST_HAS_STDINT_H -D_GLIBCPP__PTHREADS'
|
110
|
+
elsif RUBY_PLATFORM =~ /aix/
|
111
|
+
flags << '-pthread'
|
112
|
+
flags << '-DOXT_DISABLE_BACKTRACES'
|
113
|
+
elsif RUBY_PLATFORM =~ /(sparc-linux|arm-linux|^arm.*-linux|sh4-linux)/
|
114
|
+
# http://code.google.com/p/phusion-passenger/issues/detail?id=200
|
115
|
+
# http://groups.google.com/group/phusion-passenger/t/6b904a962ee28e5c
|
116
|
+
# http://groups.google.com/group/phusion-passenger/browse_thread/thread/aad4bd9d8d200561
|
117
|
+
flags << '-DBOOST_SP_USE_PTHREADS'
|
118
|
+
end
|
119
|
+
|
120
|
+
flags << '-DHAS_ALLOCA_H' if has_alloca_h?
|
121
|
+
flags << '-DHAS_SFENCE' if supports_sfence_instruction?
|
122
|
+
flags << '-DHAS_LFENCE' if supports_lfence_instruction?
|
123
|
+
|
124
|
+
return flags.compact.join(" ").strip
|
125
|
+
end
|
126
|
+
memoize :portability_cflags, true
|
127
|
+
|
128
|
+
# Linker flags that should be used for linking every C/C++ program,
|
129
|
+
# for portability reasons. These flags should be specified as last
|
130
|
+
# when invoking the linker.
|
131
|
+
def self.portability_ldflags
|
132
|
+
if RUBY_PLATFORM =~ /solaris/
|
133
|
+
result = '-lxnet -lrt -lsocket -lnsl -lpthread'
|
134
|
+
else
|
135
|
+
result = '-lpthread'
|
136
|
+
end
|
137
|
+
flags << ' -lmath' if has_math_library?
|
138
|
+
return result
|
139
|
+
end
|
140
|
+
memoize :portability_ldflags
|
141
|
+
end
|
142
|
+
|
143
|
+
end # module PhusionPassenger
|