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

x/sys/unix: Does not build on mipsel/mips64el/alpha/powerpc with gccgo #18031

Open
NightTsarina opened this issue Nov 23, 2016 · 11 comments
Open
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@NightTsarina
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

  • go version go1.6.1 gccgo (Debian 6.2.1-4) 6.2.1 20161119 linux/mipsn64
  • go version go1.6.1 gccgo (Debian 6.2.1-4) 6.2.1 20161119 linux/mipso32

Same for alpha and powerpc (the 4 arches use gccgo in Debian).

What operating system and processor architecture are you using (go env)?

GOARCH="mipsn64"
GOHOSTARCH="mipsn64"
GOHOSTOS="linux"
GOOS="linux"

What did you do?

$ go build golang.org/x/sys/unix
# golang.org/x/sys/unix
obj-mips64el-linux-gnuabi64/src/golang.org/x/sys/unix/flock.go:15:30: error: reference to undefined name 'SYS_FCNTL'
 var fcntl64Syscall uintptr = SYS_FCNTL
                              ^
obj-mips64el-linux-gnuabi64/src/golang.org/x/sys/unix/sockcmsg_linux.go:15:30: error: reference to undefined name 'SizeofUcred'
  b := make([]byte, CmsgSpace(SizeofUcred))
                              ^
obj-mips64el-linux-gnuabi64/src/golang.org/x/sys/unix/sockcmsg_linux.go:16:9: error: reference to undefined name 'Cmsghdr'
  h := (*Cmsghdr)(unsafe.Pointer(&b[0]))
         ^

(The log of errors is huge, you can see a complete build log here: https://buildd.debian.org/status/fetch.php?pkg=mtail&arch=powerpc&ver=0.0%2Bgit20161027.a7b3e3c-1&stamp=1479766693)


For mips64el, I pressume it is just a disparity of GOARCH between gccgo and gc, and possibly could be fixed by renaminng. But I don't see any support in the code for mipsel/mipso32, alpha, or powerpc (32bits)

@NightTsarina
Copy link
Author

By making mipsn64 an alias of mips64, I get this to compile (on mips64el). I also had to add Dup2 based on Dup3 (like in arm64) to get tests passing.

@bradfitz
Copy link
Contributor

Want to send a change? https://golang.org/doc/contribute.html

/cc @ianlancetaylor

@quentinmit quentinmit added the NeedsFix The path to resolution is known, but the work has not been done. label Nov 23, 2016
@quentinmit quentinmit added this to the Unreleased milestone Nov 23, 2016
@NightTsarina
Copy link
Author

@bradfitz I will try to prepare a proper patch for mips64, as it seems to work OK.

I was just trying to add support for mips, but I am finding some roadblocks, so that might take a while. Hopefully somebody who knows this will be faster than me :)

@anthonyfok
Copy link

@TheTincho: Thank you for bringing up this issue and for pioneering the solution for mips64le, which can be found in https://anonscm.debian.org/cgit/pkg-go/packages/golang-golang-x-sys.git/commit/?id=f11a3adc214152ad98e27e7896b697cfcc376959

For probably more than I year, I had been scratching my head over this, namely, Hugo failing to build on MIPS and Alpha (etc.) architectures on Debian buildd (see https://buildd.debian.org/status/package.php?p=hugo&suite=sid). Your solution opened my eyes!

A few things happened since you visited the issue in November 2016:

And it turns out that gccgo reports the same GOARCH of mipso32 on both mips and mipsel/mipsle, and mipsn64 on both mips64 and mips64el/mips64le, i.e., it seems that we cannot currently determine the endianness from GOARCH or GOHOSTARCH reported by gccgo! That perplexes me.

Anyhow, expanding on @TheTincho's idea, I came up with something like this:

    cd $GOPATH/src/golang.org/x/sys/unix/
    for i in errors syscall sysnum types; do
        cp -a z${i}_linux_mips.go z${i}_linux_mips_mipso32.go
        cp -a z${i}_linux_mipsle.go z${i}_linux_mipsle_mipso32.go
        cp -a z${i}_linux_mips64.go z${i}_linux_mips64_mipsn64.go
        cp -a z${i}_linux_mips64le.go z${i}_linux_mips64le_mipsn64.go
    done

to make sure gccgo can see these files, and then run gccgo (e.g. go build) with -tags mipsle, for example, to match the files with the correct endianness. With this, go get -v -tags mipsle github.com/gohugoio/hugo (which needs golang.org/x/sys/unix) finally works with gccgo on Debian's mipsel! Yay!

For completeness, here is what I have actually used in debian/rules for the golang-golang-x-sys package: https://anonscm.debian.org/cgit/pkg-go/packages/golang-golang-x-sys.git/commit/?id=bb8f8e16490ce03ce084c8e170ea4c9e79f53ba2

I do wonder though:

  • Is this the right solution?
  • Was it intentional that gccgo set GOARCHs like mipso32 and mipsn64 without indicating the endianness?
  • Should we modify golang.org/x/sys/unix and to add special -tags to accommodate gccgo current GOARCH values for mips* as described in the aforementioned workaround?
  • Or will gccgo returns a more specific GOARCH in future releases, such that no -tags or other "hacks" are needed?

My apologies if these questions sound silly, or have been answered elsewhere before.

Many thanks!

/cc @ianlancetaylor

@bradfitz
Copy link
Contributor

It seems like a bug that different GOARCH values are being used between gc and gccgo.

@NightTsarina
Copy link
Author

@anthonyfok Thanks for picking up this issue, I did not have any spare cycles to continue the work so far..

@bradfitz That is an issue that I have experienced a few times already with the MIPS family, having to patch sources to make gccgo work

@ianlancetaylor
Copy link
Contributor

I believe that the GOARCH values for MIPS have been harmonized on gccgo tip.

@paride
Copy link

paride commented Aug 24, 2018

This is also relevant for the sparc64 and powerpcspe architectures.

@bradfitz bradfitz modified the milestones: Unreleased, Gccgo Oct 2, 2018
@gopherbot
Copy link

Change https://golang.org/cl/262517 mentions this issue: x/sys/unix: add linux/ppc support, for use with gccgo

mirzak pushed a commit to mirzak/sys that referenced this issue Nov 9, 2020
Update scripts slightly to work with an unsupported GOARCH.

For golang/go#18031
Fixes golang/go#37443

Fixes golang/go#

Change-Id: I1a1f7b4be8bf8974b2b627331cbe93416ef21bf3
@gopherbot
Copy link

Change https://golang.org/cl/270317 mentions this issue: unix: define isBigEndian for all GOARCHes supported by gccgo

gopherbot pushed a commit to golang/sys that referenced this issue Nov 16, 2020
For golang/go#18031
For golang/go#37443

Change-Id: I49dabb362592bb61532a0c4f193919c3f2036af3
Reviewed-on: https://go-review.googlesource.com/c/sys/+/270317
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
bwh-mind added a commit to bwh-mind/golang-sys that referenced this issue Apr 21, 2021
@gopherbot
Copy link

Change https://golang.org/cl/312349 mentions this issue: unix/linux: add ppc system call definitions, for use with gccgo

gopherbot pushed a commit to golang/sys that referenced this issue Apr 21, 2021
Add system call definitions for 32-bit PowerPC (ppc).  These are
expected to be used with gccgo, as gc does not have a suitable code
generator.

These definitions are largely copied from ppc64x, with some 32-bit
specific wrappers copied from arm.

The glibc definitions of epoll_event and sockaddr_un structures need
to be overridden on ppc, similarly to some other architectures.

For golang/go#18031
Fixes golang/go#37443

Change-Id: I061ac2b8fa452dd37c2239a0b09dff2f3e9d50da
GitHub-Last-Rev: aada37a
GitHub-Pull-Request: #106
Reviewed-on: https://go-review.googlesource.com/c/sys/+/312349
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
VyattaInternal pushed a commit to danos/golang-golang-x-sys that referenced this issue Aug 13, 2021
as a continuation of the effort that Martín Ferrari started,
see golang/go#18031

Due to the current minimal code change to golang.org/x/sys/unix,
and to ensure the bool isBigEndian is set correctly, please run
gccgo with "-tags mips", "-tags mipsle" or "-tags mips64le"
as appropriate.
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsFix The path to resolution is known, but the work has not been done.
Projects
Development

No branches or pull requests

8 participants
@bradfitz @quentinmit @anthonyfok @ianlancetaylor @NightTsarina @paride @gopherbot and others