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

Add Darwin ARM target #14

Closed
1 of 2 tasks
lloeki opened this issue Nov 27, 2020 · 11 comments
Closed
1 of 2 tasks

Add Darwin ARM target #14

lloeki opened this issue Nov 27, 2020 · 11 comments

Comments

@lloeki
Copy link
Collaborator

lloeki commented Nov 27, 2020

  • as manual build
  • as CI build
@vseguin
Copy link

vseguin commented Jan 18, 2021

Hey @lloeki ! Great to see this being worked on, do you have an idea when this could be released?
We use sqreen as a dependency in our app and for new developers with Apple M1 chips we have to comment it out for now.

@lloeki
Copy link
Collaborator Author

lloeki commented Jan 19, 2021

@vseguin I released a build based on node 15.5.1 just yesterday, sq_mini_racer 0.3.1.0.3 and Sqreen should just work now on M1.

@vseguin
Copy link

vseguin commented Jan 19, 2021

@lloeki is it pushed to rubygems?
I get

  ERROR: found gems matching libv8-node:'~> 15.5.1.0.beta1', but no binary for -darwin-20
         try "gem install libv8-node:'~> 15.5.1.0.beta1'" to attempt to build libv8-node from source

I bumped sqreen to 1.23.0 - which seems to resolve to sq_mini_racer 0.3.1.03.

@lloeki
Copy link
Collaborator Author

lloeki commented Jan 19, 2021

I suppose you're trying to use macOS's own Ruby, which you can check with ruby -e 'puts RUBY_PLATFORM' or ruby -e 'p Gem.platforms'. Unfortunately this Apple-provided Ruby is built as arm64e, and currently libv8 builds as arm64.

I encourage you to try installing your own Ruby e.g. through rbenv install.

@vseguin
Copy link

vseguin commented Jan 22, 2021

@lloeki so hum sorry to come back on this, but I confirmed I am on rbenv's Ruby 2.7.1

ruby -e 'p Gem.platforms'
["ruby", #<Gem::Platform:0x000000014d0bf880 @cpu="", @os="darwin", @version="20" @cpu="", @os="darwin", @version="20">]

ruby -e 'puts RUBY_PLATFORM' 
-darwin20

I tried this and it seems that's it's only "-darwin20", no arm64 or arm64e?

@lloeki
Copy link
Collaborator Author

lloeki commented Jan 25, 2021

@vseguin Can you run file or lipo on it?

Examples:

$ lipo -info /usr/bin/ruby 
Architectures in the fat file: /usr/bin/ruby are: x86_64 arm64e 
$ lipo -info ~/.rbenv/versions/2.7.2/bin/ruby
Non-fat file: /Users/lloeki/.rbenv/versions/2.7.2/bin/ruby is architecture: x86_64

@sweetppro
Copy link

sweetppro commented Jan 28, 2021

Im also having issues installing on my M1 MacBook Air...
here's my setup:

me % ruby -e 'p Gem.platforms'
["ruby", #<Gem::Platform:0x000000013f020d88 @cpu="", @os="darwin", @version="20">]
me % ruby -e 'puts RUBY_PLATFORM'
-darwin20
me % lipo -info /usr/bin/ruby 
Architectures in the fat file: /usr/bin/ruby are: x86_64 arm64e 
me % lipo -info ~/.rbenv/versions/2.6.5/bin/ruby
Non-fat file: /Users/mrqwirk/.rbenv/versions/2.6.5/bin/ruby is architecture: arm64

and the error:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/me/myapp/gems/ruby/2.6.0/gems/sq_mini_racer-0.3.1.0.3/ext/mini_racer_extension
/Users/me/.rbenv/versions/2.6.5/bin/ruby -I /Users/me/.rbenv/versions/2.6.5/lib/ruby/site_ruby/2.6.0 -r ./siteconf20210128-7070-s9t894.rb extconf.rb
  ERROR: found gems matching libv8-node:'~> 15.5.1.0.beta1', but no binary for -darwin-20
         try "gem install libv8-node:'~> 15.5.1.0.beta1'" to attempt to build libv8-node from source
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/Users/me/.rbenv/versions/2.6.5/bin/$(RUBY_BASE_NAME)
platform ruby:-darwin20 rubygems:-darwin-20 detected:-darwin-20
looking for libv8-node-*--darwin-20 in ["/Users/me/myapp/gems/ruby/2.6.0"]
libv8-node-*--darwin-20 not found in ["/Users/me/myapp/gems/ruby/2.6.0"]
looking for libv8-node-*--darwin-20 in ["/Users/me/myapp/gems/ruby/2.6.0/gems/sq_mini_racer-0.3.1.0.3/ext/mini_racer_extension/vendor"]
libv8-node-*--darwin-20 not found in ["/Users/me/myapp/gems/ruby/2.6.0/gems/sq_mini_racer-0.3.1.0.3/ext/mini_racer_extension/vendor"]

extconf failed, exit code 1

@lloeki
Copy link
Collaborator Author

lloeki commented Jan 28, 2021

Looks like the same deal: platform ruby:-darwin20 rubygems:-darwin-20 detected:-darwin-20

This is output straight from Ruby's RUBY_PLATFORM and Gem::Platform.local, so it's Ruby itself that's hosed right there.

I see you're running 2.6.x in rbenv. Unfortunately as far as I can tell Ruby 2.7.x is the first Ruby version supporting arm64-darwin, that could very well explain why 2.6.x has a broken RUBY_PLATFORM.

Indeed, there's ruby/ruby@f469298 where you can read the following items:

  • Fix build error on Apple silicon macOS
  • Extract correct processor name for ARM64 Macs

And the patchset contains other important fixes for Apple Silicon (the desc is a bit obscured in the commit message, but there's important stuff regarding coroutines, without which you'd get seemingly random segfaults). It's apparently just followed by ruby/ruby@811b2b0 which is the bump to 2.7.2.

Of course Apple provides their own 2.6 with a set of patches of their own, but it's heavily deprecated and doesn't contain some of the fixes above.

So my suggestion would be to stick to 2.7.2 and up on M1, unless you want to backport that patchset (at least, there may be more needed).

@sweetppro
Copy link

Ah,
That’s an easy fix.
Thanks for the heads up.

@sweetppro
Copy link

sweetppro commented Jan 28, 2021

So my suggestion would be to stick to 2.7.2 and up on M1, unless you want to backport that patchset (at least, there may be more needed).

worked like a charm!
many thanks

@lloeki
Copy link
Collaborator Author

lloeki commented Feb 18, 2021

Apple's Ruby 2.6 is not to be relied on. Truly universal builds are painful, and Apple's Ruby is the only instance of it.

Reports all around say it works fine for all non-Apple, non-universal >2.7.2 rubies.

No CI yet.

@lloeki lloeki closed this as completed Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants