garble icon indicating copy to clipboard operation
garble copied to clipboard

ebitengine/purego causes: expected pseudo-register; found R11

Open tdewolff opened this issue 7 months ago • 11 comments

Go version

go version go1.24.2 linux/amd64

Output of go env in your module/workspace:

AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE=''
GOAMD64='v1'
GOARCH='amd64'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/taco/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/taco/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build861698014=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/home/taco/go/src/github.com/tdewolff/xxx/go.mod'
GOMODCACHE='/home/taco/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/taco/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/lib/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='local'
GOTELEMETRYDIR='/home/taco/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/lib/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.24.2'
GOWORK=''
PKG_CONFIG='pkg-config'

What did you do?

I've built a small reproducible example that causes this error. It doesn't surprise me since purego is probably using some unsafe methods, but it would still be nice if this bug could be fixed. We have disabled out WebP support for now since we do not wish to enable CGO just for WebP support.

Please let me know if you need additional information or if I can help figuring this out. Your help and time is greatly appreciated; this library has been a very valuable addition in our toolset.

package main

import (
	"fmt"

	"github.com/ebitengine/purego"
)

var WebPLibraries = []string{"libwebp.so", "libwebp.so.7"}

var (
	webpConfigInit func(*webpConfig, int, float32, int) int
)

type webpConfig struct {
	// fields removed
}

func init() {
	var err error
	var libwebp uintptr
	for _, lib := range WebPLibraries {
		if libwebp, err = purego.Dlopen(lib, purego.RTLD_LAZY|purego.RTLD_LOCAL); err == nil {
			break
		}
	}
	if err != nil {
		fmt.Println("webp: loading library:", err)
		return
	}

	purego.RegisterLibFunc(&webpConfigInit, libwebp, "WebPConfigInitInternal")
}

func main() {
}

What did you see happen?

Output:

$ garble build
# github.com/ebitengine/purego
/tmp/garble-shared3190220499/a3T9hlIQy/F7IhcnR.s:48: expected pseudo-register; found R11
/tmp/garble-shared3190220499/a3T9hlIQy/F7IhcnR.s:49: expected pseudo-register; found R11
/tmp/garble-shared3190220499/a3T9hlIQy/F7IhcnR.s:50: expected pseudo-register; found R11
/tmp/garble-shared3190220499/a3T9hlIQy/F7IhcnR.s:51: expected pseudo-register; found R11
/tmp/garble-shared3190220499/a3T9hlIQy/F7IhcnR.s:52: expected pseudo-register; found R11
/tmp/garble-shared3190220499/a3T9hlIQy/F7IhcnR.s:53: expected pseudo-register; found R11
/tmp/garble-shared3190220499/a3T9hlIQy/F7IhcnR.s:54: expected pseudo-register; found R11
/tmp/garble-shared3190220499/a3T9hlIQy/F7IhcnR.s:55: expected pseudo-register; found R11
/tmp/garble-shared3190220499/a3T9hlIQy/F7IhcnR.s:57: expected pseudo-register; found R11
/tmp/garble-shared3190220499/a3T9hlIQy/F7IhcnR.s:58: expected pseudo-register; found R11
/tmp/garble-shared3190220499/a3T9hlIQy/F7IhcnR.s:59: expected pseudo-register; found R11
asm: too many errors
exit status 1
exit status 1

What did you expect to see?

Expected without errors.

tdewolff avatar Apr 27 '25 21:04 tdewolff