cmd/link: wrong c-archive architecture using GNU binutils ar on macOS Mojave 10.14.1
#28,796 opened on Nov 14, 2018
Repository metrics
- Stars
- (133,883 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
What version of Go are you using (go version)?
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
What did you do?
Following the instructions at https://golang.org/doc/install/source, with the latest 1.11.2 darwin/amd64 Go binary distribution as the bootstrap toolchain:
git clone https://go.googlesource.com/go gosrc
cd gosrc
git checkout go1.11.2
cd src
./all.bash
What did you expect to see?
Go project should build successfully.
What did you see instead?
Error log: https://gist.github.com/DemonWav/8caf4fbdf9642133f53502614a231a24
Issues occur with ##### ../misc/cgo/testcarchive. I believe the issue is with this line:
ld: warning: ignoring file pkg/darwin_amd64/libgo.a, file was built for archive which is not the architecture being linked (x86_64): pkg/darwin_amd64/libgo.a
Since the architecture doesn't match, it doesn't link, and the linker can't find the missing symbols.
If I instead ask for the 386 architecture (GOARCH=386 ./all.bash), it builds successfully: https://gist.github.com/DemonWav/533894d4426e6a9dc7cc84cc613ee66d
The host is still recognized as amd64 in the build log, though.
Building packages and commands for host, darwin/amd64.
Building packages and commands for target, darwin/386
It appears libgo is always compiled as i386 architecture, even when both host and target are defined as amd64, GOARCH=amd64 GOHOSTARCH=amd64 ./all.bash gives the same result.
I'm not sure if there's something wrong with my environment or what, but I've asked on Slack and IRC and no one seems to know. I'm sorry if this isn't an issue.