golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.96k stars 17.66k forks source link

cmd/compile: implement powerpc 32-bit backend (ppc32) #22885

Open rasky opened 6 years ago

rasky commented 6 years ago

Tracking bug for missing PowerPC 32-bit backend. People interested in this can put a 👍 reaction here so that we can track interest.

villadalmine commented 6 years ago

any update ¿?

ianlancetaylor commented 6 years ago

Updates will be posted here. There are no updates. I only see ten thumbs-up which is not really very many, though of course if someone volunteers to do the work and maintain a builder we will accept the port.

villadalmine commented 6 years ago

I want to help to work with g4/g5

awilfox commented 6 years ago

32-bit PowerPC would be the 4xx, 6xx, 7xx (G3, Broadway/Wii, etc), and 74xx (G4), in addition to a few others.

The G5 is a POWER4+-based 64-bit PowerPC, which was supported until Go 1.9: see #19074 for more.

We at Adélie have a ppc32 builder that could potentially be used for CI if this went anywhere.

villadalmine commented 6 years ago

any update about go with 32 bit for g4/g3 ?

DarkDirectX commented 6 years ago

I'm interested in create backend for ppc32, but currently I only have POWER8. I need to try build and run ppc32 binaries on my machine.

awilfox commented 6 years ago

Linux installs on 64-bit PowerPC can do 32-bit chroots. You can set up a distro that supports ppc32, like Adélie or Debian, into a chroot and work with it there.

I don't know if you can cross-endian chroot; I think you will need to be using big-endian PowerPC on the host.

villadalmine commented 6 years ago

I want to work with go in openbsd with powerpc g3/g4.

travislikestocode commented 6 years ago

I'm interested in ppc32 in order to use prometheus node_exporter on a Dell/Cumulus switch

Vartkat commented 6 years ago

I'm interested in order to build restic backup on a MacMini PPC 7450.

awilfox commented 6 years ago

I'll make a note that if you're using Linux and glibc, gcc-go works fine on PPC32. It does not yet work properly on musl, but I'm investigating that. This way we have a platform to bootstrap golang with, if there is ever such a backend.

ymartin59 commented 6 years ago

Interested by PPC32 here for "qoriq" Synology architectures

Millnert commented 6 years ago

Also interested in this for deployment of Go code, including but not limited to Prometheus node_exporter & blackbox_exporter on PPC32-based network switches.

Millnert commented 6 years ago

Updates will be posted here. There are no updates. I only see ten thumbs-up which is not really very many, though of course if someone volunteers to do the work and maintain a builder we will accept the port.

@ianlancetaylor Having read up on #19074 and #24358, and fumbling slightly in the dark here except for knowing that I'd definitely would like to be able to build go apps for ppc32, it seems based on your comment alone that all that is required in order to enable this support is:

But given those two referenced tickets, is there opposition within the go community against having ppc32 supported? ppc32 runs on millions of devices, not only Wii's but various network devices with either Linux or BSD. I believe the use case me and @travbrack lists could see see significant adoption (for some value of significant).

If those two items are the "only" things required, perhaps I'd be interested in helping out. I can definitely provide a few linux & bsd-builders, but I would absolutely need help with the second point.

villadalmine commented 6 years ago

I can help testing with openbsd in ppc32 and 64 . (macppc , old powerpc apple)

ianlancetaylor commented 6 years ago

Yes, having a builder and doing the work are all that is required. But maybe I should use scare quotes around "all" because the work is not trivial.

I can't think of any reason why anybody would be opposed to adding ppc32 support to Go. It seems like a good idea to me.

awilfox commented 6 years ago

I'll note again here that any ppc64 (big endian) host can function as a ppc32 builder with a simple chroot. That's what we're doing at Adélie to take advantage of the build speed of POWER9 hardware. You'll just have to be careful to not use any newer ISA instructions, since ppc32 goes back to at least the 700. (Not sure if the 4xx and 6xx would be supported by Go. Very popular in embedded still.)

Millnert commented 6 years ago

The devices I'm looking at, I believe have 7xx, and it is exactly the fear (due to my ignorance) of accidentally using too new instruction sets that made me believe some Wii or similar would be an apt 7xx builder. But with less ignorance I guess newer hardware can be used as you say @awilfox. Regardless, I googled Wii variants and it seems definitely tractable to solve this even in that way.

The big unknown for me is: where to even start looking at the scope of adding an arch to "cmd/compiler". @ianlancetaylor is non-trivial order of 100 hours, 1000 hours or more?

ianlancetaylor commented 6 years ago

The length of time it takes is very hard to say, since it depends on how much you know about compilers already and how well you understand the PPC/PPC64 architecture. Adding PPC32 support should be much simpler than supporting a new architecture from scratch, since it will be very similar to the existing PPC64 support. The length of time is not really in doing the actual work; it is in understanding what has to be done.

awilfox commented 6 years ago

I'm not sure exactly how to set it up to be usable in this role, but I have an iBook G3 with a PPC750 running Adélie Linux that I could probably be convinced to turn in to a builder. (Or, I could simply smoketest on it when asked.)

asarghel commented 6 years ago

Hi everybody. I can help with testing in PowerMac dual G5, iMac G4 & PowerBook G4, all with Ubuntu 16.04.5:

~$ uname -a
Linux nice 4.4.0-137-powerpc64-smp #163-Ubuntu SMP Mon Sep 24 13:53:31 UTC 2018 ppc64 ppc64 ppc64 GNU/Linux

~$ cat /etc/issue
Ubuntu 16.04.5 LTS

~$ sudo apt show golang
[sudo] password for remote: 
Package: golang
Version: 2:1.6-1ubuntu4
Priority: optional
Section: devel
Source: golang-defaults
Origin: Ubuntu
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Bugs: https://bugs.launchpad.net/ubuntu/+filebug
Installed-Size: 10.2 kB
Depends: golang-1.6, golang-doc (>= 2:1.6-1ubuntu4), golang-go (>= 2:1.6-1ubuntu4), golang-src (>= 2:1.6-1ubuntu4)
Homepage: https://golang.org
Download-Size: 2,766 B
APT-Sources: http://ports.ubuntu.com/ubuntu-ports xenial/main powerpc Packages
hgy59 commented 5 years ago

Interested by PPC32 for "ppc853x" Synology architectures

magiconair commented 5 years ago

Cisco IE4000 supports running Docker containers but the platform is ppc32, AFAICT.

nununo commented 5 years ago

I own a Synology DS413 (https://en.wikichip.org/wiki/freescale/qoriq/p1022) so I would also love to be able to cross compile to POWER. Thanks!

ErinVoid commented 4 years ago

I own a Synology DS213+ and would like to run Syncthing but that requires ppc32 support. Thanks in advance.

moooofly commented 4 years ago

I want to run beats/filebeat in a ppc32 machine, but can not compile it now.

phaus commented 4 years ago

I have a mac mini G4 here. Running with MacOS 10.5.8 - I can test builds :-)

cellularmitosis commented 4 years ago

Running an eMac. Happy to help with testing!

HadetTheUndying commented 4 years ago

I've got a Powerbook G4 and Blue & White iMac G3 both running Void Linux i can help test with.

paleozogt commented 4 years ago

I also have access to some ppc32 hardware.

cellularmitosis commented 4 years ago

Quoting this super useful post from Aram Hăvărneanu from https://groups.google.com/d/msg/golang-dev/SRUK7yJVA0c/JeoCRMwzBwAJ

"I've done many ports now, so the strategy I use is this (very simplified):

1. Add GOOS/GOARCH support to the toolchain

2. Add some support for GOARCH in cmd/internal/obj
3. Add some support for GOARCH in cmd/asm
4. Add some support for GOOS/GOARCH in cmd/link

5. Iterate through 2-3-4 until you can produse some kind
   of binaries from assembly files. Depending on the specifics
   of GOOS/GOARCH you might, or might not need to use external
   linking.

6. Once you can produce binaries, thoroughly test them (link
   just assembly programs, without runtime). Basically make
   sure the low-level toolchain works.

7. Start working on the Go compiler for GOARCH.

8. Write a minimal alternative runtime for Go. The runtime
   is much too complicated as a first test Go program. Basically
   write your own runtime in assembly that is just stubbed
   out, but can run a good bulk of the programs in go/test.

9. Once that works well enough, start using the real runtime.
   This requires implementing a lot of assembly, but you can
   use the lessons learned from #8.

10. Make all the tests in go/test work.
11. Make all the stdlib tests work. You are still working
    amd64 now, and executing on GOARCH with go_GOOS_GOARCH_exec.

12. Run bootstrap.bash

13. Move over the artifacts on GOOS/GOARCH machine.

14. Make sure make.bash works. You will still likely have
    to fix problems to make this N-generation compiler work.

15. Make sure all.bash works.

16. Done.

As you can see, steps 1-14 are done on amd64 (or some other supported platform), and only step 15 is done on the target architecture.

-- Aram Hăvărneanu"

Hurricos commented 4 years ago

I'm hoping to get OpenWrt support on powerpc_8540 and powerpc_464fp, including devices which tend to have a ton of ram and storage -- and tons of backup / storage utilities are written in Go.

Hurricos commented 4 years ago

An addendum for all here:

If you really need something written in Go compiled for your machine, use gccgo. That's probably the fastest way to get it done without heavy ISA-specific knowledge.

It appears there has been success in using gccgo to build Docker on the 440fpu architecture: https://www.mail-archive.com/search?l=golang-nuts@googlegroups.com&q=subject:%22Re%5C%3A+%5C%5Bgo%5C-nuts%5C%5D+Port+to+powerpc+440fpu%22&o=newest

Hurricos commented 3 years ago

While it does not fall under the scope of the original issue, it looks like ppc32 gccgo is going OK on the go-nuts mailing list for building Docker.

Hurricos commented 3 years ago

... more information here about how they are going about developing and debugging gccgo compilation on ppc32: https://www.mail-archive.com/golang-nuts@googlegroups.com/msg39718.html

fillsa commented 3 years ago

Хотя это не подпадает под объем исходной проблемы, похоже, что ppc32 gccgo находится в хорошем списке рассылки по сборке Docker .

I do not know how much this is appropriate, I also had access to powerpc machines, on which I installed ubuntu linux and successfully built Docker 1.10.3, and as you know, docker is written in go. And everything works successfully. getconf shows my architecture as 32bit. fill@COD-1:/$ getconf LONG_BIT 32

barracuda156 commented 2 years ago

Any updates for PowerPC Darwin?

barracuda156 commented 2 years ago

32-bit PowerPC would be the 4xx, 6xx, 7xx (G3, Broadway/Wii, etc), and 74xx (G4), in addition to a few others. The G5 is a POWER4+-based 64-bit PowerPC, which was supported until Go 1.9: see #19074 for more.

@awilfox @glaubitz Was it running on Mac OS PPC?

glaubitz commented 2 years ago

32-bit PowerPC would be the 4xx, 6xx, 7xx (G3, Broadway/Wii, etc), and 74xx (G4), in addition to a few others. The G5 is a POWER4+-based 64-bit PowerPC, which was supported until Go 1.9: see #19074 for more.

@awilfox @glaubitz Was it running on Mac OS PPC?

No, that was Linux. I'm maintaining Debian for 32-bit PowerPC and 64-bit PowerPC (both big-endian).

Didn't know there was someone working on a 32-bit PowerPC port. I assume this could share a lot of code from the 64-bit PowerPC port but I don't have much hope that Google is accepting support for older hardware. :(

barracuda156 commented 2 years ago

No, that was Linux. I'm maintaining Debian for 32-bit PowerPC and 64-bit PowerPC (both big-endian).

Didn't know there was someone working on a 32-bit PowerPC port. I assume this could share a lot of code from the 64-bit PowerPC port but I don't have much hope that Google is accepting support for older hardware. :(

@glaubitz Do you have an idea what will be needed to add powerpc-apple-darwin support? Given hardware is supported, should be possible, I guess.

P. S. @catap Tagging you just to keep updated.

barracuda156 commented 2 years ago

@glaubitz Sorry to bother again, do you have a ppc32 version working on Debian? I went to look into your repo, and it seems that ppc32 is either missing or I need to pick some other branch: https://github.com/glaubitz/go/tree/master/src/cmd/asm/internal/arch (only ppc64 here)

programmingkidx commented 2 years ago

Has anyone made gccgo work on PowerPC Mac OS yet?

barracuda156 commented 2 years ago

@programmingkidx I would also like to know that.

@iains Could you please say if gccgo works on PPC?

glaubitz commented 2 years ago

@glaubitz Sorry to bother again, do you have a ppc32 version working on Debian? I went to look into your repo, and it seems that ppc32 is either missing or I need to pick some other branch: https://github.com/glaubitz/go/tree/master/src/cmd/asm/internal/arch (only ppc64 here)

I haven't worked on the code for a long time since gccgo works reasonably well with gcc-12 and builds most packages these days.

iains commented 2 years ago

@programmingkidx I would also like to know that.

@iains Could you please say if gccgo works on PPC?

gccgo does not work on any version of OSX or macOS : https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

(we just do not have sufficient developer resources to cover everything - actually even the basics can be a stretch at times).

glaubitz commented 2 years ago

(we just do not have sufficient developer resources to cover everything - actually even the basics can be a stretch at times).

We have the same problem in Debian. What I have done successfully in the past was to create a Bountysource campaign to get these tasks completed.

For example, we raised money to convert the AVR, M68K and VAX backends in GCC to MODE_CC and also to add an M68K backend to LLVM.

barracuda156 commented 2 years ago

@iains Got it, thank you very much! (Yes, resources problem is totally understandable.)

techflashYT commented 11 months ago

Are there any updates to this? I too would greatly appreciate being able to run go apps (specifically syncthing) on 32-bit PowerPC...

iains commented 11 months ago

no change, we are totally resource-limited and AFAIK there has been no new work done on supporting go on Darwin/macOS.

barracuda156 commented 11 months ago

Are there any updates to this? I too would greatly appreciate being able to run go apps (specifically syncthing) on 32-bit PowerPC...

AFAIK, Iain is right: unfortunately, no news here. For go as such, building anything requires a bootstrap compiler, and 1.4 (the last one to bootstrap from C) lacks support for ppc: not just in a build system (which would be an easy fix) but also in sources; fixing the latter requires writing some stuff from scratch. And well, while that may be feasible, nobody has time.

Fixing gccgo has a similar problem, and though there it is broken not just for ppc but across all archs, no one so far had time to fix it.

@catap Kirill, what do you think, how realistic is that? If you could take a look at i386, I guess I could take care of ppc-specific part, and maybe @iains could help us with some advice on specific issues.