Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 907639

Summary: app-containers/docker can't be cross-compiled
Product: Gentoo Linux Reporter: Mark Harmstone <mark>
Component: Current packagesAssignee: William Hubbs <williamh>
Status: UNCONFIRMED ---    
Severity: normal CC: floppym, gyakovlev
Priority: Normal    
Version: unspecified   
Hardware: AMD64   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: emerge --info

Description Mark Harmstone 2023-06-01 16:57:58 UTC
Running `aarch64-unknown-linux-gnu-emerge app-containers/docker` on amd64 appears to work, but produces an amd64 rather than aarch64 binary.

It looks like Portage isn't setting the environment variable GOARCH, so Go doesn't know that it ought to be cross-compiling. This also happens with app-containers/docker-cli, and presumably other Go ebuilds.

Reproducible: Always
Comment 1 Mark Harmstone 2023-06-01 16:58:40 UTC
Created attachment 863017 [details]
emerge --info
Comment 2 Mark Harmstone 2023-06-01 17:15:03 UTC
Adding GOARCH=arm64 to /usr/aarch64-unknown-linux-gnu/etc/portage/make.conf isn't sufficient to fix it, as it then appears to be using an amd64 assembler for aarch64 code:

make -j9 LDFLAGS= VERSION=23.0.3 GITCOMMIT=3e7cbfdee1 dynbinary 
GO_LINKMODE=dynamic ./scripts/build/binary
Building dynamic docker-linux-arm64
+ go build -o build/docker-linux-arm64 -tags ' pkcs11' -ldflags ' -X "github.com/docker/cli/cli/version.GitCommit=3e7cbfdee1" -X "github.com/docker/cli/cli/version.BuildTime=2023-06-01T17:11:38Z" -X "github.com/docker/cli/cli/version.Version=23.0.3"' -buildmode=pie github.com/docker/cli/cmd/docker
# runtime/cgo
gcc_arm64.S: Assembler messages:
gcc_arm64.S:30: Error: no such instruction: `stp x29,x30,[sp,'
gcc_arm64.S:34: Error: too many memory references for `mov'
gcc_arm64.S:36: Error: no such instruction: `stp x19,x20,[sp,'
gcc_arm64.S:39: Error: no such instruction: `stp x21,x22,[sp,'
gcc_arm64.S:42: Error: no such instruction: `stp x23,x24,[sp,'
gcc_arm64.S:45: Error: no such instruction: `stp x25,x26,[sp,'
gcc_arm64.S:48: Error: no such instruction: `stp x27,x28,[sp,'
gcc_arm64.S:52: Error: too many memory references for `mov'
gcc_arm64.S:53: Error: too many memory references for `mov'
gcc_arm64.S:54: Error: too many memory references for `mov'
gcc_arm64.S:56: Error: no such instruction: `blr x20'
gcc_arm64.S:57: Error: no such instruction: `blr x19'
gcc_arm64.S:59: Error: no such instruction: `ldp x27,x28,[sp,'
gcc_arm64.S:62: Error: no such instruction: `ldp x25,x26,[sp,'
gcc_arm64.S:65: Error: no such instruction: `ldp x23,x24,[sp,'
gcc_arm64.S:68: Error: no such instruction: `ldp x21,x22,[sp,'
gcc_arm64.S:71: Error: no such instruction: `ldp x19,x20,[sp,'
gcc_arm64.S:74: Error: no such instruction: `ldp x29,x30,[sp],'