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: support ldflags -X with gccgo #25183

Open
omac777 opened this Issue Apr 30, 2018 · 0 comments

Comments

Projects
None yet
3 participants
@omac777

omac777 commented Apr 30, 2018

Please answer these questions before submitting your issue. Thanks!

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

1.10

Does this issue reproduce with the latest release?

yes

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

GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/dma2/Code/go"
GORACE=""
GOROOT="/home/dma2/Code/go/src/github.com/cloudflare/tls-tris/_dev/go1.10"
GOTOOLDIR="/usr/lib/gcc/x86_64-pc-linux-gnu/7.3.1"
GCCGO="/usr/bin/gccgo"
CC="/usr/bin/gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build074293983=/tmp/go-build -gno-record-gcc-switches"
CXX="/usr/bin/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?

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

This works:
go build
go build -compiler gccgo

This doesn't:
go build -compiler gccgo -gccgoflags "-X main.gbBuildTime=$(date +'%Y.%m.%d.%H%M%S') -X main.gbCommitHash=$(git log --pretty=format:'%h' -n 1) -X main.gbGitVersionTag=$(git describe) -X main.gbMfwlibGitVersionTag=$(git --git-dir ../mfwlib/.git describe)"

What did you expect to see?

No errors. I wish to set some go variable using gccgoflags as I would use them with -ldflags.
I also wish more documentation as to how to set go variables when using gccgo and gccgoflags rather than go and ldflags.

What did you see instead?

github.com/go-sql-driver/mysql

gccgo: error: main.gbBuildTime=2018.04.30.102007: No such file or directory
gccgo: error: main.gbCommitHash=770fe0e: No such file or directory
gccgo: error: main.gbGitVersionTag=v1.14: No such file or directory
gccgo: error: main.gbMfwlibGitVersionTag=v1.55: No such file or directory
gccgo: error: unrecognized command line option ‘-X’
gccgo: error: unrecognized command line option ‘-X’
gccgo: error: unrecognized command line option ‘-X’
gccgo: error: unrecognized command line option ‘-X’

@gopherbot gopherbot added this to the Gccgo milestone Apr 30, 2018

@ianlancetaylor ianlancetaylor changed the title from gccgo: error: unrecognized command line option ‘-X’ to cmd/go: support ldflags -X with gccgo Apr 30, 2018

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