Amiga.org

Amiga computer related discussion => Amiga Software Issues and Discussion => Topic started by: adrian82 on September 29, 2019, 06:34:38 PM

Title: Looking for backers to support the funding of modernizing gcc on m68k
Post by: adrian82 on September 29, 2019, 06:34:38 PM
Hello!

As some of you may know, the latest version of gcc still supports m68k as a target architecture which is great as it means that even the latest C++ standards are supported on the original architecture of the Amiga.

However,  since the m68k backend has not received one important modernization change [1, 2], the backend is in danger to be removed from gcc.

Since we would like to continue to keep m68k as an unofficial architecture in Debian, I have created a bounty on BountySource.com so that someone with experience with gcc can work on the task and therefore help preserve m68k support for future versions of gcc.

If anyone here is interested in supporting our cause, please consider making a small donation:

> https://www.bountysource.com/issues/80706251-m68k-convert-the-backend-to-mode_cc-so-it-can-be-kept-in-future-releases

Thanks,
Adrian

> [1] https://gcc.gnu.org/wiki/CC0Transition
> [2] https://gcc.gnu.org/backends.html
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: kamelito on September 29, 2019, 07:40:47 PM
Bebbo is already improving GCC but I guess a bounty is welcome.
https://github.com/bebbo
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: TribbleSmasher on September 29, 2019, 08:22:05 PM
Is there any guarantee the responsible maintainer/coder will continue to support the changes after funding is used up?
Whatif the port for m68k is removed completely a year later? We are talking about ancient platforms here, after all.

Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: adrian82 on September 30, 2019, 10:09:51 AM
Bebbo is already improving GCC but I guess a bounty is welcome.
https://github.com/bebbo

Yes, I'm aware of his efforts and I've also been in contact with him.

However, he was mostly focused on bug fixes and not working on the cc0 transition which is mandatory if we want to keep m68k support in the future.

Adrian
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: adrian82 on September 30, 2019, 10:13:23 AM
Is there any guarantee the responsible maintainer/coder will continue to support the changes after funding is used up?

The m68k backend currently has an active maintainer [1] so he will take care of the code after it has been converted to MODE_CC. Since the conversion is a bit of a longer task (according to one of the gcc maintainers, it's about one month of work), he doesn't seem to be interested in this work at the moment.

Quote
Whatif the port for m68k is removed completely a year later? We are talking about ancient platforms here, after all.

It's very unlikely that it's being removed in the near future after the conversion has happened. I have talked to gcc upstream about the task and their requirement for keeping the port is simply the MODE_CC conversion.

Adrian

> [1] https://github.com/gcc-mirror/gcc/blob/master/MAINTAINERS#L80
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: SamuraiCrow on September 30, 2019, 02:02:30 PM
Development seems stalled on https://github.com/M680x0/M680x0-llvm (https://github.com/M680x0/M680x0-llvm) too.  It's not abandoned though.
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: kolla on September 30, 2019, 02:51:35 PM
@SamualCrow
I know of a certain team that have "reviving the 68k" on their agenda - here is probably _the_ opportunity for them.
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: adrian82 on September 30, 2019, 03:08:01 PM
Development seems stalled on https://github.com/M680x0/M680x0-llvm (https://github.com/M680x0/M680x0-llvm) too.  It's not abandoned though.

Not sure how llvm-m68k is related, but unfortunately, the project is currently in a limbo as the original developer currently doesn't have any plans to continue working on it.

He has actually invited me to the "M680x0" project and I have made some small contributions, but overall, we're currently stalled.

I think it would be a good candidate for another bounty on BountySource :).

But for the time being, it would be more important if the community could join forces to help modernize the m68k backend in gcc which is the most pressing task for free software on m68k at the moment.

Adrian
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: SamuraiCrow on September 30, 2019, 05:11:18 PM
Re:GCC vs. LLVM

Since LLVM is used for JITs and is modular enough that it might be able to break down into small enough units that it could run on a RAM expanded Amiga outright.  (Assuming it has a custom pass manager that only loads in the currently executing pass and flushes out all others.)  GCC is popular among Linux Distros, that's true, but even Mandriva uses Clang instead of GCC when possible.

@adrian82

Since you've worked with both LLVM and GCC, can you tell me if such a hand-over-hand pass manager would be possible on a recent GCC?  Also, how much more work is required to finish the LLVM backend?

Re:Bounties

Looking at the BountySource page it's got about $1300 in it for GCC already.  If we only get one shot at it though, I'd prefer Clang over GCC for the reasons I described above.
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: adrian82 on October 02, 2019, 11:42:18 AM
Re:GCC vs. LLVM

Since LLVM is used for JITs and is modular enough that it might be able to break down into small enough units that it could run on a RAM expanded Amiga outright.  (Assuming it has a custom pass manager that only loads in the currently executing pass and flushes out all others.)  GCC is popular among Linux Distros, that's true, but even Mandriva uses Clang instead of GCC when possible.

Clang is not really mature enough yet to build Debian packages and especially the kernel on all architectures. So I wouldn't be too optimistic.

Modernizing the m68k backend in gcc is currently the easier task.

Quote
Since you've worked with both LLVM and GCC, can you tell me if such a hand-over-hand pass manager would be possible on a recent GCC?

JITs are currently not our focus. gcc is gaining JIT support, but for the time being, the most important goal is to be able to use a modern C/C++ compiler on m68k.

Quote
Also, how much more work is required to finish the LLVM backend?

The TODO list can be found here: https://github.com/M680x0/M680x0-llvm/issues (https://github.com/M680x0/M680x0-llvm/issues)

Quote
Looking at the BountySource page it's got about $1300 in it for GCC already.  If we only get one shot at it though, I'd prefer Clang over GCC for the reasons I described above.

I disagree. LLVM/Clang is still much further ahead, in particular it will be very hard to upstream m68k support. For gcc, on the other hand, the only task is to convert the backend to MODE_CC in order to keep it in future versions of gcc.

Adrian
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: wawrzon on October 02, 2019, 07:27:20 PM
perhaps it would be best to start with aros set of patches to gcc and llvm/clang. these are among others meant to produce 68k code. latest supported 68k compiler backend is gcc 9.1 afair. the aros patches are meant as minimal. do not introduce optimisations absent upstream. and produce elf binaries. hunk binaries are being generated from these via elf2hunk utility.
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: slaapliedje on October 02, 2019, 10:46:06 PM
There are people in the Atari community also working on gcc improvements on m68k.  https://github.com/freemint/m68k-atari-mint-gcc
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: adrian82 on October 03, 2019, 11:48:21 AM
perhaps it would be best to start with aros set of patches to gcc and llvm/clang. these are among others meant to produce 68k code.

AROS has an out of tree LLVM backend for m68k? Where? And what patches do they have for gcc?

Quote
latest supported 68k compiler backend is gcc 9.1 afair.

The thing is. If we don't get this task finished that I started the BountySource campaign for, all projects working on m68k will be stuck with gcc-10 forever as all cc0 backends are planned to be removed for gcc-11. So, this is actually rather urgent.

Quote
the aros patches are meant as minimal. do not introduce optimisations absent upstream. and produce elf binaries. hunk binaries are being generated from these via elf2hunk utility.

This isn't about optimizations or generating HUNK binaries. This is about making sure m68k support is not killed off with gcc-11.

There are people in the Atari community also working on gcc improvements on m68k.  https://github.com/freemint/m68k-atari-mint-gcc

This is an outdated gcc tree from 2018 according to the ChangeLog file. Won't help us.

Adrian
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: kolla on October 03, 2019, 02:31:44 PM
@adrian82

I see VAX is also among the "endangered species" - is there a similar effort to keep it alive? :)
What counts as "a Free simulator"? I see m68k has "?" on that column.

( Also, perhaps a Linux/68k port of Toni Wilen's 68k CPU core tester/validator is possible?
http://eab.abime.net/showthread.php?t=98747 )
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: wawrzon on October 03, 2019, 03:19:04 PM
Quote
AROS has an out of tree LLVM backend for m68k? Where? And what patches do they have for gcc?
actually aros patches are not platform specific. afair i have once tried to compile the latest clang/llvm toolchain there is (llvm7) with aros patch for m68k but i havent went far, let alone it worked. but gcc 9.1 works.
the crosstools patches are here:
https://github.com/aros-development-team/AROS/tree/master/tools/crosstools

Quote
The thing is. If we don't get this task finished that I started the BountySource campaign for, all projects working on m68k will be stuck with gcc-10 forever as all cc0 backends are planned to be removed for gcc-11. So, this is actually rather urgent.

im not questioning your initiative, even if i cannot contribute as present.

Quote
This isn't about optimizations or generating HUNK binaries. This is about making sure m68k support is not killed off with gcc-11.

the patches i mentioned are used to adopt the compiler to the system itself, since the architecture is still supported anyway, it doesnt probably help anything to bother with amigaos or aros patches, one simply needs to work on the upstream 68k backend. sorry for a stupid proposal.
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: adrian82 on October 03, 2019, 04:55:34 PM
@adrian82

I see VAX is also among the "endangered species" - is there a similar effort to keep it alive? :)

Well, you could create one for sure. Just open a bug report on gcc and link that to BountySource. I would be willing to donate for this cause as well.

Quote
What counts as "a Free simulator"? I see m68k has "?" on that column.

I already complained in the #gcc IRC channel. They told me the list is horribly outdated. There is now qemu for m68k, for example.

Quote
( Also, perhaps a Linux/68k port of Toni Wilen's 68k CPU core tester/validator is possible?
http://eab.abime.net/showthread.php?t=98747 )

QEMU should be fine as it's used for most ports as well.

Adrian
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: adrian82 on October 03, 2019, 04:58:37 PM
Quote
AROS has an out of tree LLVM backend for m68k? Where? And what patches do they have for gcc?
actually aros patches are not platform specific. afair i have once tried to compile the latest clang/llvm toolchain there is (llvm7) with aros patch for m68k but i havent went far, let alone it worked. but gcc 9.1 works.
the crosstools patches are here:
https://github.com/aros-development-team/AROS/tree/master/tools/crosstools

Those patches just add "AROS" as a valid operating system to clang. They don't actually add m68k support to LLVM which is a much more involved task.

Quote
Quote
This isn't about optimizations or generating HUNK binaries. This is about making sure m68k support is not killed off with gcc-11.

the patches i mentioned are used to adopt the compiler to the system itself, since the architecture is still supported anyway, it doesnt probably help anything to bother with amigaos or aros patches, one simply needs to work on the upstream 68k backend. sorry for a stupid proposal.

Yes, the patches are merely adding "AROS" as a valid operating system. This does not change the fact that LLVM does not know how to generate code for m68k. Therefore the LLVM port for m68k mentioned earlier in this thread exists and will also need support from the community as well.

PS: We're at $2.575 now ;).

Adrian
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: kolla on October 03, 2019, 07:33:28 PM
Quote
( Also, perhaps a Linux/68k port of Toni Wilen's 68k CPU core tester/validator is possible?
http://eab.abime.net/showthread.php?t=98747 )
QEMU should be fine as it's used for most ports as well.

Yes, I understand that. The link is about software to test for example the Qemu 68k emulation, find missing or misbehaving instructions etc. if I understand things right.
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: adrian82 on October 27, 2019, 02:27:07 PM
For anyone interested, I have created a guide now how to install Debian/m68k inside qemu-system-m68k: https://wiki.debian.org/M68k/QemuSystemM68k

And our Bountysource campaign is at $5000 now!
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: adrian82 on November 13, 2019, 10:31:59 PM
Hi!

The first set of patches has now been submitted by a long-time GCC developer:

https://gcc.gnu.org/ml/gcc-patches/2019-11/msg01028.html [0/4]
https://gcc.gnu.org/ml/gcc-patches/2019-11/msg01029.html [1/4]
https://gcc.gnu.org/ml/gcc-patches/2019-11/msg01030.html [2/4]
https://gcc.gnu.org/ml/gcc-patches/2019-11/msg01031.html [3/4]
https://gcc.gnu.org/ml/gcc-patches/2019-11/msg01032.html [4/4]

The task will be finished once the patches have been merged by GCC upstream which I assume will happen within the next one or two weeks.

So, GCC on m68k will continue to be available beyond GCC-10 :).

Adrian
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: kolla on November 14, 2019, 05:17:15 AM
Very nice! :)
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: adrian82 on November 25, 2019, 01:17:02 PM
Hi!

The task has been completed successfully and all changes have been committed to the gcc SVN repository.

Anyone who has backed the BountySource campaign should now click "Accept" to accept the claim.

Adrian
Title: Re: Looking for backers to support the funding of modernizing gcc on m68k
Post by: kolla on November 25, 2019, 01:28:15 PM
Excellent!!