This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[arm-linux target] better support for soft-float and default cpu


Hello,

following patch ensures that the default processor gets passed
to the assembler (when called by gcc) :
   configure --target=arm-linux --with-cpu=XXX

It will also build in and enable support for soft-float when
configured with :
   configure --target=arm-linux --without-fp

This flag is also passed to the assembler (as -mno-fp),
unless -mcpu, -march, -msoft-float or -mhard-float is
specified explicitely.
In that case, floating point support is added to libgcc.


The reason for this patch is that we want to create a compiler
for xscale (which does not have a fp unit) that builds
everything correctly, but with soft-float, in order
to prevent inconsistencies between files compiled for
soft-float and files compiled without.


Finally, this patch also allows you to bootstrap gcc for arm,
without glibc and without needing the 'inhibit-libc' patch.
You can enable 'inhibit-libc' by configuring :
  configure --with-inhibit-libc


The patch is against gcc-3.0.2.


Greetings,
--
Jeroen Dobbelaere
Embedded Software Engineer

ACUNIA Embedded Solutions
http://www.acunia.com

diff -rNC5 gcc-3.0.2/gcc/ChangeLog gcc-3.0.2_new/gcc/ChangeLog
*** gcc-3.0.2/gcc/ChangeLog	Tue Oct 23 19:19:18 2001
--- gcc-3.0.2_new/gcc/ChangeLog	Tue Nov 27 10:21:42 2001
***************
*** 1,5 ****
--- 1,15 ----
+ 2001-11-26  Jeroen Dobbelaere  <jeroen.dobbelaere@acunia.com>
+ 
+ 	* config/arm/linux-elf.h: Pass default 'target cpu' to assembler
+ 	* config/arm/linux-elf.h: Handle 'configure --without-fp'
+ 	* config/arm/sflinux-elf.h: Likewise
+ 	* config/arm/t-float-lib2: Likewise
+ 	* config/arm/arm.h: Likewise
+ 	* config.gcc: Likewise, and handle --with-inhibit-libc
+ 	* config/arm/t-inhibit-libc: Handle --with-inhibit-libc
+ 
  2001-10-23  Release Manager
  
  	* GCC 3.0.2 Released.
  
  2001-10-23  Joseph S. Myers  <jsm28@cam.ac.uk>
diff -rNC5 gcc-3.0.2/gcc/config/arm/arm.h gcc-3.0.2_new/gcc/config/arm/arm.h
*** gcc-3.0.2/gcc/config/arm/arm.h	Thu May 24 23:03:58 2001
--- gcc-3.0.2_new/gcc/config/arm/arm.h	Mon Nov 26 14:43:18 2001
***************
*** 100,109 ****
--- 100,212 ----
  #else
  #define TARGET_CPU_DEFAULT TARGET_CPU_arm6
  #endif
  #endif
  
+ /* original names for target */
+ 
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm2)
+ #define TARGET_CPU_DEFAULT_NAME arm2
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm250)
+ #define TARGET_CPU_DEFAULT_NAME arm250
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm3)
+ #define TARGET_CPU_DEFAULT_NAME arm3
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm6)
+ #define TARGET_CPU_DEFAULT_NAME arm6
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm600)
+ #define TARGET_CPU_DEFAULT_NAME arm600
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm610)
+ #define TARGET_CPU_DEFAULT_NAME arm610
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm7)
+ #define TARGET_CPU_DEFAULT_NAME arm7
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm7m)
+ #define TARGET_CPU_DEFAULT_NAME arm7m
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm7dm)
+ #define TARGET_CPU_DEFAULT_NAME arm7dm
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm7dmi)
+ #define TARGET_CPU_DEFAULT_NAME arm7dmi
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm700)
+ #define TARGET_CPU_DEFAULT_NAME arm700
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm710)
+ #define TARGET_CPU_DEFAULT_NAME arm710
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm7100)
+ #define TARGET_CPU_DEFAULT_NAME arm7100
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm7500)
+ #define TARGET_CPU_DEFAULT_NAME arm7500
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm7500fe)
+ #define TARGET_CPU_DEFAULT_NAME arm7500fe
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm7tdmi)
+ #define TARGET_CPU_DEFAULT_NAME arm7tdmi
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm8)
+ #define TARGET_CPU_DEFAULT_NAME arm8
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm810)
+ #define TARGET_CPU_DEFAULT_NAME arm810
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_strongarm)
+ #define TARGET_CPU_DEFAULT_NAME strongarm
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_strongarm110)
+ #define TARGET_CPU_DEFAULT_NAME strongarm110
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_strongarm1100)
+ #define TARGET_CPU_DEFAULT_NAME strongarm1100
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm9)
+ #define TARGET_CPU_DEFAULT_NAME arm9
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_arm9tdmi)
+ #define TARGET_CPU_DEFAULT_NAME arm9tdmi
+ #endif
+ 
+ #if !defined(TARGET_CPU_DEFAULT_NAME) && (TARGET_CPU_DEFAULT == TARGET_CPU_xscale)
+ #define TARGET_CPU_DEFAULT_NAME xscale
+ #endif
+ 
+ #define TARGET_TO_STRING_B(t) # t
+ #define TARGET_TO_STRING(t) TARGET_TO_STRING_B(t)
+ 
+ 
  #if TARGET_CPU_DEFAULT == TARGET_CPU_arm2
  #define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_2__"
  #else
  #if TARGET_CPU_DEFAULT == TARGET_CPU_arm6 || TARGET_CPU_DEFAULT == TARGET_CPU_arm610 || TARGET_CPU_DEFAULT == TARGET_CPU_arm7500fe
  #define CPP_ARCH_DEFAULT_SPEC "-D__ARM_ARCH_3__"
***************
*** 126,135 ****
--- 229,240 ----
  #endif
  #endif
  #endif
  #endif
  
+ 
+ 
  #ifndef CPP_PREDEFINES
  #define CPP_PREDEFINES  "-Acpu=arm -Amachine=arm"
  #endif
  
  #define CPP_SPEC "\
***************
*** 229,239 ****
--- 334,350 ----
    -D__SOFTFP__} \
  %{!mhard-float:%{!msoft-float:%(cpp_float_default)}} \
  "
  
  /* Default is hard float, which doesn't define anything */
+ #ifdef TARGET_CPU_DEFAULT_USE_SOFTFLOAT
+ /* only do this if the default cpu and arch target stay the same */
+ #define CPP_FLOAT_DEFAULT_SPEC "%{!mcpu=*:%{!march=*:-D__SOFTFP__}}"
+ #else
  #define CPP_FLOAT_DEFAULT_SPEC ""
+ #endif
+ 
  
  #define CPP_ENDIAN_SPEC "\
  %{mbig-endian:								\
    %{mlittle-endian:							\
      %e-mbig-endian and -mlittle-endian may not be used together}	\
diff -rNC5 gcc-3.0.2/gcc/config/arm/linux-elf.h gcc-3.0.2_new/gcc/config/arm/linux-elf.h
*** gcc-3.0.2/gcc/config/arm/linux-elf.h	Mon Apr 16 20:25:42 2001
--- gcc-3.0.2_new/gcc/config/arm/linux-elf.h	Tue Nov 27 11:17:35 2001
***************
*** 27,38 ****
--- 27,44 ----
  #define NO_IMPLICIT_EXTERN_C
  
  /* Default is to use APCS-32 mode.  */
  #define TARGET_DEFAULT (ARM_FLAG_APCS_32 | ARM_FLAG_MMU_TRAPS)
  #define SUBTARGET_EXTRA_LINK_SPEC " -m armelf_linux -p"
+ 
+ #ifdef TARGET_CPU_DEFAULT_USE_SOFTFLOAT
+ #define MULTILIB_DEFAULTS \
+ 	{ "marm", "mlittle-endian", "msoft-float", "mapcs-32", "mno-thumb-interwork" }
+ #else
  #define MULTILIB_DEFAULTS \
  	{ "marm", "mlittle-endian", "mhard-float", "mapcs-32", "mno-thumb-interwork" }
+ #endif
  #define CPP_APCS_PC_DEFAULT_SPEC "-D__APCS_32__"
  
  /* This was defined in linux.h.  Define it here also. */
  #undef  DEFAULT_VTABLE_THUNKS
  #define DEFAULT_VTABLE_THUNKS   1
***************
*** 45,55 ****
--- 51,66 ----
    "%{shared: -lc} \
     %{!shared: %{pthread:-lpthread} \
     %{profile:-lc_p} %{!profile: -lc}}"
  
  
+ #ifdef TARGET_CPU_DEFAULT_USE_SOFTFLOAT
+ /* we add the library to libgcc */
+ #define LIBGCC_SPEC "-lgcc"
+ #else
  #define LIBGCC_SPEC "%{msoft-float:-lfloat} -lgcc"
+ #endif
  
  /* 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'. */
***************
*** 84,93 ****
--- 95,115 ----
  #undef  CPP_PREDEFINES
  #define CPP_PREDEFINES \
  "-Dunix -Dlinux -D__ELF__ \
  -Asystem=unix -Asystem=posix -Acpu=arm -Amachine=arm"
  
+ #ifdef TARGET_CPU_DEFAULT_USE_SOFTFLOAT
+ #define SUBTARGET_SOFTFLOAT_ASM_SPEC \
+ "%{!mcpu=*:%{!march=*:%{!msoft-float:%{!mhard-float:-mno-fp}}}}"
+ #else
+ #define SUBTARGET_SOFTFLOAT_ASM_SPEC
+ #endif
+ 
+ /* pass default cpu and soft-float setting to assembler */
+ #define SUBTARGET_EXTRA_ASM_SPEC \
+ "%{!mcpu=*:%{!march=*:-m" TARGET_TO_STRING(TARGET_CPU_DEFAULT_NAME) "}} " SUBTARGET_SOFTFLOAT_ASM_SPEC
+ 
  /* Allow #sccs in preprocessor.  */
  #define SCCS_DIRECTIVE
  
  #define USER_LABEL_PREFIX 	""	/* For ELF the default is no underscores */
  #define LOCAL_LABEL_PREFIX 	"."
***************
*** 262,267 ****
--- 284,295 ----
  {									\
    fprintf (STREAM, "\tbl\tmcount%s\n", NEED_PLT_RELOC ? "(PLT)" : "");	\
  }
  
  #undef  CC1_SPEC
+ 
+ #ifdef TARGET_CPU_DEFAULT_USE_SOFTFLOAT
+ /* explicitely specify that we are using soft-float */
+ #define CC1_SPEC "%{profile:-p} %{!msoft-float:%{!mhard-float:%{!mcpu=*:%{!march=*:-msoft-float}}}}"
+ #else
  #define CC1_SPEC "%{profile:-p}"
+ #endif
diff -rNC5 gcc-3.0.2/gcc/config/arm/sflinux-elf.h gcc-3.0.2_new/gcc/config/arm/sflinux-elf.h
*** gcc-3.0.2/gcc/config/arm/sflinux-elf.h	Thu Jan  1 01:00:00 1970
--- gcc-3.0.2_new/gcc/config/arm/sflinux-elf.h	Mon Nov 26 12:12:28 2001
***************
*** 0 ****
--- 1,26 ----
+ /* Definitions for ARM running ucLinux using ELF
+    Copyright (C) 1999 Free Software Foundation, Inc.
+    Contributed by Philip Blundell <pb@nexus.co.uk>
+ 
+ This file is part of GNU CC.
+ 
+ GNU CC 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 2, or (at your option)
+ any later version.
+ 
+ GNU CC 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 this program; see the file COPYING.  If not, write to
+ the Free Software Foundation, 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.  */
+ 
+ /* we wan't to use soft-float by default*/
+ #define TARGET_CPU_DEFAULT_USE_SOFTFLOAT 1
+ 
+ #include "arm/linux-elf.h"
+ 
diff -rNC5 gcc-3.0.2/gcc/config/arm/t-float-lib2 gcc-3.0.2_new/gcc/config/arm/t-float-lib2
*** gcc-3.0.2/gcc/config/arm/t-float-lib2	Thu Jan  1 01:00:00 1970
--- gcc-3.0.2_new/gcc/config/arm/t-float-lib2	Tue Nov 27 10:14:29 2001
***************
*** 0 ****
--- 1,18 ----
+ # We want fine grained libraries, so use the new code to build the
+ # floating point emulation libraries.
+ LIB2FUNCS_EXTRA += fp-bit.c dp-bit.c
+  
+ fp-bit.c:	$(srcdir)/config/fp-bit.c
+ 	echo '#define FLOAT' > fp-bit.c
+ 	echo '#ifndef __ARMEB__' >> fp-bit.c
+ 	echo '#define FLOAT_BIT_ORDER_MISMATCH' >> fp-bit.c
+ 	echo '#endif' >> fp-bit.c
+ 	cat $(srcdir)/config/fp-bit.c >> fp-bit.c
+  
+ dp-bit.c:	$(srcdir)/config/fp-bit.c
+ 	echo '#ifndef __ARMEB__' > dp-bit.c
+ 	echo '#define FLOAT_BIT_ORDER_MISMATCH' >> dp-bit.c
+ 	echo '#define FLOAT_WORD_ORDER_MISMATCH' >> dp-bit.c
+ 	echo '#endif' >> dp-bit.c
+ 	cat $(srcdir)/config/fp-bit.c >> dp-bit.c
+ 
diff -rNC5 gcc-3.0.2/gcc/config/arm/t-inhibit-libc gcc-3.0.2_new/gcc/config/arm/t-inhibit-libc
*** gcc-3.0.2/gcc/config/arm/t-inhibit-libc	Thu Jan  1 01:00:00 1970
--- gcc-3.0.2_new/gcc/config/arm/t-inhibit-libc	Tue Nov 27 10:19:14 2001
***************
*** 0 ****
--- 1,3 ----
+ # inhibit libc (for bootstrapping on systems without libc)
+ TARGET_LIBGCC2_CFLAGS += -Dinhibit_libc -D__gthr_posix_h
+ 
diff -rNC5 gcc-3.0.2/gcc/config.gcc gcc-3.0.2_new/gcc/config.gcc
*** gcc-3.0.2/gcc/config.gcc	Wed Oct 10 02:25:25 2001
--- gcc-3.0.2_new/gcc/config.gcc	Tue Nov 27 10:23:28 2001
***************
*** 587,598 ****
  	use_collect2=yes
  	;;
  arm*-*-linux*)			# ARM GNU/Linux with ELF
  	xm_file=arm/xm-linux.h
  	xmake_file=x-linux
- 	tm_file="arm/linux-elf.h"
  	tmake_file="t-slibgcc-elf-ver t-linux arm/t-linux"
  	extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
  	gnu_ld=yes
  	case x${enable_threads} in
  	x | xyes | xpthreads | xposix)
  		thread_file='posix'
--- 587,609 ----
  	use_collect2=yes
  	;;
  arm*-*-linux*)			# ARM GNU/Linux with ELF
  	xm_file=arm/xm-linux.h
  	xmake_file=x-linux
  	tmake_file="t-slibgcc-elf-ver t-linux arm/t-linux"
+ 	if test x$with_fp = xno
+ 	then
+ 		tm_file="arm/sflinux-elf.h"
+ 		tmake_file="${tmake_file} arm/t-float-lib2"
+ 	else
+ 		tm_file="arm/linux-elf.h"
+ 	fi
+ 
+ 	if test x$with_inhibit_libc = xyes
+ 	then
+ 		tmake_file="${tmake_file} arm/t-inhibit-libc"
+ 	fi
  	extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
  	gnu_ld=yes
  	case x${enable_threads} in
  	x | xyes | xpthreads | xposix)
  		thread_file='posix'

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]