summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/rubygems/ext/ext_conf_builder.rb5
-rw-r--r--test/rubygems/test_gem_ext_builder.rb5
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/rubygems/ext/ext_conf_builder.rb b/lib/rubygems/ext/ext_conf_builder.rb
index 6645c56773..e652a221f8 100644
--- a/lib/rubygems/ext/ext_conf_builder.rb
+++ b/lib/rubygems/ext/ext_conf_builder.rb
@@ -45,7 +45,10 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
full_tmp_dest = File.join(extension_dir, tmp_dest_relative)
- if Gem.install_extension_in_lib && lib_dir
+ is_cross_compiling = target_rbconfig["platform"] != RbConfig::CONFIG["platform"]
+ # Do not copy extension libraries by default when cross-compiling
+ # not to conflict with the one already built for the host platform.
+ if Gem.install_extension_in_lib && lib_dir && !is_cross_compiling
FileUtils.mkdir_p lib_dir
entries = Dir.entries(full_tmp_dest) - %w[. ..]
entries = entries.map {|entry| File.join full_tmp_dest, entry }
diff --git a/test/rubygems/test_gem_ext_builder.rb b/test/rubygems/test_gem_ext_builder.rb
index 9907ec5f21..d84091d00c 100644
--- a/test/rubygems/test_gem_ext_builder.rb
+++ b/test/rubygems/test_gem_ext_builder.rb
@@ -330,6 +330,7 @@ install:
end
f.puts "RbConfig::CONFIG['host_os'] = 'fake_os'"
f.puts "RbConfig::CONFIG['arch'] = 'fake_arch'"
+ f.puts "RbConfig::CONFIG['platform'] = 'fake_platform'"
end
system(Gem.ruby, "-rmkmf", "-e", "exit MakeMakefile::RbConfig::CONFIG['host_os'] == 'fake_os'",
@@ -340,6 +341,9 @@ install:
@builder = Gem::Ext::Builder.new @spec, "", Gem::TargetRbConfig.from_path(fake_rbconfig)
FileUtils.mkdir_p @spec.gem_dir
+ lib_dir = File.join(@spec.gem_dir, "lib")
+
+ FileUtils.mkdir lib_dir
File.open File.join(@spec.gem_dir, "extconf.rb"), "w" do |f|
f.write <<-'RUBY'
@@ -367,6 +371,7 @@ install:
arch=fake_arch
DUMP
assert_path_exist @spec.extension_dir
+ assert_equal [], Dir.glob(File.join(lib_dir, "*"))
end
def test_initialize