[RFH] M68k: Implementing support for 32-bit relocations

Hello,

the experimental M68k backend in LLVM is close to a point where it works well enough to allow the Rust compiler to build its standard library for m68k on Linux. There is just one blocker bug left which is the missing support for 32-bit relocations in the backend.

I have outlined the problem in a GitHub issue: [M68k] Backend cannot handle 32-bit offsets for memory loads and jumps

Resolving this issue would be a huge step forward and finally provide the community with a fully working Rust compiler for m68k. Unfortunately, my own skills as a compiler engineer are rather limited so that I don’t have the capability to implement a solution myself.

I have played around with both Google Gemini and Claude Code to create very hacky solution to implement 32-bit relocations, but neither of the solutions are really clean or efficient and would be suitable to be merged upstream.

I am therefore looking for someone who might be interested to help me implement support for 32-bit relocations in the M68k backend or at least give me some hints on how it could be done. From my current understand, it shouldn’t be too difficult for an experienced LLVM engineer to come up with a solution for this problem, but I might be wrong.

Does anyone have any suggestions what to do?

Thanks,
Adrian

Here is the SysV psABI documentation for M68k if that helps: https://people.debian.org/~glaubitz/m68k-sysv-abi.pdf

I have used Google Gemini Code Assist now to implement the necessary changes to the backend.

With the changes, building code with 32-bit reloactions works. I’m hesitant to open a pull request with these changes though.

See: https://github.com/llvm/llvm-project/issues/181481#issuecomment-4476933700

Maybe the patch and the changes summarize can help a skilled LLVM engineer to make the necessary changes.

Thanks,
Adrian