Open mohamedhafez opened 2 years ago
@headius perhaps this would be an easy configuration fix for someone on the JRuby team? Or possibly it could be a bug in how JRuby installs C extensions on M1 Macs?
Does the sassc gem build on CRuby on M1? This would be in the makefile for libsass so I'm not sure what we can fix on our end...
Could be a bug in our mkmf that is providing the wrong flag for arch.
Yup it installs just fine for CRuby 3.0.3.
Taking a look at the Makefile generated by the CRuby installation vs the JRuby installation, there's several differences, but the ARCH_FLAG
is -arch aarch64
in JRuby, and -m64
for CRuby...
And the only thing different between the Makefile generated by/for JRuby on an Intel Mac is that there the ARCH_FLAG
variable is set to x86_64
.
Show me jruby -v
just so I can be sure you are running natively on M1.
ARCH_FLAG seems like the culprit... we will need to figure out where that is being set and make sure it reflects an appropriate build flag on M1.
~ $ jruby -v
jruby 9.3.3.0 (2.6.8) 2022-01-19 b26de1f5c5 OpenJDK 64-Bit Server VM 17.0.2+8 on 17.0.2+8 +jit [darwin-aarch64]
Hmm oddly enough, JRuby appears to hardcode ARCH_FLAGS
to -m64
on a 64-bit platform so need to do more digging to figure out why our flags don't match CRuby.
Ok I see now that we override the ARCH_FLAG on Mac to be -arch
with either x86_64
or aarch64
. I think aarch64
is appropriate for Linux, but MacOS may want it to be arm64
.
This seems to be a case where MacOS prefers arm64
instead of aarch64
for the OS, so I have pushed https://github.com/jruby/jruby/pull/7132 to fix this in JRuby 9.3.4.0.
This might be relevant on Linux/aarch64 as well but I do not have such a machine to test against right now. I can confirm the fix above does allow sassc to build on JRuby on MacOS/M1.
I've merged the fixes into JRuby's 9.3.x branch and they will go out sometime soon in 9.3.4.
Are there any workarounds for this until 9.3.4.0 comes out? This prevents me from working on my M1 machine.
I guess I can try the nightly builds
The patch mostly changes how we set up some static configuration data. You could make the same changes in some code preamble. I'm not at my desk but I can demonstrate later if you have trouble figuring it out. The values are either writable or we can get around any read-only issues.
And by code preamble, I mean making sure to load a file that corrects those bad values before RubyGems runs install scripts. Editing RG source in place is another option.
I'm hoping to set up nightly docker images soon as well.
Hey, thanks @headius - in fact I grabbed the latest nightly of 9.4.0.0 and stuffed that into my VM as ~/.rubies/jruby-9.3.3.0 - its a hack but it works for me for now, until 9.3.3.0 proper comes along. Thanks!
Actually, scratch that, its giving me a weird error with our code. I think I probably do need to build a patched 9.3.4.0-pre from source then, or try your preamble idea.
The 9.4 builds from master are probably a little premature, since they are currently transitioning to Ruby 3.1 compatibility. A nightly build of 9.3 would be better but may not have run recently due to some unaddressed failures in CI. I'll kick off a snapshot build of 9.3 that you can try out.
An updated 9.3.4 build should appear here soon:
https://oss.sonatype.org/content/repositories/snapshots/org/jruby/jruby-dist/9.3.4.0-SNAPSHOT/
its giving me a weird error with our code
I would also very much like to know what the error was! We are trying to work towards stabilizing master for our next major release. Open an issue with the error and any information you can provide.
I and my team is also facing this issue. The entire team uses M1 MAC; the same architecture and has the system configurations. The entire team could install jruby and sassc without any issues except for me. Please note, they installed jruby-9.3.3.0 way before me whereas I installed jruby-9.3.4.0 first and then installed 9.3.3.0 very recently. Can you help us find and resolve the issue? Thanks in advance. PFB the error message while installing (gem)sassc:
/Users/rachitamishra/.rbenv/versions/jruby-9.3.3.0/lib/ruby/gems/shared/gems/sassc-2.1.0/ext
make DESTDIR\=
compiling ./libsass/src/c99func.c
clang: error: invalid arch name '-arch aarch64'
make: *** [c99func.o] Error 1
make failed, exit code 2
This really should be fixed in JRuby 9.3.4.0. can you confirm you are getting an error running 9.3.4.0 or higher and not 9.3.3.0?
Actually, the entire team uses 9.3.3.0 and they face no such issue so, wanted to understand what changed that's causing this error.
@thesigmoidfunction If you are still having issues with this, open an issue or discussion on the JRuby project, or join us on the #jruby chat room on Matrix and we'll try to help. I am convinced at this point that we fixed this issue, since we have had users on M1 for several months now.
When I try to
gem install sassc
under JRuby 9.3.3.0 with my M1 Macbook, I get the following error (even though it works fine under Ruby 3.0.3)