Summary on what's blocking full Rust support on m68k

John Paul Adrian Glaubitz <[email protected]> Thu, 23 Apr 2026 09:39:44 +0200
Newsgroups gmane.linux.ports.m68k,gmane.linux.debian.ports.68k,gmane.os.netbsd.ports.m68k
Message-ID <29d725b5647c176b8cef0d3442d1b3440e6a1a9a.camel@physik.fu-berlin.de>
Hello,

here is a quick summary of what needs to be done to get a working Rust comp=
iler for m68k
on Linux. Most of the changes apply to NetBSD as well, except for the align=
ment 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 o=
ne of the biggest
blockers for Rust on m68k on Linux and it's also what currently prevents ma=
ny 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 al=
low the kernel
to be built with either alignment without breaking the alignment. An initia=
l 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 hel=
p 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 targe=
t 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 - kn=
owledge would be
to update the Rust crates =C2=BBcc=C2=AB [6] and =C2=BBlinux-raw-sys=C2=AB =
[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

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