[PR 69920] Prevent SRA from leaving a removed SSA_NAME in IL
[gcc.git] / libgcc / Makefile.in
index a2cb7c707138701990b0b0a77f097a28dcc5306b..f09b39b0e85fdd0aa61b147238dd4b584b3d2f6a 100644 (file)
@@ -1,6 +1,6 @@
 # Makefile.in
 
-# Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation
+# Copyright (C) 2005-2016 Free Software Foundation, Inc.
 #
 # This file is part of GCC.
 #
@@ -22,7 +22,6 @@
 libgcc_topdir = @libgcc_topdir@
 host_subdir = @host_subdir@
 
-gcc_srcdir = $(libgcc_topdir)/gcc
 gcc_objdir = $(MULTIBUILDTOP)../../$(host_subdir)/gcc
 
 srcdir = @srcdir@
@@ -40,16 +39,23 @@ enable_shared = @enable_shared@
 double_type_size = @double_type_size@
 long_double_type_size = @long_double_type_size@
 decimal_float = @decimal_float@
+enable_vtable_verify = @enable_vtable_verify@
 enable_decimal_float = @enable_decimal_float@
 fixed_point = @fixed_point@
+with_aix_soname = @with_aix_soname@
 
 host_noncanonical = @host_noncanonical@
+real_host_noncanonical = @real_host_noncanonical@
 target_noncanonical = @target_noncanonical@
 
 # List of extra object files that should be compiled for this target machine.
 # The rules for compiling them should be in the t-* file for the machine.
 EXTRA_PARTS = @extra_parts@
 
+FORCE_EXPLICIT_EH_REGISTRY = @force_explicit_eh_registry@
+
+extra-parts = libgcc-extra-parts
+
 # Multilib support variables.
 MULTISRCTOP =
 MULTIBUILDTOP =
@@ -62,6 +68,7 @@ INSTALL = @INSTALL@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_DATA = @INSTALL_DATA@
 mkinstalldirs = $(SHELL) $(libgcc_topdir)/mkinstalldirs
+INSTALL_PARTS = $(EXTRA_PARTS)
 
 objext = .o
 
@@ -119,7 +126,8 @@ installcheck:
 .PHONY: all clean
 
 clean:
-       -rm -f config.h stamp-h stmp-ldirs libgcc.map
+       -rm -f libgcc_tm.h libgcc.map
+       -rm -f libgcc_tm.stamp stmp-ldirs
        -rm -f *$(objext)
        -rm -f *.dep
        -rm -f *.a
@@ -128,6 +136,8 @@ clean:
        @$(MULTICLEAN) multi-clean DO=clean
 distclean: clean
        @$(MULTICLEAN) multi-clean DO=distclean
+       -rm -f auto-target.h
+       -rm -f stamp-h
        -rm -f *~ Makefile config.cache config.status multilib.out
        -rm -f config.log
 maintainer-clean realclean: distclean
@@ -137,9 +147,9 @@ Makefile: $(srcdir)/Makefile.in config.status
 
 # Depending on Makefile makes sure that config.status has been re-run
 # if needed.  This prevents problems with parallel builds.
-config.h: stamp-h ; @true
+auto-target.h: stamp-h ; @true
 stamp-h: $(srcdir)/config.in config.status Makefile
-       CONFIG_FILES= CONFIG_HEADERS=config.h:$(srcdir)/config.in $(SHELL) ./config.status
+       CONFIG_FILES= CONFIG_HEADERS=auto-target.h:$(srcdir)/config.in $(SHELL) ./config.status
 
 config.status: $(srcdir)/configure $(srcdir)/config.host
        $(SHELL) ./config.status --recheck
@@ -176,7 +186,7 @@ STRIP = @STRIP@
 STRIP_FOR_TARGET = $(STRIP)
 
 # Directory in which the compiler finds libraries etc.
-libsubdir = $(libdir)/gcc/$(host_noncanonical)/$(version)
+libsubdir = $(libdir)/gcc/$(real_host_noncanonical)/$(version)@accel_dir_suffix@
 # Used to install the shared libgcc.
 slibdir = @slibdir@
 # Maybe used for DLLs on Windows targets.
@@ -204,7 +214,7 @@ export slibdir
 export toolexecdir
 export toolexeclibdir
 
-version := $(shell $(CC) -dumpversion)
+version := $(shell cat $(srcdir)/../gcc/BASE-VER)
 
 ifeq ($(decimal_float),yes)
 ifeq ($(enable_decimal_float),bid)
@@ -217,6 +227,41 @@ else
 DECNUMINC =
 endif
 
+# Options to use when compiling libgcc2.a.
+#
+LIBGCC2_DEBUG_CFLAGS = -g
+LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
+                $(LIBGCC2_DEBUG_CFLAGS) -DIN_LIBGCC2 \
+                -fbuilding-libgcc -fno-stack-protector \
+                $(INHIBIT_LIBC_CFLAGS)
+
+# Additional options to use when compiling libgcc2.a.
+# Some targets override this to -isystem include
+LIBGCC2_INCLUDES =
+
+# Additional target-dependent options for compiling libgcc2.a.
+HOST_LIBGCC2_CFLAGS =
+
+PICFLAG = @PICFLAG@
+
+# Defined in libgcc2.c, included only in the static library.
+LIB2FUNCS_ST = _eprintf __gcc_bcmp
+
+# List of functions not to build from libgcc2.c.
+LIB2FUNCS_EXCLUDE =
+
+# These might cause a divide overflow trap and so are compiled with
+# unwinder info.
+LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4
+
+# List of extra C and assembler files to add to static and shared libgcc2.
+# Assembler files should have names ending in `.S'.
+LIB2ADD = 
+
+# List of extra C and assembler files to add to static libgcc2.
+# Assembler files should have names ending in `.S'.
+LIB2ADD_ST =
+
 # Specify the directories to be searched for header files.
 # Both . and srcdir are used, in that order,
 # so that *config.h will be found in the compilation
@@ -238,6 +283,16 @@ override CFLAGS := $(filter-out -fprofile-generate -fprofile-use,$(CFLAGS))
 INTERNAL_CFLAGS = $(CFLAGS) $(LIBGCC2_CFLAGS) $(HOST_LIBGCC2_CFLAGS) \
                  $(INCLUDES) @set_have_cc_tls@ @set_use_emutls@
 
+# Options to use when compiling crtbegin/end.
+CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \
+  $(NO_PIE_CFLAGS) -finhibit-size-directive -fno-inline -fno-exceptions \
+  -fno-zero-initialized-in-bss -fno-toplevel-reorder -fno-tree-vectorize \
+  -fbuilding-libgcc -fno-stack-protector $(FORCE_EXPLICIT_EH_REGISTRY) \
+  $(INHIBIT_LIBC_CFLAGS)
+
+# Extra flags to use when compiling crt{begin,end}.o.
+CRTSTUFF_T_CFLAGS =
+
 MULTIDIR := $(shell $(CC) $(CFLAGS) -print-multi-directory)
 MULTIOSDIR := $(shell $(CC) $(CFLAGS) -print-multi-os-directory)
 
@@ -279,6 +334,9 @@ LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde.c \
 LIB2ADDEHSTATIC = $(LIB2ADDEH)
 LIB2ADDEHSHARED = $(LIB2ADDEH)
 
+# nm flags to list global symbols in libgcc object files.
+SHLIB_NM_FLAGS = -pg
+
 # Don't build libunwind by default.
 LIBUNWIND =
 SHLIBUNWIND_LINK =
@@ -287,6 +345,16 @@ SHLIBUNWIND_INSTALL =
 tmake_file = @tmake_file@
 include $(srcdir)/empty.mk $(tmake_file)
 
+# Collect target defines and headers from config.host.
+libgcc_tm_defines = @tm_defines@
+libgcc_tm_file = @tm_file@
+libgcc_tm.h: libgcc_tm.stamp; @true
+libgcc_tm.stamp:
+       DEFINES='$(libgcc_tm_defines)' HEADERS='$(libgcc_tm_file)' \
+               $(srcdir)/mkheader.sh > tmp-libgcc_tm.h
+       $(SHELL) $(srcdir)/../move-if-change tmp-libgcc_tm.h libgcc_tm.h
+       echo timestamp > $@
+
 # Only handle shared libraries if both:
 #   - the user requested them
 #   - we know how to build them
@@ -302,6 +370,7 @@ ifeq ($(enable_shared),yes)
   ifneq ($(LIBUNWIND),)
     install-libunwind = install-libunwind
   endif
+endif
 
 # For -fvisibility=hidden.  We need both a -fvisibility=hidden on
 # the command line, and a #define to prevent libgcc2.h etc from
@@ -325,25 +394,15 @@ else
 gen-hide-list = echo > $@
 endif
 
-else
-# Not enable_shared.
+ifneq ($(enable_shared),yes)
 iterator = $(srcdir)/empty.mk $(patsubst %,$(srcdir)/static-object.mk,$(iter-items))
-vis_hide =
-gen-hide-list = echo > \$@
-endif
-
-ifneq ($(EXTRA_PARTS),)
-  extra-parts = libgcc-extra-parts
-  INSTALL_PARTS = $(EXTRA_PARTS)
-else
-ifneq ($(GCC_EXTRA_PARTS),)
-  extra-parts = gcc-extra-parts
-  INSTALL_PARTS = $(GCC_EXTRA_PARTS)
-endif
 endif
 
 LIB2ADD += enable-execute-stack.c
 
+# While emutls.c has nothing to do with EH, it is in LIB2ADDEH*
+# instead of LIB2ADD because that's the way to be sure on some targets
+# (e.g. *-*-darwin*) only one copy of it is linked.
 LIB2ADDEH += $(srcdir)/emutls.c
 LIB2ADDEHSTATIC += $(srcdir)/emutls.c
 LIB2ADDEHSHARED += $(srcdir)/emutls.c
@@ -385,43 +444,33 @@ LIB2_DIVMOD_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE) $(LIB1ASMFUNCS), \
                       $(LIB2_DIVMOD_FUNCS))
 
 # Build "libgcc1" (assembly) components.
-ifeq ($(enable_shared),yes)
 
 lib1asmfuncs-o = $(patsubst %,%$(objext),$(LIB1ASMFUNCS))
-$(lib1asmfuncs-o): %$(objext): $(gcc_srcdir)/config/$(LIB1ASMSRC) %.vis
-       $(gcc_compile) -DL$* -xassembler-with-cpp \
-         -c $(gcc_srcdir)/config/$(LIB1ASMSRC) -include $*.vis
+$(lib1asmfuncs-o): %$(objext): $(srcdir)/config/$(LIB1ASMSRC) %.vis
+       $(gcc_compile) -DL$* -xassembler-with-cpp -c $< -include $*.vis
 $(patsubst %,%.vis,$(LIB1ASMFUNCS)): %.vis: %_s$(objext)
        $(gen-hide-list)
 libgcc-objects += $(lib1asmfuncs-o)
 
 lib1asmfuncs-s-o = $(patsubst %,%_s$(objext),$(LIB1ASMFUNCS))
-$(lib1asmfuncs-s-o): %_s$(objext): $(gcc_srcdir)/config/$(LIB1ASMSRC)
-       $(gcc_s_compile) -DL$* -xassembler-with-cpp \
-         -c $(gcc_srcdir)/config/$(LIB1ASMSRC)
-libgcc-s-objects += $(lib1asmfuncs-s-o)
-
-else
+$(lib1asmfuncs-s-o): %_s$(objext): $(srcdir)/config/$(LIB1ASMSRC)
+       $(gcc_s_compile) -DL$* -xassembler-with-cpp -c $<
+ifeq ($(enable_shared),yes)
 
-lib1asmfuncs-o = $(patsubst %,%$(objext),$(LIB1ASMFUNCS))
-$(lib1asmfuncs-o): %$(objext): $(gcc_srcdir)/config/$(LIB1ASMSRC)
-       $(gcc_compile) -DL$* -xassembler-with-cpp \
-         -c $(gcc_srcdir)/config/$(LIB1ASMSRC)
-libgcc-objects += $(lib1asmfuncs-o)
+libgcc-s-objects += $(lib1asmfuncs-s-o)
 
 endif
 
 # Build lib2funcs.  For the static library also include LIB2FUNCS_ST.
 lib2funcs-o = $(patsubst %,%$(objext),$(lib2funcs) $(LIB2FUNCS_ST))
-$(lib2funcs-o): %$(objext): $(gcc_srcdir)/libgcc2.c
-       $(gcc_compile) -DL$* -c $(gcc_srcdir)/libgcc2.c \
-         $(vis_hide)
+$(lib2funcs-o): %$(objext): $(srcdir)/libgcc2.c
+       $(gcc_compile) -DL$* -c $< $(vis_hide)
 libgcc-objects += $(lib2funcs-o)
 
 ifeq ($(enable_shared),yes)
 lib2funcs-s-o = $(patsubst %,%_s$(objext),$(lib2funcs))
-$(lib2funcs-s-o): %_s$(objext): $(gcc_srcdir)/libgcc2.c
-       $(gcc_s_compile) -DL$* -c $(gcc_srcdir)/libgcc2.c
+$(lib2funcs-s-o): %_s$(objext): $(srcdir)/libgcc2.c
+       $(gcc_s_compile) -DL$* -c $<
 libgcc-s-objects += $(lib2funcs-s-o)
 endif
 
@@ -447,18 +496,24 @@ libgcc-s-objects += $(patsubst %,%_s$(objext),$(sifuncs) $(difuncs) $(tifuncs))
 endif
 endif
 
+ifeq ($(LIB2_DIVMOD_EXCEPTION_FLAGS),)
+# Provide default flags for compiling divmod functions, if they haven't been
+# set already by a target-specific Makefile fragment.
+LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions -fnon-call-exceptions
+endif
+
 # Build LIB2_DIVMOD_FUNCS.
 lib2-divmod-o = $(patsubst %,%$(objext),$(LIB2_DIVMOD_FUNCS))
-$(lib2-divmod-o): %$(objext): $(gcc_srcdir)/libgcc2.c
-       $(gcc_compile) -DL$* -c $(gcc_srcdir)/libgcc2.c \
-         -fexceptions -fnon-call-exceptions $(vis_hide)
+$(lib2-divmod-o): %$(objext): $(srcdir)/libgcc2.c
+       $(gcc_compile) -DL$* -c $< \
+         $(LIB2_DIVMOD_EXCEPTION_FLAGS) $(vis_hide)
 libgcc-objects += $(lib2-divmod-o)
 
 ifeq ($(enable_shared),yes)
 lib2-divmod-s-o = $(patsubst %,%_s$(objext),$(LIB2_DIVMOD_FUNCS))
-$(lib2-divmod-s-o): %_s$(objext): $(gcc_srcdir)/libgcc2.c
-       $(gcc_s_compile) -DL$* -c $(gcc_srcdir)/libgcc2.c \
-         -fexceptions -fnon-call-exceptions
+$(lib2-divmod-s-o): %_s$(objext): $(srcdir)/libgcc2.c
+       $(gcc_s_compile) -DL$* -c $< \
+         $(LIB2_DIVMOD_EXCEPTION_FLAGS)
 libgcc-s-objects += $(lib2-divmod-s-o)
 endif
 
@@ -468,6 +523,10 @@ FPBIT_FUNCS := $(filter-out _sf_to_tf,$(FPBIT_FUNCS))
 DPBIT_FUNCS := $(filter-out _df_to_tf,$(DPBIT_FUNCS))
 endif
 
+FPBIT_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE),$(FPBIT_FUNCS))
+DPBIT_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE),$(DPBIT_FUNCS))
+TPBIT_FUNCS := $(filter-out $(LIB2FUNCS_EXCLUDE),$(TPBIT_FUNCS))
+
 fpbit-src := $(srcdir)/fp-bit.c
 
 # Build FPBIT.
@@ -715,9 +774,9 @@ iter-to := $(fixed-modes)
 include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/fixed-obj.mk,$(iter-items))
 
 # Add arithmetic functions to list of objects to be built
-libgcc-objects += $(patsubst %,%$(objext),$(fixed-funcs))
+libgcc-objects += $(patsubst %,%$(objext),$(filter-out $(LIB2FUNCS_EXCLUDE),$(fixed-funcs)))
 ifeq ($(enable_shared),yes)
-libgcc-s-objects += $(patsubst %,%_s$(objext),$(fixed-funcs))
+libgcc-s-objects += $(patsubst %,%_s$(objext),$(filter-out $(LIB2FUNCS_EXCLUDE),$(fixed-funcs)))
 endif
 
 # Convert from or to fractional
@@ -734,9 +793,9 @@ iter-to := $(fixed-conv-to)
 include $(srcdir)/empty.mk $(patsubst %,$(srcdir)/fixed-obj.mk,$(iter-items))
 
 # Add conversion functions to list of objects to be built
-libgcc-objects += $(patsubst %,%$(objext),$(fixed-conv-funcs))
+libgcc-objects += $(patsubst %,%$(objext),$(filter-out $(LIB2FUNCS_EXCLUDE),$(fixed-conv-funcs)))
 ifeq ($(enable_shared),yes)
-libgcc-s-objects += $(patsubst %,%_s$(objext),$(fixed-conv-funcs))
+libgcc-s-objects += $(patsubst %,%_s$(objext),$(filter-out $(LIB2FUNCS_EXCLUDE),$(fixed-conv-funcs)))
 endif
 
 endif
@@ -781,9 +840,10 @@ include $(iterator)
 
 endif
 
-# Build LIBUNWIND.
+# Build LIBUNWIND. Use -fno-exceptions so that the unwind library does
+# not generate calls to __gcc_personality_v0.
 
-c_flags := -fexceptions
+c_flags := -fno-exceptions
 
 libunwind-objects += $(addsuffix $(objext),$(basename $(notdir $(LIBUNWIND))))
 
@@ -796,18 +856,34 @@ include $(iterator)
 
 # Build libgcov components.
 
-# Defined in libgcov.c, included only in gcov library
-LIBGCOV = _gcov _gcov_merge_add _gcov_merge_single _gcov_merge_delta \
-    _gcov_fork _gcov_execl _gcov_execlp _gcov_execle \
-    _gcov_execv _gcov_execvp _gcov_execve \
-    _gcov_interval_profiler _gcov_pow2_profiler _gcov_one_value_profiler \
-    _gcov_indirect_call_profiler _gcov_average_profiler _gcov_ior_profiler \
-    _gcov_merge_ior
-
-libgcov-objects = $(patsubst %,%$(objext),$(LIBGCOV))
-
-$(libgcov-objects): %$(objext): $(srcdir)/libgcov.c
-       $(gcc_compile) -DL$* -c $(srcdir)/libgcov.c
+LIBGCOV_MERGE = _gcov_merge_add _gcov_merge_single _gcov_merge_delta   \
+       _gcov_merge_ior _gcov_merge_time_profile _gcov_merge_icall_topn
+LIBGCOV_PROFILER = _gcov_interval_profiler _gcov_pow2_profiler         \
+       _gcov_one_value_profiler _gcov_indirect_call_profiler           \
+       _gcov_average_profiler _gcov_ior_profiler                       \
+       _gcov_indirect_call_profiler_v2 _gcov_time_profiler             \
+       _gcov_indirect_call_topn_profiler
+LIBGCOV_INTERFACE = _gcov_dump _gcov_flush _gcov_fork                  \
+       _gcov_execl _gcov_execlp                                        \
+       _gcov_execle _gcov_execv _gcov_execvp _gcov_execve _gcov_reset
+LIBGCOV_DRIVER = _gcov
+
+libgcov-merge-objects = $(patsubst %,%$(objext),$(LIBGCOV_MERGE))
+libgcov-profiler-objects = $(patsubst %,%$(objext),$(LIBGCOV_PROFILER))
+libgcov-interface-objects = $(patsubst %,%$(objext),$(LIBGCOV_INTERFACE))
+libgcov-driver-objects = $(patsubst %,%$(objext),$(LIBGCOV_DRIVER))
+libgcov-objects = $(libgcov-merge-objects) $(libgcov-profiler-objects) \
+                 $(libgcov-interface-objects) $(libgcov-driver-objects)
+
+$(libgcov-merge-objects): %$(objext): $(srcdir)/libgcov-merge.c $(srcdir)/libgcov.h
+       $(gcc_compile) -DL$* -c $(srcdir)/libgcov-merge.c
+$(libgcov-profiler-objects): %$(objext): $(srcdir)/libgcov-profiler.c $(srcdir)/libgcov.h
+       $(gcc_compile) -DL$* -c $(srcdir)/libgcov-profiler.c
+$(libgcov-interface-objects): %$(objext): $(srcdir)/libgcov-interface.c $(srcdir)/libgcov.h
+       $(gcc_compile) -DL$* -c $(srcdir)/libgcov-interface.c
+$(libgcov-driver-objects): %$(objext): $(srcdir)/libgcov-driver.c \
+  $(srcdir)/libgcov-driver-system.c $(srcdir)/libgcov.h
+       $(gcc_compile) -DL$* -c $(srcdir)/libgcov-driver.c
 
 
 # Static libraries.
@@ -834,26 +910,27 @@ all: libgcc.a libgcov.a
 
 ifneq ($(LIBUNWIND),)
 all: libunwind.a
-libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT)
 endif
 
 ifeq ($(enable_shared),yes)
 all: libgcc_eh.a libgcc_s$(SHLIB_EXT)
 ifneq ($(LIBUNWIND),)
 all: libunwind$(SHLIB_EXT)
-endif
+libgcc_s$(SHLIB_EXT): libunwind$(SHLIB_EXT)
 endif
 
-ifeq ($(enable_shared),yes)
-
 # Map-file generation.
 ifneq ($(SHLIB_MKMAP),)
-libgcc.map: $(SHLIB_MKMAP) $(SHLIB_MAPFILES) $(libgcc-s-objects)
-       { $(NM) $(SHLIB_NM_FLAGS) $(libgcc-s-objects); echo %%; \
-         cat $(SHLIB_MAPFILES) \
+libgcc.map.in: $(SHLIB_MAPFILES)
+       { cat $(SHLIB_MAPFILES) \
            | sed -e '/^[       ]*#/d' \
                  -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \
            | $(gcc_compile_bare) -E -xassembler-with-cpp -; \
+       } > tmp-$@
+       mv tmp-$@ $@
+libgcc.map: $(SHLIB_MKMAP) libgcc.map.in $(libgcc-s-objects)
+       { $(NM) $(SHLIB_NM_FLAGS) $(libgcc-s-objects); echo %%; \
+         cat libgcc.map.in; \
        } | $(AWK) -f $(SHLIB_MKMAP) $(SHLIB_MKMAP_OPTS) > tmp-$@
        mv tmp-$@ $@
 libgcc_s$(SHLIB_EXT): libgcc.map
@@ -864,7 +941,7 @@ libgcc-std.ver: $(srcdir)/libgcc-std.ver.in
        sed -e 's/__PFX__/$(LIBGCC_VER_GNU_PREFIX)/g' \
            -e 's/__FIXPTPFX__/$(LIBGCC_VER_FIXEDPOINT_GNU_PREFIX)/g' < $< > $@
 
-libgcc_s$(SHLIB_EXT): $(libgcc-s-objects) $(extra-parts)
+libgcc_s$(SHLIB_EXT): $(libgcc-s-objects) $(extra-parts) libgcc.a
        # @multilib_flags@ is still needed because this may use
        # $(GCC_FOR_TARGET) and $(LIBGCC2_CFLAGS) directly.
        # @multilib_dir@ is not really necessary, but sometimes it has
@@ -872,7 +949,7 @@ libgcc_s$(SHLIB_EXT): $(libgcc-s-objects) $(extra-parts)
        $(mkinstalldirs) $(MULTIDIR)
        $(subst @multilib_flags@,$(CFLAGS) -B./,$(subst \
                @multilib_dir@,$(MULTIDIR),$(subst \
-               @shlib_objs@,$(objects),$(subst \
+               @shlib_objs@,$(objects) libgcc.a,$(subst \
                @shlib_base_name@,libgcc_s,$(subst \
                @shlib_map_file@,$(mapfile),$(subst \
                @shlib_slibdir_qual@,$(MULTIOSSUBDIR),$(subst \
@@ -897,45 +974,72 @@ ALL_CRT_CFLAGS = $(CFLAGS) $(CRTSTUFF_CFLAGS) $(INCLUDES)
 crt_compile = $(CC) $(ALL_CRT_CFLAGS) -o $@ $(compile_deps)
 
 ifeq ($(CUSTOM_CRTSTUFF),)
-crtbegin$(objext): $(gcc_srcdir)/crtstuff.c
-       $(crt_compile) $(CRTSTUFF_T_CFLAGS) \
-         -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN
+# Compile two additional files that are linked with every program
+# linked using GCC on systems using COFF or ELF, for the sake of C++
+# constructors.
+crtbegin$(objext): $(srcdir)/crtstuff.c
+       $(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_BEGIN
 
-crtend$(objext): $(gcc_srcdir)/crtstuff.c
-       $(crt_compile) $(CRTSTUFF_T_CFLAGS) \
-         -c $(gcc_srcdir)/crtstuff.c -DCRT_END
+crtend$(objext): $(srcdir)/crtstuff.c
+       $(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_END
 
 # These are versions of crtbegin and crtend for shared libraries.
-crtbeginS$(objext): $(gcc_srcdir)/crtstuff.c
-       $(crt_compile) $(CRTSTUFF_T_CFLAGS_S) \
-         -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFS_O
+crtbeginS$(objext): $(srcdir)/crtstuff.c
+       $(crt_compile) $(CRTSTUFF_T_CFLAGS_S) -c $< -DCRT_BEGIN -DCRTSTUFFS_O
 
-crtendS$(objext): $(gcc_srcdir)/crtstuff.c
-       $(crt_compile) $(CRTSTUFF_T_CFLAGS_S) \
-         -c $(gcc_srcdir)/crtstuff.c -DCRT_END -DCRTSTUFFS_O
+crtendS$(objext): $(srcdir)/crtstuff.c
+       $(crt_compile) $(CRTSTUFF_T_CFLAGS_S) -c $< -DCRT_END -DCRTSTUFFS_O
 
 # This is a version of crtbegin for -static links.
-crtbeginT.o: $(gcc_srcdir)/crtstuff.c
-       $(crt_compile) $(CRTSTUFF_T_CFLAGS) \
-         -c $(gcc_srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFT_O
+crtbeginT$(objext): $(srcdir)/crtstuff.c
+       $(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_BEGIN -DCRTSTUFFT_O
+
+# crtoffloadbegin and crtoffloadend contain symbols, that mark the begin and
+# the end of tables with addresses, required for offloading.  crtoffloadtable
+# contains the array with addresses of those symbols.
+crtoffloadbegin$(objext): $(srcdir)/offloadstuff.c
+       $(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_BEGIN
+
+crtoffloadend$(objext): $(srcdir)/offloadstuff.c
+       $(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_END
+
+crtoffloadtable$(objext): $(srcdir)/offloadstuff.c
+       $(crt_compile) $(CRTSTUFF_T_CFLAGS) -c $< -DCRT_TABLE
+endif
+
+ifeq ($(enable_vtable_verify),yes)
+# These are used in vtable verification; see comments in source files for
+# more details.
+
+# Override -finhibit-size-directive to avoid mismatch between libgcc and libvtv
+# compilations.
+VTV_CFLAGS = $(CRTSTUFF_T_CFLAGS_S) -fno-inhibit-size-directive
+
+vtv_start$(objext): $(srcdir)/vtv_start.c
+       $(crt_compile) $(VTV_CFLAGS) -c $(srcdir)/vtv_start.c
+
+vtv_end$(objext): $(srcdir)/vtv_end.c
+       $(crt_compile) $(VTV_CFLAGS) -c $(srcdir)/vtv_end.c
+
+vtv_start_preinit$(objext): $(srcdir)/vtv_start_preinit.c
+       $(crt_compile) $(VTV_CFLAGS) -c $(srcdir)/vtv_start_preinit.c
+
+vtv_end_preinit$(objext): $(srcdir)/vtv_end_preinit.c
+       $(crt_compile) $(VTV_CFLAGS) -c $(srcdir)/vtv_end_preinit.c
+endif
+
+ifeq ($(CUSTOM_CRTIN),)
+# -x assembler-with-cpp is only needed on case-insensitive filesystem.
+crti$(objext): $(srcdir)/config/$(cpu_type)/crti.S
+       $(crt_compile) -c -x assembler-with-cpp $<
+
+crtn$(objext): $(srcdir)/config/$(cpu_type)/crtn.S
+       $(crt_compile) -c -x assembler-with-cpp $<
 endif
 
 # Build extra startfiles in the libgcc directory.
 .PHONY: libgcc-extra-parts
 libgcc-extra-parts: $(EXTRA_PARTS)
-ifneq ($(GCC_EXTRA_PARTS),)
-ifneq ($(sort $(EXTRA_PARTS)),$(GCC_EXTRA_PARTS))
-       # If the gcc directory specifies which extra parts to
-       # build for this target, and the libgcc configuration also
-       # specifies, make sure they match.  This can be removed
-       # when the gcc directory no longer holds libgcc configuration;
-       # it is useful when migrating a target.
-       @echo "Configuration mismatch!"
-       @echo "Extra parts from gcc directory: $(GCC_EXTRA_PARTS)"
-       @echo "Extra parts from libgcc: $(EXTRA_PARTS)"
-       exit 1
-endif
-endif
 
        # Early copyback; see "all" above for the rationale.  The
        # early copy is necessary so that the gcc -B options find
@@ -951,51 +1055,32 @@ endif
          esac;                                                 \
        done
 
-# Build extra startfiles in the gcc directory, for unconverted
-# targets.
-.PHONY: gcc-extra-parts
-gcc-extra-parts:
-       # Recursively invoke make in the GCC directory to build any
-       # startfiles (for now).  We must do this just once, passing
-       # it all the GCC_EXTRA_PARTS as simultaneous goal targets,
-       # so that rules which cannot execute simultaneously are properly
-       # serialized.  We indirect through T_TARGET in case any multilib
-       # directories contain an equals sign, to prevent make from
-       # interpreting any of the goals as variable assignments.
-
-       # We must use cd && make rather than make -C, or else the stage
-       # number will be embedded in debug information.
-
-       T=`$(PWD_COMMAND)`/ \
-       && cd $(gcc_objdir) \
-       && $(MAKE) GCC_FOR_TARGET="$(CC)" \
-         MULTILIB_CFLAGS="$(CFLAGS)" \
-         T=$$T \
-         T_TARGET="$(patsubst %,$${T}%,$(GCC_EXTRA_PARTS))" \
-         T_TARGET
+all: $(extra-parts)
 
-       # Early copyback; see "all" above for the rationale.  The
-       # early copy is necessary so that the gcc -B options find
-       # the right startup files when linking shared libgcc.
-       $(mkinstalldirs) $(gcc_objdir)$(MULTISUBDIR)
-       parts="$(GCC_EXTRA_PARTS)";                             \
-       for file in $$parts; do                                 \
-         rm -f $(gcc_objdir)$(MULTISUBDIR)/$$file;             \
-         $(INSTALL_DATA) $$file $(gcc_objdir)$(MULTISUBDIR)/;  \
-         case $$file in                                        \
-           *.a)                                                \
-             $(RANLIB) $(gcc_objdir)$(MULTISUBDIR)/$$file ;;   \
-         esac;                                                 \
-       done
+$(libgcc-objects) $(libgcc-s-objects) $(libgcc-eh-objects) \
+       $(libgcov-objects) \
+       $(libunwind-objects) $(libunwind-s-objects) \
+       $(EXTRA_PARTS): libgcc_tm.h
 
-all: $(extra-parts)
+# Copy unwind.h to the place where gcc will look for it at build-time
+install-unwind_h-forbuild:
+       dest=$(gcc_objdir)/include/tmp$$$$-unwind.h; \
+       cp unwind.h $$dest; \
+       chmod a+r $$dest; \
+       sh $(srcdir)/../move-if-change $$dest $(gcc_objdir)/include/unwind.h
 
+# Copy unwind.h to the place where gcc will look at run-time, once installed
+#
+# This is redundant with the internal copy above when using a regular toplevel
+# "install" target, because gcc's install will copy to the destination as well.
+#
+# This is however useful for "install-no-fixincludes" case, when only the gcc
+# internal headers are copied by gcc's install.
 install-unwind_h:
-       rm -f $(gcc_objdir)/include/unwind.h
-       cp unwind.h $(gcc_objdir)/include/unwind.h
-       chmod a+r $(gcc_objdir)/include/unwind.h
+       $(mkinstalldirs) $(DESTDIR)$(libsubdir)/include
+       $(INSTALL_DATA) unwind.h $(DESTDIR)$(libsubdir)/include
 
-all: install-unwind_h
+all: install-unwind_h-forbuild
 
 # Documentation targets (empty).
 .PHONY: info html dvi pdf install-info install-html install-pdf
@@ -1054,23 +1139,16 @@ install-leaf: $(install-shared) $(install-libunwind)
          esac;                                                 \
        done
 
-install: install-leaf
+install: install-leaf install-unwind_h
        @: $(MAKE) ; $(MULTIDO) $(FLAGS_TO_PASS) multi-do DO=install
 
 install-strip: install
 
 .PHONY: install install-shared install-libunwind install-strip
+.PHONY: install-unwind_h install-unwind_h-forbuild
 
 # Don't export variables to the environment, in order to not confuse
 # configure.
 .NOEXPORT:
 
 include $(srcdir)/empty.mk $(wildcard *.dep)
-
-# TODO QUEUE:
-#   Garbage collect in gcc/:
-#     $(LIBGCC) settings in t-* are now unused
-#
-#   Remove use of $(gcc_srcdir).  Source files referenced using $(gcc_srcdir)
-#   should move into the libgcc directory.
-