Skip to content

Commit 722260c

Browse files
authored
Merge pull request #92 from rake-compiler/flavorjones-ruby-3.2
update to "3.2.0" final
2 parents 0f4b2c2 + 1b1fc06 commit 722260c

File tree

4 files changed

+79
-4
lines changed

4 files changed

+79
-4
lines changed

.github/workflows/ci.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ jobs:
117117
- macos
118118
- ubuntu
119119
ruby:
120+
- "3.2"
120121
- "3.1"
121122
- "3.0"
122123
- "2.7"
@@ -138,9 +139,14 @@ jobs:
138139
- os: windows
139140
ruby: "3.1"
140141
platform: x64-mingw-ucrt
142+
- os: windows
143+
ruby: "3.2"
144+
platform: x64-mingw-ucrt
141145
exclude:
142146
- os: windows
143147
ruby: "3.1"
148+
- os: windows
149+
ruby: "3.2"
144150

145151
runs-on: ${{ matrix.os }}-latest
146152
steps:
@@ -170,6 +176,7 @@ jobs:
170176
os:
171177
- windows
172178
ruby:
179+
- "3.2"
173180
- "3.1"
174181
- "3.0"
175182
- "2.7"
@@ -182,9 +189,14 @@ jobs:
182189
- os: windows
183190
ruby: "3.1"
184191
platform: x64-mingw-ucrt
192+
- os: windows
193+
ruby: "3.2"
194+
platform: x64-mingw-ucrt
185195
exclude:
186196
- os: windows
187197
ruby: "3.1"
198+
- os: windows
199+
ruby: "3.2"
188200

189201
runs-on: ${{ matrix.os }}-latest
190202
steps:

Dockerfile.mri.erb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ RUN bash -c " \
135135
axrubies = if platform =~ /x64-mingw-ucrt/
136136
[
137137
# Rubyinstaller-3.1.0+ is platform x64-mingw-ucrt
138-
# parallel=false because 3.2.0-rc1 has undefined references when using a high -j arg
139-
["3.2.0-rc1:3.1.0", "3.1.3", false],
138+
["3.2.0:3.1.0", "3.1.3", true],
140139
]
141140
elsif platform =~ /x64-mingw32/
142141
[
@@ -149,7 +148,7 @@ else
149148
# Build xruby versions prior ruby2_keywords in parallel using ruby-2.5
150149
["2.6.0:2.5.0:2.4.0", "2.5.9", false],
151150
# Build xruby versions with ruby2_keywords in parallel using ruby-3.x
152-
["3.2.0-rc1:3.1.0:3.0.0:2.7.0", "3.1.3", true],
151+
["3.2.0:3.1.0:3.0.0:2.7.0", "3.1.3", true],
153152
]
154153
end
155154

test/env/Dockerfile.centos

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ RUN yum install -y ruby git
1111

1212
RUN ruby --version
1313
RUN gem env
14-
RUN gem inst bundler
14+
15+
# centos-8 comes with Ruby 2.5, and this is the last version of bundler that supports it
16+
RUN gem install bundler -v2.2.28
1517

1618
WORKDIR /build
1719

test/rcd_test/ext/mri/extconf.rb

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,68 @@
2323
# https://github.com/rake-compiler/rake-compiler-dock/issues/69
2424
puts "Linking with '-static' flag"
2525
$LDFLAGS << ' -static'
26+
else
27+
if RbConfig::CONFIG["target_os"].include?("darwin")
28+
## In ruby 3.2, symbol resolution changed on Darwin, to introduce the `-bundle_loader` flag.
29+
##
30+
## See https://github.com/rake-compiler/rake-compiler-dock/issues/87 for a lot of context, but
31+
## I'll try to summarize here.
32+
##
33+
## > -bundle_loader executable
34+
## > This specifies the executable that will be loading the bundle output file being linked.
35+
## > Undefined symbols from the bundle are checked against the specified executable like it
36+
## > was one of the dynamic libraries the bundle was linked with.
37+
##
38+
## There are good reasons to do this, including faster initialiation/loading as the Darwin
39+
## toolchain gets improved over time.
40+
##
41+
## Unfortunately, this flag prevents us from building a shared object that works with both a
42+
## Ruby compiled with `--enable-shared` and one compiled with `--disabled-shared`. The result
43+
## is usually an "Symbol not found" error about `_rb_cObject`, or a "dyld: missing symbol
44+
## called" error.
45+
##
46+
## There are two workarounds that I know of (there may be others I don't know of), and
47+
## they are ...
48+
49+
## ----------------------------------------
50+
## SOLUTION 1, the `-flat_namespace` flag
51+
##
52+
## > Two-level namespace
53+
## > By default all references resolved to a dynamic library record the library to which
54+
## > they were resolved. At runtime, dyld uses that information to directly resolve symbols.
55+
## > The alternative is to use the -flat_namespace option. With flat namespace, the library
56+
## > is not recorded. At runtime, dyld will search each dynamic library in load order when
57+
## > resolving symbols. This is slower, but more like how other operating systems resolve
58+
## > symbols.
59+
##
60+
#
61+
# puts "Adding '-flat_namespace'"
62+
# $LDFLAGS << ' -flat_namespace'
63+
#
64+
## This solution unfortunately introduces new behavior that any symbols statically linked into
65+
## the shared object (e.g., libxml2 in nokogiri.bundle) may not be resolved locally from the
66+
## shared object, but instead resolved from a shared object loaded in the main process.
67+
##
68+
## This solution might be good for you if:
69+
## - you don't statically link things into your bundle,
70+
## - or you don't export those symbols,
71+
## - or you can avoid exporting those symbols (e.g., by using `-load_hidden`, or
72+
## `-exported_symbols_list` or some other mechanism)
73+
##
74+
75+
## ----------------------------------------
76+
## BUT ... if that is a problem, try SOLUTION 2, remove the `-bundle-loader` flag
77+
##
78+
## This returns us to the symbol resolution we had in previous Rubies. It feels gross but may
79+
## be a workaround for gem maintainers until we all figure out a better way to deal with this.
80+
extdldflags = RbConfig::MAKEFILE_CONFIG["EXTDLDFLAGS"].split
81+
if found = extdldflags.index("-bundle_loader")
82+
removed_1 = extdldflags.delete_at(found) # flag
83+
removed_2 = extdldflags.delete_at(found) # and its argument
84+
puts "Removing '#{removed_1} #{removed_2}' from EXTDLDFLAGS"
85+
end
86+
RbConfig::MAKEFILE_CONFIG["EXTDLDFLAGS"] = extdldflags.join(" ")
87+
end
2688
end
2789

2890
create_makefile("rcd_test/rcd_test_ext")

0 commit comments

Comments
 (0)