Skip to content

Commit d5d7750

Browse files
committed
Do not use gems precompiled for MRI on TruffleRuby
* See rubygems/rubygems#2945 * The platforms are set before they are read so this is safe. truffleruby.rb is required directly from rubygems.rb. (cherry picked from commit 6da9d7c)
1 parent 1173bdc commit d5d7750

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ Bug fixes:
7878
* Fixed linking of always-inline C API functions with `-std=gnu90` (#1837, #1879).
7979
* Avoid race conditions during `gem install` by using a single download thread.
8080
* `RSTRING_PTR()` now always returns a native pointer, resolving two bugs `memcpy`ing to (#1822) and from (#1772) Ruby Strings.
81+
* Do not use gems precompiled for MRI on TruffleRuby (#1837).
8182

8283
Compatibility:
8384

lib/truffle/rubygems/defaults/truffleruby.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@ module Gem
1616
def self.default_dir
1717
@default_dir ||= "#{Truffle::Boot.ruby_home or raise 'TruffleRuby home not found'}/lib/gems"
1818
end
19+
20+
# Only report the RUBY platform as supported to make sure gems precompiled for MRI are not used.
21+
# TruffleRuby has a different ABI and cannot reuse gems precompiled for MRI.
22+
# See https://github.com/rubygems/rubygems/issues/2945
23+
Gem.platforms = [Gem::Platform::RUBY]
1924
end
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2020 Oracle and/or its affiliates. All rights reserved. This
2+
# code is released under a tri EPL/GPL/LGPL license. You can use it,
3+
# redistribute it and/or modify it under the terms of the:
4+
#
5+
# Eclipse Public License version 2.0, or
6+
# GNU General Public License version 2, or
7+
# GNU Lesser General Public License version 2.1.
8+
# OTHER DEALINGS IN THE SOFTWARE.
9+
10+
require_relative '../../ruby/spec_helper'
11+
require 'rubygems'
12+
13+
describe "Gem.platforms" do
14+
it "returns only [RUBY] on TruffleRuby to not use gems precompiled for MRI" do
15+
Gem.platforms.should == [Gem::Platform::RUBY]
16+
end
17+
end

0 commit comments

Comments
 (0)