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

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

cmd/go: support ldflags -X with gccgo #25183

omac777 opened this issue Apr 30, 2018 · 0 comments
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@omac777
Copy link

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 gccgo: error: unrecognized command line option ‘-X’ cmd/go: support ldflags -X with gccgo Apr 30, 2018
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Apr 30, 2018
Risca added a commit to Risca/buildroot that referenced this issue Dec 21, 2021
I might just be dumb, but this was the only way I was able to compile
it with gccgo (gcc-9.4, go1.12)

At least the sed fix is needed due to '-X' not being supported by gccgo
golang/go#25183
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants