Skip to content

armv5tel "Illegal instruction" since golang 1.21.0 #62475

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
cah-jad-baz opened this issue Sep 6, 2023 · 7 comments
Closed

armv5tel "Illegal instruction" since golang 1.21.0 #62475

cah-jad-baz opened this issue Sep 6, 2023 · 7 comments
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@cah-jad-baz
Copy link

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

Compiling with:

$ go version
go1.21.0 linux/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

amd64 build environment:

go env Output
$ go env
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/jad/.cache/go-build'
GOENV='/home/jad/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/jad/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/jad/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/dev/null'
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-build3952936469=/tmp/go-build -gno-record-gcc-switches'

armv5 target environment

~# uname -a
Linux SDcard 2.6.34 #17 PREEMPT Fri Nov 11 15:06:02 MST 2011 armv5tel GNU/Linux

Issue

armv5tel is no longer supported as a runtime target (not sure if all armv5). Since the golang toolchain is not available on armv5, I'm building on amd64 and copying to armv5. I tried a simple hello world. It works with 1.20.7 but fails with 1.21.0

Full reproducer

On build machine (amd64)

vi helloworld.go

package main
import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

Then, compile it with golang 1.20.7 and 1.21 for linux and arm

env GOOS=linux GOARCH=amd64 /usr/local/go1.20.7/bin/go build helloworld.go; mv helloworld helloworld.arm.go1.20.7
env GOOS=linux GOARCH=amd64 /usr/local/go1.21.0/bin/go build helloworld.go; mv helloworld helloworld.arm.go1.21.0

Then copy both to armv5 machine

scp helloworld.arm.go1.20.7 user@IP:
scp helloworld.arm.go1.21.0 user@IP:

On target machine (armv5)

Run both

# ./helloworld.arm.go1.20.7
Hello, World!

# ./helloworld.arm.go1.21.0
Illegal instruction 

The one built with golang 1.20.7 succeeds whereas the one built with 1.21.0 fails

@randall77
Copy link
Contributor

Can you tell us what the illegal instruction is? Run the code under a debugger and disassemble around the faulting PC.

@randall77 randall77 added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Sep 6, 2023
@cah-jad-baz
Copy link
Author

@randall77, I don't think it's possible for me to run a debugger on armv5. As mentioned above, the toolchain is not available for armv5 so I need to build it on amd64 and then copy it over to armv5.

That being said, this is not an issue with the program I wrote as the program is tiny and it's also happening in VictoriaMetrics/VictoriaMetrics#4965

In any case, what other info can I provide that might aid in debugging this?

@randall77
Copy link
Contributor

I built hello world with both 1.20 and 1.21. Disassembled both and looked for an instruction in the 1.21 binary that was not in the 1.20 binary. The only one I found is mrc, which should be fine for armv5.

That said, did you set GOARM=5 when building? 6 is the default. https://github.com/golang/go/wiki/MinimumRequirements#arm

Not sure what would have changed from 1.20 to 1.21.

@cah-jad-baz
Copy link
Author

env GOOS=linux GOARCH=arm GOARM=5 /usr/local/go1.21.0/bin/go build helloworld.go; mv helloworld helloworld.arm.go1.21.0.armv5

Now it works

@randall77 do you know if prior to 1.21, default GOARM was also 6?

@randall77
Copy link
Contributor

My memory is hazy on that front.
Maybe the default for hosted builds was 6, but the default for cross-compiled builds was 5? That latter part might be what changed due to our push to make builds reproducible independent of host.

@golang/arm

@cah-jad-baz
Copy link
Author

Alright, that's great. Closing this issue. Thanks @randall77!

@randall77
Copy link
Contributor

This did indeed change for 1.21:

% GOOS=linux GOARCH=arm ~/go1.20.6/bin/go env GOARM
5
% GOOS=linux GOARCH=arm ~/go1.21.0/bin/go env GOARM
7

The issue for reproducible builds is #58884 .

valyala added a commit to VictoriaMetrics/VictoriaMetrics that referenced this issue Sep 7, 2023
Pass GOARM=5 when building GOARCH=arm production builds, since the default value for this env var
has been changed to GOARM=6 since Go1.21.0.

See #4965
and golang/go#62475
valyala added a commit to VictoriaMetrics/VictoriaMetrics that referenced this issue Sep 7, 2023
Pass GOARM=5 when building GOARCH=arm production builds, since the default value for this env var
has been changed to GOARM=6 since Go1.21.0.

See #4965
and golang/go#62475
valyala added a commit to VictoriaMetrics/VictoriaMetrics that referenced this issue Sep 7, 2023
Pass GOARM=5 when building GOARCH=arm production builds, since the default value for this env var
has been changed to GOARM=6 since Go1.21.0.

See #4965
and golang/go#62475
valyala added a commit to VictoriaMetrics/VictoriaMetrics that referenced this issue Sep 7, 2023
Pass GOARM=5 when building GOARCH=arm production builds, since the default value for this env var
has been changed to GOARM=6 since Go1.21.0.

See #4965
and golang/go#62475
valyala added a commit to VictoriaMetrics/VictoriaMetrics that referenced this issue Sep 7, 2023
Pass GOARM=5 when building GOARCH=arm production builds, since the default value for this env var
has been changed to GOARM=6 since Go1.21.0.

See #4965
and golang/go#62475
valyala added a commit to VictoriaMetrics/VictoriaMetrics that referenced this issue Sep 7, 2023
Pass GOARM=5 when building GOARCH=arm production builds, since the default value for this env var
has been changed to GOARM=6 since Go1.21.0.

See #4965
and golang/go#62475
@golang golang locked and limited conversation to collaborators Sep 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants