Project

General

Profile

Actions

Bug #21919

closed

`libruby-static.a` links to wrong `Init_enc`

Bug #21919: `libruby-static.a` links to wrong `Init_enc`

Added by reitermarkus (Markus Reiter) 1 day ago. Updated about 5 hours ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 4.0.1 (2026-01-13 revision e04267a14b) +PRISM [arm64-darwin20]
[ruby-core:124854]

Description

When building Ruby with --with-static-linked-ext, libruby-static.a links the Init_enc function from dmyenc.c instead of enc/encinit.c.erb, resulting in uninitialized constant Encoding::UTF_8 error, among other things.

There seems to be a discrepancy between INITOBJS (https://github.com/ruby/ruby/blob/e730ac41be4d427f06540e0f67fa16bbdced4789/common.mk#L81) and ENCOBJS/EXTOBJS (https://github.com/ruby/ruby/blob/e730ac41be4d427f06540e0f67fa16bbdced4789/configure.ac#L3139-L3152).

Currently, the only workaround I found is to manually link enc/libenc.a and enc/libtrans.a to the final binary.

Originally reported here: https://github.com/matsadler/magnus/issues/169

Updated by nobu (Nobuyoshi Nakada) about 7 hours ago Actions #1 [ruby-core:124865]

  • Status changed from Open to Rejected

--with-static-linked-ext means the extension libraries including encodings are linked to the ruby executable or library.so.
-static.a is not intended to link these extensions.

Updated by reitermarkus (Markus Reiter) about 5 hours ago Actions #2 [ruby-core:124866]

nobu (Nobuyoshi Nakada) wrote in #note-1:

--with-static-linked-ext means the extension libraries including encodings are linked to the ruby executable or library.so.

Which library.so is that exactly?

nobu (Nobuyoshi Nakada) wrote in #note-1:

-static.a is not intended to link these extensions.

Can you please clarify why it is not intended?

I'd like to include a fully static Ruby interpreter in a Rust executable. Also needing to ship encdb.so and transdb.so kinda defeats the purpose of a having a static binary.

What would be the proper solution here?

Actions

Also available in: PDF Atom