Skip to content

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

Closed as not planned
@sbunce

Description

@sbunce

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions