This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[arm-linux target] better softfloat support
- From: jeroen dobbelaere <jeroen dot dobbelaere at acunia dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: "Richard.Earnshaw" <Richard dot Earnshaw at arm dot com>
- Date: Wed, 12 Dec 2001 15:47:29 +0100
- Subject: [arm-linux target] better softfloat support
- Organization: ACUNIA
Hi,
Now that I understand the 'libfloat' situation better, I've
improved my softfloat patch for the arm target.
This patch (for gcc-3.0.2) provides following new configuration options :
--without-fp (or --with-fp=no)
configures for a compiler that defaults to producing binaries with 'soft-float' support
(-msoft-float)
--with-softfloat-support=[internal|external|multilib-internal|multilib-external]
configures for a compiler where softfloat is
internal (in libgcc),
external (in libfloat) (this is the default),
multilib-internal (softfloat support in libgcc, multilibs softfloat/hardfloat)
multilib-external (softfloat support in libfloat, multilibs softfloat/hardfloat)
The multilib versions will, depending on '--with-fp', default to
hard-float (providing soft-float libraries in soft-float) or,
soft-float (providing hard-float libraries in hard-float).
--with-inhibit-libc
configures for a compiler which doesn't depend on glibc. This options allows
you to get rid of the 'inhibit-glibc' patch for bootstrapping gcc.
Note :
In this patch, I don't pass the specified cpu any more to the assembler.
That was done in previous patch because the behavior of passing -mxscale
to gas was different than for the other arm processors.
This issue is resolved in a patch for gas (and in the binutils cvs), see
<http://sources.redhat.com/ml/binutils/2001-12/msg00013.html>
Note2 :
This patch will probably be made obsolete by floating-point work from Richard Earnshaw, but
I guess that it will be useful to others until then.
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 Mon Dec 3 15:59:10 2001
***************
*** 1,5 ****
--- 1,15 ----
+ 2001-12-03 Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
+
+ * config/arm/t-float-multilib: Multilib soft/hard float support.
+ * config/arm/t-float-lib2: Use gcc soft-float emulation.
+ * config/arm/t-inhibit-libc: Handle bootstrapping gcc without glibc.
+ * config.gcc: Handle 'configure --without-fp', 'configure --with-inhibit-libc',
+ 'configure --with-softfloat-support={external|internal|multilib-external|multilib-internal}'
+ * config/arm/linux-elf.h: Handle default soft-float settings.
+ * config/arm/arm.h: Likewise
+
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 Dec 3 16:02:10 2001
***************
*** 228,239 ****
%{mhard-float:%e-msoft-float and -mhard_float may not be used together} \
-D__SOFTFP__} \
%{!mhard-float:%{!msoft-float:%(cpp_float_default)}} \
"
! /* Default is hard float, which doesn't define anything */
#define CPP_FLOAT_DEFAULT_SPEC ""
#define CPP_ENDIAN_SPEC "\
%{mbig-endian: \
%{mlittle-endian: \
%e-mbig-endian and -mlittle-endian may not be used together} \
--- 228,244 ----
%{mhard-float:%e-msoft-float and -mhard_float may not be used together} \
-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 "%{!mhard-float:-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 Mon Dec 3 15:55:38 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 ****
"%{shared: -lc} \
%{!shared: %{pthread:-lpthread} \
%{profile:-lc_p} %{!profile: -lc}}"
! #define LIBGCC_SPEC "%{msoft-float:-lfloat} -lgcc"
/* 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'. */
--- 51,69 ----
"%{shared: -lc} \
%{!shared: %{pthread:-lpthread} \
%{profile:-lc_p} %{!profile: -lc}}"
! #ifdef TARGET_CPU_DEFAULT_USE_SOFTFLOAT_LIBRARY
! # ifdef TARGET_CPU_DEFAULT_USE_SOFTFLOAT
! # define LIBGCC_SPEC "%{!mhard-float:-lfloat} -lgcc"
! # else
! # define LIBGCC_SPEC "%{msoft-float:-lfloat} -lgcc"
! # endif
! #else
! # define LIBGCC_SPEC "-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 ****
--- 98,116 ----
#undef CPP_PREDEFINES
#define CPP_PREDEFINES \
"-Dunix -Dlinux -D__ELF__ \
-Asystem=unix -Asystem=posix -Acpu=arm -Amachine=arm"
+ /* Pass default cpu and soft-float setting to assembler. */
+ #ifdef TARGET_CPU_DEFAULT_USE_SOFTFLOAT
+ #define SUBTARGET_EXTRA_ASM_SPEC \
+ "%{!mhard-float:-mno-fpu}"
+ #else
+ #define SUBTARGET_EXTRA_ASM_SPEC \
+ ""
+ #endif
+
/* Allow #sccs in preprocessor. */
#define SCCS_DIRECTIVE
#define USER_LABEL_PREFIX "" /* For ELF the default is no underscores */
#define LOCAL_LABEL_PREFIX "."
***************
*** 262,267 ****
--- 285,296 ----
{ \
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} %{!mhard-float:-msoft-float}"
+ #else
#define CC1_SPEC "%{profile:-p}"
+ #endif
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 Mon Dec 3 13:52:33 2001
***************
*** 0 ****
--- 1,40 ----
+ # Internal soft-float support in libgcc.
+ # Copyright (C) 2001 Free Software Foundation, Inc.
+ # Contributed by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
+ #
+ # 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 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-float-multilib gcc-3.0.2-new/gcc/config/arm/t-float-multilib
*** gcc-3.0.2/gcc/config/arm/t-float-multilib Thu Jan 1 01:00:00 1970
--- gcc-3.0.2-new/gcc/config/arm/t-float-multilib Mon Dec 3 13:53:26 2001
***************
*** 0 ****
--- 1,29 ----
+ # Multilib support for soft-float/hard-float combination
+ # Copyright (C) 2001 Free Software Foundation, Inc.
+ # Contributed by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
+ #
+ # 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.
+ #
+
+ MULTILIB_OPTIONS = msoft-float/mhard-float
+ MULTILIB_DIRNAMES = soft-float hard-float
+ MULTILIB_EXCEPTIONS =
+
+ EXTRA_MULTILIB_PARTS = crtbegin.o crtend.o
+ LIBGCC = stmp-multilib
+ INSTALL_LIBGCC = install-multilib
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 Mon Dec 3 13:51:44 2001
***************
*** 0 ****
--- 1,26 ----
+ # Inhibit libc when bootstrapping a compiler without glibc available.
+ # Copyright (C) 2001 Free Software Foundation, Inc.
+ # Contributed by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
+ #
+ # 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.
+ #
+
+ # Inhibit libc (for bootstrapping on systems without libc).
+ TARGET_LIBGCC2_CFLAGS += -Dinhibit_libc
+
+
diff -rNC5 gcc-3.0.2/gcc/config/arm/use_softfloat.h gcc-3.0.2-new/gcc/config/arm/use_softfloat.h
*** gcc-3.0.2/gcc/config/arm/use_softfloat.h Thu Jan 1 01:00:00 1970
--- gcc-3.0.2-new/gcc/config/arm/use_softfloat.h Mon Dec 3 13:49:30 2001
***************
*** 0 ****
--- 1,25 ----
+ /* Definition for ARM using soft-float
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ Contributed by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
+
+ 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 want to use soft-float by default, supported by an external libfloat.a. */
+
+ #define TARGET_CPU_DEFAULT_USE_SOFTFLOAT 1
+
diff -rNC5 gcc-3.0.2/gcc/config/arm/use_softfloat_library.h gcc-3.0.2-new/gcc/config/arm/use_softfloat_library.h
*** gcc-3.0.2/gcc/config/arm/use_softfloat_library.h Thu Jan 1 01:00:00 1970
--- gcc-3.0.2-new/gcc/config/arm/use_softfloat_library.h Mon Dec 3 13:50:03 2001
***************
*** 0 ****
--- 1,25 ----
+ /* Definitions for ARM using an external library for soft-float
+ Copyright (C) 2001 Free Software Foundation, Inc.
+ Contributed by Jeroen Dobbelaere <jeroen.dobbelaere@acunia.com>
+
+ 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 want to use soft-float by default, supported by an external libfloat.a. */
+
+ #define TARGET_CPU_DEFAULT_USE_SOFTFLOAT_LIBRARY 1
+
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 Mon Dec 3 14:13:07 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,648 ----
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"
+ tm_file=
+
+ case x${with_fp} in
+ xno)
+ # build in software floating point emulation
+ tm_file="${tm_file} arm/use_softfloat.h"
+ ;;
+
+ x | xyes)
+ # default : hardware
+ ;;
+ x*)
+ { echo "config.gcc: error:
+ *** Unknown floating point support for --with-fp=$with_fp
+ *** Valid values are : yes, no" 2>&2; exit 1; }
+ ;;
+ esac
+
+ case x${with_softfloat_support} in
+ x | xexternal)
+ # use external software floating point emulation library by default
+ # see http://www.netwinder.org/~scottb/notes/FP-Notes-all.html
+ # and http://http.cs.berkeley.edu/~jhauser/arithmetic/softfloat.html
+ tm_file="${tm_file} arm/use_softfloat_library.h"
+ ;;
+
+ xinternal)
+ tmake_file="${tmake_file} arm/t-float-lib2"
+ ;;
+
+ xmultilib-external)
+ tm_file="${tm_file} arm/use_softfloat_library.h"
+ tmake_file="${tmake_file} arm/t-float-multilib"
+ ;;
+
+ xmultilib-internal)
+ tmake_file="${tmake_file} arm/t-float-lib2 arm/t-float-multilib"
+ ;;
+ x*)
+ { echo "config.gcc: error:
+ *** --with-softfloat-support=$with_softfloat_supprt : unknown parameter
+ *** Valid values are : internal, external (default), multilib-internal, multilib-external" 2>&2; exit 1; }
+ ;;
+ esac
+
+ if test x${with_inhibit_libc} = xyes
+ then
+ tmake_file="${tmake_file} arm/t-inhibit-libc"
+ fi
+
+ tm_file="${tm_file} arm/linux-elf.h"
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'