When build with -buildmode=plugin, go complains about an asm error

What version of Go are you using (go version)?

go1.17.5

What operating system are you using?

Mac OS 12.1 (Intel)

What version of Badger are you using?

v3.2103.2

Does this issue reproduce with the latest master?

Yes.

Steps to Reproduce the issue

Any go package that depends on Badger and builds using buildmode=plugin or anything using dynamic link will see the error:

when dynamic linking, R15 is clobbered by a global variable access and is used here

To reproduce this, try the following:

git clone https://github.com/appbaseio/reactivesearch-api
make clean && make

^ The above project uses buildmode=plugin to build and badger is a dependency of it.

This is originating from cespare/xxhash module, the issue is described over here: cespare/xxhash#54. It’s fixed in their latest release: v2.1.2. Updating this module to this release in badger should resolve this issue.

Further reference is here: github.com/golang/go/issues/43661.

What Badger options were set?

N/A

What did you do?

Built the go code

What did you expect to see?

A successful build

What did you see instead?

go build --buildmode=plugin -o build/plugins/auth.so plugins/auth/main/auth.go
# github.com/cespare/xxhash
asm: xxhash_amd64.s:120: when dynamic linking, R15 is clobbered by a global variable access and is used here: 00092 (/Users/sid/.gvm/pkgsets/go1.17.5/global/pkg/mod/github.com/cespare/xxhash@v1.1.0/xxhash_amd64.s:120)   ADDQ    R15, AX

There is an open PR that should solve the above issue over here: Bump xxhash to v2 to fix https://github.com/cespare/xxhash/issues/54 by eh-steve · Pull Request #1777 · dgraph-io/badger · GitHub.

It would be greatly appreciated if this can be merged and released :pray:

1 Like

Facing the same issue, not able to compile it on amd_64 machine

Facing the same issue. For our case dgraph/badger3 is using xxhash v1.1.0 but other modules have upgraded to xxhash/v2 v2.1.2 and this is not resolving cleanly. I’ve even tried using replace but it does not work.
I’m building on Mac OS X 12.3.1(intel), go version go1.18.1 darwin/amd64, v3.2103.2 of badger.

# github.com/cespare/xxhash
asm: xxhash_amd64.s:120: when dynamic linking, R15 is clobbered by a global variable access and is used here: 00092 (/home/go/pkg/mod/github.com/cespare/xxhash@v1.1.0/xxhash_amd64.s:120)  ADDQ  R15, AX
asm: assembly failed
make[1]: *** [go-build] Error 2

Getting this fixed would be great in the main repo. Thanks!