Bug #21919
closed`libruby-static.a` links to wrong `Init_enc`
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
- 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
nobu (Nobuyoshi Nakada) wrote in #note-1:
--with-static-linked-extmeans 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.ais 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?