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/go: -buildmode=c-shared with non-main package should fail rather than building an archive #15082

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

Comments

@jaseg
Copy link

jaseg commented Apr 3, 2016

Please answer these questions before submitting your issue. Thanks!

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

Go 1.6, but tried with 1.5.3 to same result.

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

(debian 8/jessie, amd64 on KVM)

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GORACE=""
GOROOT="/home/jaseg/ffi/go"
GOTOOLDIR="/home/jaseg/ffi/go/pkg/tool/linux_amd64"
GO15VENDOREXPERIMENT=""
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
CXX="g++"
CGO_ENABLED="1"
  1. What did you do?

Using the source file at https://github.com/jaseg/ffi/blob/9baa10bd4f5c780a7ae6816db48ea7e5b79a813b/stage24.go

go build -buildmode=c-shared -o libstage24.so stage24.go
  1. What did you expect to see?

Something along the lines of

debian~/ffi <3 file libstage24.so
libstage24.so: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=26aed769e1c0f9026e59b47ab0544d32aada2b40, not stripped

as promised by go help buildmode.

  1. What did you see instead?
debian~/ffi <3 file libstage24.so
libstage24.so: current ar archive

edit: Here is the output of go build -x [...].

Since I do not have any experience with go, this might very well be due to some oversight on my part. I would still be glad for any hints.

Thank you.

@ianlancetaylor
Copy link
Contributor

You need to use package main, not package stage24.

Let's change this issue to reporting an error rather than building something useless.

@ianlancetaylor ianlancetaylor changed the title buildmode c-shared produces static archive instead of shared object on debian/amd64 using go build 1.6 cmd/go: -buildmode=c-shared with non-main package should fail rather than building an archive Apr 3, 2016
@ianlancetaylor ianlancetaylor added this to the Go1.7 milestone Apr 3, 2016
@jaseg
Copy link
Author

jaseg commented Apr 3, 2016

Thank you, that fixed it. I agree that an error message would be helpful in this case.

@rsc rsc modified the milestones: Go1.8, Go1.7 May 17, 2016
@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Oct 6, 2016
@quentinmit quentinmit modified the milestones: Go1.8Maybe, Go1.8 Oct 6, 2016
@rsc rsc modified the milestones: Go1.9, Go1.8Maybe Nov 2, 2016
@rsc
Copy link
Contributor

rsc commented Jun 22, 2017

I will send a CL making -buildmode=c-shared match the others that require a single main package as the argument. I have no idea if that's correct.

@gopherbot
Copy link

CL https://golang.org/cl/46421 mentions this issue.

gopherbot pushed a commit that referenced this issue Jun 27, 2017
After https://golang.org/cl/46421 is landed.
helpdoc.go should be updated that -buildmode=c-shared
requires only one main package.

Fixes #15082

Change-Id: I30a0ee956e6c4655c975ecdaa905887bd474952c
Reviewed-on: https://go-review.googlesource.com/46810
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@gopherbot
Copy link

Change https://golang.org/cl/46810 mentions this issue: cmd/go: update helpdoc.go about '-buildmode'

@golang golang locked and limited conversation to collaborators Jul 27, 2018
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

5 participants