[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [Pcc] First cut of m68k support.



Anders Magnusson dixit:

> I have just added the beginning of 68k support.

I have just added Linux/m68k support to it (initial, untested),
done on a Debian unstable/m68k system ;)

> It can generate enough code to put out "Hello world", which means that the
> remaining to add it almost only instructions :-)

Not for me:

root@ara4:~ # cat hw.c
#include <sys/types.h>
#include <unistd.h>

static const char msg[] = "Hello, World!\n";

int
main(void)
{
        write(1, msg, 14);
        return (0);
}
root@ara4:~ # /opt/pcc/bin/pcc -c hw.c
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 81: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 83: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 83: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 83: warning: shift larger than type
/usr/include/m68k-linux-gnu//bits/byteswap.h, line 83: warning: shift larger than type
hw.c, line 9: compiler error: Cannot generate code, node 0x80062c54 op FUNARG
/opt/pcc/libexec/ccom terminated with status 1


Please share your testcase, so I can test better ☻

bye,
//mirabilos
-- 
22:20⎜<asarch> The crazy that persists in his craziness becomes a master
22:21⎜<asarch> And the distance between the craziness and geniality is
only measured by the success 18:35⎜<asarch> "Psychotics are consistently
inconsistent. The essence of sanity is to be inconsistently inconsistent
Index: configure
===================================================================
RCS file: /cvsroot/pcc/configure,v
retrieving revision 1.105
diff -u -p -r1.105 configure
--- configure	9 Mar 2014 09:34:20 -0000	1.105
+++ configure	23 Mar 2014 21:55:37 -0000
@@ -2389,6 +2389,7 @@ case "$target_os" in
 	    i?86) targmach=i386 ;;
 	    powerpc*) targmach=powerpc endian=big ;;
 	    x86_64) targmach=amd64 ;;
+	    m68k*) targmach=m68k endian=big ;;
 	    mipseb) targmach=mips endian=big ;;
 	    mips*) targmach=mips ;;
 	esac
Index: configure.ac
===================================================================
RCS file: /cvsroot/pcc/configure.ac,v
retrieving revision 1.122
diff -u -p -r1.122 configure.ac
--- configure.ac	9 Mar 2014 09:34:20 -0000	1.122
+++ configure.ac	23 Mar 2014 21:55:37 -0000
@@ -97,6 +97,7 @@ case "$target_os" in
 	    i?86) targmach=i386 ;;
 	    powerpc*) targmach=powerpc endian=big ;;
 	    x86_64) targmach=amd64 ;;
+	    m68k*) targmach=m68k endian=big ;;
 	    mipseb) targmach=mips endian=big ;;
 	    mips*) targmach=mips ;;
 	esac
Index: cc/cc/cc.c
===================================================================
RCS file: /cvsroot/pcc/cc/cc/cc.c,v
retrieving revision 1.264
diff -u -p -r1.264 cc.c
--- cc/cc/cc.c	20 Mar 2014 18:48:05 -0000	1.264
+++ cc/cc/cc.c	23 Mar 2014 21:55:40 -0000
@@ -187,6 +187,9 @@ char	*sysroot = "", *isysroot;
 /* preprocessor stuff */
 #ifndef STDINC
 #define	STDINC	  	"/usr/include/"
+#else
+/* remove Multi-Arch include path when user passed altincdir */
+#undef STDINC2
 #endif
 
 char *cppadd[] = CPPADD;
@@ -1628,6 +1631,9 @@ setup_cpp_flags(void)
 	/* Include dirs */
 	strlist_append(&sysincdirs, "=" INCLUDEDIR "pcc/");
 	strlist_append(&sysincdirs, "=" STDINC);
+#ifdef STDINC2
+	strlist_append(&sysincdirs, "=" STDINC2);
+#endif
 #ifdef PCCINCDIR
 	if (cxxflag)
 		strlist_append(&sysincdirs, "=" PCCINCDIR "/c++");
Index: os/linux/ccconfig.h
===================================================================
RCS file: /cvsroot/pcc/os/linux/ccconfig.h,v
retrieving revision 1.25
diff -u -p -r1.25 ccconfig.h
--- os/linux/ccconfig.h	12 Dec 2012 17:45:23 -0000	1.25
+++ os/linux/ccconfig.h	23 Mar 2014 21:55:40 -0000
@@ -2,6 +2,7 @@
 
 /*
  * Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se).
+ * Copyright (c) 2014 Thorsten "mirabilos" Glaser <tg@debian.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -48,6 +49,15 @@
 	"-D__amd64", "-D__LP64__", "-D_LP64", NULL, }
 #define	DYNLINKER { "-dynamic-linker", "/lib64/ld-linux-x86-64.so.2", NULL }
 #define	DEFLIBDIRS	{ "/usr/lib64/", 0 }
+#elif defined(mach_m68k)
+#define CPPMDADD	{ "-D__m68k__", "-D__HAVE_68881__", \
+	"-D__mc68000", "-D__mc68000__", "-Dmc68000", \
+	"-D__mc68020", "-D__mc68020__", "-Dmc68020", \
+	NULL }
+#define DYNLINKER	{ "-dynamic-linker", "/lib/ld.so.1", NULL }
+/* support Multi-Arch */
+#define DEFLIBDIRS	{ "/usr/lib/m68k-linux-gnu", "/usr/lib", NULL }
+#define STDINC2		"/usr/include/m68k-linux-gnu/"
 #elif defined(mach_mips)
 #define CPPMDADD { "-D__mips__", NULL, }
 #define DYNLINKER { "-dynamic-linker", "/lib/ld.so.1", NULL }
? csu/linux/m68k
Index: configure
===================================================================
RCS file: /cvsroot/pcc-libs/configure,v
retrieving revision 1.17
diff -u -p -r1.17 configure
--- configure	30 Aug 2012 17:42:30 -0000	1.17
+++ configure	23 Mar 2014 21:57:06 -0000
@@ -1955,6 +1955,7 @@ case "$target_os" in
 	targos=linux
 	case "$target_cpu" in
 	    i?86) targmach=i386 ;;
+	    m68k*) targmach=m68k endian=big ;;
 	    powerpc*) targmach=powerpc endian=big ;;
 	    x86_64) targmach=amd64 ;;
 	esac
Index: configure.ac
===================================================================
RCS file: /cvsroot/pcc-libs/configure.ac,v
retrieving revision 1.17
diff -u -p -r1.17 configure.ac
--- configure.ac	30 Aug 2012 17:42:30 -0000	1.17
+++ configure.ac	23 Mar 2014 21:57:06 -0000
@@ -46,6 +46,7 @@ case "$target_os" in
 	targos=linux
 	case "$target_cpu" in
 	    i?86) targmach=i386 ;;
+	    m68k*) targmach=m68k endian=big ;;
 	    powerpc*) targmach=powerpc endian=big ;;
 	    x86_64) targmach=amd64 ;;
 	esac
Index: libsoftfloat/softfloat-specialize
===================================================================
RCS file: /cvsroot/pcc-libs/libsoftfloat/softfloat-specialize,v
retrieving revision 1.1
diff -u -p -r1.1 softfloat-specialize
--- libsoftfloat/softfloat-specialize	20 May 2008 05:29:07 -0000	1.1
+++ libsoftfloat/softfloat-specialize	23 Mar 2014 21:57:07 -0000
@@ -203,8 +203,8 @@ Returns 1 if the double-precision floati
 NaN; otherwise returns 0.
 -------------------------------------------------------------------------------
 */
-#if defined(SOFTFLOAT_FOR_GCC) && !defined(SOFTFLOATSPARC64_FOR_GCC) && \
-    !defined(SOFTFLOATM68K_FOR_GCC)
+#if 0 /*XXX defined(SOFTFLOAT_FOR_GCC) && !defined(SOFTFLOATSPARC64_FOR_GCC) && \
+    !defined(SOFTFLOATM68K_FOR_GCC)*/
 static
 #endif
 flag float64_is_signaling_nan( float64 a )
Index: libsoftfloat/arch/m68k/ieeefp.h
===================================================================
RCS file: libsoftfloat/arch/m68k/ieeefp.h
diff -N libsoftfloat/arch/m68k/ieeefp.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ libsoftfloat/arch/m68k/ieeefp.h	23 Mar 2014 21:57:07 -0000
@@ -0,0 +1,49 @@
+/* 
+ * Written by J.T. Conklin, Apr 6, 1995
+ * Modified by Jason R. Thorpe, June 22, 2003
+ * Public domain.
+ */
+
+#ifndef _M68K_IEEEFP_H_
+#define _M68K_IEEEFP_H_
+
+typedef int fenv_t;
+typedef int fexcept_t;
+
+#define	FE_INEXACT	0x01	/* imprecise (loss of precision) */
+#define	FE_DIVBYZERO	0x02	/* divide-by-zero exception */
+#define	FE_UNDERFLOW	0x04	/* overflow exception */
+#define	FE_OVERFLOW	0x08	/* underflow exception */
+#define	FE_INVALID	0x10	/* invalid operation exception */
+
+#define	FE_ALL_EXCEPT	0x1f
+
+#define	FE_TONEAREST	0	/* round to nearest representable number */
+#define	FE_TOWARDZERO	1	/* round to zero (truncate) */
+#define	FE_DOWNWARD	2	/* round toward negative infinity */
+#define	FE_UPWARD	3	/* round toward positive infinity */
+
+typedef int fp_except;
+
+#define FP_X_IMP	FE_INEXACT	/* imprecise (loss of precision) */
+#define FP_X_DZ		FE_DIVBYZERO	/* divide-by-zero exception */
+#define FP_X_UFL	FE_UNDERFLOW	/* underflow exception */
+#define FP_X_OFL	FE_OVERFLOW	/* overflow exception */
+#define FP_X_INV	FE_INVALID	/* invalid operation exception */
+
+typedef enum {
+    FP_RN=FE_TONEAREST,		/* round to nearest representable number */
+    FP_RZ=FE_TOWARDZERO,	/* round to zero (truncate) */
+    FP_RM=FE_DOWNWARD,		/* round toward negative infinity */
+    FP_RP=FE_UPWARD		/* round toward positive infinity */
+} fp_rnd;
+
+typedef enum {
+    FP_PE=0,			/* extended-precision (64-bit) */
+    FP_PS=1,			/* single-precision (24-bit) */
+    FP_PD=2			/* double-precision (53-bit) */
+} fp_prec;
+
+#define	__HAVE_FP_PREC
+
+#endif /* _M68K_IEEEFP_H_ */
Index: libsoftfloat/arch/m68k/m68k-gcc.h
===================================================================
RCS file: /cvsroot/pcc-libs/libsoftfloat/arch/m68k/m68k-gcc.h,v
retrieving revision 1.1
diff -u -p -r1.1 m68k-gcc.h
--- libsoftfloat/arch/m68k/m68k-gcc.h	20 May 2008 05:29:07 -0000	1.1
+++ libsoftfloat/arch/m68k/m68k-gcc.h	23 Mar 2014 21:57:07 -0000
@@ -5,13 +5,7 @@
 One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined.
 -------------------------------------------------------------------------------
 */
-#include <machine/endian.h>
-#if _BYTE_ORDER == _BIG_ENDIAN
 #define BIGENDIAN
-#endif
-#if _BYTE_ORDER == _LITTLE_ENDIAN
-#define LITTLEENDIAN
-#endif
 
 /*
 -------------------------------------------------------------------------------
Index: libsoftfloat/arch/m68k/softfloat.h
===================================================================
RCS file: /cvsroot/pcc-libs/libsoftfloat/arch/m68k/softfloat.h,v
retrieving revision 1.1
diff -u -p -r1.1 softfloat.h
--- libsoftfloat/arch/m68k/softfloat.h	20 May 2008 05:29:07 -0000	1.1
+++ libsoftfloat/arch/m68k/softfloat.h	23 Mar 2014 21:57:07 -0000
@@ -44,7 +44,7 @@ the `FLOAT128' macro and the quadruple-p
 #define FLOATX80
 /* #define FLOAT128 */
 
-#include <machine/ieeefp.h>
+#include "ieeefp.h"
 
 /*
 -------------------------------------------------------------------------------
# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	csu/linux/m68k/crt0.c
#	csu/linux/m68k/crti.c
#	csu/linux/m68k/crtn.c
#
echo x - csu/linux/m68k/crt0.c
sed 's/^X//' >csu/linux/m68k/crt0.c << 'END-of-csu/linux/m68k/crt0.c'
X/* $Id$ */
X/* $NetBSD: crt0.c,v 1.13 2011/03/07 05:09:10 joerg Exp $ */
X
X/*
X * Copyright (c) 2014 Thorsten "mirabilos" Glaser <tg@debian.org>
X * Copyright (c) 1999 Klaus Klein
X * Copyright (c) 1995 Christopher G. Demetriou
X * All rights reserved.
X * 
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X * 3. All advertising materials mentioning features or use of this software
X *    must display the following acknowledgement:
X *          This product includes software developed for the
X *          NetBSD Project.  See http://www.NetBSD.org/ for
X *          information about NetBSD.
X * 4. The name of the author may not be used to endorse or promote products
X *    derived from this software without specific prior written permission.
X * 
X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
X * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
X * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
X * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
X * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
X * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
X * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
X * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
X * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
X * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
X * 
X * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
X */
X
X#include "common.h"
X
Xvoid __start(int, char **, char **);
X
X__asm("\n"
X"	.text				\n"
X"	.align	4			\n"
X"	.globl	_start			\n"
X"_start:				\n"
X"	movl	(%sp),%d0		\n"
X"	movl	%a2,-(%sp)		| ps_strings	\n"
X"	movl	%a0,-(%sp)		| obj		\n"
X"	movl	%a1,-(%sp)		| cleanup	\n"
X"	movl	%d0,%d1			\n"
X"	lsll	#2,%d1			\n"
X"	pea	(16+4)(%sp,%d1.l)	| envp = &argv[argc + 1]	\n"
X"	pea	20(%sp)			| argv		\n"
X"	movl	%d0,-(%sp)		| argc		\n"
X"	jsr	__start");
X
Xvoid
X__start(int argc, char **argv, char **envp)
X{
X#ifdef PROFILE
X	atexit(_mcleanup);
X	monstartup((unsigned long)&_eprol, (unsigned long)&_etext);
X#endif
X
X	atexit(_fini);
X	_init();
X
X	exit(main(argc, argv, envp));
X}
X
X#include "common.c"
X
XIDENT("$Id$");
END-of-csu/linux/m68k/crt0.c
echo x - csu/linux/m68k/crti.c
sed 's/^X//' >csu/linux/m68k/crti.c << 'END-of-csu/linux/m68k/crti.c'
X/* $Id$ */
X/*-
X * Copyright (c) 2014 Thorsten "mirabilos" Glaser <tg@debian.org>
X * Copyright (c) 2008 Gregory McGarry <g.mcgarry@ieee.org>
X *
X * Permission to use, copy, modify, and distribute this software for any
X * purpose with or without fee is hereby granted, provided that the above
X * copyright notice and this permission notice appear in all copies.
X *
X * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
X * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
X * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
X * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
X * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
X * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X */
X
X#include "common.h"
X
Xasm(	"	.section .init,\"ax\",@progbits			\n"
X	"	.globl _init					\n"
X	"	.type _init,@function				\n"
X	"	.align 2					\n"
X	"_init:							\n"
X	"	link.w %fp,#0					\n"
X#ifdef PIC
X	"	move.l %a5,-(sp)				\n"
X	"	lea (%pc, _GLOBAL_OFFSET_TABLE_@GOTPC),%a5	\n"
X#endif
X	"	.previous					\n");
X
Xasm(	"	.section .fini,\"ax\",@progbits			\n"
X	"	.globl _fini					\n"
X	"	.type _fini,@function				\n"
X	"	.align 2					\n"
X	"_fini:							\n"
X	"	link.w %fp,#0					\n"
X#ifdef PIC
X	"	move.l %a5,-(sp)				\n"
X	"	lea (%pc, _GLOBAL_OFFSET_TABLE_@GOTPC),%a5	\n"
X#endif
X	"	.previous					\n");
X
XIDENT("$Id$");
END-of-csu/linux/m68k/crti.c
echo x - csu/linux/m68k/crtn.c
sed 's/^X//' >csu/linux/m68k/crtn.c << 'END-of-csu/linux/m68k/crtn.c'
X/* $Id$ */
X/*-
X * Copyright (c) 2014 Thorsten "mirabilos" Glaser <tg@debian.org>
X * Copyright (c) 2008 Gregory McGarry <g.mcgarry@ieee.org>
X *
X * Permission to use, copy, modify, and distribute this software for any
X * purpose with or without fee is hereby granted, provided that the above
X * copyright notice and this permission notice appear in all copies.
X *
X * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
X * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
X * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
X * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
X * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
X * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
X * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
X */
X
X#include "common.h"
X
Xasm(	"	.section .init,\"ax\",@progbits	\n"
X#ifdef PIC
X	"	move.l (%sp)+,%a5		\n"
X#endif
X	"	unlk %fp			\n"
X	"	rts				\n"
X	"	.previous			\n");
X
Xasm(	"	.section .fini,\"ax\",@progbits	\n"
X#ifdef PIC
X	"	move.l (%sp)+,%a5		\n"
X#endif
X	"	unlk %fp			\n"
X	"	rts				\n"
X	"	.previous			\n");
X
XIDENT("$Id$");
END-of-csu/linux/m68k/crtn.c
exit


Reply to: