iden3 / go-rapidsnark

go-rapidsnark
Apache License 2.0
20 stars 5 forks source link

Cross-platform build error #19

Closed syntrust closed 5 months ago

syntrust commented 5 months ago

I was trying to build my project with go-rapidsnark on linux for Macos when I ran into the errors.

I'm not sure this is a problem with go-rapidsnark code, but any comments on the following errors are appreciated.

Error building mac amd64

$ env CGO_ENABLED=1  GOOS=darwin GOARCH=amd64  go build
# runtime/cgo
clang: error: argument unused during compilation: '-arch x86_64' [-Werror,-Wunused-command-line-argument]

When I mute the argument unused error:

$ env  CGO_ENABLED=1  GOOS=darwin GOARCH=amd64  CGO_CFLAGS="-Wno-error=unused-command-line-argument" go build 
 # runtime/cgo
gcc_darwin_amd64.c:21:9: error: implicit declaration of function 'pthread_get_stacksize_np' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
gcc_darwin_amd64.c:38:9: error: implicit declaration of function 'pthread_get_stacksize_np' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

Error building mac arm64

$ env  CGO_ENABLED=1  GOOS=darwin GOARCH=arm64  CGO_CFLAGS="-Wno-error=unused-command-line-argument" go build 

# runtime/cgo
gcc_darwin_arm64.c:16:10: fatal error: 'TargetConditionals.h' file not found

Environment

$ go version
go version go1.21.4 linux/amd64
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:        20.04
Codename:       focal
$ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/ubuntu/.cache/go-build'
GOENV='/home/ubuntu/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/ubuntu/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/ubuntu/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.4'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/ubuntu/dl/es-node/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1666150730=/tmp/go-build -gno-record-gcc-switches'
syntrust commented 5 months ago

Hello, I acknowledge that cross-platform compiling can be a complex challenge, so I worked around my issue by building my project on the corresponding platform. Thank you!