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 is not set in build settings #53856

Open
capnspacehook opened this issue Jul 13, 2022 · 4 comments · May be fixed by #54218
Open

cmd/go: buildmode is not set in build settings #53856

capnspacehook opened this issue Jul 13, 2022 · 4 comments · May be fixed by #54218
Assignees
Labels
GoCommand NeedsFix
Milestone

Comments

@capnspacehook
Copy link

capnspacehook commented Jul 13, 2022

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

$ go version 18.4

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/capnspacehook/.cache/go-build"
GOENV="/home/capnspacehook/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/capnspacehook/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/capnspacehook/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.4"
GCCGO="gccgo"
GOAMD64="v3"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
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-build4110434964=/tmp/go-build -gno-record-gcc-switches"

What did you do?

go build -o hello hello.go
go version -m hello
go build -buildmode pie -o hello-pie hello.go
go version -m hello-pie

hello.go:

package main

import "fmt"

func main() {
        fmt.Println("yo")
}

What did you expect to see?

hello: go1.18.4
        path    command-line-arguments
        build   -compiler=gc
        build   -buildmode=exe
        build   CGO_ENABLED=1
        build   CGO_CFLAGS=
        build   CGO_CPPFLAGS=
        build   CGO_CXXFLAGS=
        build   CGO_LDFLAGS=
        build   GOARCH=amd64
        build   GOOS=linux
        build   GOAMD64=v3

hello-pie: go1.18.4
        path    command-line-arguments
        build   -compiler=gc
        build   -buildmode=pie
        build   CGO_ENABLED=1
        build   CGO_CFLAGS=
        build   CGO_CPPFLAGS=
        build   CGO_CXXFLAGS=
        build   CGO_LDFLAGS=
        build   GOARCH=amd64
        build   GOOS=linux
        build   GOAMD64=v3

What did you see instead?

hello: go1.18.4
        path    command-line-arguments
        build   -compiler=gc
        build   CGO_ENABLED=1
        build   CGO_CFLAGS=
        build   CGO_CPPFLAGS=
        build   CGO_CXXFLAGS=
        build   CGO_LDFLAGS=
        build   GOARCH=amd64
        build   GOOS=linux
        build   GOAMD64=v3

hello-pie: go1.18.4
        path    command-line-arguments
        build   -compiler=gc
        build   CGO_ENABLED=1
        build   CGO_CFLAGS=
        build   CGO_CPPFLAGS=
        build   CGO_CXXFLAGS=
        build   CGO_LDFLAGS=
        build   GOARCH=amd64
        build   GOOS=linux
        build   GOAMD64=v3

I expected to see the -buildmode flag in the build settings. I can see that it is not added here:

appendSetting("-compiler", cfg.BuildContext.Compiler)

@seankhliao seankhliao added NeedsFix GoCommand labels Jul 13, 2022
@seankhliao
Copy link
Member

seankhliao commented Jul 13, 2022

cc @bcmills @matloob

@bcmills
Copy link
Member

bcmills commented Jul 13, 2022

Good suggestion. Want to send a change to add it? (We can merge it when the window opens for Go 1.20.)

@bcmills bcmills added this to the Go1.20 milestone Jul 13, 2022
@capnspacehook
Copy link
Author

capnspacehook commented Jul 14, 2022

Sure, I'll send a change

cuiweixie added a commit to cuiweixie/go that referenced this issue Aug 3, 2022
@cuiweixie cuiweixie linked a pull request Aug 3, 2022 that will close this issue
@gopherbot
Copy link

gopherbot commented Aug 3, 2022

Change https://go.dev/cl/420937 mentions this issue: cmd/go: add buildmode info

cuiweixie added a commit to cuiweixie/go that referenced this issue Aug 13, 2022
cuiweixie added a commit to cuiweixie/go that referenced this issue Aug 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand NeedsFix
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants