Skip to content

go compiler: Incorrect results on GOOS=linux GOARCH=arm64 running on Google t2a-standard-8 (Ampere Altra) #66431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sbunce opened this issue Mar 20, 2024 · 2 comments

Comments

@sbunce
Copy link

sbunce commented Mar 20, 2024

Go version

go version go1.22.1 linux/amd64

Output of go env in your module/workspace:

GO111MODULE='on'
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/seth.bunce/.cache/go-build'
GOENV='/home/seth.bunce/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/seth.bunce/go/pkg/mod'
GONOPROXY='github.robot.car'
GONOSUMDB='github.robot.car'
GOOS='linux'
GOPATH='/home/seth.bunce/go'
GOPRIVATE='github.robot.car'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/home/seth.bunce/go/pkg/mod/golang.org/[email protected]'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/home/seth.bunce/go/pkg/mod/golang.org/[email protected]/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.1'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/seth.bunce/go/src/github.robot.car/cruise/rbe/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-build1436812387=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I cross compiled the following program for linux/arm64 with the following command, "GOARCH=arm64 go install ./cmd/armtest"

package main

import (
	"fmt"
	"hash/crc32"
	"math"
)

func hash() int {
	u32 := crc32.Checksum(nil, crc32.IEEETable)
	return int(u32 % math.MaxInt32)
}

func main() {
	result := hash()
	if result < 0 {
		fmt.Printf("FAIL: %d\n", result)
	} else {
		fmt.Printf("PASS: %d\n", result)
	}
}

I copied the built binary to a t2a-standard-8 running in GCP.

What did you see happen?

I ran the program and observed an incorrect result.

root@gcp-cpu-arm-rbe-test-swfn:/# ./armtest
FAIL: -4294967296

What did you expect to see?

I expected to see the same output I see on linux/amd64 (a google n1-standard-32 GCP instance).

seth.bunce@cs-a2n6x93j-heavy-homedir-946879:~/go/src/github.robot.car/cruise/rbe$ go run ./cmd/armtest/main.go 
PASS: 0
@seankhliao
Copy link
Member

This is fixed on tip, see #66076 for backport issue

@seankhliao
Copy link
Member

Duplicate of #66066

@seankhliao seankhliao marked this as a duplicate of #66066 Mar 20, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Mar 20, 2024
@golang golang locked and limited conversation to collaborators Mar 20, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants