Port-m68k archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Summary on what's blocking full Rust support on m68k



Hello,

here is a quick summary of what needs to be done to get a working Rust compiler for m68k
on Linux. Most of the changes apply to NetBSD as well, except for the alignment issues as
NetBSD is already using a 32-bit alignment on m68k by default.

Speaking of which, the default 16-bit alignment on Linux on m68k is still one of the biggest
blockers for Rust on m68k on Linux and it's also what currently prevents many other packages
from being built on Debian unstable on m68k [1][2].

Since switching the default alignment to 32 bits would break the kernel ABI, it has been
proposed to make the kernel ABI alignment-agnostic first [3]. This would allow the kernel
to be built with either alignment without breaking the alignment. An initial patch series
was proposed by Arnd Bergmann.

Once the alignment issue has been sorted out, the next issue to address is the lack of the
M68k backend in LLVM to handle 32-bit offsets for variables and jumps [4]. Currently, the
backend will always generate 16-bit offsets which is not enough to compile all Rust code,
although some Rust code compiles also with 16-bit offsets.

I have created a rough patch to add support for 32-bit offsets with the help of Gemini but
the patch has multiple problems as outlined in the GitHub issue in [4]. One of the problems
is that it creates the 32-bit offsets in an inefficient way as if the target was a ColdFire
CPU. However, the original 680x0 CPUs can actually use more efficient code to address 32-bit
variables and jumps. The inefficient way would still be used when ColdFire support gets added
to LLVM though [5].

With these changes implemented, all that would be left - to my current - knowledge would be
to update the Rust crates »cc« [6] and »linux-raw-sys« [7] to make the Rust compiler build
on Linux on m68k.

If anyone wants to help getting Rust to work on m68k, please let me know!

Thanks,
Adrian

> [1] https://wiki.debian.org/M68k/Alignment
> [2] https://github.com/M680x0/issues/issues/3
> [3] https://github.com/M680x0/issues/issues/6
> [4] https://github.com/llvm/llvm-project/issues/181481
> [5] https://github.com/M680x0/issues/issues/4
> [6] https://github.com/rust-lang/rust/issues/155602
> [7] https://github.com/rust-lang/rust/issues/155603

-- 
 .''`.  John Paul Adrian Glaubitz
: :' :  Debian Developer
`. `'   Physicist
  `-    GPG: 62FF 8A75 84E0 2956 9546  0006 7426 3B37 F5B5 F913


Home | Main Index | Thread Index | Old Index