安装sassc时出错,clang编译器不支持'-march=native',M1

xxj*_*jnn 9 ruby clang apple-m1

使用Apple Silicon M1机器。尝试安装 ruby​​ gem gem install sassc -v '2.1.0'

问题是 clang 编译器还没有 Apple M1 的“native”标志。有关的

给出的错误:(注意我用“yournamehere”替换了我的名字)

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

    current directory: /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sassc-2.1.0/ext
/Users/yournamehere/.asdf/installs/ruby/2.7.2/bin/ruby -I /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/2.7.0 -r ./siteconf20210303-14183-1uwhwj4.rb extconf.rb
creating Makefile

current directory: /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sassc-2.1.0/ext
make "DESTDIR=" clean

current directory: /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sassc-2.1.0/ext
make "DESTDIR="
compiling ./libsass/src/units.cpp
clang: error: the clang compiler does not support '-march=native'
make: *** [units.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/sassc-2.1.0 for inspection.
Results logged to /Users/yournamehere/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/extensions/arm64-darwin-20/2.7.0/sassc-2.1.0/gem_make.out

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

In Gemfile:
  sassc-rails was resolved to 2.1.2, which depends on
    sassc
Run Code Online (Sandbox Code Playgroud)

Joã*_*tta 33

根据sassc-ruby 上的这个答案,这个标志作为当前的解决方法对我有用:

gem install sassc -- --disable-march-tune-native
Run Code Online (Sandbox Code Playgroud)

  • 这对我的 sassc 版本 2.2.1 有用。默认情况下,在“arm64”上执行此操作的 PR 已在[此处](https://github.com/sass/sassc-ruby/pull/223) 开放。 (4认同)