Subject: Which compiler should I use to make mips64 kernel

From: "Guo Michael" <[email-masked]>
Date: Tue, 06 May 2003 14:54:52 +0800

Hello, I want to build mips64el kernel and downloaded the mips64el 
toolchain from ftp://ftp.ds2.pg.gda.pl/pub/macro/ (Maciej W. Rozycki's 
site) and I got following errors:
. scripts/mkversion > .tmpversion
mips64el-linux-gcc -D__KERNEL__ -I/home/michael/linux-working/linux/include 
-Wall -Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing 
-fno-common -fomit-frame-pointer -I 
/home/michael/linux-working/linux/include/asm/gcc -mabi=64 -G 0 
-mno-abicalls -fno-pic -Wa,--trap -pipe -mcpu=r4600 -mips3 -Wa,-32 
-Wa,-mgp64  -DUTS_MACHINE='"mips64"' -DKBUILD_BASENAME=version -c -o 
init/version.o init/version.c
make CFLAGS="-D__KERNEL__ -I/home/michael/linux-working/linux/include -Wall 
-Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common 
-fomit-frame-pointer -I /home/michael/linux-working/linux/include/asm/gcc 
-mabi=64 -G 0 -mno-abicalls -fno-pic -Wa,--trap -pipe -mcpu=r4600 -mips3 
-Wa,-32 -Wa,-mgp64 " -C  arch/mips/tools
make[1]: Entering directory 
`/home/michael/linux-working/linux/arch/mips/tools'
cmp -s offset.h 
/home/michael/linux-working/linux/include/asm-mips64/offset.h || (cp 
offset.h /home/michael/linux-working/linux/include/asm-mips64/offset.h.new 
&& mv /home/michael/linux-working/linux/include/asm-mips64/offset.h.new 
/home/michael/linux-working/linux/include/asm-mips64/offset.h)
make[1]: Leaving directory 
`/home/michael/linux-working/linux/arch/mips/tools'
make CFLAGS="-D__KERNEL__ -I/home/michael/linux-working/linux/include -Wall 
-Wstrict-prototypes -Wno-trigraphs -O2 -fno-strict-aliasing -fno-common 
-fomit-frame-pointer -I /home/michael/linux-working/linux/include/asm/gcc 
-mabi=64 -G 0 -mno-abicalls -fno-pic -Wa,--trap -pipe -mcpu=r4600 -mips3 
-Wa,-32 -Wa,-mgp64 " -C  kernel
make[1]: Entering directory `/home/michael/linux-working/linux/kernel'
make all_targets
make[2]: Entering directory `/home/michael/linux-working/linux/kernel'
rm -f kernel.o
mips64el-linux-ld  -r -o kernel.o sched.o dma.o fork.o exec_domain.o 
panic.o printk.o module.o exit.o itimer.o info.o time.o softirq.o 
resource.o sysctl.o acct.o capability.o ptrace.o timer.o user.o signal.o 
sys.o kmod.o context.o ksyms.o
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117
mips64el-linux-ld: Attempt to do relocateable link with 
elf32-tradlittlemips input and elf64-tradlittlemips output
mips64el-linux-ld: final link failed: File in wrong format
make[2]: *** [kernel.o] Error 1
make[2]: Leaving directory `/home/michael/linux-working/linux/kernel'
make[1]: *** [first_rule] Error 2
make[1]: Leaving directory `/home/michael/linux-working/linux/kernel'
make: *** [_dir_kernel] Error 2

Where should I get the right toolchain or how can I build one?

-Michael

_________________________________________________________________
与联机的朋友进行交流，请使用 MSN Messenger:  http://messenger.msn.com/cn

---

From: Ralf Baechle <[email-masked]>
Date: Tue, 6 May 2003 14:40:29 +0200

> mips64el-linux-ld: BFD 2.13.2.1 assertion fail elflink.h:5117

This is a known but not yet fixed problem that only seems to hit certain
kernel configurations; I believe it somehow tied to little endianess also.

  Ralf

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Tue, 6 May 2003 15:04:18 +0200 (MET DST)

> site) and I got following errors:

 My 64-bit binutils package has `ld' that assumes output is to be 64-bit
ELF.  When fed with 32-bit ELF objects such as these created by `as -32'
(as invoked when building the kernel) it should convert them to 64-bit on
the fly, but it wasn't really ever tested and doesn't work.  There are two
immediate ways to deal with that: 

1. Add "-m elf32ltsmip" or "-m elf32btsmip" (depending on the endianness) 
to `ld' invocation (there is a commented-out example how to do this in
arch/mips64/Makefile).  This is probably the simplest and safest way to
deal with the problem.  It could probably be added to the CVS to avoid
confusion. 

2. Build all objects as 64-bit.  This will enlarge the kernel noticeably
and possibly reveal bugs.  I have a patch (or maybe a hack) to enable such
a setup if you were really interested. 

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email-masked], PGP key available        +

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Thu, 8 May 2003 21:21:41 +0200 (MET DST)

> kernel configurations; I believe it somehow tied to little endianess also.

 This patch makes ld work for the kernel regardless of the default
emulation (output format).  What do you think?

patch-mips-2.4.21-pre4-20030505-mips64-ld-oformat-0
diff -up --recursive --new-file linux-mips-2.4.21-pre4-20030505.macro/arch/mips64/Makefile linux-mips-2.4.21-pre4-20030505/arch/mips64/Makefile
--- linux-mips-2.4.21-pre4-20030505.macro/arch/mips64/Makefile	2003-02-27 03:56:44.000000000 +0000
+++ linux-mips-2.4.21-pre4-20030505/arch/mips64/Makefile	2003-05-08 15:44:25.000000000 +0000
@@ -251,10 +251,20 @@ LINKFLAGS += -T arch/mips64/ld.script.el
 #LINKFLAGS += -T arch/mips64/ld.script.elf64
 endif
 
+ifdef CONFIG_CPU_LITTLE_ENDIAN
+32bit-bfd = elf32-tradlittlemips
+64bit-bfd = elf64-tradlittlemips
+else
+32bit-bfd = elf32-tradbigmips
+64bit-bfd = elf64-tradbigmips
+endif
+
 
 AFLAGS		+= $(GCCFLAGS)
 CFLAGS		+= $(GCCFLAGS)
 
+LD		+= --oformat $(32bit-bfd)
+
 
 LINKFLAGS += -Ttext $(LOADADDR)
 
@@ -266,12 +276,6 @@ LIBS := arch/mips64/lib/lib.a $(LIBS)
 
 MAKEBOOT = $(MAKE) -C arch/$(ARCH)/boot
 
-ifdef CONFIG_CPU_LITTLE_ENDIAN
-64bit-bfd = elf64-tradlittlemips
-else
-64bit-bfd = elf64-tradbigmips
-endif
-
 vmlinux: arch/mips64/ld.script.elf32
 arch/mips64/ld.script.elf32: arch/mips64/ld.script.elf32.S
 	$(CPP) -C -P -I$(HPATH) -imacros $(HPATH)/asm-mips64/sn/mapped_kernel.h -Umips arch/mips64/ld.script.elf32.S > arch/mips64/ld.script.elf32