Table of Contents
Toolchains
Alpha/Linux is built with the GNU toolchain: GCC, binutils, and glibc, all of which carry Alpha support in their main development trees. GCC builds the kernel, the C library, and every current distribution. The Alpha-specific parts of the toolchain differ from those of other architectures in three respects: processor selection, the -m options that have no counterpart on other architectures, and the size limit of the global offset table (GOT). Several newer tools, LLVM above all, have no Alpha support; see Not available on Alpha.
Compaq C (ccc), a commercial compiler, was also available for Alpha/Linux from 1999; see Compaq C.
GCC
Richard Henderson maintains GCC's Alpha back end. 1) Upstream GCC's default target is the architecture baseline, so a compiler built without –with-cpu produces code that runs on every Alpha processor, including those current kernels no longer support.
Selecting a processor
-mcpu= selects both the instruction set and the scheduling model. Values up to ev5 change only scheduling and produce code that runs on every Alpha; ev56 and above add instructions, and their code does not run on earlier processors. 2)
-mcpu | Processors | Adds |
|---|---|---|
ev4, ev45 | 21064, 21064A, 21066, 21068 | baseline |
ev5 | 21164 | scheduling only |
ev56 | 21164A | BWX |
pca56 | 21164PC | BWX, MVI |
ev6 | 21264 | BWX, MVI, FIX |
ev67 | 21264A and later | BWX, MVI, FIX, CIX |
GCC has no ev68 value. 3) -mcpu=ev67 is the right choice for the EV68 processors, which add no instructions and schedule like the EV67. 4) The extensions themselves are described on the Instruction Set page.
-mtune= takes the same values and changes only instruction scheduling, never the instruction set. The numeric names (21064, 21164a, 21264 and so on) are accepted as synonyms.
Two compatibility issues apply:
- An extension may be implemented and still disabled. Early versions of the PALcode used by MILO left BWX disabled on the AlphaPC 164, so code built with
-mcpu=ev56failed with an illegal instruction on a CPU that implements it; later MILO versions enable it. 5) - Binaries built for ev56 do not run on older CPUs. Linux does not emulate the byte and word instructions; on a pre-EV56 processor they raise an illegal instruction fault and the process receives
SIGILL. 6) See Byte and Word Access.
The amask instruction reports what the running processor implements.
Choosing -mcpu today
Linux 6.10 removed support for processors older than the EV56 (21164A), so every system that runs a current kernel implements BWX, and -mcpu=ev56 is the natural baseline for new binaries: it runs on every such system, and avoids the long instruction sequences and the atomicity problems of pre-BWX byte and word access. The kernel's own generic configuration uses -mcpu=ev56 -mtune=ev6, scheduling for the 21264 while staying compatible with the 21164A. 7) A binary built for a specific machine can use that processor's own value, -mcpu=ev67 for a 21264A or later, which adds the FIX, CIX, and MVI instructions.
-mcpu=ev6 and -mcpu=ev67 binaries do not run on the 21164A and 21164PC, which the kernel still supports.
Distribution baselines
Debian's GCC packages have been configured with –with-cpu=ev56 since gcc-13 13.1.0-3 and gcc-12 12.3.0-2, in May 2023, 8) 9) after glibc 2.37 removed the legacy hardware capabilities directories and with them the separate EV67 build of glibc. 10) An EV67 baseline was also proposed, but owners of pre-EV67 systems objected that they were the majority of working Alphas. 11)
T2 builds its Alpha images for EV56. 12) Gentoo's Alpha profile sets no -mcpu, so its stages use the compiler's default, the architecture baseline. 13) The release stages are built by catalyst with its generic alpha subarchitecture, whose flags are -mieee -pipe -O2 -mcpu=ev4; catalyst also writes them into the stage's make.conf. 14) 15) Code in a stage therefore stores bytes and words with non-atomic pre-BWX sequences (see Byte and Word Access) until it is rebuilt with a newer -mcpu. Gentoo users choose their own in make.conf; since current kernels need an EV56 or later, -mcpu=ev56 or the processor's own value (see Choosing -mcpu today) loses nothing.
Alpha-specific options
| Option | What it does |
|---|---|
-mbwx / -mno-bwx | byte/word extension, independently of -mcpu |
-mcix / -mno-cix | count extension (CTLZ, CTPOP, CTTZ) |
-mmax / -mno-max | multimedia extension (MVI) |
-mfix / -mno-fix | square-root and FP convert extension |
-mieee, -mieee-with-inexact, -mieee-conformant | software completion, see Floating Point |
-mtrap-precision=, -mfp-rounding-mode= | trap precision and rounding mode written into each instruction |
-mfp-regs / -mno-fp-regs | whether the FP register file may be used at all. The kernel is built -mno-fp-regs |
-msmall-data / -mlarge-data | put small objects in .sdata addressed off the GP, or not |
-msmall-text / -mlarge-text | assume the text segment fits in 4 MiB so calls can be BSR |
-mexplicit-relocs | emit explicit relocations rather than leaving the assembler to macro-expand memory references |
-msafe-bwa, -msafe-partial | make byte and word accesses without BWX (-msafe-bwa), and piecemeal unaligned and partial-quadword accesses (-msafe-partial), thread and signal safe; added in GCC 15 (PR117759) 16) |
-mmemory-latency= | scheduling assumption for the memory system |
-mieee is the option most often needed. Upstream GCC does not enable it by default, but the Debian and Gentoo GCC packages do. The reasoning, and its cost, are described on the Floating Point page.
"relocation truncated to fit"
Alpha addresses global data through the GP register plus a 16-bit signed displacement, so one GOT holds 64 KiB of entries. A link failure such as relocation truncated to fit: LITERAL means a GOT or small data area has overflowed. 17) The linker splits an application's GOT into multiple subsections, each with its own GP, so ordinary programs do not reach the limit. 18)
The limit is still reached in these cases:
-fpicshared libraries.-fpicimplies-msmall-data, which limits the small data area to 64 KiB;-fPICimplies-mlarge-data, which does not. A large library that fails to link with-fpicshould be built with-fPIC. 19)- The kernel itself. The statically linked kernel has no such diagnostic: an overflowing kernel
.gotsection produces a kernel that fails at run time rather than at build time. 22)
binutils
The assembler takes -mev4 to -mev68, -mpca56, and -mall to select the instruction set; the numeric forms (-m21064 to -m21264b) also accept the PALcode instructions of that processor. The .arch directive does the same from within a source file. GCC passes its -mcpu value to the assembler as the corresponding -m option. 23) 24)
Without one of these options the assembler targets the base architecture, and hand-written assembly is affected in two ways. Instructions from the extensions, such as ctpop, are rejected. The byte and word instructions ldbu, ldwu, stb, stw, sextb, and sextw are not rejected but treated as macros, and silently expanded into pre-BWX sequences; the expansions of stb and stw are non-atomic read-modify-write sequences (see Byte and Word Access). 25) An assembly file that uses byte stores should therefore start with .arch ev56 or be assembled with -mcpu=ev56.
GDB
GDB supports Alpha/Linux as a native debugger, and can debug Alpha core files and QEMU's gdbstub from another host. 26) 27) gdbserver has no Alpha support. 28)
glibc
glibc is the only C library for Alpha/Linux. Its library is libc.so.6.1, not libc.so.6, and glibc builds itself with -mieee. Both have Alpha-specific reasons, covered in Why Alpha Has libc.so.6.1 and Floating Point.
Alpha's long double is the 128-bit IEEE quadruple format, implemented in software, and its pages are 8 KiB. These and the other ways in which Alpha's Linux ABI differs from x86-64 are described in Linux ABI Differences.
Not available on Alpha
The following are missing on Alpha; details and sources are on the Current Status page.
- LLVM and Clang. LLVM has had no Alpha back end since 2011, so Clang cannot be used, and the kernel cannot be built with
LLVM=1. - Rust, except through the GCC-based projects rustc_codegen_gcc and gccrs, both still in development. Zig and other LLVM-based compilers are likewise unavailable.
- musl. glibc is the only C library.
- The Go toolchain.
gccgobuilds Go code on Alpha.
Cross compilers
A cross compiler is the usual way to build a kernel for Alpha, and a quick way to check that other software builds. Prebuilt ones are available from several sources:
| Source | Package or file | Prefix | Notes |
|---|---|---|---|
| Debian and Ubuntu | gcc-alpha-linux-gnu, binutils-alpha-linux-gnu | alpha-linux-gnu- | In the main archive. Versioned packages such as gcc-15-alpha-linux-gnu are also available. 29) Includes glibc, so it builds user programs as well as kernels |
| Gentoo | crossdev –target alpha-unknown-linux-gnu | alpha-unknown-linux-gnu- | Builds binutils, GCC, the kernel headers, and glibc from source |
| kernel.org | x86_64-gcc-version-nolibc-alpha-linux.tar.xz | alpha-linux- | Arnd Bergmann's prebuilt compilers, mirrors.edge.kernel.org/pub/tools/crosstool. Without a C library, so for kernels only |
For example, on Debian:
apt install gcc-alpha-linux-gnu alpha-linux-gnu-gcc -O2 -mcpu=ev56 -o hello hello.c qemu-alpha -L /usr/alpha-linux-gnu ./hello
The last line runs the result with QEMU's user-mode emulator; see QEMU. Building a kernel with a cross compiler is described on the Kernel page.
Compaq C
Compaq C (ccc) was the DEC C compiler of Digital UNIX and OpenVMS, built on Digital's GEM optimizing back end and retargeted to Linux. Compaq released it free of charge in December 1999, with a Fortran compiler (fort), a C++ compiler (cxx), and the CPML and CXML math libraries. 30) It was faster than GCC on floating-point code, but by 2003 there was little difference for integer code, 31) and it was never used to build a distribution. The packages could not be redistributed, 32) and the compilers are no longer available.
See also
- Linux ABI Differences, for
long double, the page size, and system call conventions - Architecture Mask (amask) for detecting extensions at runtime
- Bugs for open gcc, glibc and binutils bugs against Alpha
