best practices for gccgo and external packages

83 views
Skip to first unread message

Philip Brown

unread,
Apr 23, 2018, 9:56:59 PM4/23/18
to golang-nuts
the docs at 
seem to mention how to use packages for your own code, but dont mention how to use third party packages.

In other words, in situations where you would normally do



What should you do for gccgo, once you have downloaded/cloned somepackage ?

Of particular interest is, for example, the gccgo equivalent of


What would be best practices for that?
Seems like the tools are either undocumented, or just plain missing


also:
one would think that

go build -compiler gccgo -buildmode=archive

would appear to be the right tool.
But it doenst work on my platform.
So I need other suggestions.


Ian Lance Taylor

unread,
Apr 24, 2018, 12:23:51 AM4/24/18
to Philip Brown, golang-nuts
On Mon, Apr 23, 2018 at 6:40 PM, Philip Brown <ph...@bolthole.com> wrote:
>
> the docs at
> https://golang.org/doc/install/gccgo
> seem to mention how to use packages for your own code, but dont mention how
> to use third party packages.
>
> In other words, in situations where you would normally do
>
> go get github.org/blah/somepackage
>
>
> What should you do for gccgo, once you have downloaded/cloned somepackage ?
>
> Of particular interest is, for example, the gccgo equivalent of
>
> go get golang.org/x/net
>
> What would be best practices for that?

The equivalent is the same command: `go get golang.org/x/net`.
Although there is no such package, perhaps you want `go get
golang.org/x/net/ipv4` or something.


> also:
> one would think that
>
> go build -compiler gccgo -buildmode=archive
>
> would appear to be the right tool.
> But it doenst work on my platform.
> So I need other suggestions.

There is no -buildmode=archive. Using -buildmode=c-archive should
work if that is what you want to do.

Ian

Philip Brown

unread,
Apr 24, 2018, 1:33:03 AM4/24/18
to Ian Lance Taylor, golang-nuts
On Mon, Apr 23, 2018 at 9:23 PM, Ian Lance Taylor <ia...@golang.org> wrote:
>
>
> There is no -buildmode=archive. Using -buildmode=c-archive should
> work if that is what you want to do.
>

ORLLY? :-}

$ go help buildmode
The 'go build' and 'go install' commands take a -buildmode argument which
indicates which kind of object file is to be built. Currently supported values
are:

-buildmode=archive
Build the listed non-main packages into .a files. Packages named
main are ignored.

Ian Lance Taylor

unread,
Apr 24, 2018, 9:56:21 AM4/24/18
to Philip Brown, golang-nuts
Sorry, you're quite right. I completely forgot that
-buildmode=archive is the default for a non-main package.

Ian

Philip Brown

unread,
Apr 24, 2018, 1:15:21 PM4/24/18
to golang-nuts


On Tuesday, April 24, 2018 at 6:56:21 AM UTC-7, Ian Lance Taylor wrote:

Sorry, you're quite right.  I completely forgot that
-buildmode=archive is the default for a non-main package.


Okay, so just to close the loop on information sharing, I think you are saying that
-buildmode=archive
is what the gcc go front end uses, when it builds packages under 
$HOME/go/pkg/gccgo_$OS_$ARCH/

(which comes as a result of "go get x/y/z")
It is also interesting that it does not appear to generate .gox files under there to match.




Ian Lance Taylor

unread,
Apr 24, 2018, 1:21:15 PM4/24/18
to Philip Brown, golang-nuts
The .gox files are used for the Go standard library, which is
typically a single shared library. Go packages other than the
standard library are normally linked directly into the program, so a
single .a file per package suffices.

Ian
Reply all
Reply to author
Forward
0 new messages