diff mbox

Create common hooks structure shared between driver and cc1

Message ID Pine.LNX.4.64.1105242225350.21283@digraph.polyomino.org.uk
State New
Headers show

Commit Message

Joseph Myers May 24, 2011, 10:29 p.m. UTC
This patch implements a target hooks structure for hooks shared
between the driver and the core compilers.  Such hooks go in
libcommon-target.a which is then linked into the relevant binaries.
ALWAYS_STRIP_DOTDOT is converted to a hook as the initial hook for the
new structure.

Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  Also
tested building cc1 and xgcc for cross to hppa2.0w-hp-hpux11.23
(pa/som.h was the only header defining ALWAYS_STRIP_DOTDOT; note that
pa/t-pa previously was not used by any target, hence the complete
replacement of its contents).  OK to commit?

The general structure for these hooks is as described in
<http://gcc.gnu.org/ml/gcc-patches/2011-04/msg00434.html>, the
description of the patch that separated the C-family hooks structure
more cleanly from the main hooks.  In particular, the common/ and
common/config/ directories are used as described there.  I don't plan
to work on moving "common" files to the common/ directory but would
certainly encourage people to do so (and likewise to set up the
driver/ directory); files that should move include the sources of
libcommon.a and libcommon-target.a, and opts.c and params.c (which
will end up being used in libcommon-target.a), and *most* of the
headers used by those files.

(flags.h is a mess and should not I think be considered common; some
declarations should perhaps move to opts.h or tree.h.  The
SWITCHABLE_TARGET bits of flags.h, in particular, represent a hidden
dependency on tm.h (if tm.h isn't included first, flags.h will quietly
produce the wrong declarations), and a reason the header should not be
included in common or driver code; while cc1-only code generally uses
flags.h instead of options.h, maybe options.h should actually be more
widely used instead and flags.h should #error if used without tm.h.
coretypes.h isn't strictly common - many types defined there should
properly only be visible in the core compilers - but I think can
reasonably be treated as common initially.)

I *do* plan to move all the target hooks used in opts.c to the new
structure.

The following target macros used in both the driver (including cc1)
and the core compilers should I think end up in the new structure
(some are currently used in code built for the target so would need
extra work arranging for the compiler to predefine macros based on
them if -fbuilding-libgcc): NAME__MAIN NEXT_OBJC_RUNTIME
NO_DOLLAR_IN_LABEL NO_DOT_IN_LABEL STANDARD_EXEC_PREFIX
TARGET_EXECUTABLE_SUFFIX TARGET_OBJECT_SUFFIX USER_LABEL_PREFIX.  The
same applies to the following macros used in opts.c:
DEFAULT_GDB_EXTENSIONS DEFAULT_SIGNED_CHAR STACK_CHECK_BUILTIN
STACK_CHECK_STATIC_BUILTIN.  TARGET_64BIT is a special case that is
wrongly used in target-independent code but should be private to
particular ports.

The following target macros are used in both the driver and the core
compilers, but probably can't become hooks because of the ways they
are used: DBX_DEBUGGING_INFO DWARF2_DEBUGGING_INFO
PREFERRED_DEBUGGING_TYPE XCOFF_DEBUGGING_INFO.  Making them into
configure-defined macros (with different names for the sake of
poisoning) is probably appropriate; they are set by logic based on
combinations of target cases in config.gcc, configure options to
select particular formats that contribute entries to tm_file, and
toplevel configure.ac code(!)  that defaults --with-stabs on for
certain targets, and much simpler logic is probably appropriate in
practice (i.e. first follow configure options, failing that default to
DWARF2 except for a list of targets deliberately choosing other
formats, and similarly control what set of formats have support built
in).


2011-05-24  Joseph Myers  <joseph@codesourcery.com>

	* common/common-target-def.h, common/common-target.def,
	common/common-target.h, common/config/default-common.c,
	common/config/pa/pa-common.c: New files.
	* Makefile.in (EXTRA_COMMON_OBJS, COMMON_TARGET_DEF,
	COMMON_TARGET_H, COMMON_TARGET_DEF_H): New.
	(OBJS-libcommon-target): Include $(EXTRA_COMMON_OBJS).
	(prefix.o): Update dependencies.
	(default-common.o, common/common-target-hooks-def.h,
	s-common-target-hooks-def-h): New.
	(s-tm-texi): Also check timestamp on common-target.def.
	(build/genhooks.o): Update dependencies.
	* config.gcc (extra_common_objs, target_has_targetm_common):
	Define.
	(hppa*-*-*): Add pa/t-pa to tmake_file.
	* config/pa/som.h (ALWAYS_STRIP_DOTDOT): Replace with
	TARGET_ALWAYS_STRIP_DOTDOT.
	* config/pa/t-pa: Remove previous contents.
	(pa-common.o): New.
	* configure.ac (extra_common_objs): Substitute.
	(common): Create directory.
	* configure: Regenerate.
	* doc/tm.texi.in (targetm_common): Document.
	(TARGET_ALWAYS_STRIP_DOTDOT): Add @hook entry.
	* doc/tm.texi: Regenerate.
	* genhooks.c (hook_array): Also include common/common-target.def.
	* prefix.c (tm.h): Don't include.
	(common/common-target.h): Include.
	(ALWAYS_STRIP_DOTDOT): Don't define.
	(update_path): Use targetm_common.always_strip_dotdot instead of
	ALWAYS_STRIP_DOTDOT.
	* system.h (ALWAYS_STRIP_DOTDOT): Poison.
diff mbox

Patch

Index: gcc/doc/tm.texi
===================================================================
--- gcc/doc/tm.texi	(revision 174109)
+++ gcc/doc/tm.texi	(working copy)
@@ -99,6 +99,16 @@  initializer @code{TARGETCM_INITIALIZER} 
 themselves, they should set @code{target_has_targetcm=yes} in
 @file{config.gcc}; otherwise a default definition is used.
 
+Similarly, there is a @code{targetm_common} variable for hooks that
+are shared between the compiler driver and the compilers proper,
+documented as ``Common Target Hook''.  This is declared in
+@file{common/common-target.h}, the initializer
+@code{TARGETM_COMMON_INITIALIZER} in
+@file{common/common-target-def.h}.  If targets initialize
+@code{targetm_common} themselves, they should set
+@code{target_has_targetm_common=yes} in @file{config.gcc}; otherwise a
+default definition is used.
+
 @node Driver
 @section Controlling the Compilation Driver, @file{gcc}
 @cindex driver
@@ -383,6 +393,10 @@  directories from linking commands.  Do n
 removing duplicate search directories changes the linker's semantics.
 @end defmac
 
+@deftypevr {Common Target Hook} bool TARGET_ALWAYS_STRIP_DOTDOT
+True if @file{..} components should always be removed from directory names computed relative to GCC's internal directories, false (default) if such components should be preserved and directory names containing them passed to other tools such as the linker.
+@end deftypevr
+
 @defmac MULTILIB_DEFAULTS
 Define this macro as a C expression for the initializer of an array of
 string to tell the driver program which options are defaults for this
Index: gcc/doc/tm.texi.in
===================================================================
--- gcc/doc/tm.texi.in	(revision 174109)
+++ gcc/doc/tm.texi.in	(working copy)
@@ -99,6 +99,16 @@  initializer @code{TARGETCM_INITIALIZER} 
 themselves, they should set @code{target_has_targetcm=yes} in
 @file{config.gcc}; otherwise a default definition is used.
 
+Similarly, there is a @code{targetm_common} variable for hooks that
+are shared between the compiler driver and the compilers proper,
+documented as ``Common Target Hook''.  This is declared in
+@file{common/common-target.h}, the initializer
+@code{TARGETM_COMMON_INITIALIZER} in
+@file{common/common-target-def.h}.  If targets initialize
+@code{targetm_common} themselves, they should set
+@code{target_has_targetm_common=yes} in @file{config.gcc}; otherwise a
+default definition is used.
+
 @node Driver
 @section Controlling the Compilation Driver, @file{gcc}
 @cindex driver
@@ -383,6 +393,8 @@  directories from linking commands.  Do n
 removing duplicate search directories changes the linker's semantics.
 @end defmac
 
+@hook TARGET_ALWAYS_STRIP_DOTDOT
+
 @defmac MULTILIB_DEFAULTS
 Define this macro as a C expression for the initializer of an array of
 string to tell the driver program which options are defaults for this
Index: gcc/configure
===================================================================
--- gcc/configure	(revision 174109)
+++ gcc/configure	(working copy)
@@ -644,6 +644,7 @@  float_h_file
 extra_programs
 extra_passes
 extra_parts
+extra_common_objs
 extra_objs
 extra_headers_list
 user_headers_inc_next_post
@@ -17517,7 +17518,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17520 "configure"
+#line 17521 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -17623,7 +17624,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17626 "configure"
+#line 17627 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -26297,6 +26298,7 @@  fi
 
 
 
+
 # Echo link setup.
 if test x${build} = x${host} ; then
   if test x${host} = x${target} ; then
@@ -27854,7 +27856,7 @@  case ${CONFIG_HEADERS} in
   echo > cstamp-h ;;
 esac
 # Make sure all the subdirs exist.
-for d in $subdirs doc build c-family
+for d in $subdirs doc build common c-family
 do
     test -d $d || mkdir $d
 done
Index: gcc/common/common-target.h
===================================================================
--- gcc/common/common-target.h	(revision 0)
+++ gcc/common/common-target.h	(revision 0)
@@ -0,0 +1,35 @@ 
+/* Data structure definitions for common hooks.
+   Copyright (C) 2011
+   Free Software Foundation, Inc.
+
+   This program 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 3, or (at your option) any
+   later version.
+
+   This program 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 COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.
+
+   In other words, you are welcome to use, share and improve this program.
+   You are forbidden to forbid anyone else to use, share and improve
+   what you give them.   Help stamp out software-hoarding!  */
+
+#ifndef GCC_COMMON_TARGET_H
+#define GCC_COMMON_TARGET_H
+
+#define DEFHOOKPOD(NAME, DOC, TYPE, INIT) TYPE NAME;
+#define DEFHOOK(NAME, DOC, TYPE, PARAMS, INIT) TYPE (* NAME) PARAMS;
+#define DEFHOOK_UNDOC DEFHOOK
+#define HOOKSTRUCT(FRAGMENT) FRAGMENT
+
+#include "common-target.def"
+
+extern struct gcc_targetm_common targetm_common;
+
+#endif /* GCC_C_TARGET_H */
Index: gcc/common/config/pa/pa-common.c
===================================================================
--- gcc/common/config/pa/pa-common.c	(revision 0)
+++ gcc/common/config/pa/pa-common.c	(revision 0)
@@ -0,0 +1,28 @@ 
+/* HPPA common hooks.
+   Copyright (C) 2011
+   Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC 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 3, or (at your option)
+any later version.
+
+GCC 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 GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "common/common-target.h"
+#include "common/common-target-def.h"
+#include "tm.h"
+
+struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
Index: gcc/common/config/default-common.c
===================================================================
--- gcc/common/config/default-common.c	(revision 0)
+++ gcc/common/config/default-common.c	(revision 0)
@@ -0,0 +1,34 @@ 
+/* Default common target hooks initializer.
+   Copyright (C) 2011
+   Free Software Foundation, Inc.
+
+This file is part of GCC.
+
+GCC 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 3, or (at your option) any later
+version.
+
+GCC 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 GCC; see the file COPYING3.  If not see
+<http://www.gnu.org/licenses/>.  */
+
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "common/common-target.h"
+#include "common/common-target-def.h"
+
+/* Do not include tm.h or tm_p.h here; if it is useful for a target to
+   define some macros for the initializer in a header without defining
+   targetm_common itself (for example, because of interactions with
+   some hooks depending on the target OS and others on the target
+   architecture), create a separate tm_common.h for only the relevant
+   definitions.  */
+
+struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER;
Index: gcc/common/common-target.def
===================================================================
--- gcc/common/common-target.def	(revision 0)
+++ gcc/common/common-target.def	(revision 0)
@@ -0,0 +1,39 @@ 
+/* Target hook definitions for common hooks.
+   Copyright (C) 2011
+   Free Software Foundation, Inc.
+
+   This program 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 3, or (at your option) any
+   later version.
+
+   This program 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 COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+/* See target-hooks-macros.h for details of macros that should be
+   provided by the including file, and how to use them here.  */
+#include "target-hooks-macros.h"
+
+#undef HOOK_TYPE
+#define HOOK_TYPE "Common Target Hook"
+
+HOOK_VECTOR (TARGETM_COMMON_INITIALIZER, gcc_targetm_common)
+
+#undef HOOK_PREFIX
+#define HOOK_PREFIX "TARGET_"
+
+DEFHOOKPOD
+(always_strip_dotdot,
+ "True if @file{..} components should always be removed from directory names\
+ computed relative to GCC's internal directories, false (default) if such\
+ components should be preserved and directory names containing them passed\
+ to other tools such as the linker.",
+ bool, false)
+ 
+HOOK_VECTOR_END (C90_EMPTY_HACK)
Index: gcc/common/common-target-def.h
===================================================================
--- gcc/common/common-target-def.h	(revision 0)
+++ gcc/common/common-target-def.h	(revision 0)
@@ -0,0 +1,20 @@ 
+/* Default initializers for common target hooks.
+   Copyright (C) 2011
+   Free Software Foundation, Inc.
+
+   This program 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 3, or (at your option) any
+   later version.
+
+   This program 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 COPYING3.  If not see
+   <http://www.gnu.org/licenses/>.  */
+
+#include "common/common-target-hooks-def.h"
+#include "hooks.h"
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac	(revision 174109)
+++ gcc/configure.ac	(working copy)
@@ -4808,6 +4808,7 @@  AC_SUBST(user_headers_inc_next_pre)
 AC_SUBST(user_headers_inc_next_post)
 AC_SUBST(extra_headers_list)
 AC_SUBST(extra_objs)
+AC_SUBST(extra_common_objs)
 AC_SUBST(extra_parts)
 AC_SUBST(extra_passes)
 AC_SUBST(extra_programs)
@@ -5032,7 +5033,7 @@  case ${CONFIG_HEADERS} in
   echo > cstamp-h ;;
 esac
 # Make sure all the subdirs exist.
-for d in $subdirs doc build c-family
+for d in $subdirs doc build common c-family
 do
     test -d $d || mkdir $d
 done
Index: gcc/genhooks.c
===================================================================
--- gcc/genhooks.c	(revision 174109)
+++ gcc/genhooks.c	(working copy)
@@ -34,6 +34,7 @@  static struct hook_desc hook_array[] = {
   { "*", #TYPE, HOOK_PREFIX #NAME, #PARAMS, #INIT, HOOK_TYPE },
 #include "target.def"
 #include "c-family/c-target.def"
+#include "common/common-target.def"
 #undef DEFHOOK
 };
 
Index: gcc/system.h
===================================================================
--- gcc/system.h	(revision 174109)
+++ gcc/system.h	(working copy)
@@ -759,7 +759,7 @@  extern void fancy_abort (const char *, i
 	LABEL_ALIGN_MAX_SKIP LOOP_ALIGN_MAX_SKIP			\
 	LABEL_ALIGN_AFTER_BARRIER_MAX_SKIP JUMP_ALIGN_MAX_SKIP 		\
 	CAN_DEBUG_WITHOUT_FP UNLIKELY_EXECUTED_TEXT_SECTION_NAME	\
-	HOT_TEXT_SECTION_NAME LEGITIMATE_CONSTANT_P
+	HOT_TEXT_SECTION_NAME LEGITIMATE_CONSTANT_P ALWAYS_STRIP_DOTDOT
 
 /* Target macros only used for code built for the target, that have
    moved to libgcc-tm.h.  */
Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc	(revision 174109)
+++ gcc/config.gcc	(working copy)
@@ -114,6 +114,9 @@ 
 #  extra_gcc_objs	List of extra objects that should be linked into
 #			the compiler driver (gcc) depending on target.
 #
+#  extra_common_objs	List of extra objects that should go in
+#			libcommon-target.c depending on target.
+#
 #  extra_headers	List of used header files from the directory
 #			config/${cpu_type}.
 #
@@ -192,6 +195,9 @@ 
 #
 #  target_has_targetcm	Set to yes or no depending on whether the target
 #			has its own definition of targetcm.
+#
+#  target_has_targetm_common	Set to yes or no depending on whether the
+#			target has its own definition of targetm_common.
 
 out_file=
 tmake_file=
@@ -205,11 +211,13 @@  extra_parts=
 extra_programs=
 extra_objs=
 extra_gcc_objs=
+extra_common_objs=
 extra_options=
 c_target_objs=
 cxx_target_objs=
 fortran_target_objs=
 target_has_targetcm=no
+target_has_targetm_common=no
 tm_defines=
 xm_defines=
 libgcc_tm_file=
@@ -358,6 +366,8 @@  ia64-*-*)
 	;;
 hppa*-*-*)
 	cpu_type=pa
+	extra_common_objs="$extra_common_objs pa-common.o"
+	target_has_targetm_common=yes
 	;;
 lm32*)
 	extra_options="${extra_options} g.opt"
@@ -2698,6 +2708,10 @@  if [ "$target_has_targetcm" = "no" ]; th
   cxx_target_objs="$cxx_target_objs default-c.o"
 fi
 
+if [ "$target_has_targetm_common" = "no" ]; then
+  extra_common_objs="$extra_common_objs default-common.o"
+fi
+
 # Support for --with-cpu and related options (and a few unrelated options,
 # too).
 case ${with_cpu} in
@@ -3542,6 +3556,7 @@  case ${target} in
 
 	hppa*-*-*)
 		target_cpu_default2="MASK_BIG_SWITCH"
+		tmake_file="pa/t-pa $tmake_file"
 		if test x$gas = xyes
 		then
 			target_cpu_default2="${target_cpu_default2}|MASK_GAS|MASK_JUMP_IN_DELAY"
Index: gcc/Makefile.in
===================================================================
--- gcc/Makefile.in	(revision 174109)
+++ gcc/Makefile.in	(working copy)
@@ -714,6 +714,9 @@  EXTRA_OBJS = @extra_objs@
 # the gcc driver.
 EXTRA_GCC_OBJS =@extra_gcc_objs@
 
+# List of extra objects that should go in libcommon-target.a.
+EXTRA_COMMON_OBJS = @extra_common_objs@
+
 # List of additional header files to install.
 EXTRA_HEADERS =@extra_headers_list@
 
@@ -889,8 +892,10 @@  VEC_H = vec.h statistics.h
 EXCEPT_H = except.h $(HASHTAB_H) vecprim.h vecir.h
 TARGET_DEF = target.def target-hooks-macros.h
 C_TARGET_DEF = c-family/c-target.def target-hooks-macros.h
+COMMON_TARGET_DEF = common/common-target.def target-hooks-macros.h
 TARGET_H = $(TM_H) target.h $(TARGET_DEF) insn-modes.h
 C_TARGET_H = c-family/c-target.h $(C_TARGET_DEF)
+COMMON_TARGET_H = common/common-target.h $(COMMON_TARGET_DEF)
 MACHMODE_H = machmode.h mode-classes.def insn-modes.h
 HOOKS_H = hooks.h $(MACHMODE_H)
 HOSTHOOKS_DEF_H = hosthooks-def.h $(HOOKS_H)
@@ -898,6 +903,8 @@  LANGHOOKS_DEF_H = langhooks-def.h $(HOOK
 TARGET_DEF_H = target-def.h target-hooks-def.h $(HOOKS_H) targhooks.h
 C_TARGET_DEF_H = c-family/c-target-def.h c-family/c-target-hooks-def.h \
   $(TREE_H) $(C_COMMON_H) $(HOOKS_H)
+COMMON_TARGET_DEF_H = common/common-target-def.h \
+  common/common-target-hooks-def.h $(HOOKS_H)
 RTL_BASE_H = rtl.h rtl.def $(MACHMODE_H) reg-notes.def insn-notes.def \
   $(INPUT_H) $(REAL_H) statistics.h $(VEC_H) $(FIXED_VALUE_H) alias.h \
   $(HASHTAB_H)
@@ -1493,7 +1500,7 @@  OBJS-libcommon = diagnostic.o pretty-pri
 
 # Objects in libcommon-target.a, used by drivers and by the core
 # compiler and containing target-dependent code.
-OBJS-libcommon-target = prefix.o opts-common.o options.o
+OBJS-libcommon-target = $(EXTRA_COMMON_OBJS) prefix.o opts-common.o options.o
 
 # This lists all host objects for the front ends.
 ALL_HOST_FRONTEND_OBJS = $(C_OBJS) \
@@ -2220,8 +2227,8 @@  incpath.o: incpath.c incpath.h $(CONFIG_
 		intl.h prefix.h coretypes.h $(TM_H) cppdefault.h $(TARGET_H) \
 		$(MACHMODE_H)
 
-prefix.o: prefix.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) prefix.h \
-	Makefile $(BASEVER)
+prefix.o: prefix.c $(CONFIG_H) $(SYSTEM_H) coretypes.h prefix.h \
+	$(COMMON_TARGET_H) Makefile $(BASEVER)
 	$(COMPILER) $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
 	-DPREFIX=\"$(prefix)\" -DBASEVER=$(BASEVER_s) \
 	  -c $(srcdir)/prefix.c $(OUTPUT_OPTION)
@@ -2259,6 +2266,11 @@  gccspec.o: gccspec.c $(CONFIG_H) $(SYSTE
 cppspec.o: cppspec.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(GCC_H) \
     $(OPTS_H)
 
+default-common.o: common/config/default-common.c $(CONFIG_H) $(SYSTEM_H) \
+    coretypes.h $(COMMON_TARGET_H) $(COMMON_TARGET_DEF_H)
+	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
+	  $< $(OUTPUT_OPTION)
+
 specs.h : s-specs ; @true
 s-specs : Makefile
 	lsf="$(lang_specs_files)"; for f in $$lsf; do \
@@ -3738,6 +3750,15 @@  s-c-target-hooks-def-h: build/genhooks$(
 					     c-family/c-target-hooks-def.h
 	$(STAMP) s-c-target-hooks-def-h
 
+common/common-target-hooks-def.h: s-common-target-hooks-def-h; @true
+
+s-common-target-hooks-def-h: build/genhooks$(build_exeext)
+	$(RUN_GEN) build/genhooks$(build_exeext) "Common Target Hook" \
+					     > tmp-common-target-hooks-def.h
+	$(SHELL) $(srcdir)/../move-if-change tmp-common-target-hooks-def.h \
+					     common/common-target-hooks-def.h
+	$(STAMP) s-common-target-hooks-def-h
+
 # check if someone mistakenly only changed tm.texi.
 # We use a different pathname here to avoid a circular dependency.
 s-tm-texi: $(srcdir)/doc/../doc/tm.texi
@@ -3760,6 +3781,7 @@  s-tm-texi: build/genhooks$(build_exeext)
 	elif test $(srcdir)/doc/tm.texi -nt $(srcdir)/doc/tm.texi.in \
 	  && ( test $(srcdir)/doc/tm.texi -nt $(srcdir)/target.def \
 	    || test $(srcdir)/doc/tm.texi -nt $(srcdir)/c-family/c-target.def \
+	    || test $(srcdir)/doc/tm.texi -nt $(srcdir)/common/common-target.def \
 	  ); then \
 	  echo >&2 ; \
 	  echo You should edit $(srcdir)/doc/tm.texi.in rather than $(srcdir)/doc/tm.texi . >&2 ; \
@@ -3974,7 +3996,7 @@  build/genpreds.o : genpreds.c $(RTL_BASE
 build/genrecog.o : genrecog.c $(RTL_BASE_H) $(BCONFIG_H) $(SYSTEM_H)	\
   coretypes.h $(GTM_H) errors.h $(READ_MD_H) gensupport.h
 build/genhooks.o : genhooks.c $(TARGET_DEF) $(C_TARGET_DEF)		\
-  $(BCONFIG_H) $(SYSTEM_H) errors.h
+  $(COMMON_TARGET_DEF) $(BCONFIG_H) $(SYSTEM_H) errors.h
 
 # Compile the programs that generate insn-* from the machine description.
 # They are compiled with $(COMPILER_FOR_BUILD), and associated libraries,
Index: gcc/config/pa/som.h
===================================================================
--- gcc/config/pa/som.h	(revision 174109)
+++ gcc/config/pa/som.h	(working copy)
@@ -1,5 +1,5 @@ 
 /* Definitions for SOM assembler support.
-   Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2007, 2010
+   Copyright (C) 1999, 2001, 2002, 2003, 2004, 2005, 2007, 2010, 2011
    Free Software Foundation, Inc.
 
 This file is part of GCC.
@@ -269,7 +269,8 @@  do {						\
    must be removed from library prefixes to prevent binaries from depending
    on the location of the GCC tool directory.  The downside is GCC
    cannot be moved after installation using a symlink.  */
-#define ALWAYS_STRIP_DOTDOT 1
+#undef TARGET_ALWAYS_STRIP_DOTDOT
+#define TARGET_ALWAYS_STRIP_DOTDOT true
 
 /* If GAS supports weak, we can support weak when we have working linker
    support for secondary definitions and are generating code for GAS.
Index: gcc/config/pa/t-pa
===================================================================
--- gcc/config/pa/t-pa	(revision 174109)
+++ gcc/config/pa/t-pa	(working copy)
@@ -1,7 +1,4 @@ 
-TARGET_LIBGCC2_CFLAGS = -fPIC
-
-LIB2FUNCS_EXTRA=lib2funcs.asm
-
-lib2funcs.asm: $(srcdir)/config/pa/lib2funcs.asm
-	rm -f lib2funcs.asm
-	cp $(srcdir)/config/pa/lib2funcs.asm .
+pa-common.o: $(srcdir)/common/config/pa/pa-common.c $(CONFIG_H) $(SYSTEM_H) \
+    coretypes.h $(COMMON_TARGET_H) $(COMMON_TARGET_DEF_H)
+	$(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) \
+	  $< $(OUTPUT_OPTION)
Index: gcc/prefix.c
===================================================================
--- gcc/prefix.c	(revision 174109)
+++ gcc/prefix.c	(working copy)
@@ -1,6 +1,6 @@ 
 /* Utility to update paths from internal to external forms.
    Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
-   2007  Free Software Foundation, Inc.
+   2007, 2011  Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -67,11 +67,11 @@  License along with GCC; see the file COP
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
-#include "tm.h"
 #if defined(_WIN32) && defined(ENABLE_WIN32_REGISTRY)
 #include <windows.h>
 #endif
 #include "prefix.h"
+#include "common/common-target.h"
 
 static const char *std_prefix = PREFIX;
 
@@ -271,10 +271,6 @@  update_path (const char *path, const cha
   else
     result = xstrdup (path);
 
-#ifndef ALWAYS_STRIP_DOTDOT
-#define ALWAYS_STRIP_DOTDOT 0
-#endif
-
   p = result;
   while (1)
     {
@@ -289,7 +285,8 @@  update_path (const char *path, const cha
 	  && (p != result && IS_DIR_SEPARATOR (p[-1])))
 	{
 	  *p = 0;
-	  if (!ALWAYS_STRIP_DOTDOT && access (result, X_OK) == 0)
+	  if (!targetm_common.always_strip_dotdot
+	      && access (result, X_OK) == 0)
 	    {
 	      *p = '.';
 	      break;