Committed 3.3: CRIS: recent trunk patches (build problems+CPP_PREDEFINES)

Hans-Peter Nilsson hp@bitrange.com
Tue Mar 11 03:04:00 GMT 2003


This is the 3.3 version of the recent trunk patches.  Actually only a
subset is needed, but keeping pertinent bits in sync with the trunk
simplifies my work and presumably does not complicate anything for
anyone else.  Built and tested cris-axis-aout (well, now builds, have
reasonable test-results), cris-elf and cris-axis-linux-gnu.
Committed.

	* config/cris/aout.h (ENDFILE_SPEC): Undef.
	(CRIS_CPP_SUBTARGET_SPEC): Move -D__AOUT__ to...
	(TARGET_OS_CPP_BUILTINS): New macro.
	(HAVE_GAS_HIDDEN): Undef.
	* config/cris/cris.h: Remove EGCS references.
	(CPP_SPEC): Remove "-$".
	(INIT_CUMULATIVE_ARGS): Correct comment.
	* config/cris/cris.h (CRIS_CPP_SUBTARGET_SPEC): Move -D__ELF__ to...
	(TARGET_OS_CPP_BUILTINS): New macro.
	(CPP_PREDEFINES): Don't define.  Move old definitions and...
	(CPP_SPEC): ...move -D__CRIS_ABI_version=2 to...
	(TARGET_CPU_CPP_BUILTINS): New macro.
	* config/cris/linux.h (CRIS_CPP_SUBTARGET_SPEC): Move constant
	definitions and the optional __PIC__, __pic__ and
	__NO_UNDERSCORES__ definitions to...
	(TARGET_OS_CPP_BUILTINS): New macro.

Index: aout.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/cris/aout.h,v
retrieving revision 1.6
diff -p -c -r1.6 aout.h
*** aout.h	26 Nov 2002 04:54:47 -0000	1.6
--- aout.h	11 Mar 2003 02:56:41 -0000
*************** Boston, MA 02111-1307, USA.  */
*** 48,53 ****
--- 48,56 ----
      %{!sim:%{pg:gcrt0.o%s}\
       %{!pg:%{p:mcrt0.o%s}%{!p:crt0.o%s}}}}}"

+ /* Override cris.h define.  */
+ #undef ENDFILE_SPEC
+
  /* Which library to get.  The only difference from the default is to get
     libsc.a if -sim is given to the driver.  Repeat -lc -lsysX
     {X=sim,linux}, because libsysX needs (at least) errno from libc, and
*************** Boston, MA 02111-1307, USA.  */
*** 64,71 ****

  #undef CRIS_CPP_SUBTARGET_SPEC
  #define CRIS_CPP_SUBTARGET_SPEC \
!  "-D__AOUT__\
!   %{melinux:-D__gnu_linux__ -D__linux__ -D__unix__ -D__elinux__ -D__uclinux__\
      %{!nostdinc:\
        %{!mbest-lib-options:%{isystem*}}\
        -isystem elinux/include%s\
--- 67,73 ----

  #undef CRIS_CPP_SUBTARGET_SPEC
  #define CRIS_CPP_SUBTARGET_SPEC \
!  "%{melinux:-D__gnu_linux__ -D__linux__ -D__unix__ -D__elinux__ -D__uclinux__\
      %{!nostdinc:\
        %{!mbest-lib-options:%{isystem*}}\
        -isystem elinux/include%s\
*************** Boston, MA 02111-1307, USA.  */
*** 118,123 ****
--- 120,138 ----
  #undef CRIS_SUBTARGET_DEFAULT
  #define CRIS_SUBTARGET_DEFAULT 0

+
+ /* Node: Run-time Target */
+
+ /* For the cris-*-aout subtarget.  */
+ #undef TARGET_OS_CPP_BUILTINS
+ #define TARGET_OS_CPP_BUILTINS()		\
+   do						\
+     {						\
+       builtin_define ("__AOUT__");		\
+     }						\
+   while (0)
+
+
  /* Node: Storage Layout */

  /* We can align to 16 bits (only) with CRIS a.out.  */
*************** Boston, MA 02111-1307, USA.  */
*** 342,347 ****
--- 357,369 ----
  	ASM_OUTPUT_MEASURED_SIZE (FILE, FNAME);			\
      }								\
    while (0)
+
+ /* The configure machinery invokes the assembler without options, which is
+    not how gcc invokes it.  Without options, the multi-target assembler
+    will probably be found, which is ELF by default.  To counter that, we
+    need to override ELF auto-host.h config stuff which we know collides
+    with a.out.  */
+ #undef HAVE_GAS_HIDDEN


  /* Node: Alignment Output */
Index: cris.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/cris/cris.h,v
retrieving revision 1.42
diff -p -c -r1.42 cris.h
*** cris.h	20 Oct 2002 22:37:09 -0000	1.42
--- cris.h	11 Mar 2003 02:56:42 -0000
***************
*** 1,5 ****
  /* Definitions for GCC.  Part of the machine description for CRIS.
!    Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
     Contributed by Axis Communications.  Written by Hans-Peter Nilsson.

  This file is part of GCC.
--- 1,5 ----
  /* Definitions for GCC.  Part of the machine description for CRIS.
!    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
     Contributed by Axis Communications.  Written by Hans-Peter Nilsson.

  This file is part of GCC.
*************** extern const char *cris_elinux_stacksize
*** 115,132 ****
  /* Also provide canonical vN definitions when user specifies an alias.
     Note that -melf overrides -maout.  */

- /* The `-$' is here mostly due to the integrated preprocessor not
-    handling the builtin expansion of "#define __REGISTER_PREFIX__ $"
-    gracefully.  This is slightly redundant although not incorrect.
-    We're quite alone defining REGISTER_PREFIX as "$" so it's unlikely
-    someone will fight for us.  This year in the mountains.
-    Note that for -melinux and -mlinux, command-line -isystem options are
-    emitted both before and after the synthesized one.  We can't remove all
-    of them: a %{<isystem} will only remove the first one and %{<isystem*}
-    will not do TRT.  Those extra occurrences are harmless anyway.  */
  #define CPP_SPEC \
!  "-$ -D__CRIS_ABI_version=2\
!   %{mtune=*:-D__tune_%* %{mtune=v*:-D__CRIS_arch_tune=%*}}\
     %{mtune=etrax4:-D__tune_v3 -D__CRIS_arch_tune=3}\
     %{mtune=etrax100:-D__tune_v8 -D__CRIS_arch_tune=8}\
     %{mtune=svinto:-D__tune_v8 -D__CRIS_arch_tune=8}\
--- 115,122 ----
  /* Also provide canonical vN definitions when user specifies an alias.
     Note that -melf overrides -maout.  */

  #define CPP_SPEC \
!  "%{mtune=*:-D__tune_%* %{mtune=v*:-D__CRIS_arch_tune=%*}}\
     %{mtune=etrax4:-D__tune_v3 -D__CRIS_arch_tune=3}\
     %{mtune=etrax100:-D__tune_v8 -D__CRIS_arch_tune=8}\
     %{mtune=svinto:-D__tune_v8 -D__CRIS_arch_tune=8}\
*************** extern const char *cris_elinux_stacksize
*** 150,157 ****

  /* For the cris-*-elf subtarget.  */
  #define CRIS_CPP_SUBTARGET_SPEC \
!  "-D__ELF__\
!   %{mbest-lib-options:\
     %{!moverride-best-lib-options:\
      %{!march=*:%{!metrax*:%{!mcpu=*:-D__tune_v10 -D__CRIS_arch_tune=10}}}}}"

--- 140,146 ----

  /* For the cris-*-elf subtarget.  */
  #define CRIS_CPP_SUBTARGET_SPEC \
!  "%{mbest-lib-options:\
     %{!moverride-best-lib-options:\
      %{!march=*:%{!metrax*:%{!mcpu=*:-D__tune_v10 -D__CRIS_arch_tune=10}}}}}"

*************** extern const char *cris_elinux_stacksize
*** 255,262 ****

  /* Node: Run-time Target */

! /* Only keep the non-varying ones here.  */
! #define CPP_PREDEFINES	"-Dcris -DCRIS -DGNU_CRIS"

  /* This needs to be at least 32 bits.  */
  extern int target_flags;
--- 244,266 ----

  /* Node: Run-time Target */

! #define TARGET_CPU_CPP_BUILTINS()		\
!   do						\
!     {						\
!       builtin_define_std ("cris");		\
!       builtin_define_std ("CRIS");		\
!       builtin_define_std ("GNU_CRIS");		\
!       builtin_define ("__CRIS_ABI_version=2");	\
!     }						\
!   while (0)
!
! #define TARGET_OS_CPP_BUILTINS()		\
!   do						\
!     {						\
!       builtin_define ("__ELF__");		\
!     }						\
!   while (0)
!

  /* This needs to be at least 32 bits.  */
  extern int target_flags;
*************** enum reg_class {NO_REGS, ALL_REGS, LIM_R
*** 956,964 ****
  struct cum_args {int regs;};

  /* The regs member is an integer, the number of arguments got into
!    registers so far, and lib is nonzero if init_cumulative_args was
!    found to generate a call to a library function.  */
! #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT)	  \
   ((CUM).regs = 0)

  #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)		\
--- 960,967 ----
  struct cum_args {int regs;};

  /* The regs member is an integer, the number of arguments got into
!    registers so far.  */
! #define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT)	\
   ((CUM).regs = 0)

  #define FUNCTION_ARG_ADVANCE(CUM, MODE, TYPE, NAMED)		\
*************** struct cum_args {int regs;};
*** 1246,1253 ****
     FIXME: Check and adjust for gcc-2.9x.  */
  #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) {}

! /* Functionality import from EGCS.
!    Kludge to solve Axis-990219: Work around imperfection in
     reload_load_address1:
      (plus (sign_extend (mem:qi (reg))) (reg))
     should be reloaded as (plus (reg) (reg)), not
--- 1249,1255 ----
     FIXME: Check and adjust for gcc-2.9x.  */
  #define LEGITIMIZE_ADDRESS(X, OLDX, MODE, WIN) {}

! /* Kludge to solve Axis-990219: Work around imperfection in
     reload_load_address1:
      (plus (sign_extend (mem:qi (reg))) (reg))
     should be reloaded as (plus (reg) (reg)), not
*************** struct cum_args {int regs;};
*** 1255,1263 ****
     There are no checks that reload_load_address_1 "reloads"
     addresses correctly, so invalidness is not caught or
     corrected.
!     When the right thing happens, the "something_reloaded" kludge can
!    be removed.  The right thing does not appear to happen for
!    EGCS CVS as of this date (above).  */

  #define LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_LEVELS, WIN) \
    do									\
--- 1257,1264 ----
     There are no checks that reload_load_address_1 "reloads"
     addresses correctly, so invalidness is not caught or
     corrected.
!     When the right thing happens in reload, the kludge can
!    be removed; still not as of 2003-02-27.  */

  #define LEGITIMIZE_RELOAD_ADDRESS(X, MODE, OPNUM, TYPE, IND_LEVELS, WIN) \
    do									\
Index: linux.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/cris/linux.h,v
retrieving revision 1.6
diff -p -c -r1.6 linux.h
*** linux.h	17 Jul 2002 01:49:49 -0000	1.6
--- linux.h	11 Mar 2003 02:56:42 -0000
***************
*** 1,5 ****
  /* Definitions for GCC.  Part of the machine description for CRIS.
!    Copyright (C) 2001, 2002 Free Software Foundation, Inc.
     Contributed by Axis Communications.  Written by Hans-Peter Nilsson.

  This file is part of GCC.
--- 1,5 ----
  /* Definitions for GCC.  Part of the machine description for CRIS.
!    Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
     Contributed by Axis Communications.  Written by Hans-Peter Nilsson.

  This file is part of GCC.
*************** Boston, MA 02111-1307, USA.  */
*** 47,56 ****

  #undef CRIS_CPP_SUBTARGET_SPEC
  #define CRIS_CPP_SUBTARGET_SPEC \
!   "-D__gnu_linux__ -D__linux__ -D__unix__  -D__ELF__\
!    %{pthread:-D_REENTRANT}\
!    %{fPIC|fpic: -D__PIC__ -D__pic__}\
!    %{!fleading-underscore:-fno-leading-underscore -D__NO_UNDERSCORES__}\
     %{!march=*:%{!cpu=*:-D__arch_v10 -D__CRIS_arch_version=10}}\
     %{!ansi:%{!std=*:%{!undef:-Dlinux -Dunix}\
       -Asystem(unix) -Asystem(posix) -Acpu(cris) -Amachine(cris)}}"
--- 47,53 ----

  #undef CRIS_CPP_SUBTARGET_SPEC
  #define CRIS_CPP_SUBTARGET_SPEC \
!   "%{pthread:-D_REENTRANT}\
     %{!march=*:%{!cpu=*:-D__arch_v10 -D__CRIS_arch_version=10}}\
     %{!ansi:%{!std=*:%{!undef:-Dlinux -Dunix}\
       -Asystem(unix) -Asystem(posix) -Acpu(cris) -Amachine(cris)}}"
*************** Boston, MA 02111-1307, USA.  */
*** 98,103 ****
--- 95,123 ----
    %{!shared:%{!static:%{rdynamic:-export-dynamic}}}\
    %{!r:%{O2|O3: --gc-sections}}"

+
+ /* Node: Run-time Target */
+
+ /* For the cris-*-linux* subtarget.  */
+ #undef TARGET_OS_CPP_BUILTINS
+ #define TARGET_OS_CPP_BUILTINS()		\
+   do						\
+     {						\
+       extern int flag_leading_underscore;	\
+       builtin_define ("__gnu_linux__");		\
+       builtin_define ("__linux__");		\
+       builtin_define ("__unix__");		\
+       builtin_define ("__ELF__");		\
+       if (flag_pic)				\
+ 	{					\
+ 	  builtin_define ("__PIC__");		\
+ 	  builtin_define ("__pic__");		\
+ 	}					\
+       if (flag_leading_underscore <= 0)		\
+ 	builtin_define ("__NO_UNDERSCORES__");	\
+     }						\
+   while (0)
+

  /* Node: Sections */

brgds, H-P



More information about the Gcc-patches mailing list