Skip to content

Commit

Permalink
Merge pull request #481 from ruby/katei/remove-build-hack
Browse files Browse the repository at this point in the history
Build baseruby before building extensions for PIC target
  • Loading branch information
kateinoigakukun authored Jun 29, 2024
2 parents 73d3d5a + f3ed2a5 commit ea36739
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
5 changes: 4 additions & 1 deletion lib/ruby_wasm/build/product/crossruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ def do_extconf(executor, crossruby)
return
end
objdir = product_build_dir crossruby
source = crossruby.source
rbconfig_rb = Dir.glob(File.join(crossruby.dest_dir, "usr/local/lib/ruby/*/wasm32-wasi/rbconfig.rb")).first
raise "rbconfig.rb not found" unless rbconfig_rb
extconf_args = [
Expand Down Expand Up @@ -359,6 +358,10 @@ def configure_args(build_triple, toolchain)
args << %Q(wasmoptflags=#{@wasmoptflags.join(" ")})
end
args << "--disable-install-doc"
unless @params.target.pic?
# TODO: Remove this hack after dropping Ruby 3.2 support
args << "ac_cv_func_dlopen=no"
end
args
end
end
Expand Down
6 changes: 6 additions & 0 deletions lib/ruby_wasm/packager/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ def _link_gem_exts(executor, build, ruby_root, gem_home, module_bytes)
end

def _build_gem_exts(executor, build, gem_home)
build.toolchain.install
baseruby = build.baseruby
unless Dir.exist?(baseruby.install_dir)
baseruby.build(executor)
end

exts = specs_with_extensions.flat_map do |spec, exts|
exts.map do |ext|
ext_feature = File.dirname(ext) # e.g. "ext/cgi/escape"
Expand Down
4 changes: 0 additions & 4 deletions rakelib/packaging.rake
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ def npm_pkg_build_command(pkg)
end

def npm_pkg_rubies_cache_key(pkg)
# FIXME: Now CrossRubyExtProduct depends on just built baseruby, and exts can be
# built after restoring the tarball cache. So it can fail to find baseruby when the
# cache hit. We need to orchestrate the build dependency graph properly.
return nil if pkg[:name] == "ruby-head-wasm-wasi"
build_command = npm_pkg_build_command(pkg)
return nil unless build_command
require "open3"
Expand Down
1 change: 1 addition & 0 deletions sig/ruby_wasm/build.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module RubyWasm
@source: BuildSource

attr_reader toolchain: Toolchain
attr_reader baseruby: BaseRubyProduct

def initialize: (
string name,
Expand Down

0 comments on commit ea36739

Please sign in to comment.