From 1ac98ca9409926bc7c5cdc0db2a2e37061954bca Mon Sep 17 00:00:00 2001 From: Andi Idogawa Date: Fri, 20 Nov 2026 11:07:22 +0100 Subject: [PATCH 1/2] RbConfig: system triplets, binutils and install directories, as CRuby's nokogiri's extconf.rb compiles its own libxml2 and libxslt through mini_portile, and gives their configure `--host` from RbConfig. It reads `CONFIG["host_alias"].empty?`, which raised NoMethodError on IronRuby: CONFIG had no host, host_alias, build or target at all. Build scripts read more of what CRuby's configure records, so these are filled in, with CRuby's values for the same platform: - host, build, target and their _cpu, _os, _vendor ("pc") and _alias (empty, since IronRuby is not cross-built). For example host "x86_64-pc-linux". - NM, RANLIB, LD, OBJDUMP, OBJCOPY, PKG_CONFIG, GNU_LD, LN_S, GREP, EGREP and SOEXT: the tools configure found, by name. - datarootdir, includedir, docdir, mandir, sysconfdir, localstatedir and the other autoconf directories, under prefix. platform is RUBY_PLATFORM. With this, `gem install nokogiri --platform ruby` (IRONRUBY_NATIVE_GEMS=nokogiri) builds the extension with its packaged libxml2, libxslt and gumbo. A script exercising it gives the same output as on CRuby 4.0: HTML, HTML5, XML with namespaces, Builder, fragments, SAX, XSLT, parse errors, and 2000 parses through a GC. spec/library/rbconfig and RbConfig_ExecutableExts1 pass. --- Src/StdLib/ironruby/rbconfig.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/Src/StdLib/ironruby/rbconfig.rb b/Src/StdLib/ironruby/rbconfig.rb index 1da2a55e3..c31a7f170 100644 --- a/Src/StdLib/ironruby/rbconfig.rb +++ b/Src/StdLib/ironruby/rbconfig.rb @@ -146,6 +146,27 @@ module RbConfig CONFIG["topdir"] = File.dirname(__FILE__) CONFIG["build_os"] ||= CONFIG["host_os"].dup + # autoconf's system triplets, as CRuby's configure records them ("x86_64-pc-linux"): build + # scripts hand them to the configure of a library they compile (nokogiri's libxml2, through + # mini_portile, passes --host=CONFIG["host"] unless host_alias names one). The *_alias are + # what --host/--build/--target said, and IronRuby is not cross-built: empty. + %w[host build target].each do |kind| + CONFIG["#{kind}_cpu"] ||= cpu_and_os[0].dup + CONFIG["#{kind}_os"] ||= cpu_and_os[1].dup + CONFIG["#{kind}_vendor"] = "pc" + CONFIG["#{kind}_alias"] = "" + end + + # The installation layout autoconf describes, under prefix as in CRuby. + { + "datarootdir" => "#{prefix}/share", "includedir" => "#{prefix}/include", "oldincludedir" => "/usr/include", + "docdir" => "#{prefix}/share/doc/ruby", "htmldir" => "#{prefix}/share/doc/ruby", "mandir" => "#{prefix}/share/man", + "infodir" => "#{prefix}/share/info", "localedir" => "#{prefix}/share/locale", "sysconfdir" => "#{prefix}/etc", + "localstatedir" => "#{prefix}/var", "runstatedir" => "#{prefix}/var/run", "sharedstatedir" => "#{prefix}/com", + "sbindir" => "#{prefix}/sbin", "libexecdir" => "#{prefix}/libexec", + }.each { |key, value| CONFIG[key] = value } + CONFIG["platform"] = RUBY_PLATFORM.dup + # The C toolchain mkmf drives. Where IronRuby has no C API (Windows so far), every one of # these is empty: mkmf reads them while it loads and would otherwise fail on nil, and empty # makes every compile mkmf attempts fail rather than appear to succeed. Linux fills the @@ -217,6 +238,17 @@ module RbConfig }.each { |key, value| CONFIG[key] = value.dup } end + # the binutils and helpers configure found, by name: build scripts run them (mini_portile's + # libxml2 build, extconf.rb's pkg-config lookups), and the triplets are complete only now + { + "NM" => "nm", "RANLIB" => "ranlib", "LD" => "ld", "OBJDUMP" => "objdump", "OBJCOPY" => "objcopy", + "PKG_CONFIG" => "pkg-config", "GNU_LD" => "yes", "LN_S" => "ln -s", "GREP" => "grep", "EGREP" => "grep -E", + "SOEXT" => windows ? "dll" : "so", + }.each { |key, value| CONFIG[key] = value.dup } + %w[host build target].each do |kind| + CONFIG[kind] = "#{CONFIG["#{kind}_cpu"]}-#{CONFIG["#{kind}_vendor"]}-#{CONFIG["#{kind}_os"]}" + end + # Naming conventions rather than tools, so these have an answer even here. CONFIG["OBJEXT"] ||= windows ? "obj" : "o" CONFIG["LIBEXT"] ||= windows ? "lib" : "a" From 81a68d0df2bf34e1fb373e089b4cba7a6372b53a Mon Sep 17 00:00:00 2001 From: Andi Idogawa Date: Fri, 20 Nov 2026 11:40:48 +0100 Subject: [PATCH 2/2] C API README: the second batch of gems tried, nokogiri among them Nineteen more C extension gems were installed with gem install --platform ruby and compared with CRuby 4.0 by a script exercising each, and the real nokogiri with IRONRUBY_NATIVE_GEMS once RbConfig had what its extconf.rb reads. The README's list of gems known to work now has them, and says why digest-crc runs its Ruby code: its Rakefile builds the extensions on RUBY_ENGINE == "ruby" only. --- Src/Ruby/CApi/README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Src/Ruby/CApi/README.md b/Src/Ruby/CApi/README.md index 0f7b68385..ef5270687 100644 --- a/Src/Ruby/CApi/README.md +++ b/Src/Ruby/CApi/README.md @@ -37,8 +37,12 @@ path would otherwise win over the gem's `.so`. Gems whose extensions build and give CRuby's results (Linux x64, checked against CRuby 4.0 with a script exercising each): fast_blank, redcarpet, jaro_winkler, escape_utils, racc (cparse), -digest-murmurhash, unf_ext (C++), and with `IRONRUBY_NATIVE_GEMS` bigdecimal, msgpack, bcrypt -and oj. +digest-murmurhash, unf_ext (C++), ox, yajl-ruby, rinku, rdiscount, RedCloth, http_parser.rb, +websocket-driver, cbor, xxhash, ed25519, rbtree, damerau-levenshtein, hiredis, murmurhash3, ffi +(through libffi), byebug (loads and starts; its line tracing follows IronRuby's TracePoint), and with +`IRONRUBY_NATIVE_GEMS` bigdecimal, msgpack, bcrypt, oj and nokogiri (its packaged libxml2, +libxslt and gumbo, built by mini_portile). digest-crc builds no extension on an engine other than +CRuby, by its own check, and uses its Ruby implementation. ## Adding a function