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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rasky opened this issue Nov 27, 2017 · 80 comments
Open

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

rasky opened this issue Nov 27, 2017 · 80 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. FeatureRequest
Milestone

Comments

@rasky
Copy link
Member

rasky commented Nov 27, 2017

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

@ALTree ALTree changed the title gc: Implement powerpc 32-bit backend (ppc32) cmd/compile: implement powerpc 32-bit backend (ppc32) Nov 27, 2017
@bradfitz bradfitz added this to the Unplanned milestone Nov 27, 2017
@villadalmine
Copy link

any update 驴?

@ianlancetaylor
Copy link
Contributor

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
Copy link

I want to help to work with g4/g5

@awilfox
Copy link

awilfox commented May 25, 2018

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
Copy link

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

@DarkDirectX
Copy link

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
Copy link

awilfox commented Jun 15, 2018

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
Copy link

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

@travislikestocode
Copy link

travislikestocode commented Jun 21, 2018

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

@Vartkat
Copy link

Vartkat commented Jul 13, 2018

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

@awilfox
Copy link

awilfox commented Jul 14, 2018

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
Copy link

Interested by PPC32 here for "qoriq" Synology architectures

@Millnert
Copy link

Millnert commented Oct 1, 2018

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
Copy link

Millnert commented Oct 1, 2018

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:

  • that ppc32-based builders are provided
  • that someone gifts the work to the project of enabling support for the arch

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
Copy link

villadalmine commented Oct 1, 2018

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

@ianlancetaylor
Copy link
Contributor

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
Copy link

awilfox commented Oct 1, 2018

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
Copy link

Millnert commented Oct 3, 2018

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
Copy link
Contributor

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
Copy link

awilfox commented Oct 4, 2018

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
Copy link

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

publicarray added a commit to publicarray/spksrc that referenced this issue Nov 18, 2018
publicarray added a commit to publicarray/spksrc that referenced this issue Nov 18, 2018
Synology has no PPC64 devices and Go has no ppc32 support golang/go#22885
ymartin59 pushed a commit to SynoCommunity/spksrc that referenced this issue Dec 1, 2018
* Fix script having 0 bytes after wget failes to get an IP

Use the cached file to fix the 0 byte file on upgrade
Can also be upgraded in the future

* Address issues raised

#3501 (comment)

* Disable online checks after saving file and reduce netprobe_timeout

* This decreases the boot time when offline (e.g setting up a new network)

* Should also reduce long service status updates in the package center.

Also allow the user to change the logfile location and the ability to disable it

* PPC is unsupported #1011 (comment)
and Go has no ppc32 support: golang/go#22885

* dnscrypt-proxy 2.0.19
@hgy59
Copy link

hgy59 commented Dec 31, 2018

Interested by PPC32 for "ppc853x" Synology architectures

@iains
Copy link

iains commented Nov 22, 2023

the right place to look at gccgo is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986 - AFAIR the compiler, itself, builds but we do not have complete runtime support. It is, sadly, quite far down my list of priorities.

@ErinVoid
Copy link

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

For my application; it was for Synology rather than a Mac

@barracuda156
Copy link

For my application; it was for Synology rather than a Mac

Didn鈥檛 know Synology uses ppc. Anyway, to a certain extent implementation for MacOS and Linux will be overlapping, though the former gonna require more, for obvious reasons.

@catap
Copy link

catap commented Nov 22, 2023

Didn鈥檛 know Synology uses ppc.

It had, but migrated to Intel a few years ago.

@programmingkidx
Copy link

Maybe implementing a Darwin-PowerPC backend could be a Google Summer of Code project.

@barracuda156
Copy link

the right place to look at gccgo is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986 - AFAIR the compiler, itself, builds but we do not have complete runtime support. It is, sadly, quite far down my list of priorities.

@iains Do you know if that will be sufficient to bootstrap Go itself via gccgo?

That was used on AIX, apparently:

We are porting golang to AIX.
We used our port of GCC 8.1 Go to AIX for bootstrapping and we used the work done by IBM Linux/Power about the Go assembler for PPC64 machines.
So, you need a Go compiler for bootstrapping. Either GCC Go, or an old golang written in C (v1.4 if I'm correct).

@iains
Copy link

iains commented Feb 10, 2024

the right place to look at gccgo is https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986 - AFAIR the compiler, itself, builds but we do not have complete runtime support. It is, sadly, quite far down my list of priorities.

@iains Do you know if that will be sufficient to bootstrap Go itself via gccgo?

Sorry, I have no idea - stretched way too thin at the moment - I have not tried go since maybe GCC-7 ..
.. but I would be surprised if the compiler could build something without its runtime?

That was used on AIX, apparently:

We are porting golang to AIX.
We used our port of GCC 8.1 Go to AIX for bootstrapping and we used the work done by IBM Linux/Power about the Go assembler for PPC64 machines.
So, you need a Go compiler for bootstrapping. Either GCC Go, or an old golang written in C (v1.4 if I'm correct).

@ericlagergren
Copy link
Contributor

ericlagergren commented Feb 10, 2024

fyi, gccgo does work for non-Darwin ppc32. I鈥檝e only tested a fork of gccgo that targeted VxWorks, however.

@barracuda156
Copy link

fyi, gccgo does work for non-Darwin ppc32. I鈥檝e only tested a fork of gccgo that targeted VxWorks, however.

@ericlagergren So it is not in GCC upstream, you mean? Could you please refer to the fork in question? (This won鈥檚 be sufficient for macOS, but it may be helpful.)

@ericlagergren
Copy link
Contributor

fyi, gccgo does work for non-Darwin ppc32. I鈥檝e only tested a fork of gccgo that targeted VxWorks, however.

@ericlagergren So it is not in GCC upstream, you mean? Could you please refer to the fork in question? (This won鈥檚 be sufficient for macOS, but it may be helpful.)

Correct. The isn't currently public, sorry. Most of the work was adding or working around APIs that don't exist on VxWorks 6. For example, VxWorks 6 doesn't have pread/pwrite or getcontext/setcontext. I also had to implement the atomic APIs, too.

I'll post on this thread if/when we (my work) ever release the source code.

@barracuda156
Copy link

fyi, gccgo does work for non-Darwin ppc32. I鈥檝e only tested a fork of gccgo that targeted VxWorks, however.

@ericlagergren So it is not in GCC upstream, you mean? Could you please refer to the fork in question? (This won鈥檚 be sufficient for macOS, but it may be helpful.)

Correct. The isn't currently public, sorry. Most of the work was adding or working around APIs that don't exist on VxWorks 6. For example, VxWorks 6 doesn't have pread/pwrite or getcontext/setcontext. I also had to implement the atomic APIs, too.

I'll post on this thread if/when we (my work) ever release the source code.

@ericlagergren Got it, thank you.

On a side note, did you work only on gccgo or some other components of GCC? I think IEEE arithmetic fix for gfortran on VxWorks, for example, while been discussed in gcc mailing list time ago, had never been merged.

@iains
Copy link

iains commented Feb 11, 2024

I think Ian was pretty clear about what areas needed work for Darwin (not just PowerPC - but all Darwin). Big Endian powerpc64-linux (with a 32b multilib) also has working go/libgo - so there is another example to work from.

@ericlagergren
Copy link
Contributor

fyi, gccgo does work for non-Darwin ppc32. I鈥檝e only tested a fork of gccgo that targeted VxWorks, however.

@ericlagergren So it is not in GCC upstream, you mean? Could you please refer to the fork in question? (This won鈥檚 be sufficient for macOS, but it may be helpful.)

Correct. The isn't currently public, sorry. Most of the work was adding or working around APIs that don't exist on VxWorks 6. For example, VxWorks 6 doesn't have pread/pwrite or getcontext/setcontext. I also had to implement the atomic APIs, too.

I'll post on this thread if/when we (my work) ever release the source code.

@ericlagergren Got it, thank you.

On a side note, did you work only on gccgo or some other components of GCC? I think IEEE arithmetic fix for gfortran on VxWorks, for example, while been discussed in gcc mailing list time ago, had never been merged.

Only gccgo and libbacktrace. We actually didn't need libbacktrace, but it was easier to get it to compile than it was to make gccgo not use it. We enabled software floats for some reason, I don't remember why. We were targeting an e500 core btw.

@techflashYT
Copy link

Just checked back here, so essentially, yall are saying that if 1.4 could build, modern Go could be bootstrapped for PPC? I'm specifically concerned about PPC32 Linux here, I don't have Mac hardware to test this on.

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.

I would be willing to chuck some hours at this if there's a chance it could acutally get up-to-date Go working on PowerPC Linux (primarily, my target is the PPC750CL in the Nintendo Wii, as I am one of the lead developers of the Wii-Linux project, but I'll try to get it working for all 32-bit PPC regardless).

If I were to get 1.4 building properly, someone else would need to figure out how to use it to get modern Go boostrapping with it, as I don't have unlimited time unfortunately.

I'll post an update here if I'm successful.

@awilfox
Copy link

awilfox commented Mar 20, 2024

I would say that, since gcc-go already works on PPC32, you don't have to start with 1.4. Adding support to mainline Go could probably be in anything that gcc-go could bootstrap.

@randall77
Copy link
Contributor

I don't entirely understand the bootstrapping issue. Just build a recent Go on amd64/linux and cross-compile a toolchain from there. There's no need to bootstrap completely from ancient Go versions on the platform itself.
Gory details: https://go.dev/blog/rebuild

@rollcat
Copy link

rollcat commented Mar 20, 2024

Just build a recent Go on amd64/linux and cross-compile a toolchain from there.

Some platforms (OpenBSD/macppc comes to mind) might want to bootstrap the whole thing from the base system without cross-compiling, but I agree, that's probably the easiest way.

@phaus
Copy link

phaus commented Mar 20, 2024

So that sounds that it might be possible to have a Go Version for darwin/ppc32 and darwin/ppc64 right now?

@awilfox
Copy link

awilfox commented Mar 20, 2024

So that sounds that it might be possible to have a Go Version for darwin/ppc32 and darwin/ppc64 right now?

Unfortunately I don't believe gcc-go supports the Mac OS, at least not versions of that age. It does however support Linux on these systems.

Mainline Go should work on G5 machines running Linux, too, but doesn't because of #19074. I still believe this was a mistake to merge, it still impedes my work on G5s and Power6/Power7 systems (including trying to make Docker run on them), and it still makes me frustrated, but what are you going to do鈥

@yhaenggi
Copy link

Mainline Go dosnt work on G5 since (Go 1.9) quite some time...

@barracuda156
Copy link

So that sounds that it might be possible to have a Go Version for darwin/ppc32 and darwin/ppc64 right now?

Well, in practice current versions of Go will not build even on Intel, and somewhat earlier versions which can be built do not work :(
This is quite unfortunate, given that this is a useful compiler and it would not take much to maintain fallbacks for older systems, but that was not done. The last ppc-capable system is 10.6, and Go does not build there.

I have fixed Go 1.11.13 for 10.6 i386 in macports/macports-ports@0435fe5 鈥 however when I tried to build a few dependents, it is either too old or just does not work.
It is also broken on x86_64 for older macOS.

Unfortunately I don't believe gcc-go supports the Mac OS, at least not versions of that age.

It does not work on any macOS, as of now: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46986

@awilfox
Copy link

awilfox commented Mar 20, 2024

The last ppc-capable system is 10.6, and Go does not build there.

This is not accurate. The last PPC capable system is 10.5 (Leopard). There are some beta builds of 10.6 for PPC, but no released version. There is a community effort called Sorbet Leopard to make more bits of it work, but I wouldn't call it official at all. If you want real Darwin PPC support, you'd need to support 10.5 at least. Note also that many systems were dropped with 10.5, including all G3 and a wide swath of G4, so you really would want to target 10.4 for maximal compatibility.

@barracuda156
Copy link

Mainline Go dosnt work on G5 since (Go 1.9) quite some time...

@yhaenggi Do you know whether it was a policy to break it or just accidental breakage? macOS aside, OpenBSD/FreeBSD/NetBSD support PowerPC systems back to G4, and it would be nice to have Go working there.

@awilfox
Copy link

awilfox commented Mar 20, 2024

Mainline Go dosnt work on G5 since (Go 1.9) quite some time...

@yhaenggi Do you know whether it was a policy to break it or just accidental breakage? macOS aside, OpenBSD/FreeBSD/NetBSD support PowerPC systems back to G4, and it would be nice to have Go working there.

As I linked above, #19074 made it policy, but it's one I would be willing to help overturn if such a thing exists in the Go community. I would be more than happy to put the work in to make it work on down level ISA versions again, provide CI, and whatever else needed.

@barracuda156
Copy link

The last ppc-capable system is 10.6, and Go does not build there.

This is not accurate. The last PPC capable system is 10.5 (Leopard). There are some beta builds of 10.6 for PPC, but no released version.

@awilfox Well, first of all 10.6.8 is ppc-capable. It does not boot on PowerPC, but it can build and run ppc binaries.

Then, here is 10.6 on PowerPC, running natively:

snow_leopard_ppc

There is a community effort called Sorbet Leopard to make more bits of it work, but I wouldn't call it official at all.

That is just 10.5.8 with a few tweaks, not on a system level. For all practical purposes it is 10.5.8.

If you want real Darwin PPC support, you'd need to support 10.5 at least. Note also that many systems were dropped with 10.5, including all G3 and a wide swath of G4, so you really would want to target 10.4 for maximal compatibility.

Aside from some archaic G4, later ones run 10.5 and 10.6 with no issues. I do not think it is a realistic concern to support G3 and super-old G4, they are too slow for anything.
10.4 is a problematic system with much of stuff broken. It is very different from 10.5鈥10.6.

@awilfox
Copy link

awilfox commented Mar 20, 2024

@awilfox Well, first of all 10.6.8 is ppc-capable. It does not boot on PowerPC, but it can build and run ppc binaries.

Building PPC binaries is not that big of a deal; you can do that on any Mac running Big Sur or earlier with Xcode 12 and XcodeLegacy.

Then, here is 10.6 on PowerPC, running natively:

This is 10A190, which is a beta build. Yes, you can get it to work, but it is not entirely stable and has bugs that are even fixed in 10.5.8 (10.5.8 is newer than 10.6 final, let alone a WWDC build). I just don't think 10.6/ppc is a useful target for a compiler. You would literally be having users install a private beta OS that was never meant for public consumption.

If you want real Darwin PPC support, you'd need to support 10.5 at least. Note also that many systems were dropped with 10.5, including all G3 and a wide swath of G4, so you really would want to target 10.4 for maximal compatibility.

Aside from some archaic G4, later ones run 10.5 and 10.6 with no issues. I do not think it is a realistic concern to support G3 and super-old G4, they are too slow for anything. 10.4 is a problematic system with much of stuff broken. It is very different from 10.5鈥10.6.

Any G4 < 867 MHz will not run Leopard without hacks. My G3 runs gitlab-runner fine with gcc-go, and it would run it fine with mainline Go if it had a ppc32 backend. 馃し鈥嶁檧锔

10.5 is old enough that it doesn't have the *64 APIs (open64, readdir64, etc), as a single omission that comes directly to my mind. I'm not sure what APIs Go uses internally, but I'm pretty sure porting it backwards to 10.5 would be a lot more work than the work to go the bit further to make it work on 10.4 as well. I will admit I don't know that for certain.

@awilfox
Copy link

awilfox commented Mar 20, 2024

As an aside, I don't think it is particularly useful to discuss a theoretical Darwin port for ppc32. It will be hard enough convincing upstream to accept ppc32 at all, so can we at least focus on operating systems that have existed in the last decade as a bare minimum to even see if this is viable?

@cellularmitosis
Copy link

cellularmitosis commented Mar 20, 2024 via email

@barracuda156
Copy link

I don't think it is particularly useful to discuss a theoretical Darwin port for ppc32

@awilfox While ppc ABI of Darwin is not identical to BSD or Linux, it is perhaps a secondary problem, which we could realistically deal with on our end, provided some ppc works and provided x86 Go works on 10.6. (10.5 is not hugely different; perhaps one issue which will matter is a lack of GCD, so mach semaphores are to be used instead.)

@iains
Copy link

iains commented Mar 21, 2024

For my 0.02GBP (noting that I will keep testing/supporting ppc 10.5 until the hardware is no longer working)

  • Actually, I would expect that most of the work would be in supporting Darwin (generically) and Mach-O (generically).

  • Certainly, there is some run-time architecture-specific stuff applicable to each language (but even then, I often find that 10.5 i686 has similar constraints to 10.5 ppc).

  • If you have a faster machine with a more modern version of the OS, it can be quite a bit quicker to work on that and then back port to the earlier OS (I tend to use Darwin17 [because it supports 32b] on an oldish but still quite capable xeon box)

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. FeatureRequest
Projects
None yet
Development

No branches or pull requests