Subject: port-m68k/25086: -msoft-float patch such that LC040s work in Mac68k
To: None <gnats-bugs@gnats.netbsd.org>
From: None <edoneel@sdf.lonestar.org>
List: netbsd-bugs
Date: 04/07/2004 07:39:55
>Number:         25086
>Category:       port-m68k
>Synopsis:       Allows netbsd release 2.0 to run on LC040s
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-m68k-maintainer
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 07 11:41:00 UTC 2004
>Closed-Date:
>Last-Modified:
>Originator:     Bruce O'neel
>Release:        NetBSD 2.0 Beta from 2004 Apr 3
>Organization:
	
	None
>Environment:
	
	
System: NetBSD lain.ziaspace.com 1.6.2_STABLE NetBSD 1.6.2_STABLE (LAIN-$Revision: 1.633 $) #0: Thu Apr 1 10:16:07 EST 2004 john@lain.ziaspace.com:/usr/src/sys/arch/macppc/compile/LAIN macppc
Architecture: m68k
Machine: mac68k
>Description:
	
	Currently netbsd/Mac68k boots and runs on LC040s, but, it runs badly.  Many
	programs (ls -l, top, ps) "randomly" segfault/bus error seemingly because the FP
	emulator and LC040s are unhappy together.

	This patch changes the build so that -msoft-float is used throughout.  This means
	that gcc does not generate f instructions but calls subroutines to do FP work.
	This produces a working NetBSD on LC040s which also run on 030s (and probably 020s) 
	without FPUs.  Though untested it should run correctly on systems with FPUs.

	Setenving MKSOFTFLOAT to "yes" causes the soft-float build to happen.
	Unsetenving MKSOFTFLOAT causes the origional build to happen.
>How-To-Repeat:
	
	Find a LC040 mac, boot netbsd.  Watch the core files drop around the system.
	Apply this patch to NetBSD 2.0 beta from 2004 Apr 3 and rebuild.  Note that the
	core files have gone away.
>Fix:
	

	
Index: lib/libc/arch/m68k/Makefile.inc
===================================================================
RCS file: /cvsroot/src/lib/libc/arch/m68k/Makefile.inc,v
retrieving revision 1.9
diff -r1.9 Makefile.inc
1c1
< #	$NetBSD: Makefile.inc,v 1.9 2003/09/22 14:42:02 cl Exp $
---
> #	$NetBSD: Makefile.inc,v 1.7 1999/01/15 13:31:18 bouyer Exp $
11c11,15
< SRCS+=	__sigaction14_sigtramp.c __sigtramp1.S __sigtramp2.S
---
> .if ${MKSOFTFLOAT} != "no"
> CPPFLAGS+= -DSOFTLOFLOAT_NEED_FIXUNS -DSOFTFLOAT
> .include <softfloat/Makefile.inc>
> .endif
> SRCS+=        __sigaction14_sigtramp.c __sigtramp1.S __sigtramp2.S
Index: lib/libc/arch/m68k/gen/Makefile.inc
===================================================================
RCS file: /cvsroot/src/lib/libc/arch/m68k/gen/Makefile.inc,v
retrieving revision 1.24
diff -r1.24 Makefile.inc
33c33,34
< .if	${MACHINE_ARCH} == "m68000"
---
> .if	(${MACHINE_ARCH} == "m68000" || ${MKSOFTFLOAT} == "yes")
> # BEO 4 Aug 2003, the flt_rounds_softfloat_lc040.S is broken
35c36
< SRCS+=	flt_rounds_softfloat.S
---
> SRCS+=	flt_rounds_softfloat_lc040.S
54a56,57
> .elifdef MKSOFTFLOAT
> SRCS+=	ldexp_ieee754.c			# generic ieee754 version
Index: lib/libc/softfloat/softfloat-specialize
===================================================================
RCS file: /cvsroot/src/lib/libc/softfloat/softfloat-specialize,v
retrieving revision 1.3
diff -r1.3 softfloat-specialize
107c107
< static
---
> /* static */
206c206
< static
---
> /* static */
Index: lib/libc/softfloat/softfloat-for-gcc.h
===================================================================
RCS file: /cvsroot/src/lib/libc/softfloat/softfloat-for-gcc.h,v
retrieving revision 1.6
diff -r1.6 softfloat-for-gcc.h
1c1
< /* $NetBSD: softfloat-for-gcc.h,v 1.6 2003/07/26 19:24:51 salo Exp $ */
---
> /* $NetBSD: softfloat-for-gcc.h,v 1.5 2002/05/12 13:12:45 bjh21 Exp $ */
5c5
<  * namespace.  -- Klaus Klein <kleink@NetBSD.org>, May 5, 1999
---
>  * namespace.  -- Klaus Klein <kleink@netbsd.org>, May 5, 1999
24a25
> #define floatx80_add			__addxf3
26a28
> #define floatx80_sub			__subxf3
28a31
> #define floatx80_mul			__mulxf3
30a34
> #define floatx80_div			__divxf3
32a37
> #define int32_to_floatx80		__floatsixf
34a40
> #define int64_to_floatx80		__floatdixf
36a43
> #define floatx80_to_int32_round_to_zero __fixxfsi
38a46
> #define floatx80_to_int64_round_to_zero __fixxfdi
41a50,51
> #define float64_to_floatx80		__extenddfxf2
> #define float32_to_floatx80		__extendsfxf2
42a53,58
> #define floatx80_to_float64		__truncxfdf2
> #define floatx80_to_float32		__truncxfsf2
> 
> #define floatx80_lt			__ltxf2
> #define floatx80_eq			__eqxf2
> #define floatx80_le			__lexf2
Index: lib/libc/softfloat/Makefile.inc
===================================================================
RCS file: /cvsroot/src/lib/libc/softfloat/Makefile.inc,v
retrieving revision 1.3
diff -r1.3 Makefile.inc
1c1
< #	$NetBSD: Makefile.inc,v 1.3 2003/05/06 08:58:20 rearnsha Exp $
---
> #	$NetBSD: Makefile.inc,v 1.2 2002/05/21 23:51:05 bjh21 Exp $
17c17,18
< 		unordsf2.c unorddf2.c
---
> 			nexf2.c gtxf2.c gexf2.c                 negxf2.c \
> 			 unordsf2.c unorddf2.c
Index: lib/libm/Makefile
===================================================================
RCS file: /cvsroot/src/lib/libm/Makefile,v
retrieving revision 1.59
diff -r1.59 Makefile
1c1
< #  $NetBSD: Makefile,v 1.59 2002/06/15 00:13:07 matt Exp $
---
> #  $NetBSD: Makefile,v 1.58.2.1 2002/06/18 13:30:14 lukem Exp $
80a81
> .if (${MKSOFTFLOAT} != "yes")
86a88
> .endif
Index: sys/arch/mac68k/mac68k/machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mac68k/mac68k/machdep.c,v
retrieving revision 1.297
diff -r1.297 machdep.c
425,426c425,426
< 	if (fputype != FPU_NONE)
< 		m68k_make_fpu_idle_frame();
---
> 	/* if (fputype != FPU_NONE)
> 		m68k_make_fpu_idle_frame(); */
	cvs diff: I know nothing about lib/libc/arch/m68k/gen/flt_rounds_softfloat_lc040.S
	cvs diff: I know nothing about lib/libc/softfloat/negxf2.c
	cvs diff: I know nothing about lib/libc/softfloat/nexf2.c
	cvs diff: I know nothing about lib/libc/softfloat/gtxf2.c
	cvs diff: I know nothing about lib/libc/softfloat/gexf2.c

	For the files that cvs knowns nothing about one can find the complete
	patch tar file in 

	http://edoneel.chaosnet.org/download/NetBSD-current/lc040-softfloat-20040218.tar.gz


>Release-Note:
>Audit-Trail:
>Unformatted: