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: `go test -c` does not respect gcflags sometimes #27681

Open
aarzilli opened this Issue Sep 14, 2018 · 7 comments

Comments

Projects
None yet
5 participants
@aarzilli
Contributor

aarzilli commented Sep 14, 2018

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

go version go1.11 linux/amd64

Does this issue reproduce with the latest release?

Yes

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/home/a/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/a/n/go/"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build874739252=/tmp/go-build -gno-record-gcc-switches"

What did you do?

go get github.com/aarzilli/testflags
cd $GOPATH/src/github.com/aarzilli/testflags
go test -c -gcflags 'all=-N -l'
objdump --dwarf testflags.test | grep -A 7 'DW_TAG_compile_unit' | grep 'DW_AT_name\|DW_AT_producer'

What did you expect to see?

All packages except runtime compiled with -N -l

What did you see instead?

    DW_AT_name         DW_FORM_string
    DW_AT_producer     DW_FORM_string
    <c>   DW_AT_name        : sync/atomic
    <2b>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <2efb0>   DW_AT_name        : internal/cpu
    <2efd0>   DW_AT_producer    : Go cmd/compile go1.11; -l
    <2f794>   DW_AT_name        : runtime/internal/sys
    <2f7bc>   DW_AT_producer    : Go cmd/compile go1.11; -l
    <300dc>   DW_AT_name        : runtime/internal/atomic
    <30107>   DW_AT_producer    : Go cmd/compile go1.11; -l
    <3024f>   DW_AT_name        : internal/bytealg
    <30273>   DW_AT_producer    : Go cmd/compile go1.11; -l
    <30732>   DW_AT_name        : runtime
    <3074d>   DW_AT_producer    : Go cmd/compile go1.11; -l
    <593d5>   DW_AT_name        : errors
    <593ef>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <594a7>   DW_AT_name        : internal/race
    <594c8>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <5955b>   DW_AT_name        : sync
    <59573>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <5a287>   DW_AT_name        : io
    <5a29d>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <5a67e>   DW_AT_name        : syscall
    <5a699>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <67e76>   DW_AT_name        : os
    <67e8c>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <6987c>   DW_AT_name        : internal/testlog
    <698a0>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <69a07>   DW_AT_name        : time
    <69a1f>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <6c810>   DW_AT_name        : internal/poll
    <6c831>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <6da1d>   DW_AT_name        : internal/syscall/unix
    <6da46>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <6db96>   DW_AT_name        : math
    <6dbae>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <6df47>   DW_AT_name        : math/bits
    <6df64>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <6e166>   DW_AT_name        : unicode/utf8
    <6e186>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <6eaa3>   DW_AT_name        : strconv
    <6eabe>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <721ee>   DW_AT_name        : unicode
    <72209>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <729bb>   DW_AT_name        : reflect
    <729d6>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <823d8>   DW_AT_name        : fmt
    <823ef>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <843c7>   DW_AT_name        : sort
    <843df>   DW_AT_producer    : Go cmd/compile go1.11
    <84e93>   DW_AT_name        : strings
    <84eae>   DW_AT_producer    : Go cmd/compile go1.11
    <85d64>   DW_AT_name        : flag
    <85d7c>   DW_AT_producer    : Go cmd/compile go1.11
    <8762a>   DW_AT_name        : testing
    <87645>   DW_AT_producer    : Go cmd/compile go1.11
    <8a141>   DW_AT_name        : bytes
    <8a15a>   DW_AT_producer    : Go cmd/compile go1.11
    <8ae44>   DW_AT_name        : runtime/debug
    <8ae65>   DW_AT_producer    : Go cmd/compile go1.11
    <8aeb4>   DW_AT_name        : context
    <8aecf>   DW_AT_producer    : Go cmd/compile go1.11
    <8af8c>   DW_AT_name        : runtime/trace
    <8afad>   DW_AT_producer    : Go cmd/compile go1.11
    <8b137>   DW_AT_name        : bufio
    <8b150>   DW_AT_producer    : Go cmd/compile go1.11
    <8b586>   DW_AT_name        : regexp/syntax
    <8b5a7>   DW_AT_producer    : Go cmd/compile go1.11
    <9042c>   DW_AT_name        : regexp
    <90446>   DW_AT_producer    : Go cmd/compile go1.11
    <92c2b>   DW_AT_name        : encoding/binary
    <92c4e>   DW_AT_producer    : Go cmd/compile go1.11
    <937a6>   DW_AT_name        : text/tabwriter
    <937c8>   DW_AT_producer    : Go cmd/compile go1.11
    <94380>   DW_AT_name        : compress/flate
    <943a2>   DW_AT_producer    : Go cmd/compile go1.11
    <97961>   DW_AT_name        : hash
    <97979>   DW_AT_producer    : Go cmd/compile go1.11
    <979bf>   DW_AT_name        : hash/crc32
    <979dd>   DW_AT_producer    : Go cmd/compile go1.11
    <97f88>   DW_AT_name        : compress/gzip
    <97fa9>   DW_AT_producer    : Go cmd/compile go1.11
    <9858d>   DW_AT_name        : path/filepath
    <985ae>   DW_AT_producer    : Go cmd/compile go1.11
    <9863d>   DW_AT_name        : io/ioutil
    <9865a>   DW_AT_producer    : Go cmd/compile go1.11
    <9885f>   DW_AT_name        : runtime/pprof
    <98880>   DW_AT_producer    : Go cmd/compile go1.11
    <9c2d2>   DW_AT_name        : testing/internal/testdeps
    <9c2ff>   DW_AT_producer    : Go cmd/compile go1.11
    <9cbca>   DW_AT_name        : github.com/aarzilli/testflags
    <9cbfb>   DW_AT_producer    : Go cmd/compile go1.11; -N -l
    <9ccf0>   DW_AT_name        : main
    <9cd08>   DW_AT_producer    : Go cmd/compile go1.11; -N -l

It's pretty weird that it only gets applied to some packages.

@aarzilli

This comment has been minimized.

Contributor

aarzilli commented Sep 19, 2018

This is a regression, it used to work in 1.10, and bisects to 2ce6da0

@gopherbot

This comment has been minimized.

gopherbot commented Sep 19, 2018

Change https://golang.org/cl/136275 mentions this issue: cmd/go: respect gcflags, ldflags in 'go test'

@jared2501

This comment has been minimized.

jared2501 commented Oct 24, 2018

Just ran into this issue - any chance we could get a fix as a patch to 1.11?

@ianlancetaylor

This comment has been minimized.

Contributor

ianlancetaylor commented Oct 24, 2018

As far as I can see, this hasn't been fixed on tip yet. CC @bcmills

@gopherbot please open a backport to 1.11

@gopherbot

This comment has been minimized.

gopherbot commented Oct 24, 2018

Backport issue(s) opened: #28346 (for 1.11).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.

@jared2501

This comment has been minimized.

jared2501 commented Oct 24, 2018

Thanks Ian!

@heschik

This comment has been minimized.

Contributor

heschik commented Nov 20, 2018

This is pretty bad for the debugging experience when it hits. Marking as a release blocker; feel free to undo it if I'm overstating things.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment