Open cguess opened 2 years ago
A quick note that I tried this on the v0.1.1.2 tag as well and it's the same error. I'm guessing it's something to do with the c extensions on x64 vs ARM?
Further: This compiles on Ubuntu ARM running in Parallels and Raspberry Pi OS on a Pi 3 without an issue, so it's something with the compiler on MacOS Monterey (maybe older versions as well).
Weird.
compiling idhash.c
linking shared-object idhash.bundle
This has compiled the extension that supposedly defines the method here:
rb_define_module_function(mm, "distance3_c", idhash_distance, 2);
If there was any problem during compilation it would not invoke the test.
Unfortunately I don't have neither ARM nor Monterey to dig deeper.
Thanks for getting back to me! Do you have any guidance? I'm going to attempt to dig in myself and fix this for you.
Just basic starting points would be very helpful.
to dig in myself and fix this
Would be cool but I wish I had any guidance for myself. The whole native extensions thing has no comprehensive manual, only a ton of mkmf methods with no explanation on how to use them properly and how the gem installation routine goes at all. And if you ask at SO they downvote, close and delete, lol. So the post-install-check thing is a pure local invention on how to check if the native extension produces correct fingerprints after installation to detect any platform issue.
The extconf.rb
builds the Makefile
and I've included some comments in it showing how I test it. Basically you do the ruby extconf.rb && make clean && make
and it's presumably the same what the gem install
is doing. The makefile creates the .bundle
(for macOS) or .o
(for Linux) file that is then required in Ruby code and is aliased to pure Ruby implementation as a fallback in case of exception. In your case it looks like it has created the .bundle
file but without a C function for some reason.
Thanks so much for this write up! I totally get the SO frustration. I have a few ARM machines, so I may be in a good spot to work on this a bit. Let me dig in over the week and see what I can come up with.
Thank you so much for your work so far on all this, it's wildly appreciated.
Due to how rarely I test the compilation, yesterday I was surprised as "I don't understand how it worked at all" ..)
https://github.com/Nakilon/dhash-vips/commit/2ccc42b1a3960bf1f9c34a39f7ca9a57fe146d01#diff-06bfa1add88aa00af234039a463c42fdd10e629d95926ed4d091b46d9696adaaR37
Due to the lack of class << self
the alias was working in some wrong scope and you had to have the "undefined method `distance3_ruby'". Since this is the LoadError condition branch, the reason why no one reported it is probably that everyone (surprisingly) managed to have the native extension compiled.
When trying to install the dhash-vips gem on MacOS 12.0.1 on Apple Silicon (ARM) using Ruby 3.0.2, I'm getting the following error:
This happens when using either
gem "dhash-vips"
or `gem "dhash-vips", git: "https://github.com/nakilon/dhash-vips/"Thank you for any help you can provide in figuring this out!