Running cgo -cdefs with gccgo

128 views
Skip to first unread message

John Paul Adrian Glaubitz

unread,
Jul 5, 2017, 9:45:43 AM7/5/17
to golang-dev
Hi!

I'm currently hacking on the linux-sparc64 port of Golang again, based on
Aram's port for solaris-sparc64. For Linux, I need to generate some Go
files with definitions like defs_linux_sparc64.go.

Looking at defs_linux_386.go, the first line states that this file was
generated and modified, i.e.:

// created by cgo -cdefs and then converted to Go
// cgo -cdefs defs2_linux.go

I'm trying to do that on a sparc64 box running Linux now where gccgo-6
and -7 is available. Unfortunately, I can't figure out how to run the
above command to generate the definitions. I remember having done that
in the past with gccgo but I don't remember the exact command anymore.

Can someone help?

Thanks,
Adrian

--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer - glau...@debian.org
`. `' Freie Universitaet Berlin - glau...@physik.fu-berlin.de
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913

Aram Hăvărneanu

unread,
Jul 5, 2017, 2:40:20 PM7/5/17
to John Paul Adrian Glaubitz, golang-dev
You don't need gccgo (although you can use it) and you don't need to
do it on the target (although you can, but then you do need gccgo).
What I do is run it on the host, having set a gcc cross-compiler for
the target (just C, not gccgo) that the host cgo tool is set to use.

You might need an old version of the cgo tool.

--
Aram Hăvărneanu

John Paul Adrian Glaubitz

unread,
Jul 5, 2017, 5:30:03 PM7/5/17
to Aram Hăvărneanu, golang-dev
On 07/05/2017 08:39 PM, Aram Hăvărneanu wrote:
> You don't need gccgo (although you can use it) and you don't need to
> do it on the target (although you can, but then you do need gccgo).
> What I do is run it on the host, having set a gcc cross-compiler for
> the target (just C, not gccgo) that the host cgo tool is set to use.

I found cgo, it's a bit hidden in Debian's gccgo package:

> https://packages.debian.org/search?suite=sid&arch=any&mode=exactfilename&searchon=contents&keywords=cgo

But it can also be invoked with "go tool cgo". That's what I was trying
to remember ;).
Reply all
Reply to author
Forward
0 new messages