[lld] [ELF,SPARC] Add the 32-bit SPARC target (PR #228200)
Imre Kaloz via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 4 12:06:38 PDT 2026
kaloz wrote:
> Thanks for the patches and for disclosing the AI assistance.
>
> Here is where 32-bit SPARC stands today:
>
> * Linux: the kernel keeps sparc32 mainly for LEON, and current kernels don't boot on non-LEON hardware.
> * glibc: requires CAS, which excludes sun4m/SuperSPARC. 32-bit is tested only as a -m32 variant of sparc64.
> * musl: no SPARC port.
> * Distributions: none ships a 32-bit SPARC userland. Debian dropped it after wheezy.
> * BSDs: OpenBSD/sparc ended with 5.9, and FreeBSD never had it. NetBSD/sparc remains, using GNU ld.
>
> The remaining users with a vendor behind them are LEON (Frontgrade Gaisler), and they are moving to RISC-V (NOEL-V).
Thanks for the detailed reasoning, and for making the objection explicit.
Some context I think changes the picture:
* sun4m is active again - sparc32/sun4m traffic on the sparclinux list went from almost nothing earlier this year to 40-60 messages a month since August, from several people (Magnus Lindholm's SILO and kernel work, Sam Ravnborg, myself). I have posted the kernel fixes SuperSPARC SMP systems need, tested on a dual-CPU SPARCstation 20.
* The proposed casa emulation takes care of glibc as well: it completes the casa opcode in the kernel, so a glibc built to use casa runs on sun4m without a rebuild.
* Mainline works on sun4m, what stops a current distro-sized kernel is the boot path: SILO only offers a ~2.5 MB window below itself, and larger images hit an early-boot bug in the nocache pool setup. There are patches for both, and with them 7.3-rc4 boots SMP on that SS-20.
* There is a musl port for both sparc64 and 32-bit V8, currently under stress-testing on QEMU and real hardware and shared with other sun4m developers; the SS-20 boot above runs a musl userspace.
> Given that, as lld/ELF, MC, and binary utilities maintainer, I'm not in favor of adding 32-bit SPARC to lld in-tree. Once code is in-tree it is a shared cost, and for lld/ELF that cost largely falls on me. Retro-computing targets need a high bar:
>
> * Harm to the generic core. Old architectures rarely stay inside Arch/. They need workarounds here and there in the driver, input-file handling and output writing, which every later refactor must preserve. This series already does it: #228201 remaps EM_SPARC32PLUS to EM_SPARC across inferMachineType, isCompatible and writeEhdr. Distribution libgcc and libatomic are EM_SPARC32PLUS, so that patch would have to follow.
> * No testing infrastructure. With no buildbot and no runtime testing, this code would bitrot quietly.
> * Reviewability. Largely LLM-generated contributions are discouraged under the AI Tool Use Policy. For generated code, the open question is whether anyone understands it well enough to maintain and debug it independently. First-time contributors are also not expected to send a stacked series adding a new ELF target.
> * Precedent. If we accept this, we should expect more single-author, low-community targets. I'd rather hold the bar than relax it case by case. See the similar EZH discussion.
>
The target patch is about 120 lines of non-test code, 95 of them in Arch/SPARC.cpp; the rest are a few lines each in the driver and input handling. If the EM_SPARC32PLUS remapping in #228201 is the part you see as harm to the generic core, I'm fine dropping it. On testing, I already boot sun4m guests in QEMU system mode as part of this work, and I can offer that as runtime coverage on a buildbot.
> A downstream fork fits this effort better. It keeps the cost with the people who benefit, and you can iterate without waiting on upstream review. The usual objection is rebase pain, but that is largely gone: resolving API churn against upstream, rebuilding and rerunning the target's tests is exactly what an agent does well.
More and more userland, and parts of the kernel, need Rust to build, and Rust needs LLVM. Every piece of 32-bit SPARC support that has to live in a fork makes the target look less maintained, which then becomes the argument for dropping it. That's the chicken-and-egg problem I'd like to avoid.
> I'm marking this "Request changes" to make the objection explicit, since I may not follow every notification here. This PR, and #228201 with it, should be considered rejected. Overturning that would take strong community support, raised on Discourse, not an approval on this PR.
I'll raise it on Discourse as you suggest. Meanwhile #228197 and #228198 don't depend on the 32-bit target: the first adds the missing TLS GD/LD relocations to the existing 64-bit target, the second is a delay-slot codegen fix tested on sparc64. Could they still get a review?
https://github.com/llvm/llvm-project/pull/228200
More information about the llvm-commits
mailing list