-
Notifications
You must be signed in to change notification settings - Fork 14
Fix static builds #25
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
base: master
Are you sure you want to change the base?
Conversation
- Use `libdir` for both static and dynamic builds - Link `CoreFoundation` framework for Mac OS - Extract the name of static library from `LIBRUBY_A`
What are the shortcomings of the current state of static libraries on macOS? I ask because I haven't had problems when using my branch you merged yesterday. |
Which version of MacOS and Ruby did you use? Was ruby installed with I could not build static libs because of few things:
As for
When I took a look at Could you please try to test this branch on your machine when you have few minutes? Would be nice to test it against some other library, for example in the simplest case, to run |
t12r is the gem, the static binaries are in GitHub Releases. I've tested this on Sierra and High Sierra (whatever version numbers those are) with Ruby 2.4.2. |
@malept, maybe you've had a chance to test this on your machine? |
Just wondering if there's any update on this? |
@andrewstucki have you tried building extensions on macOS with and without this PR? |
@malept Sorry, long post ahead. So, I dug more into this and it looks a bit funky. I ran the ruru unit tests to try this out. Here's the compiler error I get on my machine building with ruby 2.4.1 installed via
Pointing ruru at this branch fixes the issues:
Off the top of my head I'm not sure why the project you linked worked, but I'm willing to bet it has something to do with how Thermite (which that project is using) grabs and unpacks the ruby static library tarballs and how those libraries (naming convention and linkage) differ from whatever stock So, just for recreation purposes on a Mac, here's what I did:
Now here's where things get a bit gross. I decided to download current ruby source to verify that That being said, from what I can tell, the patch seems to support linking to both libraries named Regarding the
That being say, it points to the fact that what we might want to do is grab
Interestingly enough switching to ruby 2.5.0 gives me the following:
Honestly, I have no idea what the difference is between |
Also worth noting that it looks like there's also |
Hmmm. I still have no idea why t12r works. Thermite doesn't do anything regarding static libraries, except distinguish between prebuilt Rust extensions. For the most part, it lets |
@malept I have no idea either, especially since as far as I can tell from taking a look at the build logs the ruby that the project appears to be using to build the libraries looks like it's coming from Travis's pre-built rubies which are here: http://rubies.travis-ci.org/osx/10.12/x86_64/ruby-2.4.2. If you download the tarball it looks like the static libraries aren't even included. At the same time, downloading the artifacts from t12r, the build seems to be generating a library that doesn't depend on |
@malept So I think I figured out what's going on here. It has to do with a couple of things -- first is the way ruruBecause t12rIs built using That flag suppresses errors trying to resolve symbols at linking time. If you manually remove that and invoke that same line directly you'll see the a whole bunch of failed symbol resolutions a la:
Why? Because we're not passing a dynamic linking reference to
What's interesting about all of this is that when you look at how Ruby native extensions are actually built what you see is that they always pass these linker flags in and basically never directly link to In other words, if you're actually executing extensions built with The reason your In other words it's actually kind of good news. We shouldn't actually be involving EDIT You can confirm that |
Just did a further validation that the former explanation is indeed the case. Forked
So the limitation of not linking in If you want to recreate, just build the gem and run mspec for https://github.com/andrewstucki/faster_path. |
libdir
for both static and shared librariesCoreFoundation
framework for Mac OSLIBRUBY_A
Those builds which test static linking will fail on Travis for now (see travis-ci/travis-rubies#43)