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: internal linking for GOOS=linux, -buildmode=plugin #18157

Open
urso opened this issue Dec 2, 2016 · 4 comments
Open

cmd/link: internal linking for GOOS=linux, -buildmode=plugin #18157

urso opened this issue Dec 2, 2016 · 4 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Milestone

Comments

@urso
Copy link

urso commented Dec 2, 2016

Please answer these questions before submitting your issue. Thanks!

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

(1.8beta1)
go version devel +41908a5 Thu Dec 1 02:54:21 2016 +0000 darwin/amd64

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

Darwin:

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/urso/.gvm/pkgsets/go1.8beta1/global"
GORACE=""
GOROOT="/Users/urso/.gvm/gos/go1.8beta1"
GOTOOLDIR="/Users/urso/.gvm/gos/go1.8beta1/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2s/38f_b6sj0mn6_14km12vyq0r0000gn/T/go-build255645567=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

Linux:

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/urso/.gvm/pkgsets/go1.8beta1/global"
GORACE=""
GOROOT="/home/urso/.gvm/gos/go1.8beta1"
GOTOOLDIR="/home/urso/.gvm/gos/go1.8beta1/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build240993252=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"

What did you do?

Try to cross compile the plugin by setting GOOS=linux (darwin)

package main

import "fmt"

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

func main() {}

What did you expect to see?

plugin being build

What did you see instead?

Darwin:

$ GOOS=linux go build -buildmode=plugin plugin.go
# command-line-arguments
warning: unable to find runtime/cgo.a
/Users/urso/.gvm/gos/go1.8beta1/pkg/tool/darwin_amd64/link: running clang failed: exit status 1
ld: unknown option: -z
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Linux:

$ GOOS=darwin go build -buildmode=plugin plugin.go
# command-line-arguments
warning: unable to find runtime/cgo.a
/home/urso/.gvm/gos/go1.8beta1/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: -f may not be used without -shared
collect2: error: ld returned 1 exit status
@minux
Copy link
Member

minux commented Dec 2, 2016 via email

@bradfitz
Copy link
Contributor

bradfitz commented Dec 2, 2016

Should the go tool emit a more helpful error message after the existing failure messages?

Or is there missing documentation?

/cc @ianlancetaylor @crawshaw

@bradfitz bradfitz added this to the Go1.8Maybe milestone Dec 2, 2016
@minux
Copy link
Member

minux commented Dec 3, 2016 via email

@crawshaw
Copy link
Member

crawshaw commented Dec 3, 2016

Better error handling is covered by #16395, any solution to that will work here.

There are two potential feature requests here, the first is internal linking of plugins which don't use cgo when GOOS=linux, the second is the same for GOOS=darwin.

Let's turn this issue into a feature request for GOOS=linux, -buildmode=plugin internal linking. It's not a priority for me, but it's an entirely reasonable feature request.

@urso if you want, you can file a separate bug for GOOS=darwin, -buildmode=plugin internal linking.

@crawshaw crawshaw changed the title plugin: cross compiling fails cmd/link: internal linking for GOOS=linux, -buildmode=plugin Dec 3, 2016
@crawshaw crawshaw modified the milestones: Unplanned, Go1.8Maybe Dec 3, 2016
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
None yet
Development

No branches or pull requests

5 participants