Skip to content

Commit 93cd250

Browse files
committed
$extmk must be true for MRI C-ext tests to compile
1 parent b730cbf commit 93cd250

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

lib/mri/mkmf.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def map_dir(dir, map = nil)
233233
end
234234

235235
if RUBY_ENGINE == 'truffleruby'
236-
$extmk = Truffle::Boot.get_option('building.core.cexts')
236+
$extmk = Truffle::Boot.get_option('building.core.cexts') || ENV.key?('MKMF_SET_EXTMK_TO_TRUE')
237237
topdir = RbConfig::CONFIG['prefix'] # the TruffleRuby home
238238
$hdrdir = RbConfig::CONFIG["rubyhdrdir"] # lib/cext/include
239239
$arch_hdrdir = RbConfig::CONFIG["rubyarchhdrdir"] # lib/cext/include

tool/jt.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -781,18 +781,18 @@ def cextc(cext_dir, *clang_opts)
781781
name = File.basename(cext_dir)
782782
ext_dir = "#{cext_dir}/ext/#{name}"
783783
target = "#{cext_dir}/lib/#{name}/#{name}.su"
784-
compile_cext(name, ext_dir, target, *clang_opts)
784+
compile_cext(name, ext_dir, target, clang_opts)
785785
end
786786

787-
def compile_cext(name, ext_dir, target, *clang_opts)
787+
def compile_cext(name, ext_dir, target, clang_opts, env: {})
788788
extconf = "#{ext_dir}/extconf.rb"
789789
raise "#{extconf} does not exist" unless File.exist?(extconf)
790790

791791
# Make sure ruby.su is built
792792
build("cexts")
793793

794794
chdir(ext_dir) do
795-
run_ruby('-rmkmf', "#{ext_dir}/extconf.rb") # -rmkmf is required for C ext tests
795+
run_ruby(env, '-rmkmf', "#{ext_dir}/extconf.rb") # -rmkmf is required for C ext tests
796796
if File.exists?('Makefile')
797797
raw_sh("make")
798798
FileUtils::Verbose.cp("#{name}.su", target) if target
@@ -1026,6 +1026,11 @@ def run_mri_tests(extra_args, test_files, runner_args, run_options)
10261026
"RUBYOPT" => [*ENV['RUBYOPT'], '--disable-gems'].join(' '),
10271027
"TRUFFLERUBY_RESILIENT_GEM_HOME" => nil,
10281028
}
1029+
compile_env = {
1030+
# MRI C-ext tests expect to be built with $extmk = true.
1031+
"MKMF_SET_EXTMK_TO_TRUE" => "true",
1032+
}
1033+
10291034
cext_tests = test_files.select do |f|
10301035
f.include?("cext-ruby") ||
10311036
f == "ruby/test_file_exhaustive.rb"
@@ -1058,7 +1063,7 @@ def run_mri_tests(extra_args, test_files, runner_args, run_options)
10581063
end
10591064
dest_dir = File.join(MRI_TEST_CEXT_LIB_DIR, target_dir)
10601065
FileUtils::Verbose.mkdir_p(dest_dir)
1061-
compile_cext(name, compile_dir, dest_dir)
1066+
compile_cext(name, compile_dir, dest_dir, [], env: compile_env)
10621067
else
10631068
puts "c require not found for cext test: #{test_path}"
10641069
end
@@ -1193,7 +1198,7 @@ def test_cexts(*args)
11931198
gem_root = "#{TRUFFLERUBY_DIR}/test/truffle/cexts/#{gem_name}"
11941199
ext_dir = Dir.glob("#{gem_home}/gems/#{gem_name}*/")[0] + "ext/#{gem_name}"
11951200

1196-
compile_cext gem_name, ext_dir, "#{gem_root}/lib/#{gem_name}/#{gem_name}.su", '-Werror=implicit-function-declaration'
1201+
compile_cext gem_name, ext_dir, "#{gem_root}/lib/#{gem_name}/#{gem_name}.su", ['-Werror=implicit-function-declaration']
11971202

11981203
next if gem_name == 'psd_native' # psd_native is excluded just for running
11991204
run_ruby *dependencies.map { |d| "-I#{gem_home}/gems/#{d}/lib" },

0 commit comments

Comments
 (0)