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/link: Deprecated syntax `-ldflags "-X var val"` fails with usage message #15489

Closed
ryandesign opened this issue Apr 29, 2016 · 3 comments

Comments

Projects
None yet
4 participants
@ryandesign
Copy link

commented Apr 29, 2016

  1. What version of Go are you using (go version)?
go version go1.6.2 darwin/amd64
  1. What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH=""
GORACE=""
GOROOT="/opt/local/lib/go"
GOTOOLDIR="/opt/local/lib/go/pkg/tool/darwin_amd64"
GO15VENDOREXPERIMENT="1"
CC="/usr/bin/clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fno-common"
CXX="clang++"
CGO_ENABLED="1"
  1. 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.

Try to build mongo-tools 3.2.5 or earlier on OS X with go 1.5 or later

  1. What did you expect to see?

Expected successful build

  1. What did you see instead?

Got this warning and error:

link: warning: option -X github.com/mongodb/mongo-tools/common/options.Gitspec -X may not work in future releases; use -X github.com/mongodb/mongo-tools/common/options.Gitspec=-X
usage: link [options] main.o
  -B note
        add an ELF NT_GNU_BUILD_ID note when using ELF
  -C    check Go calls to C code
  -D address
        set data segment address (default -1)
  -E entry
        set entry symbol name
  -H type
        set header type
  -I linker
        use linker as ELF dynamic linker
  -L directory
        add specified directory to library path
  -R quantum
        set address rounding quantum (default -1)
  -T address
        set text segment address (default -1)
  -V    print version and exit
  -X definition
        add string value definition of the form importpath.name=value
  -a    disassemble output
  -buildid id
        record id as Go toolchain build id
  -buildmode mode
        set build mode
  -c    dump call graph
  -cpuprofile file
        write cpu profile to file
  -d    disable dynamic executable
  -extar string
        archive program for buildmode=c-archive
  -extld linker
        use linker when linking in external mode
  -extldflags flags
        pass flags to external linker
  -f    ignore version mismatch
  -g    disable go package data checks
  -h    halt on error
  -installsuffix suffix
        set package directory suffix
  -k symbol
        set field tracking symbol
  -libgcc string
        compiler support lib for internal linking; use "none" to disable
  -linkmode mode
        set link mode (internal, external, auto)
  -linkshared
        link against installed Go shared libraries
  -memprofile file
        write memory profile to file
  -memprofilerate rate
        set runtime.MemProfileRate to rate
  -msan
        enable MSan interface
  -n    dump symbol table
  -o file
        write output to file
  -r path
        set the ELF dynamic linker search path to dir1:dir2:...
  -race
        enable race detector
  -s    disable symbol table
  -shared
        generate shared object (implies -linkmode external)
  -tmpdir directory
        use directory for temporary files
  -u    reject unsafe packages
  -v    print link trace
  -w    disable DWARF generation

I have reported this bug to the developers of mongo-tools, and while they will address the problem by changing mongo-tools to use the new var=val syntax, because they no longer care about compatibility with old go versions, they feel it is a bug in go that the old syntax is not being accepted. They feel that after the link: warning message about the deprecated syntax, the build should proceed, and not exit with a usage message.

@dominikh

This comment has been minimized.

Copy link
Member

commented Apr 29, 2016

link: warning: option -X github.com/mongodb/mongo-tools/common/options.Gitspec -X

The warning and the failure are unrelated. The failure is because the -X flag expects two arguments: a variable name and a value. However, you're only providing a variable name, followed by another -X flag.

It looks like the git rev-parse HEAD invocation (from https://trac.macports.org/browser/trunk/dports/devel/mongo-tools/files/patch-build.sh.diff?rev=148181) is yielding an empty string.

The only issue on Go's side is that it emits the warning even if the -X flag was invalid to begin with.

@ianlancetaylor

This comment has been minimized.

Copy link
Contributor

commented Apr 29, 2016

This doesn't meet our criteria for fixing in a future Go 1.6 release, and 1.7 no longer accepts the old form of the -X argument, so there is nothing to do.

@ryandesign

This comment has been minimized.

Copy link
Author

commented Apr 29, 2016

The warning and the failure are unrelated. The failure is because the -X flag expects two arguments: a variable name and a value. However, you're only providing a variable name, followed by another -X flag.

It looks like the git rev-parse HEAD invocation (from https://trac.macports.org/browser/trunk/dports/devel/mongo-tools/files/patch-build.sh.diff?rev=148181) is yielding an empty string.

Of course! I should have noticed this. The git invocations return empty strings because in my case the source is not from git; it's from a tarball downloaded from GitHub. Sorry for the invalid bug report.

@golang golang locked and limited conversation to collaborators Apr 30, 2017

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