Skip to content

Commit

Permalink
Drop DEC Alpha processor support
Browse files Browse the repository at this point in the history
Keeping DEC Alpha support is difficult because there are no Alpha
machines available for toolchain developers, and even if there were,
no modern Linux distros still support Alpha. For example, Debian
dropped Alpha support in Debian 6.0. As a result, I cannot test my
linker with real-world programs.

In fact, I believe mold has never been able to link real-world large
programs. Object files for Alpha are compiled with the small code
model by default, so it is not easy to support it in the linker.

There's no means to verify that my implementation is correct for Alpha
because Alpha's psABI has never been published by DEC. The most
"reliable" source of correctness is GNU ld's source code and comments.

Last but not least, I believe there are literally zero mold/Alpha
users. Unlike some other retro computers like the m68k, Alpha doesn't
seem to get much love from the community, perhaps because the
availability of Alpha machines was limited in the first place, even in
the 90s.

Therefore, I'll remove Alpha support now. If there's someone who wants
to keep it, we can resurrect and re-test it.

This change should make the mold binary size a little smaller.
  • Loading branch information
rui314 committed Sep 24, 2024
1 parent 0ee12e4 commit 3711ddb
Show file tree
Hide file tree
Showing 20 changed files with 9 additions and 531 deletions.
3 changes: 1 addition & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
# on a multicore machine.
list(APPEND MOLD_ELF_TARGETS
X86_64 I386 ARM64 ARM32 RV32LE RV32BE RV64LE RV64BE PPC32 PPC64V1 PPC64V2
S390X SPARC64 M68K SH4 ALPHA LOONGARCH32 LOONGARCH64)
S390X SPARC64 M68K SH4 LOONGARCH32 LOONGARCH64)

list(APPEND MOLD_ELF_TEMPLATE_FILES
src/arch-loongarch.cc
Expand Down Expand Up @@ -376,7 +376,6 @@ target_sources(mold PRIVATE
lib/perf.cc
lib/random.cc
lib/tar.cc
src/arch-alpha.cc
src/arch-arm32.cc
src/arch-arm64.cc
src/arch-i386.cc
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ free to [file a bug report](https://github.com/rui314/mold/issues).

mold supports x86-64, i386, ARM64, ARM32, 64-bit/32-bit little/big-endian
RISC-V, 32-bit PowerPC, 64-bit big-endian PowerPC ELFv1, 64-bit little-endian
PowerPC ELFv2, s390x, 64-bit/32-bit LoongArch, SPARC64, m68k, SH-4, and DEC
Alpha.
PowerPC ELFv2, s390x, 64-bit/32-bit LoongArch, SPARC64, m68k, and SH-4.

## Why does linking speed matter?

Expand Down
2 changes: 1 addition & 1 deletion install-cross-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set -x

case "$ID-$VERSION_ID" in
ubuntu-* | pop-* | linuxmint-* | debian-* | raspbian-*)
apt-get install -y qemu-user {gcc,g++}-{i686,aarch64,riscv64,powerpc,powerpc64,powerpc64le,s390x,sparc64,m68k,sh4,alpha}-linux-gnu {gcc,g++}-arm-linux-gnueabihf
apt-get install -y qemu-user {gcc,g++}-{i686,aarch64,riscv64,powerpc,powerpc64,powerpc64le,s390x,sparc64,m68k,sh4}-linux-gnu {gcc,g++}-arm-linux-gnueabihf
;;
*)
echo "Error: don't know anything about build dependencies on $ID-$VERSION_ID"
Expand Down
319 changes: 0 additions & 319 deletions src/arch-alpha.cc

This file was deleted.

8 changes: 3 additions & 5 deletions src/cmdline.cc
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ inline const char helpmsg[] = R"(
-z notext
-z textoff
mold: supported targets: elf32-i386 elf64-x86-64 elf32-littlearm elf64-littleaarch64 elf32-littleriscv elf32-bigriscv elf64-littleriscv elf64-bigriscv elf32-powerpc elf64-powerpc elf64-powerpc elf64-powerpcle elf64-s390 elf64-sparc elf32-m68k elf32-sh-linux elf64-alpha elf64-loongarch elf32-loongarch
mold: supported emulations: elf_i386 elf_x86_64 armelf_linux_eabi aarch64linux aarch64elf elf32lriscv elf32briscv elf64lriscv elf64briscv elf32ppc elf32ppclinux elf64ppc elf64lppc elf64_s390 elf64_sparc m68kelf shlelf_linux elf64alpha elf64loongarch elf32loongarch)";
mold: supported targets: elf32-i386 elf64-x86-64 elf32-littlearm elf64-littleaarch64 elf32-littleriscv elf32-bigriscv elf64-littleriscv elf64-bigriscv elf32-powerpc elf64-powerpc elf64-powerpc elf64-powerpcle elf64-s390 elf64-sparc elf32-m68k elf32-sh-linux elf64-loongarch elf32-loongarch
mold: supported emulations: elf_i386 elf_x86_64 armelf_linux_eabi aarch64linux aarch64elf elf32lriscv elf32briscv elf64lriscv elf64briscv elf32ppc elf32ppclinux elf64ppc elf64lppc elf64_s390 elf64_sparc m68kelf shlelf_linux elf64loongarch elf32loongarch)";

template <typename E>
static std::vector<std::string_view>
Expand Down Expand Up @@ -682,7 +682,7 @@ std::vector<std::string> parse_nonpositional_args(Context<E> &ctx) {
<< " elf64briscv\n elf32lriscv\n elf32briscv\n"
<< " elf32ppc\n elf64ppc\n elf64lppc\n elf64_s390\n"
<< " elf64_sparc\n m68kelf\n shlelf_linux\n"
<< " elf64alpha\n elf64loongarch\n elf32loongarch";
<< " elf64loongarch\n elf32loongarch";
version_shown = true;
} else if (read_arg("m")) {
if (arg == "elf_x86_64") {
Expand Down Expand Up @@ -715,8 +715,6 @@ std::vector<std::string> parse_nonpositional_args(Context<E> &ctx) {
ctx.arg.emulation = M68K::target_name;
} else if (arg == "shlelf_linux") {
ctx.arg.emulation = SH4::target_name;
} else if (arg == "elf64alpha") {
ctx.arg.emulation = ALPHA::target_name;
} else if (arg == "elf64loongarch") {
ctx.arg.emulation = LOONGARCH64::target_name;
} else if (arg == "elf32loongarch") {
Expand Down
Loading

21 comments on commit 3711ddb

@glaubitz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there anything we can do to get Alpha back? Alpha is still supported in Debian Ports and Gentoo.

CC @thesamesam @mattst88

@rui314
Copy link
Owner Author

@rui314 rui314 commented on 3711ddb Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is lack of testing environment, so if there's a VM image of some Linux/Alpha distro which I can easily boot with qemu-system, I may be able to bring it back. If that happens, I also want to run that VM image on GitHub Actions so that I'll get a notification if something breaks the Alpha port. Note that the distro needs to be modern enough to compile programs written in C++20.

@glaubitz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can just install Debian unstable which contains the latest version of GCC in QEMU:

$ wget https://cdimage.debian.org/cdimage/ports/snapshots/2023-06-18/debian-12.0.0-alpha-NETINST-1.iso
$ qemu-img create -f qcow2 alpha-system.img 30G && qemu-img create -f qcow2 alpha-swap.img 4G
$ mount -o loop debian-12.0.0-alpha-NETINST-1.iso /mnt/
$ cp -av /mnt/boot/vmlinuz . && cp -av /mnt/boot/initrd.gz .
$ mv vmlinuz vmlinux.gz && unzip vmlinux.gz
$ qemu-system-alpha -serial none -serial mon:stdio -m 4096M -drive file=alpha-system.img,format=qcow2 \
  -drive file=debian-12.0.0-alpha-NETINST-1.iso,if=ide,media=cdrom -drive file=alpha-swap.img,format=qcow2 \
  -net nic -net user,hostfwd=tcp::2222-:22  -nographic -append "root=/dev/ram rw console=ttyS0" \
  -kernel vmlinux -initrd initrd.gz

After installation has finished, you need to extract both the kernel and initrd of the installed system and boot the system with:

$ qemu-system-alpha -serial none -serial mon:stdio -m 4096M -drive file=alpha-system.img,format=qcow2 \
   -drive file=debian-12.0.0-alpha-NETINST-1.iso,if=ide,media=cdrom -drive file=alpha-swap.img,format=qcow2 \
   -net nic -net user,hostfwd=tcp::2222-:22  -nographic -append "root=/dev/sda2 rw console=ttyS0" \
   -kernel vmlinux -initrd initrd.gz

@rui314
Copy link
Owner Author

@rui314 rui314 commented on 3711ddb Sep 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last command to install Debian (qemu-system-alpha) doesn't show anything. Is this expected? It looks like it is doing something, as the process uses a core 100%.

@glaubitz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, please drop -serial none from the command line.

@thesamesam
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matoro also provides access to running systems running up-to-date Gentoo for Alpha and other arches: https://static.matoro.tk/isa-sandbox-faq.html.

@jinghao-jia
Copy link

@jinghao-jia jinghao-jia commented on 3711ddb Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that Alpha support on Mold is never keyworded in Gentoo (at least on the currently available versions).

@matoro
Copy link

@matoro matoro commented on 3711ddb Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was never keyworded because it never worked. I've already provided access to the hardware and shared specific steps for reproducing the failure, but didn't get any response: #1166

@rui314
Copy link
Owner Author

@rui314 rui314 commented on 3711ddb Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set up an Alpha VM with qemu-system-alpha and tried to build mold inside it. Unfortunately, the build failed due to a "corrupted size vs. prev_size" error which was reported by GNU ld. It seems even GNU ld doesn't work correctly on Alpha. Is this expected?

@matoro
Copy link

@matoro matoro commented on 3711ddb Sep 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set up an Alpha VM with qemu-system-alpha and tried to build mold inside it. Unfortunately, the build failed due to a "corrupted size vs. prev_size" error which was reported by GNU ld. It seems even GNU ld doesn't work correctly on Alpha. Is this expected?

That's an error from glibc, not from GNU ld. It indicates that there's some inconsistency in memory state, so nothing is reliable from that point forward. I do know that on real hardware I did observe memory corruption unless CONFIG_COMPACTION was disabled in my kernel, but I don't know if that would be an issue on QEMU.

In the meantime, that specific issue may be reproducible with a cross toolchain. I'll try it out and see.

@glaubitz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I set up an Alpha VM with qemu-system-alpha and tried to build mold inside it. Unfortunately, the build failed due to a "corrupted size vs. prev_size" error which was reported by GNU ld. It seems even GNU ld doesn't work correctly on Alpha. Is this expected?

That's odd. We're not seeing this issue on Debian on the buildds where the last 12 or so releases built fine:

https://buildd.debian.org/status/logs.php?pkg=mold&arch=alpha

Even the testsuite passes 100%:

https://buildd.debian.org/status/fetch.php?pkg=mold&arch=alpha&ver=2.33.0%2Bdfsg-1&stamp=1723077809&raw=0

@rui314
Copy link
Owner Author

@rui314 rui314 commented on 3711ddb Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like GNU ld fails if I try to build mold with -DCMAKE_BUILD_TYPE=Debug. Release build builds fine.

@glaubitz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like GNU ld fails if I try to build mold with -DCMAKE_BUILD_TYPE=Debug. Release build builds fine.

Wouldn't that be enough for the time being?

@rui314
Copy link
Owner Author

@rui314 rui314 commented on 3711ddb Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If GNU binutils are so broken that GNU ld cannot build mold for the release build, it's a signal that the entire ecosystem has rotted to the extent that it doesn't make much sense to try to port new software to it. If Alpha community is serious enough to sustain their ecosystem, they need to fix the toolchain so that developers can trust the tools.

GNU ld's issue also means a lot to mold because the GNU ld's source code is the psABI spec for Alpha because DEC has never published Alpha processor-specific ABI.

@glaubitz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If GNU binutils are so broken that GNU ld cannot build mold for the release build, it's a signal that the entire ecosystem has rotted to the extent that it doesn't make much sense to try to port new software to it.

But we're building the whole Debian software stack for Alpha, including mold, see:

If Alpha community is serious enough to sustain their ecosystem, they need to fix the toolchain so that developers can trust the tools. I have absolutely no idea what makes you think it's broken.

I will try to reproduce the issue with mold and report the issue upstream. I don't think the »entire ecosystem« is broken just because a single package doesn't build. I find this criticism quite harsh.

GNU ld's issue also means a lot to mold because the GNU ld's source code is the psABI spec for Alpha because DEC has never published Alpha processor-specific ABI.

The generic Unix documentation won't help?

@rui314
Copy link
Owner Author

@rui314 rui314 commented on 3711ddb Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try to reproduce the issue with mold and report the issue upstream. I don't think the »entire ecosystem« is broken just because a single package doesn't build. I find this criticism quite harsh.

Well, I have to say that the situation for Alpha is definitely worse than MIPS which we ended up giving up supporting. On MIPS, at least all existing tools worked as expected for me. On the other hand, mold is the only program I tried to build myself so far for Alpha so far, and that didn't built correctly with debug info.

The generic Unix documentation won't help?

http://bitsavers.trailing-edge.com/pdf/dec/alpha/Alpha_Calling_Standard_Rev_2.0_19900427.pdf

Unfortunately, no. Calling convention spec is different from a processor-specific ELF spec. For example, here is a calling convention spec (https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc) and here is an ELF psABI (https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc) for RISC-V.

@glaubitz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I have to say that the situation for Alpha is definitely worse than MIPS which we ended up giving up supporting. On MIPS, at least all existing tools worked as expected for me. On the other hand, mold is the only program I tried to build myself so far for Alpha so far, and that didn't built correctly with debug info.

FWIW, there are some newly discovered bugs in the Alpha toolchain. Luckly, Maciej W.Rozycki is currently working on improving the Alpha backend in GCC, so chances are good that this issues will resolve in the near future.

The generic Unix documentation won't help?
http://bitsavers.trailing-edge.com/pdf/dec/alpha/Alpha_Calling_Standard_Rev_2.0_19900427.pdf

Unfortunately, no. Calling convention spec is different from a processor-specific ELF spec. For example, here is a calling convention spec (https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-cc.adoc) and here is an ELF psABI (https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc) for RISC-V.

OK, I'll try to figure out whether the calling convention spec can be obtained.

@glaubitz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rui314 Does the Tru64 Unix Object File Specification for Alpha help?

This seems to contain the specification about object files and linking on Alpha.

@rui314
Copy link
Owner Author

@rui314 rui314 commented on 3711ddb Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Close, but it looks like that document explains COFF object files instead of ELF.

@glaubitz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't the relocations the same for COFF and ELF?

According this this article, the Alpha ELF format is based on the object file format used in Tru64 Unix.

@rui314
Copy link
Owner Author

@rui314 rui314 commented on 3711ddb Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That document works as a hint as to how its ELF correspondent should look like, but that cannot be a substitute for a specification. It's just like we have other hints such as GNU ld's source code, but those are not a spec.

Please sign in to comment.