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: how can I build using -linkshared in a go modules project? #29651

Closed
zylthinking opened this issue Jan 10, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@zylthinking
Copy link

commented Jan 10, 2019

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

go version go1.11.2 linux/amd64

Does this issue reproduce with the latest release?

YES

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

go env Output
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/zylthinking/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/zylthinking/go"
GOPROXY=""
GORACE=""
GOROOT="/opt/go"
GOTMPDIR=""
GOTOOLDIR="/opt/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/zylthinking/TSConsole/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build148896868=/tmp/go-build -gno-record-gcc-switches"

What did you do?

my project tree:
├── code
│   ├── main.go
│   └── sysapi
│   ├── bitmask.go
│   ├── syslog.go
│   └── task.go
├── go.mod
├── go.sum

and I wants to build sysapi into a shared kibrary because init.so/ test.so depends on it
my step:

  1. go install -buildmode=shared -linkshared std
  2. go install -buildmode=shared -linkshared

What did you expect to see?

build scuccess

What did you see instead?

zylthinking@linux ~/TSConsole/code$ ls
main.go sysapi

zylthinking@linux ~/code$ go build
zylthinking@linux ~/TSConsole/code$ ls
code main.go sysapi

zylthinking@linux:~/TSConsole/code$ rm code

zylthinking@linux ~/code$ go build -buildmode=shared
no packages to build
zylthinking@linux ~/TSConsole/code$ ls
main.go sysapi

@ALTree ALTree changed the title how can I build using -linkshared in a go modules project? cmd/go: how can I build using -linkshared in a go modules project? Jan 10, 2019

@ALTree ALTree added the Question label Jan 10, 2019

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Jan 11, 2019

As the documentation for -buildmode=shared says, "Packages named main are ignored." That is because it doesn't make sense to build a main package into a shared library.

(You will likely get faster and better answers in a forum; see https://golang.org/wiki/Questions.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.