Build notes for Alpha toolchain
These are my notes while I was creating a toolchain for Alpha (on DS10 for
AS800). In addition, there are some bootstrap notes.
General
- Not every program is suitable for static linking (
-static
).
E.g. calls to NSS, iconv, or dlopen will emit a warning when linking, but
they'll almost certainly crash when run.
AS800
- glibc ()
- When building glibc for the toolchain, mind that the library remains
compatible with the kernel version you're running. Compiling the library
for, say kernel 2.6.38, prevents you from building the rest of the
toolchain if you were running on kernel 2.6.2. Binaries compiled against
the new library will abort with error "Kernel too old".
- Optimize flag
-Os
causes a link error at the end
("undefined reference to fstatat64"). Forced to use -O2
.
- linux (2.6.39.4)
- Build target to create bootpfiles doesn't work anymore:
arch/alpha/boot/tools/objstrip.c
- in
main():153
, replace expression of
if
statement:
!elf_check_arch(elf)
by:
elf->e_machine != EM_ALPHA
- bootpfile
- Copy
<linux>/lib/vsprintf.c
to
arch/alpha/lib/
and add vsprintf.o
to
lib-y
in
<linux>/arch/alpha/lib/Makefile
. This adds
vsprintf.o
to
<linux>/arch/alpha/lib/lib.a
but the goal is to
get vsprintf.c
compiled.
- In
<linux>/arch/alpha/lib/vsprintf.c
, the
function named pointer()
, line
"case 'K'
", comment out the if
statement with kptr_restrict
. Also, in function
symbol_string()
comment out the "true"-clause of the
CONFIG_KALLSYMS
#ifdef
(including the
#ifdef
/#else
/#endif
).
Functions bstr_printf()
and vsnprintf()
,
comment out the if
statement containing
WARN_ON_ONCE
.
- Add
vsprintf.o
to OBJ_bootlx
,
OBJ_bootph
and OBJ_bootpzh
definitions in
<linux>/arch/alpha/boot/Makefile: "$(obj)/../lib/vsprintf.o"
Fixes undefined references to has_capability_noaudit
and warn_slowpath_null
.
- Add CFLAGS for
objstrip
utility in
<linux>/arch/alpha/boot/Makefile:
HOSTCFLAGS_objstrip.o := -Delfhdr=elf64_hdr -Delf_phdr=elf64_phdr
- Move
hexdump.o
from obj-y
to
lib-y
variable in
<linux>/lib/Makefile
.
Fixes undefined references to hex_asc
.
- Disabled kernel option "Enable PCI quirk workarounds" (General
setup).
Enabling this option seems to hang-up the kernel.
- Cannot use Heirloom shell with kernel build system.
- Linking kernel (binutils 2.21, gcc 4.6.1) may result in an error
"relocation truncated to fit: ...". Adding the linker flag
--no-relax
to the variable LDFLAGS_vmlinux
in
the main Makefile
.
DS10
- aboot (0.92b)
If aboot
hangs immediately after launching the kernel (after
decompressing step), then your aboot
loader probably supports
the old kernel header, only. You need to patch various files of the
aboot
package:
- all Makefiles
- Set
CC
to correct compiler.
./Makefile
- Re-set path for
KSRC
and "root" variables.
- Exporting variable
mandir
(used by
doc/man/Makefile
).
- Added toolchain library paths to
ABOOT_LDFLAGS
.
- Added toolchain include path to
CPPFLAGS
.
- Added
-DCONFIG_64BIT
and -D__KERNEL__
to
CFLAGS
.
- Added
-DCONFIG_64BIT
to ASFLAGS
.
- Commented
tools/elfencap
from diskboot
target.
(prevent elfencap
from being build)
- Added
install
command for sdisklabel
to
install target.
- Commented prerequisite
install-man
of
install
target due to install-man
failing
for now.
./doc/man/Makefile
- Man page of
isomarkboot
is section 8 manual instead of
section 1.
Adapted Makefile
accordingly.
- Disabled manual
netabootwrap
due to missing tools
nsgmls
.
- Added
sdisklabel
man page to install
target.
./lib/Makefile
- Added
-DCONFIG_64BIT
and -D__KERNEL__
to
CFLAGS
.
- Added
-DCONFIG_64BIT
to ASFLAGS
.
./sdisklabel/Makefile
- Added
LDFLAGS
with toolchain library paths.
- Added
-static
flag to LDFLAGS
.
./tools/Makefile
- Make
CPPFLAGS
separate definition and undefine
__KERNEL__
.
Using override
directive and +=
to add to
CPPFLAGS
from command line.
Remove CPPFLAGS
from CFLAGS
.
- Added
-DCONFIG_64BIT
to CFLAGS
.
- Added
-Delfhdr=elf64_hdr
and
-Delf_phdr=elf64_phdr
to CFLAGS
.
(for compiling objstrip.c
)
- Added
-static
flag to LDFLAGS
.
./aboot.c
- Added
linux/
to elf.h
include.
./cons.c
- Commented prototype of
dispatch()
.
./disk.c
- Added
break
statement for "default:
"
label.
./fs/ext2.c
- Swapped "
#include <linux/fs.h>
" and
"#include <linux/ext2_fs.h>
", line 29-30.
./lib/isolib.c
- Commented "
#include <linux/config.h>
".
- Added
break
statement for "default:
"
label.
./tools/elfencap.c
- Replace undeclared definitions:
ELF_CLASS
by ELFCLASS64
ELF_DATA
by ELFDATA2LSB
ELF_ARCH
by EM_ALPHA
./tools/isomarkboot.c
- Including "
asm/fcntl.h
" instead of
"sys/fcntl.h
".
./tools/objstrip.c
- If fails to build, build kernel and copy
objstrip
from
architecture-specific directory.
- Put the whole lot and other fixes in a patch.
- bash (3.2.48)
CPPFLAGS='-I/home/nfs/rootfs.unimatrix/usr/include'
LDFLAGS='-L/home/nfs/rootfs.unimatrix/lib -L/home/nfs/rootfs.unimatrix/usr/lib'
./configure --build=alphaev67-unknown-linux-gnu --host=alphaev56-gomtuu-linux-gnu --prefix=/usr
--bindir=/bin --infodir=\${datadir}/info --mandir=\${datadir}/man --disable-multibyte
--disable-net-redirections --disable-restricted --enable-separate-helpfiles
--disable-mem-scramble --disable-profiling --disable-nls
- Disabling bash debugger (
--disable-debugger
) causes
undeclared identifier shell_function_defs
in file
variables.c
, so forced to keep the debugger enabled. Also, due
to cross-compiling ./configure
cannot detect certain features
(e.g., signals, job control), so such features are missing from the
resulting binary. It seems re-compilation is necessary on the destination
system.
- coreutils (8.16)
LDFLAGS='-L/home/nfs/rootfs.unimatrix/lib -L/home/nfs/rootfs.unimatrix/usr/lib'
CPPFLAGS='-I/home/nfs/rootfs.unimatrix/usr/include' ./configure
--build=alphaev67-unknown-linux-gnu --host=alphaev56-gomtuu-linux-gnu --prefix=/usr
--disable-nls --enable-install-program=hostname,su --without-selinux --without-gmp
- When cross-compiling,
./configure
fails on the
fstatat
test. Seen on 8.13 and 8.14, newer version may be
fixed (8.16 is fixed). The test is failed explicitely in case of
cross-compiling. Fixed by setting
gl_cv_func_fstatat_zero_flag=yes
for ./configure
or commenting the test.
Removed the -mieee
throughout the Makefiles.
- Skip building
hostname
since it is provided by
net-tools
.
- The
df
utility is not being built when cross-compiling.
For a number of systems (Linux, OSF/1), the ./configure
script
doesn't support cross-compiling for library function statfs()
(see lib/fsusage.c:get_fs_usage()
) which is needed for the
df
utility. To circumvent this, pass the parameter
fu_cv_sys_stat_statfs2_bsize=yes
to the
./configure
script or do a native build.
- e2fsprogs (1.42)
LDFLAGS='-L/home/nfs/rootfs.unimatrix/lib -L/home/nfs/rootfs.unimatrix/usr/lib'
CPPFLAGS='-I/home/nfs/rootfs.unimatrix/usr/include' ../configure
--build=alphaev67-unknown-linux-gnu --host=alphaev56-gomtuu-linux-gnu --prefix=/usr
--with-root-prefix= --disable-nls --enable-verbose-makecmds --disable-testio-debug
- Link error
e2fsck
(undefined reference to
fallocate
).
#ifdef
condition in lib/ext2fs/unix_io.c:898
is
insufficient, new #ifdef
is:
#if defined(HAVE_FALLOCATE) && defined(FALLOC_FL_PUNCH_HOLE)
- file (4.24)
LDFLAGS='-L/home/nfs/rootfs.unimatrix/lib -L/home/nfs/rootfs.unimatrix/usr/lib'
CPPFLAGS='-I/home/nfs/rootfs.unimatrix/usr/include' ./configure
--build=alphaev67-unknown-linux-gnu --host=alphaev56-gomtuu-linux-gnu --prefix=/usr
--disable-nls --enable-fsect-man5
- Target
check
is failing due to magic.h
is
missing from tests
directory. Copied the file from
src
directory.
- Target
magic.mgc
fails to build due to missing
prerequisite file
in magic/Makefile
. Fixed by
setting FILE_COMPILE
variable in magic/Makefile
to file
binary in src
directory.
- flex (2.5.35)
CPPFLAGS='-I/home/nfs/rootfs.unimatrix/usr/include'
LDFLAGS='-L/home/nfs/rootfs.unimatrix/lib -L/home/nfs/rootfs.unimatrix/usr/lib' ./configure
--build=alphaev67-unknown-linux-gnu --host=alphaev56-gomtuu-linux-gnu --prefix=/usr
--infodir=\${datadir}/info --mandir=\${datadir}/man --disable-nls
./configure
"rejects" libc compatible malloc
due to cross-compiling and consequently fails at linking flex binary. I've
set ac_cv_func_malloc_0_nonnull=yes
to circumvent. Same for
realloc
, set ac_cv_func_realloc_0_nonnull=yes
.
- gcc (4.6.1), including gmp (5.0.2), mpfr (3.0.1) and mpc (0.9)
LDFLAGS='-L/home/nfs/rootfs.unimatrix/lib -L/home/nfs/rootfs.unimatrix/usr/lib'
CPPFLAGS='-I/home/nfs/rootfs.unimatrix/usr/include' ../gcc-4.6.1/configure
--build=alphaev67-unknown-linux-gnu --host=alphaev56-gomtuu-linux-gnu --prefix=/usr
--target=alphaev56-gomtuu-linux-gnu --enable-threads --enable-__cxa_atexit
--disable-libstdcxx-pch --disable-multilib --disable-libssp --disable-gomp --disable-nls
--with-cpu=ev56 --with-tune=ev56 --with-mpc=/home/nfs/rootfs.unimatrix/usr
--with-mpfr=/home/nfs/rootfs.unimatrix/usr --with-gmp=/home/nfs/rootfs.unimatrix/usr
--without-ppl --without-cloog
- Needed to remove
gcc/stmp-int-hdrs
stamp (after
install-gcc
) since it prevents limits.h
from
being generated. Also added --with-cpu=ev67
.
- Optimization
-Os
causes build errors (i.e. missing header
files), so used -O2
instead. Also, when changing
CFLAGS
you must pass the CPU type to the assembler
through the -Wa
option. The CPU type specified must be at
least as high as is used for the compiler. See GMP's
configure.in
file for more info.
--without-headers
causes build error for target
libgcc
(signal.h
not found).
make all-gcc install-gcc
make all-target-libgcc install-target-libgcc
- Noticed the files
limits.h
and syslimits.h
in the directory
/usr/lib/gcc/<GCC>/<VERSION>/include-fixed
are
the same while they differ on other systems. syslimits.h
contains an "include_next
" directive in that case.
Although I did not verify, fixincludes/mkheaders
may be
responsible: it checks whether to rename limits.h
to
syslimits.h
or to copy syslimits.h
from a file
named gsyslimits.h
. If configured with
--prefix=/usr
, limits.h
is found on the
host system and limits.h
will be renamed to
syslimits.h
. However, according to
this source, the fixincludes
procedure is unnecessary and various distro's apply a patch to prevent it
from being executed. For example the Linux From Scratch project:
sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in
- glibc (2.13)
- Need to specify relative path to
glibc-ports
add-on when
configuring. Otherwise TLS support is missing and you get an appropriate
#error
message from the preprocessor.
- Patch
gcc_eh.patch.cross
does not seem to be necessary.
Applying this patch causes the build of sln
to fail with
undefined references (related to _Unwind_*
).
Makefile
's of glibc do not seem to entirely
/bin/sh
-compatible (i.e. the original Bourne shell). Either
override the SHELL
variable of make
with a
different shell (e.g., /bin/bash
) or modify the
/bin/sh
symlink.
- After installation, create a symlink
/lib/cpp
which links
to /usr/bin/cpp
. A tool like rpcgen
expects a
cpp binary in /lib
.
- groff (1.19.2)
CPPFLAGS='-I/home/nfs/rootfs.unimatrix/usr/include'
LDFLAGS='-L/home/nfs/rootfs.unimatrix/lib -L/home/nfs/rootfs.unimatrix/usr/lib' ./configure
--build=alphaev67-unknown-linux-gnu --host=alphaev56-gomtuu-linux-gnu --prefix=/usr
--infodir=\${datadir}/info --mandir=\${datadir}/man --without-x
- Contains C++ sources, so specify
CXXFLAGS
. Also, may need
to specify --without-x
option for ./configure
since it will add /usr/include
directory by default. For
cross-compiling you may want to avoid that directory.
- gzip (1.3.9)
LDFLAGS='-L/home/nfs/rootfs.unimatrix/lib -L/home/nfs/rootfs.unimatrix/usr/lib'
CPPFLAGS='-I/home/nfs/rootfs.unimatrix/usr/include' ./configure
--build=alphaev67-unknown-linux-gnu --host=alphaev56-gomtuu-linux-gnu --prefix=/usr
--bindir=/bin
- May need to rename function
futimens
in files
gzip.c
, lib/utimens.c
, and
lib/utimens.h
because its definition is incompatible with
glibc.
- inetutils (1.9.1)
LDFLAGS='-L/home/nfs/rootfs.unimatrix/lib -L/home/nfs/rootfs.unimatrix/usr/lib'
CPPFLAGS='-I/home/nfs/rootfs.unimatrix/usr/include' ./configure
--build=alphaev67-unknown-linux-gnu --host=alphaev56-gomtuu-linux-gnu --prefix=/usr
--disable-syslogd --disable-uucpd --disable-hostname --disable-ifconfig
--with-ncurses-include-dir=/home/nfs/rootfs.unimatrix/usr/include/ncurses
- No need to build
hostname
and ifconfig
(provided by net-tools); no need to build logger
(provided by
util-linux).
- man (1.6f)
- Check
conf_script
after configuring. Also added or adjusted
CPPFLAGS
, CFLAGS
and LDFLAGS
in
./man2html/Makefile
and ./src/Makefile
.
CPPFLAGS
isn't used in build rules, so substituted in
CFLAGS
.
- mpc (0.9)
LDFLAGS='-L/home/nfs/rootfs.unimatrix/lib -L/home/nfs/rootfs.unimatrix/usr/lib'
CPPFLAGS='-I/home/nfs/rootfs.unimatrix/usr/include' ./configure
--build=alphaev67-unknown-linux-gnu --host=alphaev56-gomtuu-linux-gnu --prefix=/usr
- In
libmpfr.la
(/usr/lib
) needed to prefix the
libgmp.la
dependency with appropriate rootfs directory (e.g.,
/home/nfs/rootfs.unimatrix
) in setting
dependency_libs
. Maybe fixed in newer libtool's (>=2.4.2)
since those would have support for cross-compilation
(--sysroot
option).
- module-init-tools (3.15)
LDFLAGS='-L/home/nfs/rootfs.unimatrix/lib -L/home/nfs/rootfs.unimatrix/usr/lib'
CPPFLAGS='-I/home/nfs/rootfs.unimatrix/usr/include' ../configure
--build=alphaev67-unknown-linux-gnu --host=alphaev56-gomtuu-linux-gnu --prefix=/usr
--bindir=/bin --sbindir=/sbin --disable-static-utils
- Commented man page files in variable
dist_man_MANS
(build/Makefile
). docbook2man
utility missing,i
so cannot generate man pages.
- net-tools (1.60)
- Pass
CC
variable to make
to set correct
compiler/linker. Added break
keyword to hostname.c
(line 100 & 119) and lib/inet_sr.c
(line 107); double-quoted
every line of the "usage" text of mii-tool.c
(382-392).
- patch
CPPFLAGS='-I/home/nfs/rootfs.unimatrix/usr/include'
LDFLAGS='-L/home/nfs/rootfs.unimatrix/lib -L/home/nfs/rootfs.unimatrix/usr/lib' ./configure
--build=alphaev67-unknown-linux-gnu --host=alphaev56-gomtuu-linux-gnu --prefix=/usr
--infodir=\${prefix}/share/info --mandir=\${prefix}/share/man
- Updated
config.guess
and config.sub
since
they did not recognize ev67 CPU.
- perl (5.16.1)
- Using a non-default install prefix (e.g.,
/opt/perl5
) may
not automatically change the man page directories, so you need to adjust
those directories in the config.sh
file and run
./Configure -S
, make depend
and finally
make
.
However, it may be better to archive the Policy.sh
file as it
can act as a site-wide config file. The Policy.sh
file can be
copied to the perl source directory and ./Configure
will
automatically fetch the settings from the file. Settings in
Policy.sh
are defined in the same way as in
config.sh
.
- Test suite fails on some (math) tests which, I suspect, is due to the
Alpha not being IEEE-compliant by default.
Confirmed: Adding -mieee
flag causes test suite to succeed.
- When using a non-standard installation directory (e.g.,
/opt/perl5
) it may be necessary to create a symlink to the
perl binary since certain scripts are using a hardcoded interpreter path
like "#!/usr/bin/perl
".
- procps (3.2.7)
- Specified
make
variables CC=alphaev...
when
building.
- psmisc (22.6)
LDFLAGS='-L/home/nfs/rootfs.unimatrix/lib -L/home/nfs/rootfs.unimatrix/usr/lib'
CPPFLAGS='-I/home/nfs/rootfs.unimatrix/usr/include' ./configure
--build=alphaev67-unknown-linux-gnu --host=alphaev56-gomtuu-linux-gnu --prefix=/usr
--disable-selinux --disable-nls
- Same
malloc
issues as flex
, used same
solution.
- shadow (4.0.15)
CPPFLAGS='-I/home/nfs/rootfs.unimatrix/usr/include'
LDFLAGS='-L/home/nfs/rootfs.unimatrix/lib -L/home/nfs/rootfs.unimatrix/usr/lib' ./configure
--build=alphaev67-unknown-linux-gnu --host=alphaev56-gomtuu-linux-gnu --prefix=/usr
--sysconfdir=/etc --infodir=\${datadir}/info --mandir=${datadir}/man --disable-nls
--without-audit --without-libpam --without-selinux
./configure
test for setpgrp
fails when
cross-compiling. set ac_cv_func_setpgrp_void=yes
.
- Moved the
groups
and su
utility from
bin_PROGRAMS
and ubin_PROGRAMS
to
noinst_PROGRAMS
. Also commented su
utility in
suidbins
variable.
- Removed man pages of
groups
, id
,
su
and sulogin
from man_MANS
variable and EXTRA_DIST
variable in man/Makefile
.
- sysvinit (2.86)
- Statically linked
sulogin
segfaults.
- Build target for
killall5
utility is missing, so copied
target of mountpoint
and changed filenames.
- udev (120)
- Static linking is an option, but does not work properly (see General
note). Linked
udev
dynamically.
- util-linux (2.20)
LDFLAGS='-L/home/nfs/rootfs.unimatrix/lib -L/home/nfs/rootfs.unimatrix/usr/lib'
CPPFLAGS='-I/home/nfs/rootfs.unimatrix/usr/include' ./configure
--build=alphaev67-unknown-linux-gnu --host=alphaev56-gomtuu-linux-gnu --prefix=/usr
--enable-static-programs=losetup,mount,umount,fdisk,sfdisk,blkid --disable-partx --disable-nls
--enable-arch --enable-ddate --disable-fallocate --disable-unshare --enable-line --enable-raw
--disable-rename --enable-write
./term-utils/agetty.c
- In
open_tty()
, the errors (2) logged when ioctl
TIOCSCTTY
fails ("cannot get controlling tty") changed to
logging warning messages. Same goes for error logged when
tcsetpgrp()
fails ("cannot set process group").
- vim (6.4)
- Specified environment variables for
CC
and
CPP
. Also, when cross-compiling, check
src/auto/config.mk
and remove
"-I/usr/local/include
" from CPPFLAGS
variable and
"-L/usr/local/lib
" from LDFLAGS
variable.
If changing installation directories, verify them in config.mk
!
If ncurses
is configured with --disable-overwrite
option, then ncurses
headers are stored in an
ncurses
sub-directory. In this case, src/term.c
may be using the wrong termcap.h
file (e.g., the one from
libtermcap
), so need to include ncurses/termcap.h
in src/term.c
instead of just termcap.h
.
DS20E
- glibc-ports & fxstatat.patch
- Results in build error when
--enable-kernel
is too low
(e.g., 2.6.0). You get an error like "`err' redefined ...".
No build error with --enable-kernel=2.6.25
.
- Booting NFS image (bootpfile) from SRM and specify os-flags
console=ttyS0 root=/dev/nfs rootfstype=nfs ip=bootp
nfsroot=<server-ip>:<root-dir>
- ntp (4.2.6p5) & SSL
- Without SSL support (i.e. libcrypto.so) you should
not let
ntp
generate cryptostats else it will simply
segfault. So, ensure the filegen
keyword for cryptostats is
comment out in ntp.conf
.
GBS
- ncurses (5.7)
- Ensure the host system uses the same version of ncurses as GBS is
building (i.e., the cross-compiled version). A problem may occur when
installing the cross-compiled version where the
tic
utility
on the host system hangs when building the terminfo database. I my case,
remnants of ncurses 5.6 seem to have been the culprit.
- Another problem that may occur is "undefined references" when building
for a second time but with a different configuration. This may only apply
to the utility programs (
tic
, toe
etc) and is
caused by an incorrect order of library search paths. GBS uses the
environment variable LDFLAGS
to pass library search paths of
the target installation. When ncurses
links a program such as
tic
, the paths on LDFLAGS
are searched first and
next the library paths in the ncurses
source tree. An obvious
fix would be to remove the ncurses
libraries from the target
installation before starting the second build. Alternatively, one could
first build and install the libraries by executing the targets
libs
and install.libs
of the main
Makefile
and subsequently execute the default target (i.e.,
all
). This way the proper libraries will already be present
on the target installation before the utility programs are built.
- perl (5.16.1)
- Cross-compilation breaks due to C++-style comment in header file
/usr/include/stdlib.h
and specific CFLAGS of perl
(-ansi
or -std=c89
). A native build, using the
same CFLAGS, doesn't appear to suffer from this problem. As a "workaround",
I've turned the C++-style comments into C-style comments.