[PATCH] Fix powerpc-netbsd target

Jason R Thorpe thorpej@wasabisystems.com
Sun Nov 24 16:32:00 GMT 2002


"Where shall I begin?" :-)

As it exists before this patch, it gets quite a number of things wrong.
This is largely due to the spec mess caused by trying to cram all of the
SVR4 ABI configs into one (a failed experiment, IMO -- it's not like you
could actually produce correct Linux binaries with -mcall-linux from a
non-Linux-targeted compiler, for example).

My fix for the powerpc-netbsd target is to shed that mess of specs, and
use the nice generic NetBSD support that all the other NetBSD targets use.

There are also some other slight differences in multilib handling between
the "ppccom" and NetBSD configs.

Anyway, I'm sure someone will be upset that this change turns it back
on the "merged" SVR4 ABI PowerPC config, and for this reason I'll hold
off on checking it in for a couple of days.  But I'll go ahead and say
up-front that my position regarding losing -mcall-netbsd from the "merged"
config is:

	So?  I am really only concerned with a powerpc-netbsd targeted
	toolchain generating correct NetBSD binaries.

:-)

In any case, I *really* want the powerpc-netbsd config to work properly
in GCC 3.3, and this is the simplest and most maintainable way to achieve
that goal.

After 3.4-b-i-b is merged to the mainline, I'll submit a patch to get
rid of -mcall-netbsd from the "merged" config.

	* config.gcc (powerpc-*-netbsd*): Replace "svr4.h" with
	"netbsd.h netbsd-elf.h" in tm_file.  Set tmake_file to
	"${tmake_file} rs6000/t-netbsd".
	* config/rs6000/netbsd.h: Rewrite.
	* config/rs6000/t-netbsd: New file.

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>
-------------- next part --------------
Index: config.gcc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config.gcc,v
retrieving revision 1.261
diff -c -r1.261 config.gcc
*** config.gcc	24 Nov 2002 23:36:25 -0000	1.261
--- config.gcc	25 Nov 2002 00:29:52 -0000
***************
*** 2001,2008 ****
  	tmake_file="rs6000/t-ppcos rs6000/t-ppccomm"
  	;;
  powerpc-*-netbsd*)
! 	tm_file="${tm_file} dbxelf.h elfos.h svr4.h freebsd-spec.h rs6000/sysv4.h rs6000/netbsd.h"
! 	tmake_file="rs6000/t-ppcos rs6000/t-ppccomm"
  	;;
  powerpc-*-chorusos*)
  	xm_defines=POSIX
--- 2001,2008 ----
  	tmake_file="rs6000/t-ppcos rs6000/t-ppccomm"
  	;;
  powerpc-*-netbsd*)
! 	tm_file="${tm_file} dbxelf.h elfos.h netbsd.h netbsd-elf.h freebsd-spec.h rs6000/sysv4.h rs6000/netbsd.h"
! 	tmake_file="${tmake_file} rs6000/t-netbsd"
  	;;
  powerpc-*-chorusos*)
  	xm_defines=POSIX
Index: config/rs6000/netbsd.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/rs6000/netbsd.h,v
retrieving revision 1.5
diff -c -r1.5 netbsd.h
*** config/rs6000/netbsd.h	3 Jun 2002 00:28:12 -0000	1.5
--- config/rs6000/netbsd.h	25 Nov 2002 00:30:05 -0000
***************
*** 1,6 ****
  /* Definitions of target machine for GNU compiler,
     for PowerPC NetBSD systems.
!    Copyright 2001 Free Software Foundation, Inc.
  
  This file is part of GNU CC.
  
--- 1,7 ----
  /* Definitions of target machine for GNU compiler,
     for PowerPC NetBSD systems.
!    Copyright 2002 Free Software Foundation, Inc.
!    Contributed by Wasabi Systems, Inc.
  
  This file is part of GNU CC.
  
***************
*** 19,66 ****
  the Free Software Foundation, 59 Temple Place - Suite 330,
  Boston, MA 02111-1307, USA.  */
  
! /* Under NetBSD, the normal location of the various *crt*.o files is
!    the /usr/lib directory [from config/netbsd.h].  */
  
- #undef STANDARD_STARTFILE_PREFIX
- #define STANDARD_STARTFILE_PREFIX "/usr/lib/"
- 
- /* FIXME: Should this macro be treated the same as for the other
-    spec's?  */
- /* NOTE: -dc and -dp are equivalent yet NetBSD's CC passes both both!
-    NetBSD's CC also passes -O1 but we can skip that.  NetBSD explictly
-    sets ``-e _start'', since LD knows this, skip it.  */
- 
- #undef LINK_SHLIB_SPEC
- #define LINK_SHLIB_SPEC "\
- %{shared:-shared} \
- %{!shared: %{static:-dc -dp -static}} \
- %{!shared: %{!static:-dc -dp}} \
- "
- 
- /* Override the defaults.  */
- #undef LIB_DEFAULT_SPEC
- #define LIB_DEFAULT_SPEC "%(lib_netbsd)"
- 
- #undef STARTFILE_DEFAULT_SPEC
- #define STARTFILE_DEFAULT_SPEC "%(startfile_netbsd)"
- 
- #undef ENDFILE_DEFAULT_SPEC
- #define ENDFILE_DEFAULT_SPEC "%(endfile_netbsd)"
- 
- #undef LINK_START_DEFAULT_SPEC
- #define LINK_START_DEFAULT_SPEC "%(link_start_netbsd)"
- 
- #undef	LINK_OS_DEFAULT_SPEC
- #define LINK_OS_DEFAULT_SPEC "%(link_os_netbsd)"
- 
- #undef	CPP_OS_DEFAULT_SPEC
- #define CPP_OS_DEFAULT_SPEC "%(cpp_os_netbsd)"
  
  #undef TARGET_VERSION
! #define TARGET_VERSION fprintf (stderr, " (PowerPC NetBSD/ELF)");
! 
! /* Use STABS debugging information by default.  DWARF2 makes a mess of
!    the 1.5.2 linker.  */
! #undef  PREFERRED_DEBUGGING_TYPE
! #define PREFERRED_DEBUGGING_TYPE DBX_DEBUG
--- 20,73 ----
  the Free Software Foundation, 59 Temple Place - Suite 330,
  Boston, MA 02111-1307, USA.  */
  
! #undef TARGET_OS_CPP_BUILTINS	/* FIXME: sysv4.h should not define this! */
! #define TARGET_OS_CPP_BUILTINS()		\
!   do						\
!     {						\
!       NETBSD_OS_CPP_BUILTINS_ELF();		\
!       builtin_define ("__powerpc__");		\
!       builtin_assert ("cpu=powerpc");		\
!       builtin_assert ("machine=powerpc");	\
!     }						\
!   while (0)
! 
! /* Make GCC agree with <machine/ansi.h>.  */
! 
! #undef SIZE_TYPE
! #define SIZE_TYPE "unsigned int"
! 
! #undef PTRDIFF_TYPE
! #define PTRDIFF_TYPE "int"
! 
! /* Undo the spec mess from sysv4.h, and just define the specs
!    the way NetBSD systems actually expect.  */
! 
! #undef CPP_SPEC
! #define CPP_SPEC NETBSD_CPP_SPEC
! 
! #undef LINK_SPEC
! #define LINK_SPEC \
!   "%{!msdata=none:%{G*}} %{msdata=none:-G0} \
!    %(netbsd_link_spec)"
! 
! #define NETBSD_ENTRY_POINT "_start"
! 
! #undef STARTFILE_SPEC
! #define STARTFILE_SPEC NETBSD_STARTFILE_SPEC
! 
! #undef ENDFILE_SPEC
! #define ENDFILE_SPEC \
!   "crtsavres%O%s %(netbsd_endfile_spec)"
! 
! #undef LIB_SPEC
! #define LIB_SPEC NETBSD_LIB_SPEC
! 
! #undef SUBTARGET_EXTRA_SPECS
! #define SUBTARGET_EXTRA_SPECS					\
!   { "netbsd_link_spec",		NETBSD_LINK_SPEC_ELF },		\
!   { "netbsd_entry_point",	NETBSD_ENTRY_POINT },		\
!   { "netbsd_endfile_spec",	NETBSD_ENDFILE_SPEC },
  
  
  #undef TARGET_VERSION
! #define TARGET_VERSION fprintf (stderr, " (NetBSD/powerpc ELF)");
Index: config/rs6000/t-netbsd
===================================================================
RCS file: config/rs6000/t-netbsd
diff -N config/rs6000/t-netbsd
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- config/rs6000/t-netbsd	25 Nov 2002 00:30:05 -0000
***************
*** 0 ****
--- 1,42 ----
+ # Support for NetBSD PowerPC ELF targets (SVR4 ABI).
+ 
+ LIB2FUNCS_EXTRA = tramp.S
+ 
+ tramp.S: $(srcdir)/config/rs6000/tramp.asm
+ 	cat $(srcdir)/config/rs6000/tramp.asm > tramp.S
+ 
+ crtsavres.S: $(srcdir)/config/rs6000/crtsavres.asm
+ 	cat $(srcdir)/config/rs6000/crtsavres.asm >crtsavres.S
+ 
+ EXTRA_PARTS += crtsavres$(objext)
+ 
+ # It is important that crtbegin.o, etc., aren't surprised by stuff in .sdata.
+ CRTSTUFF_T_CFLAGS += -msdata=none
+ CRTSTUFF_T_CFLAGS_S += -msdata=none
+ 
+ # Switch synonyms
+ MULTILIB_MATCHES_FLOAT	= msoft-float=mcpu?401 \
+ 			  msoft-float=mcpu?403 \
+ 			  msoft-float=mcpu?405 \
+ 			  msoft-float=mcpu?ec603e \
+ 			  msoft-float=mcpu?801 \
+ 			  msoft-float=mcpu?821 \
+ 			  msoft-float=mcpu?823 \
+ 			  msoft-float=mcpu?860
+ 
+ MULTILIB_OPTIONS	= msoft-float
+ MULTILIB_DIRNAMES	= soft-float
+ MULTILIB_EXTRA_OPTS	= fPIC mstrict-align
+ MULTILIB_EXCEPTIONS	=
+ 
+ MULTILIB_MATCHES	= ${MULTILIB_MATCHES_FLOAT}
+ 
+ LIBGCC = stmp-multilib
+ INSTALL_LIBGCC = install-multilib
+ EXTRA_MULTILIB_PARTS = crtbegin$(objext) crtend$(objext) \
+   crtbeginS$(objext) crtendS$(objext) crtbeginT$(objext) \
+   crtsavres$(objext)
+ 
+ $(T)crtsavres$(objext): crtsavres.S
+ 	$(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS) \
+ 	  -c crtsavres.S -o $(T)crtsavres$(objext)


More information about the Gcc-patches mailing list