Subject: New toolchain for Linux/mips

From: "H . J . Lu" <[email-masked]>
Date: Tue, 5 Jun 2001 22:06:05 -0700

I have a new toolchain for Linux/mips, which consists of gcc 2.96 and
glibc 2.2 from RedHat 7.1 as well as my current binutils. I have used
it to compile RedHat 7.1 to Linux/mipsel. I have built all RedHat 7.1
rpms necessary, except for X related, to boot up RedHat 7.1 on
Linux/mipsel:

# telnet xxxx
.....
Escape character is '^]'.

Red Hat Linux release 7.1 (Seawolf)
Kernel 2.4.3 on a mips
login: 

My toolchain should be as capable as the x86 version in RedHat 7.1.
But I do have 2 issues:

1. I got quite a few C++ exception execution failures from "make check"
in gcc 2.96. But I got more C++ exception execution failures on
IRIX 6.5. I guess the bugs are in gcc and/or binutils.
2. gdb in RedHat 7.1 has yet to be ported to mips. Without a working
gdb, it is very hard to fix 1.

I'd like to fold back my mips changes to gcc, glibc and binutils.
Before I submit my changes, I'd like to get them checked out by the
Linux/mips experts and users, especially on big endian mips. It will
also be nice to have a working gdb and reliable C++ exception.

Is there anyone interested in my new mips toolchain? Is there anyone
interested in fixing gdb and C++ exception?

H.J.

---

From: Ralf Baechle <[email-masked]>
Date: Wed, 6 Jun 2001 08:22:44 +0200

On Tue, Jun 05, 2001 at 10:06:05PM -0700, H . J . Lu wrote:

> Is there anyone interested in my new mips toolchain?

Definately.

> Is there anyone interested in fixing gdb and C++ exception?

We're definately interested and are painfully aware of shortcomings in
those areas.  Alone the limitation of days to just 48h so far has prevented
us from fixing it.

  Ralf

---

From: Geert Uytterhoeven <[email-masked]>
Date: Wed, 6 Jun 2001 09:29:57 +0200 (MET DST)

> those areas.  Alone the limitation of days to just 48h so far has prevented
                                                     ^^^
> us from fixing it.

You're a lucky guy! Wished mine were that long, too... :-)

Gr{oetje,eeting}s,

						Geert

--
Geert Uytterhoeven ------------- Sony Software Development Center Europe (SDCE)
[email-masked] ------------------- Sint-Stevens-Woluwestraat 55
Voice +32-2-7248626 Fax +32-2-7262686 ---------------- B-1130 Brussels, Belgium

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Wed, 6 Jun 2001 12:44:04 +0200 (MET DST)

> gdb, it is very hard to fix 1.

 Gdb 5.0 works for me (and a few other people, I think).  Check
'ftp://ftp.ds2.pg.gda.pl/pub/macro/SRPMS/gdb-5.0-6.src.rpm'.  Most of the
patches have been submitted.  The only remaining one is the port of 4.17
changes from oss that needs copyright assignments from its authors.  There
might be a few insignificant issues remaining (I think "next" and "nexti"
don't work properly), but this is the version of gdb that helped me very,
very much to debug a few quirks in MIPS/Linux ld.so during glibc's 2.1.9x
development stage. 

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

---

From: "H . J . Lu" <[email-masked]>
Date: Wed, 6 Jun 2001 07:15:25 -0700

> patches have been submitted.  The only remaining one is the port of 4.17

This is a very old gdb. Since gdb has changed a lot at the same
time, if the patches haven't been installed, we may have to redo them.
I'd like to see Linux/mips as a supported target in gdb. gdb in RedHat
7.1 is quite current. Also, my new toolchain uses stabs, not ecoff.
It may need some work.

H.J.

---

From: "H . J . Lu" <[email-masked]>
Date: Wed, 6 Jun 2001 09:08:16 -0700

On Wed, Jun 06, 2001 at 05:47:08PM +0200, Maciej W. Rozycki wrote:
> 
>  So the success ratio is 1/4 and for two trivial patches only -- not much
> encouraging for me for further work, especially as what I have now works
> for me quite well.  Feel free to look at the stuff -- I might check it as
> well, but I can't afford spending much time on it at the moment, sorry. 

There are many changes in gdb, especially in thread and C++ supports.
We need those on mips also. I am willing to spend my time. But I need
some help. I don't know much about mips :-(.

I'd like to get gdb working first. Do you have time to answer some
questions?

Thanks.

H.J.

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Wed, 6 Jun 2001 17:47:08 +0200 (MET DST)

> time, if the patches haven't been installed, we may have to redo them.

 If things were easy the patches would already have been installed.  I
submitted the ones I wrote myself a year ago -- they were current then.  I
believe most, if not all of them got applied.  The oss one was not
submitted as I had troubles finding out who were all the authors (my
changes were rather cosmetic -- I tried to separate work into different
patches).  The patch is named "gdb-5.0-mips-linux.patch.gz" in my package. 

 Finally I found out Dave Miller was the author of most of the patch (his
name appears on a few files, but not all of them).  Unfortunately, this
was much, much later -- at the beginning of this year. The CVS of gdb
changed meanwhile and my time constraints didn't allow me to check what
needed to be updated.  Therefore there was no point to bother Dave about a
copyright assignment without updating the patch and making sure it'll get 
applied. 

 I believe it's still the best idea to port the patch instead of starting
from scratch.  I've already ported it from 4.17 to 5.0 and it took no more
than a few days.  Porting to current shouldn't be much more difficult or
time-consuming.  I'd be pleased to do this work, yet I'm not sure I can
afford doing it now.  If you look at my spec file, there is a somewhat
detailed change log, which explains the most significant changes.  The
"mips-linux" patch is quite small -- about 20kB and mostly adds new files,
so it should be quite trivial to port. 

> 7.1 is quite current. Also, my new toolchain uses stabs, not ecoff.

 Since I have a current gdb snapshot handy I checked all the patches I
have against it.  Here are the results: 

1. readline -- non-MIPS/Linux specific; a single hunk fails.  Unimportant
but linking against local readline statically is evil. 

2. ulfc-mips -- fails for a number of hunks but already present in the
current BFD; supposedly gdb shares it with binutils on sourceware. 

3. gdbserver -- non-MIPS/Linux specific; applies cleanly -- I'll submit
it, but it might need a semantics validity check. 

4. mips-linux -- important; two hunks fail and needs a semantics validity
check. 

5. sim-install -- applied. 

6. core-xregset -- necessary for core file analysis; one hunk fails.  It
might not be needed though, since I was told the generic core file
handling code was to be rewritten.

7. sim-mips-clean -- applied. 

8. so-lmstart -- crucial for shared library handling; fails completely --
maybe unneeded (there was a base address vs load address confusion in
gdb's generic shlib handling code). 

9. sign-extend -- crucial for shared library handling; fails partially. 

10. mips-branch-predict -- necessary for placing breakpoints after
branches; fails partially -- no idea why it wasn't applied as what is
already ther is completely broken. 

  Maciej

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Wed, 6 Jun 2001 19:48:24 +0200 (MET DST)

> some help. I don't know much about mips :-(.

 It would be nice to have at least basic C support in mainline. 

> I'd like to get gdb working first. Do you have time to answer some

 I often have time to write mails (but I don't have most of my development
resources here).  Feel free to ask -- I'll try to answer as I can.  I
haven't been into MIPS/Linux development tools for some time now, since
they are mostly working for me, so my memory might be vague.  I'm working
on the kernel mostly these days -- my primary goal is to find out why
Linux crashes hard when building binutils natively on my DECstation (the
progress is at a snail speed, unfortunately). 

  Maciej

---

From: Daniel Jacobowitz <[email-masked]>
Date: Wed, 6 Jun 2001 11:00:19 -0700

> progress is at a snail speed, unfortunately). 

I've actually spent this week porting the gdb CVS head to MIPS; I've
got it almost entirely working now.  There's one problem with SIGTRAP
that I haven't quite figured out yet, and thread attach isn't quite
working, and there's a kernel bug I've been repeatedly triggering that
I think I just fixed.  I anticipate it all being done in a couple of
days - I'll post here and on the GDB list when I have it in slightly
better shape.

-- 
Daniel Jacobowitz                           Debian GNU/Linux Developer
Monta Vista Software                              Debian Security Team

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Wed, 6 Jun 2001 20:40:07 +0200 (MET DST)

> got it almost entirely working now.  There's one problem with SIGTRAP

 Make sure your kernel is flushing the icache right. 

> days - I'll post here and on the GDB list when I have it in slightly

 Great!  Did you do you work from scratch -- hopefully not?

---

From: "H . J . Lu" <[email-masked]>
Date: Wed, 6 Jun 2001 13:19:59 -0700

> they are mostly working for me, so my memory might be vague.  I'm working

As far as I can tell, all the currently available Linux/mips binutils
are broken. I am working on fixing it.

H.J.

---

From: Daniel Jacobowitz <[email-masked]>
Date: Wed, 6 Jun 2001 13:24:02 -0700

>  Make sure your kernel is flushing the icache right. 

Hmm, thanks, I'll check.  I don't think that's it, though.

>  Great!  Did you do you work from scratch -- hopefully not?

Nope.  It's based mostly on the same 4.17 patch from David Miller, and
some bits from Ralf, all marked as assigned to the FSF (though I'm not
sure if that ever actually happened); I'll straighten out copyright
once I've got the whole thing done.

---

From: Ralf Baechle <[email-masked]>
Date: Wed, 6 Jun 2001 23:09:09 +0200

> once I've got the whole thing done.

The FSF already has a copyright assignment for my GDB work however David
to my knowledge never assigned his code to the FSF nor as he did this
work during his internship at SGI do I know if SGI still has any rights
on his work.  Unfortunately by now I fear David's and my work is tangled
in a way that we won't be able to distinguish who wrote what to the degree
required by the FSF ...

David, can you comment?

  Ralf

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Thu, 7 Jun 2001 12:37:27 +0200 (MET DST)

> Hmm, thanks, I'll check.  I don't think that's it, though.

 This happened to me once.  Otherwise, it looks like gdb doesn't recognize
a breakpoint for some reason -- possibly it places it at a wrong address. 
It shouldn't be difficult to debug -- you get information of the address
the trap happened. 

> once I've got the whole thing done.

 You need to contact David, then.

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Thu, 7 Jun 2001 12:32:27 +0200 (MET DST)

> are broken. I am working on fixing it.

 That depends on how you define "broken".  All software has bugs.  What I
currently use is sufficient to build working Linux 2.4.x, glibc 2.2.x as
well as all programs I built up to date.  I haven't tried C++, I admit. 
Libstdc++ of gcc 2.95.3 compiles fine, but I have not used it so far, so I
have no idea if the binary works. 

 If you know of particular problems, you are welcomed to fix them, of
course.

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Thu, 7 Jun 2001 12:37:27 +0200 (MET DST)

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Thu, 7 Jun 2001 12:37:27 +0200 (MET DST)

---

From: "H . J . Lu" <[email-masked]>
Date: Thu, 7 Jun 2001 09:28:28 -0700

>  If you know of particular problems, you are welcomed to fix them, of

See my post on the binutils mailing list. I have reason to believe
that it also misassembles the mips kernel with certain configuration.

H.J.

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Thu, 7 Jun 2001 19:03:08 +0200 (MET DST)

> that it also misassembles the mips kernel with certain configuration.

 I've seen them.  Unfortunately I'm far from being a BFD expert, so it's
not immediately obvious to me whether your fixes are fine or not.  And I
can't dig into BFD at the moment.  Just make sure your changes adhere to
the ELF ABI, both the generic part and the MIPS supplement. 

 Also note I can only run-time test MIPS I, so if there is something wrong
with higher ISAs, I wouldn't even notice unless I happen to study a
dissassembly of affected code.

 The kernel crashes for me weirdly from time to time, indeed.  I have a
reproducible test case as well.  I don't speak up on details, though, as I
now have outdated binutils as well as the kernel I'm running is still
2.4.0-test12.  Any conclusions will be sent to the list once collected and
if relevant to current versions, of course.

---

From: Daniel Jacobowitz <[email-masked]>
Date: Thu, 7 Jun 2001 12:17:41 -0700

> It shouldn't be difficult to debug -- you get information of the address

Wouldn't you hope?  No such luck.

Program received signal SIGTRAP, Trace/breakpoint trap.
[Switching to Thread 1024 (LWP 89)]
0x00000000 in ?? ()

I blame the threads handling, which I'm only about half through
debugging.

>  You need to contact David, then.

Yep, I'm going to do that.

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Thu, 7 Jun 2001 21:35:57 +0200 (MET DST)

> [Switching to Thread 1024 (LWP 89)]

 Then patch your kernel to display the address.  It's trivial.  See
do_bp() in arch/mips/kernel/traps.c. 

> I blame the threads handling, which I'm only about half through

 Ah, threads...  They might be completely non-fuctional on MIPS/Linux. 
I've never run threaded programs on MIPS/Linux, but such trivial users as
ls appear to work.

---

From: Daniel Jacobowitz <[email-masked]>
Date: Thu, 7 Jun 2001 12:41:52 -0700

> do_bp() in arch/mips/kernel/traps.c. 

Good idea.  Thanks.

> I've never run threaded programs on MIPS/Linux, but such trivial users as

They work, with a couple of kernel patches and a couple of library
patches.  I'm sorting through them right now.