Issue with go get on M1 MacOS
Opened this issue · 6 comments
Hey all, pretty new to go and having a problem with go get on MacOS 12.2/Go 1.17.6 on M1.
Here is what I am facing:
face-detector % go get github.com/Kagami/go-face
# github.com/Kagami/go-face
clang: error: the clang compiler does not support '-march=native'
I am not sure if I am missing some flag that would allow this to build. Here is my go env:
face-detector % go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/<username>/Library/Caches/go-build"
GOENV="/Users/<username>/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/<username>/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/<username>/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/opt/homebrew/Cellar/go/1.17.6/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/homebrew/Cellar/go/1.17.6/libexec/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.17.6"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/<username>/Development/face-detector/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/j1/gdnt9_0d3811nn7d8t63hbc80000gn/T/go-build658795374=/tmp/go-build -gno-record-gcc-switches -fno-common"
Any recommendations? I am not seeing where -march=native is set. There was a stack overflow thread that suggested using -mcpu=apple-m1 however I am not seeing where to put that.
modify face.go at this project
package face
// #cgo CXXFLAGS: -std=c++1z -Wall -O3 -DNDEBUG -mcpu=apple-m1
another solutions is update clang with brew
lang: error: the clang compiler does not support '-march=native'
1° - Install llvm con brew
brew install llvm
2° - Check clang version
cd /opt/homebrew/opt/llvm
.clang --version
Result:
Homebrew clang version 15.0.6
Target: arm64-apple-darwin22.2.0
Thread model: posix
InstalledDir: /opt/homebrew/opt/llvm/bin
3° - modify path with the new version, for example add to .zshrc
export PATH="/opt/homebrew/opt/llvm/bin:$PATH"
I tried the solution above, and now it gets an error
classify.cc:2:10: fatal error: 'dlib/graph_utils.h' file not found
I tried the solution above, and now it gets an error
classify.cc:2:10: fatal error: 'dlib/graph_utils.h' file not found
try
CPLUS_INCLUDE_PATH=/opt/homebrew/Cellar/jpeg/9d/include/:/opt/homebrew/Cellar/dlib/19.24_1/include LD_LIBRARY_PATH=/opt/homebrew/Cellar/dlib/19.24_1/lib/:/opt/homebrew/Cellar/jpeg/9d/lib/ LIBRARY_PATH=/opt/homebrew/Cellar/dlib/19.24_1/lib/:/opt/homebrew/Cellar/jpeg/9d/lib/ go build
Fixed by copying dlib in $GOPATH/pkg/path/to/go-face
and changing import in classify.cc