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

Allow usage on Apple silicon #29

Merged
merged 1 commit into from
Sep 1, 2022

Conversation

dentarg
Copy link
Contributor

@dentarg dentarg commented Aug 31, 2022

Related to #4, maybe not enough to close it?

@tarcieri
Copy link
Contributor

tarcieri commented Sep 1, 2022

Passes for me locally on a M1 Max

@tarcieri tarcieri merged commit 78cd9f6 into RubyCrypto:main Sep 1, 2022
@dentarg dentarg deleted the arm64-darwin-support branch September 1, 2022 21:48
@dentarg dentarg restored the arm64-darwin-support branch September 1, 2022 21:48
@dentarg dentarg deleted the arm64-darwin-support branch September 2, 2022 05:27
@dentarg
Copy link
Contributor Author

dentarg commented Sep 8, 2022

@tarcieri do you want to make a release with this change? :) so the gem works out of the box with M1/M2 Macs

@dentarg
Copy link
Contributor Author

dentarg commented Sep 8, 2022

Crap, don't think it will help with a release.

I never tried until today using the gem from a Gemfile. I tried now with gem "x25519", github: "RubyCrypto/x25519" but it fails with Makefile not found.

Full output
arm64 $ bundle install
Fetching https://github.com/RubyCrypto/x25519.git
Resolving dependencies...
Using bundler 2.3.7
Using x25519 1.0.9 from https://github.com/RubyCrypto/x25519.git (at main@78cd9f6)
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/x25519-78cd9f6692e0/ext/x25519_precomputed
/Users/dentarg/.arm64_rubies/3.1.2/bin/ruby -I /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0 -r ./siteconf20220908-81997-wttu7m.rb extconf.rb

Makefile not found

Gem files will remain installed in /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/x25519-78cd9f6692e0 for inspection.
Results logged to /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/bundler/gems/extensions/arm64-darwin-21/3.1.0/x25519-78cd9f6692e0/gem_make.out

  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:22:in `make'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:63:in `block in build'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/tempfile.rb:317:in `open'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:26:in `build'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:161:in `build_extension'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:195:in `block in build_extensions'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `each'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/rubygems/ext/builder.rb:192:in `build_extensions'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/rubygems/installer.rb:853:in `build_extensions'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/bundler/rubygems_gem_installer.rb:71:in `build_extensions'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/bundler/source/path/installer.rb:34:in `post_install'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/bundler/source/path.rb:244:in `generate_bin'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/bundler/source/git.rb:194:in `install'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/bundler/installer/gem_installer.rb:54:in `install'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/bundler/installer/parallel_installer.rb:186:in `do_install'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/bundler/worker.rb:62:in `apply_func'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/bundler/worker.rb:57:in `block in process_queue'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/bundler/worker.rb:54:in `loop'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/bundler/worker.rb:54:in `process_queue'
  /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/3.1.0/bundler/worker.rb:91:in `block (2 levels) in create_threads'

An error occurred while installing x25519 (1.0.9), and Bundler cannot continue.

In Gemfile:
  x25519

Same thing if I built the gem and try to install it with gem (name and version changed for clarity)

Output from gem install --local --verbose ./spinels-x25519-1.0.10.gem
arm64 $ gem install --local --verbose ./spinels-x25519-1.0.10.gem
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/.github/workflows/ci.yml
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/.gitignore
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/.rspec
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/.rubocop.yml
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/CHANGELOG.md
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/CODE_OF_CONDUCT.md
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/Gemfile
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/LICENSE
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/README.md
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/Rakefile
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_precomputed/cputest.c
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_precomputed/extconf.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_precomputed/fp25519_x64.c
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_precomputed/fp25519_x64.h
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_precomputed/table_ladder_x25519.h
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_precomputed/x25519_precomputed.c
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_precomputed/x25519_precomputed.h
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_precomputed/x25519_x64.c
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_ref10/api.h
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_ref10/base.c
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_ref10/extconf.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_ref10/fe.c
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_ref10/fe.h
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_ref10/montgomery.h
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_ref10/pow225521.h
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_ref10/scalarmult.c
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_ref10/x25519_ref10.c
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_ref10/x25519_ref10.h
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/lib/x25519.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/lib/x25519/montgomery_u.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/lib/x25519/precomputed_not_available.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/lib/x25519/scalar.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/lib/x25519/test_vectors.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/lib/x25519/version.rb
/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/x25519.gemspec
Building native extensions. This could take a while...
current directory: /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_precomputed
["/Users/dentarg/.arm64_rubies/3.1.2/bin/ruby", "-I", "/Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/site_ruby/3.1.0", "extconf.rb"]

ERROR:  Error installing ./spinels-x25519-1.0.10.gem:
	ERROR: Failed to build gem native extension.

    current directory: /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10/ext/x25519_precomputed
/Users/dentarg/.arm64_rubies/3.1.2/bin/ruby -I /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/site_ruby/3.1.0 extconf.rb
Makefile not found

Gem files will remain installed in /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/gems/spinels-x25519-1.0.10 for inspection.
Results logged to /Users/dentarg/.arm64_rubies/3.1.2/lib/ruby/gems/3.1.0/extensions/arm64-darwin-21/3.1.0/spinels-x25519-1.0.10/gem_make.out

Back to the drawing board... need to understand how extensions really work.

@dentarg
Copy link
Contributor Author

dentarg commented Sep 8, 2022

I think I found a way: #31

dentarg added a commit to dentarg/ruby that referenced this pull request Sep 8, 2022
@tarcieri tarcieri mentioned this pull request Oct 6, 2022
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

Successfully merging this pull request may close these issues.

2 participants