Skip to content

Commit

Permalink
Merge pull request #94 from rake-compiler/flavorjones-ruby-3.2-darwin…
Browse files Browse the repository at this point in the history
…-dldflags

darwin: work around the Ruby 3.2 symbol resolution changes
  • Loading branch information
flavorjones authored Jan 4, 2023
2 parents db23ffd + 0328204 commit ce619f2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
12 changes: 9 additions & 3 deletions Dockerfile.mri.erb
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,15 @@ RUN find /usr/local/rake-compiler/ruby -name rbconfig.rb | while read f ; do sed
RUN find /usr/local/rake-compiler/ruby -name lib*-ruby*.dll.a | while read f ; do n=`echo $f | sed s/.dll//` ; mv $f $n ; done
<% end %>

# ruby-2.5 links to libcrypt, which isn't necessary for extensions
RUN find /usr/local/rake-compiler/ruby -name rbconfig.rb | while read f ; do sed -i 's/-lcrypt//' $f ; done

<% if platform=~/darwin/ %>
# ruby-3.2 on darwin links with `-bundle_loader`, see https://github.com/rake-compiler/rake-compiler-dock/issues/87
RUN find /usr/local/rake-compiler/ruby/*/*/lib/ruby/3.2.0 -name rbconfig.rb | \
while read f ; do sed -i 's/\["EXTDLDFLAGS"\] = "/&-Wl,-flat_namespace /' $f ; done
<% end %>
##
## Final adjustments
##
Expand Down Expand Up @@ -218,9 +227,6 @@ RUN echo "export PATH=\$DEVTOOLSET_ROOTPATH/usr/bin:\$PATH" >> /etc/rubybashrc
# Add prefixed versions of compiler tools
RUN for f in addr2line gcc gcov-tool ranlib ar dwp gcc-ranlib nm readelf as elfedit gcc-ar gprof objcopy size c++filt g++ gcov ld objdump strings cpp gcc-nm pkg-config strip ; do ln -sf $DEVTOOLSET_ROOTPATH/usr/bin/$f $DEVTOOLSET_ROOTPATH/usr/bin/<%= target %>-$f ; done

# ruby-2.5 links to libcrypt, which isn't necessary for extensions
RUN find /usr/local/rake-compiler/ruby -name rbconfig.rb | while read f ; do sed -i 's/-lcrypt//' $f ; done

# Use builtin functions of newer gcc to avoid linker issues on Musl based Linux
COPY build/math_h.patch /root/
RUN cd /usr/include/ && \
Expand Down
16 changes: 9 additions & 7 deletions test/rcd_test/ext/mri/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,15 @@
##
## This returns us to the symbol resolution we had in previous Rubies. It feels gross but may
## be a workaround for gem maintainers until we all figure out a better way to deal with this.
extdldflags = RbConfig::MAKEFILE_CONFIG["EXTDLDFLAGS"].split
if found = extdldflags.index("-bundle_loader")
removed_1 = extdldflags.delete_at(found) # flag
removed_2 = extdldflags.delete_at(found) # and its argument
puts "Removing '#{removed_1} #{removed_2}' from EXTDLDFLAGS"
end
RbConfig::MAKEFILE_CONFIG["EXTDLDFLAGS"] = extdldflags.join(" ")
#
# extdldflags = RbConfig::MAKEFILE_CONFIG["EXTDLDFLAGS"].split
# if found = extdldflags.index("-bundle_loader")
# removed_1 = extdldflags.delete_at(found) # flag
# removed_2 = extdldflags.delete_at(found) # and its argument
# puts "Removing '#{removed_1} #{removed_2}' from EXTDLDFLAGS"
# end
# RbConfig::MAKEFILE_CONFIG["EXTDLDFLAGS"] = extdldflags.join(" ")
#
end
end

Expand Down

0 comments on commit ce619f2

Please sign in to comment.