Hello

I'm working on a gcc port to a hobby operating system. I got it working 
partially (cc1 works and I think I'm not far from get the gcc frontend 
working).

Now i wanted to rename my target from i386-elf-lost to i386-pc-lost because I 
was told that this would be more canonical. (I don't wanted to rename it to 
i386-lost-elf because I was told that this would enable some newlib features, 
and we aren't using newlib).

I wanted to recompile gcc for the new target. First I made the changes in 
binutils and recompiled them without any problem. Recompiling gcc worked too 
after some small changes. But when I tried to compile a simple Hello World, 
gcc failed with some assembler error messages about illegal operad size with 
some push instructions. As i guessed they seem to come from the host 64bit 
as. I compared the error messages by trying to assemble the code manually.

This seems very strange to me, because there were no problems with the old 
target name. configure locates as correctly (as far as I can judge this):
checking for as... no
checking for i386-pc-lost-as... i386-pc-lost-as

Any ideas why this doesn't work anymore?

I attached the relevant parts of the diff to the original gcc-source (I left 
out some changes in libiberty which are only useful for the native compiler).

Thanks

Toni Kaufmann
diff -ruN ../gcc-4.2.2/config.sub ./config.sub
--- ../gcc-4.2.2/config.sub	2006-10-16 05:27:17.000000000 +0200
+++ ./config.sub	2008-02-04 12:51:15.000000000 +0100
@@ -121,8 +121,8 @@
 maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
 case $maybe_os in
   nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
-  uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
-  storm-chaos* | os2-emx* | rtmk-nova*)
+  lost* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | \
+  netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
     os=-$maybe_os
     basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
     ;;
@@ -1249,6 +1249,9 @@
 	-linux*)
 		os=`echo $os | sed -e 's|linux|linux-gnu|'`
 		;;
+    -lost*)
+        os=-lost
+        ;;
 	-sunos5*)
 		os=`echo $os | sed -e 's|sunos5|solaris2|'`
 		;;
diff -ruN ../gcc-4.2.2/gcc/config/i386/lost.h ./gcc/config/i386/lost.h
--- ../gcc-4.2.2/gcc/config/i386/lost.h	1970-01-01 01:00:00.000000000 +0100
+++ ./gcc/config/i386/lost.h	2008-02-04 12:51:15.000000000 +0100
@@ -0,0 +1,56 @@
+/* Definitions for Intel 386 running Linux-based GNU systems with ELF format.
+   Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2001, 2002, 2004, 2005,
+   2006, 2007 Free Software Foundation, Inc.
+   Contributed by Eric Youngdale.
+   Modified for stabs-in-ELF by H.J. Lu.
+   Adapted from linux.h by Antoine Kaufmann
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+/* Output at beginning of assembler file.  */
+/* The .file command should always begin the output.  */
+#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true
+
+#define TARGET_VERSION fprintf (stderr, " (i386 LOST/ELF)");
+
+/* The svr4 ABI for the i386 says that records and unions are returned
+   in memory.  */
+#undef DEFAULT_PCC_STRUCT_RETURN
+#define DEFAULT_PCC_STRUCT_RETURN 1
+
+#undef ASM_COMMENT_START
+#define ASM_COMMENT_START "#"
+
+#undef SIZE_TYPE
+#define SIZE_TYPE "unsigned int"
+ 
+#undef PTRDIFF_TYPE
+#define PTRDIFF_TYPE "int"
+  
+#undef WCHAR_TYPE
+#define WCHAR_TYPE "long int"
+   
+#undef WCHAR_TYPE_SIZE
+#define WCHAR_TYPE_SIZE BITS_PER_WORD
+    
+#define TARGET_OS_CPP_BUILTINS()		\
+  do						\
+    {						\
+	LOST_TARGET_OS_CPP_BUILTINS();		\
+    }						\
+  while (0)
+
diff -ruN ../gcc-4.2.2/gcc/config/lost.h ./gcc/config/lost.h
--- ../gcc-4.2.2/gcc/config/lost.h	1970-01-01 01:00:00.000000000 +0100
+++ ./gcc/config/lost.h	2008-02-04 12:51:15.000000000 +0100
@@ -0,0 +1,57 @@
+/* Definitions for Linux-based GNU systems with ELF format
+   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2003, 2004, 2005, 2006,
+   2007 Free Software Foundation, Inc.
+   Contributed by Eric Youngdale.
+   Modified for stabs-in-ELF by H.J. Lu ([EMAIL PROTECTED]).
+   Adapted from linux.h by Antoine Kaufmann
+
+This file is part of GCC.
+
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+/* Don't assume anything about the header files.  */
+#define NO_IMPLICIT_EXTERN_C
+
+/* Provide a STARTFILE_SPEC appropriate for GNU/Linux.  Here we add
+   the GNU/Linux magical crtbegin.o file (see crtstuff.c) which
+   provides part of the support for getting C++ file-scope static
+   object constructed before entering `main'.  */
+   
+#undef	STARTFILE_SPEC
+#define STARTFILE_SPEC \
+  "crtbegin.o%s -l:crtlost.o"
+
+/* Provide a ENDFILE_SPEC appropriate for GNU/Linux.  Here we tack on
+   the GNU/Linux magical crtend.o file (see crtstuff.c) which
+   provides part of the support for getting C++ file-scope static
+   object constructed before entering `main', followed by a normal
+   GNU/Linux "finalizer" file, `crtn.o'.  */
+
+#undef	ENDFILE_SPEC
+#define ENDFILE_SPEC \
+  "crtend.o%s"
+
+#define LOST_TARGET_OS_CPP_BUILTINS()			\
+    do {					    	    	    \
+	builtin_define ("__LOST__");    			\
+	builtin_define_std ("LOST");				\
+	builtin_assert ("system=LOST");			    \
+    } while (0)
+
+/*#define LINK_GCC_C_SEQUENCE_SPEC \
+  "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}"*/
+#define LINK_GCC_C_SEQUENCE_SPEC \
+  "--start-group %G %L --end-group"
+
diff -ruN ../gcc-4.2.2/gcc/config/t-lost ./gcc/config/t-lost
--- ../gcc-4.2.2/gcc/config/t-lost	1970-01-01 01:00:00.000000000 +0100
+++ ./gcc/config/t-lost	2008-02-04 18:08:54.000000000 +0100
@@ -0,0 +1,9 @@
+# Compile crtbeginS.o and crtendS.o with pic.
+CRTSTUFF_T_CFLAGS_S = -fPIC
+
+# Compile libgcc.a with pic.
+TARGET_LIBGCC2_CFLAGS += -fPIC
+
+SYSTEM_HEADER_DIR = $(prefix)/system/links/include
+CROSS_SYSTEM_HEADER_DIR = $(prefix)/system/links/include
+
diff -ruN ../gcc-4.2.2/gcc/config.gcc ./gcc/config.gcc
--- ../gcc-4.2.2/gcc/config.gcc	2007-09-01 17:28:30.000000000 +0200
+++ ./gcc/config.gcc	2008-02-07 08:27:38.000000000 +0100
@@ -500,6 +500,13 @@
   # Assume that glibc is being used and so __cxa_atexit is provided.
   default_use_cxa_atexit=yes
   ;;
+*-*-lost*)
+  gas=yes
+  gnu_ld=yes
+  extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o"
+  tmake_file="t-slibgcc-elf-ver t-lost"
+  ;;
+
 *-*-netbsd*)
   tmake_file="t-slibgcc-elf-ver t-libc-ok t-netbsd t-libgcc-pic"
   gas=yes
@@ -1116,6 +1123,13 @@
 	gnu_ld=yes
 	gas=yes
 	;;
+i[34567]86-*-lost*)
+	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h lost.h \
+        i386/lost.h"
+    tmake_file="i386/t-i386elf i386/t-crtstuff t-lost"
+    use_fixproto=yes
+	;;
+
 i[34567]86-*-lynxos*)
 	xm_defines=POSIX
 	tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h i386/lynx.h lynx.h"

Reply via email to