-
Notifications
You must be signed in to change notification settings - Fork 30
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
[Ruby 3.2] having runtime issues on darwin #87
Comments
Interesting: when I install 3.2.0-rc1 using |
The |
Looks like if I build ruby with |
Here was a similar issue with nokogiri on Macos: sparklemotion/nokogiri#2063 (comment) |
Wow, thanks for refreshing my memory, I have very little recollection of doing that work. 🤷 So at this point, I think the 3.2 bundle is fine ... do you agree? I want to understand better what's changed about the Ruby build system, but as long as |
Tagging @kateinoigakukun in case he spots something that's wrong with either the rake-compiler-dock build process or Ruby's makefiles. |
@flavorjones Unfortunately, an extension library compiled with a I think the compatibility has not been guaranteed but it just worked so far. The |
@kateinoigakukun Thanks for confirming. @larskanis Do you know why the 3.2.0-rc1 ruby binaries installed by |
@flavorjones Which ruby binaries aren't compatible with what? Do you have a CI link? |
@larskanis Darwin 3.2.0-rc1 binaries aren't compatible with the extensions being built by rake-compiler-dock. CI link: https://github.com/sparklemotion/nokogiri/actions/runs/3735058984/jobs/6350173407 The CI config is: cruby-x86_64-darwin-install:
needs: ["cruby-package"]
strategy:
fail-fast: false
matrix:
ruby: ["2.7", "3.0", "3.1", "3.2.0-rc1"]
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
submodules: true
- uses: ruby/setup-ruby@v1
with:
ruby-version: "${{matrix.ruby}}"
- uses: actions/download-artifact@v3
with:
name: cruby-x86_64-darwin-gem
path: gems
- run: ./scripts/test-gem-install gems and it's passing for the other Ruby versions. |
#90 reproduces this error in rake-compiler-dock's CI pipeline |
@larskanis I confirmed that the rubies built by ruby-builder (and downloadable from here) are built with Not sure what you think we should do here. I just pushed #91 to see what will break if we set |
@kateinoigakukun This change may have unintended consequences. Over the past two years, nokogiri precompiled for darwin has been downloaded 12,062,659 times, so I'm very worried that if we can no longer ship precompiled binaries for darwin that this is going to be a burden on both users and gem maintainers. Is the recommended workaround to ship two bundles for darwin? One for rubies configured with |
@flavorjones I've committed a patch to restore the compatibility nokogiri has been expecting so far: "An extension built with --disable-shared Ruby is loadable from --enable-shared Ruby". I think it would repair your build and you don't need to distribute two dylibs for darwin now :) |
@kateinoigakukun Thank you! I will run that change through the rake-compiler-dock test suite! |
Here's how I tested: I'm still using The good news is that a gem precompiled with that flag does run on darwin both with a "enable-shared ruby" and a "disable-shared ruby". However, the bad news is that the libxml2 and libxslt symbols are no longer being resolved from within the bundle -- they are resolving against system libraries! I see these warnings:
Here's the complete output from `nokogiri -v`
These warnings are generated by comparing the version of libxml2 present in They should always match, but in gems built this way, Looking at the symbols present in the bundle, the libxml2 symbols are properly in the text (code) section, denoted with a "T":
@kateinoigakukun Do you understand why the bundle isn't being used as the primary location for resolving symbols? Should I play with |
I've pushed the workaround mentioned in my previous comment here, in case anyone needs to reproduce: I'll link to the specific warnings when CI gets there. |
Hmm, very strange, it works fine in the actions runner: https://github.com/sparklemotion/nokogiri/actions/runs/3767005588/jobs/6404353192#step:5:36 Maybe this is close enough for me to cut a release candidate of Nokogiri and get feedback from people. |
OK, I'm not sure why I can't reproduce this in github runners, but I've reproduced now the symbol-loading error on three different macs. When I run But I believe what is new is that now function calls from the nokogiri.bundle are no longer resolved to symbols that exist in the bundle, but to symbols in the ruby process. This makes sense given the explanation of the I'm not sure how to get unblocked from here. |
OK, I made some progress with trying See sparklemotion/nokogiri@1714e77 for what seems to work. |
Well, @kateinoigakukun This all seems really bad. See some conversation with another nokogiri maintainer at sparklemotion/nokogiri#2732 where we're proposing to try to undo these changes when we build the extension. |
@kateinoigakukun Please see https://github.com/stevecheckoway/bundle_test for a working example of why |
I reverted katei's fix with
Thank you for clarifying the problem. What I am wondering now is that is the problem is really the problem? I fixed the files as below and its result is as the same as flat_namespace. Therefore if a gem cause a problem with flat_namespace, it doesn't work on Linux.
|
Thank you all 🙏 Will have a closer look next month. |
I've written up a brief summary of how Nokogiri is working around this at nokogiri/2022-12-darwin-symbol-resolution.md at main · sparklemotion/nokogiri · GitHub |
OK, after shipping an RC for nokogiri native gems, and working on sqlite3-ruby native gems, it looks like everybody who precompiles for Darwin and Ruby 3.2 will need to add something like this to their extconf: if cross_build? &&
darwin? &&
RbConfig::CONFIG["ruby_version"] >= "3.2"
append_ldflags("-Wl,-flat_namespace")
end @kateinoigakukun Do you have any ideas on how to make this situation better, potentially in a future Ruby 3.2.1 release? @larskanis Do you think we should try to add this flag into the link line for users from within rake-compiler-dock? Possibly by modifying the |
Yes, I think so. We shouldn't demand these lines. |
OK, will put together a PR |
If we merge #94, then I think we should cut a release soon. Then I can confidently document how to deal with global symbol resolution in https://github.com/flavorjones/ruby-c-extensions-explained. (I think we need to start recommending that everyone build their extension (and all libraries that are statically linked into it) with |
I've merged #94 and I think we can cut a release. I'm building another rc for sqlite3-ruby based on images generated from ce619f2 and they look good. @larskanis I think you're still the only owner of the dockerhub account, but if there is anything I can do to help with a release, please let me know? |
@flavorjones As far as I can see, there is no way to add other contributors to the docker hub account. The only way is to convert "larskanis" to an organization, which doesn't feel like a good solution. Instead I think it makes sense to create a new organization and publish the images there? Maybe the name "rake-compiler" like on Github? Then we can change the name in the gem as well. |
Nevertheless I can do the release and publish the images on the "larskanis" account. I did some tests on my side (with fxruby, libusb, ffi and ruby-pg) and the latest images worked well. I found only one issue with |
@larskanis I'd like to again propose that we use ghcr.io instead of dockerhub as the future home of these images. I started this work to demonstrate it could work with the weekly snapshots. We could similarly automate creation of the versioned images (and we can cache layers to ensure that image diffs stay small between patch releases). |
@larskanis Would it be helpful if I did the work to cut over to ghcr.io to be the primary registry for RCD images so that I'm able to cut a release? You could then sync those images to dockerhub for convenience for folks. I should have some time this week to do that if you're not able to cut a release. |
I didn't work with ghcr.io so far, so I'd be happy if you could prepare it. I don't care too much about the platform we use to distribute our images. So if ghcr.io fulfills our needs, I think we can switch the gem to it with no need to mirror the images on docker hub. |
See #95! ❤️ |
Closing this, I think we have a path forward for Ruby 3.2. |
@larskanis I'm hoping you can help me out here, I'm not sure what's going wrong in the toolchain.
I've built a version of Nokogiri that precompiles Ruby 3.2 shared objects using the docker images published here. (The pipeline to build and test Nokogiri is here if you're curious, and the PR is here).
For both
x86_64-darwin
andarm64-darwin
(the latter I run manually on my dev machine), I see this runtime error:You can see this in the CI logs here. You can download this gem yourself if you like from the "Artifacts" section of this pipeline run:
Comparing the 3.2 dylib and the 3.1 dylib (which still works), both have
_rb_cObject
listed asU
ndefined, so I'm not actually sure the problem is in how the shared object is built. Do you have any ideas?The text was updated successfully, but these errors were encountered: