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 native extensions as static libraries #50

Open
d-unsed opened this issue Jan 3, 2017 · 4 comments
Open

Build native extensions as static libraries #50

d-unsed opened this issue Jan 3, 2017 · 4 comments
Labels
Milestone

Comments

@d-unsed
Copy link
Owner

d-unsed commented Jan 3, 2017

RbConfig::CONFIG provides all the required information for linking with static libraries. But Cargo does not allow to use all the flags, for example -framework CoreFoundation on Mac OS X.

Investigate thermite + RbConfig::CONFIG + gcc as a final (optional) step while building an extension.

This allows to use MRI without --enable-shared option (emk/heroku-buildpack-rust#15)

@seven1m
Copy link

seven1m commented Jan 26, 2017

Ruru is such an awesome project. Getting rid of the need for --enable-shared would get much ❤️ ❤️ ❤️ from me. 😄

@danielpclark
Copy link
Contributor

danielpclark commented Sep 11, 2017

Here's some info that may prove useful. My build complains when I run the bundle exec test suite from VIM about libruby.so.2.4 missing, but if I copy that file into my target/debug/deps folder then everything works. Cargo builds work outside of VIM for me without the lib copied as the RVM environment variables seem to be enough.

Here are the relevant RbConfig variables:

  • RbConfig::CONFIG["libdir"]
  • RbConfig::CONFIG["LIBRUBY_ALIASES"].split(" ").first
require "fileutils"
FileUtils.cp(
  File.join(
    RbConfig::CONFIG["libdir"],
    RbConfig::CONFIG["LIBRUBY_ALIASES"].split(" ").first
  ),
  File.join(FileUtils.pwd, "target/debug/deps")
)

If the build is failing for people otherwise you can do the same copy as above but change it to target release dependencies target/release/deps.

For those who want to use the command line to get the path for the libruby file you can use the following.

ruby -e 'puts File.join(RbConfig::CONFIG["libdir"], RbConfig::CONFIG["LIBRUBY_ALIASES"].split(" ").first)'

@sbeckeriv
Copy link

@seven1m checkout malept/thermite#41

@malept
Copy link
Contributor

malept commented Oct 6, 2017

Still doesn't work on Windows. I'd need help with that.

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

No branches or pull requests

5 participants