FAQ
Hi,

If I invoke go build like this:
CC='/bin/true test test' go build -x -ldflags "-v -linkmode=external"
github.com/x/x/cmd/x

This is how go build later executes this:
host link: "/bin/true" "-m64" "-gdwarf-2" "-o" "/tmp/go-build680348205/
github.com/x/x/cmd/x/_obj/exe/a.out" "-rdynamic"
"/tmp/go-link-007899183/000000.o" "/tmp/go-link-007899183/000001.o"
"/tmp/go-link-007899183/go.o" "-g" "-O2" "-g" "-O2" "-lpthread"

Note how my two "test" arguments are just silently discarded.
Surely this is a bug?

My actual use case is that with the compile I have I need to supply
arguments for the compilation/linking to work at all. The way I worked
around it for now is to move the arguments to -extldflags, but I would
prefer if CC worked the same as it does everywhere else.

Thanks,
Christian

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Christian Svensson at Feb 20, 2016 at 3:14 pm
    FTR: This seems to be the commit where this was added:
    https://github.com/golang/go/commit/f0ff63ea64c878ebe67db70be8f41f73f21bbaff

    The code explicitly only passes the first part of CC down to the linker but
    the commit doesn't make it clear why this would be beneficial or correct.
    Over the years this code has wandered to different places but
    the append(ldflags, "-extld="+compiler[0]) remains.
    On Sat, Feb 20, 2016 at 12:39 PM, Christian Svensson wrote:

    Hi,

    If I invoke go build like this:
    CC='/bin/true test test' go build -x -ldflags "-v -linkmode=external"
    github.com/x/x/cmd/x

    This is how go build later executes this:
    host link: "/bin/true" "-m64" "-gdwarf-2" "-o" "/tmp/go-build680348205/
    github.com/x/x/cmd/x/_obj/exe/a.out" "-rdynamic"
    "/tmp/go-link-007899183/000000.o" "/tmp/go-link-007899183/000001.o"
    "/tmp/go-link-007899183/go.o" "-g" "-O2" "-g" "-O2" "-lpthread"

    Note how my two "test" arguments are just silently discarded.
    Surely this is a bug?

    My actual use case is that with the compile I have I need to supply
    arguments for the compilation/linking to work at all. The way I worked
    around it for now is to move the arguments to -extldflags, but I would
    prefer if CC worked the same as it does everywhere else.

    Thanks,
    Christian
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Christian Svensson at Feb 20, 2016 at 3:14 pm
    After getting my morning coffee I see what the code is trying to do: Set
    "/bin/true" to -extld and "test test" as -extldflags. But for some reason
    the latter appears to be broken.
    On Sat, Feb 20, 2016 at 12:54 PM, Christian Svensson wrote:

    FTR: This seems to be the commit where this was added:

    https://github.com/golang/go/commit/f0ff63ea64c878ebe67db70be8f41f73f21bbaff

    The code explicitly only passes the first part of CC down to the linker
    but the commit doesn't make it clear why this would be beneficial or
    correct. Over the years this code has wandered to different places but
    the append(ldflags, "-extld="+compiler[0]) remains.
    On Sat, Feb 20, 2016 at 12:39 PM, Christian Svensson wrote:

    Hi,

    If I invoke go build like this:
    CC='/bin/true test test' go build -x -ldflags "-v -linkmode=external"
    github.com/x/x/cmd/x

    This is how go build later executes this:
    host link: "/bin/true" "-m64" "-gdwarf-2" "-o" "/tmp/go-build680348205/
    github.com/x/x/cmd/x/_obj/exe/a.out" "-rdynamic"
    "/tmp/go-link-007899183/000000.o" "/tmp/go-link-007899183/000001.o"
    "/tmp/go-link-007899183/go.o" "-g" "-O2" "-g" "-O2" "-lpthread"

    Note how my two "test" arguments are just silently discarded.
    Surely this is a bug?

    My actual use case is that with the compile I have I need to supply
    arguments for the compilation/linking to work at all. The way I worked
    around it for now is to move the arguments to -extldflags, but I would
    prefer if CC worked the same as it does everywhere else.

    Thanks,
    Christian
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedFeb 20, '16 at 3:14p
activeFeb 20, '16 at 3:14p
posts3
users1
websitegolang.org

1 user in discussion

Christian Svensson: 3 posts

People

Translate

site design / logo © 2022 Grokbase