Subject: sheb/shel toolchain problems?
To: None <port-dreamcast@netbsd.org, port-sh3@netbsd.org>
From: Andrew Gillham <gillham@vaultron.com>
List: port-dreamcast
Date: 02/03/2001 03:49:08
Hello,

I was not able to cross build a working toolchain.  The problems I would
run into were messages like "can't write a.out file" from 'as', and
BFD errors from 'ld'.

To get a working libbfd I hacked Makefile like this:
--- Makefile.save       Sat Feb  3 03:36:44 2001
+++ Makefile    Fri Jan 12 12:46:02 2001
@@ -178,7 +178,7 @@
 .else
 DEFAULT_VEC.sh3el=     shcoff_vec
 DEFAULT_VEC.sh3eb=     shcoff_vec
-SELECT_VECS+=          ${DEFAULT_VEC.sh3el} shlcoff_vec \
+SELECT_VECS+=          ${DEFAULT_VEC.sh3} shlcoff_vec \
                        bfd_elf32_shunx_vec bfd_elf32_shlunx_vec
 .endif
 SRCS+=                 cpu-sh.c sh-dis.c \

This seemed to fix the problem with 'as', since it appeared to be trying
to use a BFD format that wasn't there or something.

For ld.new, I make the following change to Makefile:
--- Makefile    Fri Jan 12 12:47:33 2001
+++ Makefile.save       Sat Feb  3 03:40:14 2001
@@ -14,6 +14,8 @@
     (${MACHINE_ARCH} == "mipsel") || \
     (${MACHINE_ARCH} == "powerpc") || \
     (${MACHINE_ARCH} == "sh3") || \
+    (${MACHINE_ARCH} == "sh3el") || \
+    (${MACHINE_ARCH} == "sh3eb") || \
     (${MACHINE_ARCH} == "sparc" && defined(ELF_PLEASE))
 PROG=          ld
 MAN=           ld.1
@@ -76,11 +78,13 @@
 DEFAULT_EMUL.powerpc=  elf32ppc

 ##### sh3 #####
+EMULS.sh3el=           shunx shlunx elf32shunx elf32shlunx
 EMULS.sh3=             shunx shlunx elf32shunx elf32shlunx
 .if defined(ELF_PLEASE)
 DEFAULT_EMUL.sh3=      elf32shunx
 .else
-DEFAULT_EMUL.sh3=      shunx
+DEFAULT_EMUL.sh3=      shlunx
+DEFAULT_EMUL.sh3el=    shlunx
 .endif

 ##### sparc #####

This got me to a working 'ld' also, but neither patch is exactly
right.  I think there needs to be a check for sh3eb .vs. sh3el.
Also, gas appears to default to big endian, which ends up requiring
a '-Wa,-little' argument to gcc.  Should some patch be added to the
build to default to little endian?

Anyway, I am trying to get my dreamcast to be self-hosting, so the
toolchain is kind of important. :-)  The cross compile tools work
pretty nicely, but it appears nobody is using sh3el yet to selfhost?

-Andrew