lightsparkdev / go-sdk

Lightspark Go SDK
Apache License 2.0
5 stars 6 forks source link

Error running clang with arm64 architecture. #123

Closed JamieW87 closed 1 month ago

JamieW87 commented 1 month ago

Running the example file locally after importing lightspark/go-sdk v0.15.0:

adminuser@MacBook-Pro server % go run main.go
# command-line-arguments
/usr/local/go/pkg/tool/darwin_arm64/link: running clang failed: exit status 1
ld: warning: directory not found for option '-L/Users/adminuser/dev/deblock/crypto/vendor/github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go/libs/darwin/arm64'
ld: library not found for -llightspark_crypto
clang: error: linker command failed with exit code 1 (use -v to see invocation)

My go env:

adminuser@MacBook-Pro server % go env
GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/adminuser/Library/Caches/go-build'
GOENV='/Users/adminuser/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/adminuser/go/pkg/mod'
GOOS='darwin'
GOPATH='/Users/adminuser/go'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.3'
GCCGO='gccgo'
AR='ar'
CC='clang'
CXX='clang++'
CGO_ENABLED='1'
GOMOD='/Users/adminuser/dev/deblock/crypto/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 -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/s4/d7kfkxj17x56twxn5j25cssw0000gn/T/go-build3296032941=/tmp/go-build -gno-record-gcc-switches -fno-common'

Is this a known issue with arm64 architecture, or is there something wrong locally that I am not seeing. Google is being especially unhelpful.

JamieW87 commented 1 month ago

Digging into it, it seems it's looking for the directory

github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go/libs/darwin/arm64

But looking into my vendor directory, this doesnt exist:

Screenshot 2024-07-11 at 18 14 01

zhenlu commented 1 month ago

It seems like you need to pull this dependency. Try

% go get github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.4.1
zhenlu commented 1 month ago

The folder exists in the latest version. You can see it here

https://github.com/lightsparkdev/lightspark-crypto-uniffi/tree/main/lightspark-crypto-go/libs/darwin/arm64
JamieW87 commented 1 month ago

I tried pulling that dependency, and still get the original error.

The version listed in my go mod is github.com/lightsparkdev/go-sdk v0.15.0

If i look in my vendor folder now i still see the incomplete lightspark-crypto-uniffi directory, like above.

So I've tried deleting my vendor folder, Retrying:

go get github.com/lightsparkdev/go-sdk@v0.15.0 and go get github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go@v0.4.1

and the problem still persists

JamieW87 commented 1 month ago

Also, The import statement for uniffi in my go.mod is also correct:

github.com/lightsparkdev/lightspark-crypto-uniffi/lightspark-crypto-go v0.4.1 // indirect

So not sure why that folder doesn't exist in my vendor

zhenlu commented 1 month ago

I checked your go env and it's similar to mine. Could you check your network setup to see if any binary is blocked through go get command?

JamieW87 commented 1 month ago

My local Go is 1.22.3

The project go is 1.21

How do i check the network setup? My installations are pretty bog standard, I haven't done much customisation

JamieW87 commented 1 month ago

Ok i git clone 'd the uniffi folder and copy and pasted the libs directory manually into my vendor directory and got the code working. However I still cant figure out why a standard go get on the base directory isnt getting this particular folder

zhenlu commented 1 month ago

Yeah, this is weird. Maybe try reinstall your go toolchain again? I'm not able to reproduce this issue. My go get will download everything for me and I'm running a mac as well.

JamieW87 commented 1 month ago

Hey! Sorry about the late reply. Got moved onto something else.

I will try a few things and get back to you. It must be a setup issue my side if it works fine on your end.