Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build option to build a shared library and link it with the resulting binaries #6239

Open
mkoncek opened this issue Apr 16, 2024 · 2 comments

Comments

@mkoncek
Copy link

mkoncek commented Apr 16, 2024

Is there a reason why there is no libmruby.so?
Even if mruby is intended as a small implemetation to be statically linked, same goes for example for Lua, which is still usually found as a shared library in Linux distributions.

@dearblue
Copy link
Contributor

Try specifying build_config/host-shared.rb as the build configuration file.
A shared object file should be generated.

% rake -m MRUBY_CONFIG=host-shared clean all

However, as far as I understand, there are several problems.

  • It does not yet support Microsoft VisualC++.
    The build configuration file only supports gcc/clang compatible compilers.
    Requires a developer for MSVC.

  • The executable files built as mrbgems contain the absolute path to libmruby.so in the build directory.
    For example, the mruby command built on FreeBSD has the following required libraries.

    % ldd build/host/bin/mruby
    build/host/bin/mruby:
            /var/tmp/mruby/build/host/lib/libmruby.so (0xae43fe2b000)
            libm.so.5 => /lib/libm.so.5 (0xae43e9ab000)
            libc.so.7 => /lib/libc.so.7 (0xae43f84c000)
            [vdso] (0xae43e379000)
  • Replacing it with a relative path requires a change to the mruby build system.
    In addition, the proper specification of the LD_LIBRARY_PATH environment variable is required, at least when executing commands done internally.
    Otherwise, no test can be performed, and the mrbc command cannot be called before that.

@mkoncek
Copy link
Author

mkoncek commented Apr 17, 2024

Thank you, I found the MRUBY_CONFIG=host-shared option later. You are right about those issues and there is one more: Linux distributions tend to add special compiler flags such as -Wl,-soname,libmruby.so.3.3 indicating the binary compatibility.

I was able to produce a working result by removing the binaries and recompiling them manually as well as compiling the .so manually using -Wl,--whole-archive lib/libmruby.a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants