Skip to content

cmd/cgo: unknown ptrSize for $GOARCH mips when using gccgo #7398

@gopherbot

Description

@gopherbot

by erik.westrup:

In a cross-compilaton situation targeting a MIPS running device from my amd64 
host I want to be able to run cgo. However cgo does not seems to be adjusted to 
handle the architectures that gccgo supports. More specifically 
src/cmd/cgo/main.go:132 only accepts the architectures that are supported by 
gc. I expect that, if I compile cgo with gccgo, that the correct architectures 
should be supported, just like when you compile the Go tool with gccgo. 

What steps will reproduce the problem?
1. Follow the steps to build a cross-compiler and the go tool with gccgo 
   (binary named xgo here), as documented in a new wikipage I wrote: 
   http://code.google.com/p/go-wiki/wiki/GccgoCrossCompilation
2.  $ cd ~/tmp/go/src/cmd/cgo # the copy of the repo that is outside $GOROOT
    $ go build -o xcgo -compiler gccgo .
    $ ln -s xcgo cgo
    $ export PATH="$(pwd):$PATH"
3. Save simple program using C to disk: http://play.golang.org/p/smQwaB0dfG
4.  $ CGO_ENABLED=1 GOARCH=mips xgo build -x -compiler gccgo goctest
    WORK=/tmp/go-build946830148
    mkdir -p $WORK/goctest/_obj/
    mkdir -p $WORK/goctest/_obj/exe/
    cd /home/erikw/dev/go/src/goctest
    /home/erikw/src/go/pkg/tool/linux_amd64/cgo -objdir $WORK/goctest/_obj/ -gccgo -- -I $WORK/goctest/_obj/ goc.go
    # goctest
    unknown ptrSize for $GOARCH "mips"

What is the expected output?
    No errors from cgo, as cgo is compiled with gccgo.


What do you see instead?
    A compiled program with cgo generating .[ch]-files as is done when using a 
    gc-supported $GOARCH.


Which operating system are you using?
    Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64 GNU/Linux

Which version are you using?  (run 'go version' or 'gccgo --version')
    go version devel +7f2863716967 Tue Feb 18 16:48:34 2014 +1100 linux/amd64
    gccgo (GCC) 4.9.0 20131127 (experimental)

Please provide any additional information below.
    Discussion leading up to this issue can be found at
    "[golang-nuts] Simplification of MIPS cross-compilation?" 
    https://groups.google.com/forum/#!topic/golang-nuts/PgyS2yoO2jM

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions