Subject: Re: LC040 softfloat build of 1.6.1
To: None <tech-userlevel@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-userlevel
Date: 08/11/2003 14:48:07
In article <0HJG00DMIGZOCQ@mbx.unige.ch>,
Bruce ONeel <edoneel@sdf.lonestar.org> wrote:

Hi,

Can't you do a similar trick like we do for i387? I.e. build libm
by default without the m68881 assembly stuff, and then build a libm68881.so
and have that selected via /etc/ld.so.conf like i386 and alpha do it?
Yes you'll still need to build everything with soft-float enabled because
of the chip bugs, but at least libm will be handled in a sane way.
I suppose the rest of the softfloat changes to support 80 bit doubles
can just go in...

christos

>Hi,
>
>I've gotten 1.6.1 to build with -msoft-float so that it now
>runs correctly on mac68k LC040s.  This brings a lot of macs
>into to fold so that they can run NetBSD.
>
>All of the files (thanks to John Klos for the bandwidth) live
>at:
>ftp://reva.sixgirls.org/pub/NetBSD/m68k/
>
>You also can get them from http://edoneel.chaosnet.org/Downloads.html.
>
>The 1.6.1 build lives at:
>ftp://reva.sixgirls.org/pub/NetBSD/m68k/NetBSD-1.6.1-mac-lc040/
>
>The file named lc040-softfloat-20030806.tgz holds all of the
>changes to the 1.6.1 source tree that allow this all to work.
>The changes are all to the m68k code, none of them really
>matter what sub arch beyond that.  Ie, it should be the same
>if someone has say an amiga with a LC040.  That said, this build
>is for mac68k and I've only tested it there.
>
>A few notes:
>
>- fpgetround is known to be broken.  It will aways return 0.
>- The kernels have a slightly changed ams.c so that the PB500
>trackpad works.
>- I built the color xserver and it lives in xserver_color.tgz.  You
>have to hand install this.
>- The testing is limited.  I'm sending this from a pb540 with a
>LC040 and everything seems fine.  That does not qualify as 
>well tested though.
>
>Some background for those of you just brought into the conversation:
>
>Motorola produced the 68040 which, unlike earlier 68k chips, contained
>a built in FPU.  They also weren't thinking and produced an LC040,
>the same chip either with the FPU disabled or not present.  Apple built
>a lot of systems with the LC040 since from the Apple POV they
>already did FP emulation with SANE.
>
>NetBSD uses a FPemulator which works well on 020 and 030 systems
>which don't have a separate FPU.  This fp emulator does not work
>on the LC040 systems.  In some versions, a LC040 will not trap
>correctly when faced with a F instruction.  In other cases it seems
>to be possible to get the trap right and then emulate the instruction.
>In the mac world softfpu seems to manage this.  In neither
>case does NetBSD work correctly though.  The user symptom is
>that programs randomly bus error and segfault.  When I poke
>at it the stack seems messed up.
>
>My approach was the following.  Since gcc can generate fpu emulation
>calls rather than f instructions when presented with the flag 
>-msoft-float I build all of 1.6.1 with this flag.  Then I fixed some
>places in libc and libm so that the proper emulation routines were
>called.
>
>The file lc040-softfloat-20030806.tgz  when exploded over top 
>of a 1.6.1 source tree produces a source tree that if MKSOFTFLOAT
>is set builds with -msoft-float, else it builds normally.
>
>The good part here is that these binaries will work on any 020,
>030, 040, or lc040 mac.  The bad part is that 020 and 030 macs with
>external fpus, and full 040 macs will run fp instructions slower.  
>This is probably most noticable in libm.
>
>Next I'm off to do current.  Thanks again to John Klos for 
>a faast 68060 to build on!
>
>cheers
>
>bruce