Patchwork svr4.h avoidance: sh

login
register
mail settings
Submitter Joseph S. Myers
Date Dec. 14, 2010, 6:34 p.m.
Message ID <Pine.LNX.4.64.1012141833590.9479@digraph.polyomino.org.uk>
Download mbox | patch
Permalink /patch/75519/
State New
Headers show

Comments

Joseph S. Myers - Dec. 14, 2010, 6:34 p.m.
This patch in the series removing svr4.h from the headers used by
particular targets in GCC stops sh*-* targets from using svr4.h.

The cases for these targets in config.gcc are very complicated.  But
the end effect as far as svr4.h is concerned is that all sh*-* targets
use sh/elf.h, and those sh*-* targets using svr4.h (which is all of
them except for sh*-*-netbsd*) use it immediately before sh/elf.h.
sh/elf.h then overrides most of the settings from svr4.h.  Thus the
only setting from svr4.h which ends up being used by any affected
targets is LIB_SPEC, which is only used by targets matching the first
case for many targets and then not matching sh*-*-linux*,
sh*-*-netbsd* or sh*-superh-elf, so ending up in the subcase

        *)              if test x$with_newlib = xyes \
                           && test x$with_libgloss = xyes; then
                                tm_file="${tm_file} sh/newlib.h"
                        fi
                        tm_file="${tm_file} sh/embed-elf.h" ;;

and not satisfying the condition for use of sh/newlib.h.  To deal with
these targets I added LIB_SPEC to sh/elf.h; other targets (including
sh*-*-netbsd* which did not use svr4.h) will continue to override that
macro in subsequent headers as they do now.  I used the same
simplified generic LIB_SPEC as in
<http://gcc.gnu.org/ml/gcc-patches/2010-12/msg00566.html>; the same
reasoning as there applies to the generic bare-metal targets, and for
the other affected case, Symbian, empty LIB_SPEC is used on ARM so it
seems doubtful the more complicated svr4.h version is appropriate for
SH.

Tested building cc1 and xgcc for crosses to: sh-elf sh-symbianelf
sh-linux-gnu sh-netbsdelf sh-rtems sh-wrs-vxworks.  (sh-symbianelf
remains broken for the same reason I previously noted: "error: attempt
to use poisoned "GCC_RTL_H"" and subsequent errors.)  OK to commit?

2010-12-14  Joseph Myers  <joseph@codesourcery.com>

	* config/sh/elf.h (LIB_SPEC): Define.
	* config.gcc (sh-*-elf* | sh[12346l]*-*-elf* | sh-*-symbianelf* |
	sh[12346l]*-*-symbianelf* | sh-*-linux* | sh[2346lbe]*-*-linux* |
	sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* |
	sh5l*-*-netbsd* | sh64-*-netbsd* | sh64l*-*-netbsd*, sh-*-rtems*,
	sh-wrs-vxworks): Don't use svr4.h.
Kaz Kojima - Dec. 15, 2010, 12:14 a.m.
"Joseph S. Myers" <joseph@codesourcery.com> wrote:
> Tested building cc1 and xgcc for crosses to: sh-elf sh-symbianelf
> sh-linux-gnu sh-netbsdelf sh-rtems sh-wrs-vxworks.  (sh-symbianelf
> remains broken for the same reason I previously noted: "error: attempt
> to use poisoned "GCC_RTL_H"" and subsequent errors.)  OK to commit?
> 
> 2010-12-14  Joseph Myers  <joseph@codesourcery.com>
> 
> 	* config/sh/elf.h (LIB_SPEC): Define.
> 	* config.gcc (sh-*-elf* | sh[12346l]*-*-elf* | sh-*-symbianelf* |
> 	sh[12346l]*-*-symbianelf* | sh-*-linux* | sh[2346lbe]*-*-linux* |
> 	sh-*-netbsdelf* | shl*-*-netbsdelf* | sh5-*-netbsd* |
> 	sh5l*-*-netbsd* | sh64-*-netbsd* | sh64l*-*-netbsd*, sh-*-rtems*,
> 	sh-wrs-vxworks): Don't use svr4.h.

OK.  Thanks!

Regards,
	kaz

Patch

Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 167746)
+++ gcc/config.gcc	(working copy)
@@ -2289,12 +2289,7 @@  sh-*-symbianelf* | sh[12346l]*-*-symbian
 	case ${with_endian} in
 	little*)	tm_file="sh/little.h ${tm_file}" ;;
 	esac
-	tm_file="${tm_file} dbxelf.h elfos.h"
-	case ${target} in
-	sh*-*-netbsd*)	;;
-	*)		tm_file="${tm_file} svr4.h" ;;
-	esac
-	tm_file="${tm_file} sh/elf.h"
+	tm_file="${tm_file} dbxelf.h elfos.h sh/elf.h"
 	case ${target} in
 	sh*-*-linux*)	tmake_file="${tmake_file} sh/t-linux"
 			tm_file="${tm_file} linux.h glibc-stdint.h sh/linux.h" ;;
@@ -2448,11 +2443,11 @@  sh-*-symbianelf* | sh[12346l]*-*-symbian
 	;;
 sh-*-rtems*)
 	tmake_file="sh/t-sh sh/t-elf t-rtems sh/t-rtems"
-	tm_file="${tm_file} dbxelf.h elfos.h svr4.h sh/elf.h sh/embed-elf.h sh/rtemself.h rtems.h newlib-stdint.h"
+	tm_file="${tm_file} dbxelf.h elfos.h sh/elf.h sh/embed-elf.h sh/rtemself.h rtems.h newlib-stdint.h"
 	;;
 sh-wrs-vxworks)
 	tmake_file="$tmake_file sh/t-sh sh/t-elf sh/t-vxworks"
-	tm_file="${tm_file} elfos.h svr4.h sh/elf.h sh/embed-elf.h vx-common.h vxworks.h sh/vxworks.h"
+	tm_file="${tm_file} elfos.h sh/elf.h sh/embed-elf.h vx-common.h vxworks.h sh/vxworks.h"
 	;;
 sparc-*-elf*)
 	tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h svr4.h sparc/sysv4.h sparc/sp-elf.h"
Index: gcc/config/sh/elf.h
===================================================================
--- gcc/config/sh/elf.h	(revision 167746)
+++ gcc/config/sh/elf.h	(working copy)
@@ -86,6 +86,9 @@  along with GCC; see the file COPYING3.  
 #define ENDFILE_SPEC \
   "%{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s"
 
+#undef LIB_SPEC
+#define LIB_SPEC "-lc"
+
 /* ASM_OUTPUT_CASE_LABEL is defined in elfos.h.  With it,
    a redundant .align was generated.  */
 #undef  ASM_OUTPUT_CASE_LABEL