pytorch / pytorch/pytorch.github.io

M1 build issue and fix

Open
#1,827 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
285
Forks
317
PR merge metrics
No merged PRs in 30d

Description

@cjyabraham and I have been running into a recent issue where building native (c++) gem extensions has been failing on M1 and we at first thought it was because of my PR https://github.com/pytorch/pytorch.github.io/pull/1816 but upon reverting we noticed the issue persisted

Fetching unf_ext 0.0.7.7
Installing unf_ext 0.0.7.7 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
/Users/cjyabraham/Sites/pytorch.github.io/vendor/bundler/ruby/2.7.0/gems/unf_ext-0.0.7.7/ext/unf_ext
/Users/cjyabraham/.asdf/installs/ruby/2.7.8/bin/ruby -I /Users/cjyabraham/.asdf/installs/ruby/2.7.8/lib/ruby/2.7.0 -r
./siteconf20241127-13764-141w4yo.rb extconf.rb
checking for -lstdc++... yes
creating Makefile

current directory: /Users/cjyabraham/Sites/pytorch.github.io/vendor/bundler/ruby/2.7.0/gems/unf_ext-0.0.7.7/ext/unf_ext
make "DESTDIR=" clean

current directory: /Users/cjyabraham/Sites/pytorch.github.io/vendor/bundler/ruby/2.7.0/gems/unf_ext-0.0.7.7/ext/unf_ext
make "DESTDIR="
compiling unf.cc
In file included from unf.cc:1:
./unf/normalizer.hh:4:10: fatal error: 'vector' file not found
    4 | #include <vector>
      |          ^~~~~~~~
1 error generated.
make[1]: *** [unf.o] Error 1

make failed, exit code 2

Gem files will remain installed in
/Users/cjyabraham/Sites/pytorch.github.io/vendor/bundler/ruby/2.7.0/gems/unf_ext-0.0.7.7 for inspection.
Results logged to
/Users/cjyabraham/Sites/pytorch.github.io/vendor/bundler/ruby/2.7.0/extensions/arm64-darwin-22/2.7.0/unf_ext-0.0.7.7/gem_make.out

An error occurred while installing unf_ext (0.0.7.7), and Bundler cannot continue.
Make sure that `gem install unf_ext -v '0.0.7.7' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  github-pages was resolved to 214, which depends on
    github-pages-health-check was resolved to 1.17.0, which depends on
      dnsruby was resolved to 1.61.5, which depends on
        simpleidn was resolved to 0.2.1, which depends on
          unf was resolved to 0.1.4, which depends on
            unf_ext
make: *** [install] Error 5

The problem is that custom gem extensions were failing and the fix was

softwareupdate --all --install --force
xcode-select --install
rbenv uninstall 3.1.2
git clone https://github.com/rbenv/ruby-build.git "$(rbenv root)"/plugins/ruby-build
cd "$(rbenv root)"/plugins/ruby-build && git pull
RUBY_CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 3.1.2
rbenv local 3.1.2
ruby -v

There might be a simpler solution but not sure what

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
gem install unf_ext -v '0.0.7.7'

Fetching unf_ext-0.0.7.7.gem
Building native extensions. This could take a while...
Successfully installed unf_ext-0.0.7.7
Parsing documentation for unf_ext-0.0.7.7
Installing ri documentation for unf_ext-0.0.7.7
Done installing documentation for unf_ext after 0 seconds
1 gem installed

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reported Bundler dependency chain from github-pages through unf_ext and the M1 error showing that the C++ vector header is missing. Review the listed macOS, Xcode Command Line Tools, and Ruby setup commands, then determine whether the project needs a simpler fix or documented workaround. Done means an M1 build can install the native extension reliably.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, macos, ruby
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.