Skip to content
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

cmd/link: provide meaningful error message if -linkmode=external is attempted with GOARCH=ppc64 #25079

Closed
laboger opened this issue Apr 25, 2018 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@laboger
Copy link
Contributor

laboger commented Apr 25, 2018

Please answer these questions before submitting your issue. Thanks!

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

tip

Does this issue reproduce with the latest release?

yes

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

ppc64

Support was never added to golang for the ppc64 v1 ABI, so if files are generated that require the external linker on any ppc64 big endian machine, it will likely fail in some way where it is not always obvious why, and then users are confused.

Seems like golang should be able to provide an error message when an attempt is made to use -linkmode=external with GOARCH=ppc64. I think there are already cases where the use of unsupported linkmodes are flagged. I can make the change it if someone can advise where best it should go.

@laboger laboger changed the title link: provide meaningful error message if -linkmodex=external is attempted with GOARCH=ppc64 cmd/link: provide meaningful error message if -linkmodex=external is attempted with GOARCH=ppc64 Apr 25, 2018
@laboger laboger changed the title cmd/link: provide meaningful error message if -linkmodex=external is attempted with GOARCH=ppc64 cmd/link: provide meaningful error message if -linkmode=external is attempted with GOARCH=ppc64 Apr 25, 2018
@ianlancetaylor
Copy link
Contributor

Probably cmd/link/internal/ld/config.go.

@FiloSottile FiloSottile added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 25, 2018
@FiloSottile FiloSottile added this to the Unplanned milestone Apr 25, 2018
@laboger
Copy link
Contributor Author

laboger commented Apr 26, 2018

Here are two examples of how this fails now:

  1. Non-cgo program where -linkmode=external is specified
go build -ldflags '-linkmode=external' hello.go
# command-line-arguments
loadinternal: cannot find runtime/cgo

This is just a warning, and a dynamic binary is built, but the binary won't run because it hasn't been built according to the ppc64 v1 ABI and the dynamic linker fails:

./hello 
Segmentation fault
  1. cgo program:
 go build hello_cgo.go 
can't load package: package main: build constraints exclude all Go files in /home/boger/gotests

This message is not very useful, I believe it occurs because of this code in go/build/build.go:

  if isCgo {
                        allTags["cgo"] = true
                        if ctxt.CgoEnabled {
                                p.CgoFiles = append(p.CgoFiles, name)
                        } else {
                                p.IgnoredGoFiles = append(p.IgnoredGoFiles, name)
                        }

@gopherbot
Copy link

Change https://golang.org/cl/109915 mentions this issue: cmd/link: provide meaningful error msg with ext linking on ppc64

@golang golang locked and limited conversation to collaborators May 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

4 participants