[gcc-7] 199/354: [ Nicolas Boulenguez ] * Remove ada-gnattools-noparallel patch, apparently fixed. Closes: #857831. * Reduce diff with upstream in ada-gnattools-cross patch. * debian/rules2: Simplify build flags transmission. * Append build flags from dpkg during Ada target builds.

Ximin Luo infinity0 at debian.org
Thu Nov 23 15:50:53 UTC 2017


This is an automated email from the git hooks/post-receive script.

infinity0 pushed a commit to branch master
in repository gcc-7.

commit efba1290505371fe75a739223fbd8b5832129dde
Author: doko <doko at 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca>
Date:   Sun May 21 20:26:49 2017 +0000

      [ Nicolas Boulenguez ]
      * Remove ada-gnattools-noparallel patch, apparently fixed. Closes: #857831.
      * Reduce diff with upstream in ada-gnattools-cross patch.
      * debian/rules2: Simplify build flags transmission.
      * Append build flags from dpkg during Ada target builds.
    
    
    git-svn-id: svn+ssh://svn.debian.org/svn/gcccvs/branches/sid/gcc-7@9500 6ca36cf4-e1d1-0310-8c6f-e303bb2178ca
---
 debian/changelog                             |   8 +
 debian/gnat-BV.overrides                     |   1 -
 debian/gnatvsn.gpr                           |   2 +-
 debian/patches/ada-gcc-name.diff             |   4 +-
 debian/patches/ada-gnattools-cross.diff      | 582 +++++----------------------
 debian/patches/ada-gnattools-noparallel.diff |  14 -
 debian/patches/ada-libgnatvsn.diff           |  60 ++-
 debian/patches/ada-link-lib.diff             |  65 ++-
 debian/patches/ada-sjlj.diff                 |   6 +-
 debian/patches/ada-tools-move-ldflags.diff   |  39 ++
 debian/rules.patch                           |   2 +-
 debian/rules2                                | 127 ++----
 12 files changed, 286 insertions(+), 624 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 19aea6c..353723c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -4,6 +4,8 @@ gcc-7 (7.1.0-6) UNRELEASED; urgency=medium
     - Fix PR libstdc++/80796, PR libstdc++/80478, PR libstdc++/80761,
       PR target/80799 (x86), PR ada/80784, PR fortran/78659, PR fortran/80752,
       PR libgfortran/80727.
+
+  [ Matthias Klose ]
   * Re-add unwind support on kfreebsd-amd64 (James Clarke).
   * Work around #814977 (gnat calling gcc-7-7) by providing a gcc-7-7
     symlink.
@@ -13,6 +15,12 @@ gcc-7 (7.1.0-6) UNRELEASED; urgency=medium
   * Fix libmpx dependency generation for cross builds.
   * Build again gnat cross compilers on 32bit archs targeting 64bit targets.
 
+  [ Nicolas Boulenguez ]
+  * Remove ada-gnattools-noparallel patch, apparently fixed. Closes: #857831.
+  * Reduce diff with upstream in ada-gnattools-cross patch.
+  * debian/rules2: Simplify build flags transmission.
+  * Append build flags from dpkg during Ada target builds.
+
  -- Matthias Klose <doko at debian.org>  Fri, 19 May 2017 09:20:41 -0700
 
 gcc-7 (7.1.0-5) experimental; urgency=medium
diff --git a/debian/gnat-BV.overrides b/debian/gnat-BV.overrides
deleted file mode 100644
index f07d2d6..0000000
--- a/debian/gnat-BV.overrides
+++ /dev/null
@@ -1 +0,0 @@
-gnat- at BV@ binary: quilt-build-dep-but-no-series-file
diff --git a/debian/gnatvsn.gpr b/debian/gnatvsn.gpr
index 461ca0d..c36aca7 100644
--- a/debian/gnatvsn.gpr
+++ b/debian/gnatvsn.gpr
@@ -21,7 +21,7 @@
 --     for Main use ("example");
 --  end Example;
 
-project Gnatvsn is
+library project Gnatvsn is
    for Library_Name use "gnatvsn";
    for Library_Dir use "/usr/lib";
    for Library_Kind use "dynamic";
diff --git a/debian/patches/ada-gcc-name.diff b/debian/patches/ada-gcc-name.diff
index 16422ee..10928ce 100644
--- a/debian/patches/ada-gcc-name.diff
+++ b/debian/patches/ada-gcc-name.diff
@@ -18,7 +18,7 @@
        Write_Line ("  --GCC=comp Use comp as the compiler");
 -      Write_Line ("  --LINK=nam Use 'nam' for the linking rather than 'gcc'");
 +      Write_Line ("  --LINK=nam Use 'nam' for the linking rather than 'gcc-"
-+		 & Gnatvsn.Library_Version & "'");
++        & Gnatvsn.Library_Version & "'");
        Write_Eol;
        Write_Line ("  [non-Ada-objects]  list of non Ada object files");
        Write_Line ("  [linker-options]   other options for the linker");
@@ -103,7 +103,7 @@
              if Gcc_Name = null then
 -               Gcc_Name := Osint.Program_Name ("gcc", "gnatmake");
 +               Gcc_Name := Osint.Program_Name
-+		 ("gcc-" & Gnatvsn.Library_Version, "gnatmake");
++                 ("gcc-" & Gnatvsn.Library_Version, "gnatmake");
              end if;
  
              Gcc_Exec := Locate_Exec_On_Path (Gcc_Name.all);
diff --git a/debian/patches/ada-gnattools-cross.diff b/debian/patches/ada-gnattools-cross.diff
index 757e8e5..e6d2fdd 100644
--- a/debian/patches/ada-gnattools-cross.diff
+++ b/debian/patches/ada-gnattools-cross.diff
@@ -1,5 +1,25 @@
-# DP: - When building the native gnat, link the gnat tools against
-# DP:   the build tree (build/$(host_alias)/libgnatvsn).
+* Link tools dynamically.
+* Prevent direct embedding of libada objects:
+  Mark ALI files as read-only, remove objects after the build.
+  A solution keeping the objects would be more intrusive.
+* Rebuild gnatbind/make/link with themselves.
+  This removes unneeded objects inherited from the hardcoded bootstrap list.
+  The same thing would be useful for gnat1drv, but is less easy.
+* TOOLS_ALREADY_COMPILED lists LIBGNAT objects that
+  gcc/ada/gcc-interface/Makefile should not rebuild.
+* Install the shared Ada libraries as '.so.1', not '.so' to conform
+  to the Debian policy.
+* Link libgnat/gnarl with LDFLAGS.
+* Create libgnat-BV.so symbolic link, use it and -L to link libgnarl.
+  This prevents undefined symbols or unwanted usage of host libgnat.
+* Compile with -gnatn, link with --as-needed -z defs.
+* Force addition of the build flags from dpkg-buildflags.
+  One day they may be transmitted via *FLAGS_FOR_TARGET,
+  but at least this allows to set noopt for the Ada components.
+* set LD_LIBRARY_PATH so that rebuilt tools can be executed.
+
+This patch depends on ada-libgnatvsn.diff.
+
 # DP: - When building a cross gnat, link against the libgnatvsnBV-dev
 # DP:   package.
 # DP:   This link will be done by /usr/bin/$(host_alias)-gnat*, thus
@@ -9,92 +29,6 @@ Index: b/src/gcc/ada/gcc-interface/Makefile.in
 ===================================================================
 --- a/src/gcc/ada/gcc-interface/Makefile.in
 +++ b/src/gcc/ada/gcc-interface/Makefile.in
-@@ -102,7 +102,7 @@ INSTALL_DATA_DATE = cp -p
- MAKEINFO = makeinfo
- TEXI2DVI = texi2dvi
- TEXI2PDF = texi2pdf
--GNATBIND_FLAGS = -static -x
-+GNATBIND_FLAGS = -shared -x
- ADA_CFLAGS =
- ADAFLAGS = -W -Wall -gnatpg -gnata
- FORCE_DEBUG_ADAFLAGS = -g
-@@ -141,6 +141,7 @@ target=@target@
- target_cpu=@target_cpu@
- target_vendor=@target_vendor@
- target_os=@target_os@
-+host=@host@
- host_cpu=@host_cpu@
- host_vendor=@host_vendor@
- host_os=@host_os@
-@@ -235,7 +236,10 @@ ALL_CPPFLAGS = $(CPPFLAGS)
- ALL_COMPILERFLAGS = $(ALL_CFLAGS)
- 
- # This is where we get libiberty.a from.
--LIBIBERTY = ../../libiberty/libiberty.a
-+LIBIBERTY = ../../libiberty/pic/libiberty.a
-+
-+# Sources and ALI files for gnatvsn may be found here.
-+VSN_DIR := ../../../$(target_alias)/libgnatvsn
- 
- # We need to link against libbacktrace because diagnostic.c in
- # libcommon.a uses it.
-@@ -248,8 +252,13 @@ LIBDEPS = $(LIBINTL_DEP) $(LIBICONV_DEP)
- # Default is no TGT_LIB; one might be passed down or something
- TGT_LIB =
- TOOLS_LIBS = ../link.o ../targext.o ../../ggc-none.o ../../libcommon-target.a \
--  ../../libcommon.a ../../../libcpp/libcpp.a $(LIBGNAT) $(LIBINTL) $(LIBICONV) \
--  ../$(LIBBACKTRACE) ../$(LIBIBERTY) $(SYSLIBS) $(TGT_LIB)
-+  ../../libcommon.a ../../../libcpp/libcpp.a \
-+  ../$(LIBBACKTRACE) ../$(LIBIBERTY) \
-+  ../../version.o ../../../libiberty/pic/lrealpath.o ../../libbackend.a -lstdc++
-+
-+ifeq ($(host),$(target))
-+  TOOLS_LIBS += -L$(VSN_DIR) -lgnatvsn -L../$(RTSDIR) -lgnat-$(LIB_VERSION)
-+endif
- 
- # Add -no-pie to TOOLS_LIBS since some of them are compiled with -fno-PIE.
- TOOLS_LIBS += @NO_PIE_FLAG@
-@@ -262,6 +271,9 @@ INCLUDES = -iquote . -iquote .. -iquote
- 	   -I $(ftop_srcdir)/include $(GMPINC)
- 
- ADA_INCLUDES = -I- -I. -I$(srcdir)/ada
-+ifeq ($(host),$(target))
-+  ADA_INCLUDES = -I../rts -I$(VSN_DIR) $(ADA_INCLUDES)
-+endif
- 
- # Likewise, but valid for subdirectories of the current dir.
- # FIXME: for VxWorks, we cannot add $(fsrcdir) because the regs.h file in
-@@ -334,6 +346,21 @@ GNATMAKE_OBJS = a-except.o ali.o ali-uti
-  uname.o urealp.o usage.o widechar.o \
-  $(EXTRA_GNATMAKE_OBJS)
- 
-+# Remove unneeded objects or objects provided by a shared library.
-+RTS_OBJS := $(patsubst $(RTSDIR)/%.ali,%.o,$(wildcard $(RTSDIR)/*.ali))
-+VSN_OBJS := $(patsubst $(VSN_DIR)/%.ali,%.o,$(wildcard $(VSN_DIR)/*.ali))
-+GNATLINK_OBJS := $(filter-out $(VSN_OBJS) $(RTS_OBJS) \
-+  ali butil fmap osint rident sdefault stylesw switch targparm \
-+  ,$(GNATLINK_OBJS))
-+GNATMAKE_OBJS := $(filter-out $(VSN_OBJS) $(RTS_OBJS) \
-+  scil_ll \
-+  ,$(GNATMAKE_OBJS))
-+# This list is duplicated in gnattools/Makefile.in.
-+
-+# TODO: understand why upstream does not need this.
-+GNATLINK_OBJS += link.o
-+GNATMAKE_OBJS += link.o
-+
- # Make arch match the current multilib so that the RTS selection code
- # picks up the right files. For a given target this must be coherent
- # with MULTILIB_DIRNAMES defined in gcc/config/target/t-*.
-@@ -436,7 +463,7 @@ X86_64_TARGET_PAIRS = \
-   s-atocou.adb<s-atocou-builtin.adb
- 
- # Shared library version
--LIB_VERSION = $(strip $(shell grep ' Library_Version :' $(fsrcpfx)ada/gnatvsn.ads | sed -e 's/.*"\(.*\)".*/\1/'))
-+LIB_VERSION := $(shell sed s/[^0-9].*// $(srcdir)/BASE-VER)
- 
- # Additionnal object files from C source to be added to libgnat.
- EXTRA_LIBGNAT_OBJS=
 @@ -1641,6 +1668,11 @@ ifeq ($(strip $(filter-out s390% linux%,
    LIBRARY_VERSION := $(LIB_VERSION)
  endif
@@ -107,160 +41,27 @@ Index: b/src/gcc/ada/gcc-interface/Makefile.in
  # HP/PA HP-UX 10
  ifeq ($(strip $(filter-out hppa% hp hpux10%,$(target_cpu) $(target_vendor) $(target_os))),)
    LIBGNAT_TARGET_PAIRS = \
-@@ -2521,24 +2553,6 @@ ADA_EXCLUDE_FILES=$(filter-out \
-   $(patsubst %$(objext),%.adb,$(GNATRTL_OBJS)), \
-   $(ADA_EXCLUDE_SRCS))
- 
--LIBGNAT=../$(RTSDIR)/libgnat.a
--
--TOOLS_FLAGS_TO_PASS=		\
--	"CC=$(CC)" 		\
--	"CFLAGS=$(CFLAGS)"	\
--	"LDFLAGS=$(LDFLAGS)"	\
--	"ADAFLAGS=$(ADAFLAGS)"	\
--	"INCLUDES=$(INCLUDES_FOR_SUBDIR)"\
--	"ADA_INCLUDES=$(ADA_INCLUDES) $(ADA_INCLUDES_FOR_SUBDIR)"\
--	"libsubdir=$(libsubdir)"	\
--	"exeext=$(exeext)"	\
--	"fsrcdir=$(fsrcdir)"	\
--	"srcdir=$(fsrcdir)"	\
--	"TOOLS_LIBS=$(TOOLS_LIBS) $(TGT_LIB)"	\
--	"GNATMAKE=$(GNATMAKE)"	\
--	"GNATLINK=$(GNATLINK)"	\
--	"GNATBIND=$(GNATBIND)"
--
- GCC_LINK=$(CXX) $(GCC_LINK_FLAGS) $(ADA_INCLUDES) $(LDFLAGS)
- 
- # Build directory for the tools. Let's copy the target-dependent
-@@ -2556,95 +2570,36 @@ GCC_LINK=$(CXX) $(GCC_LINK_FLAGS) $(ADA_
- 	                tools/$(word 1,$(subst <, ,$(PAIR)));)
- 	touch ../stamp-tools
- 
--# when compiling the tools, the runtime has to be first on the path so that
--# it hides the runtime files lying with the rest of the sources
--ifeq ($(TOOLSCASE),native)
--  vpath %.ads ../$(RTSDIR) ../
--  vpath %.adb ../$(RTSDIR) ../
--  vpath %.c   ../$(RTSDIR) ../
--  vpath %.h   ../$(RTSDIR) ../
--endif
--
--# in the cross tools case, everything is compiled with the native
--# gnatmake/link. Therefore only -I needs to be modified in ADA_INCLUDES
--ifeq ($(TOOLSCASE),cross)
--  vpath %.ads ../
--  vpath %.adb ../
--  vpath %.c   ../
--  vpath %.h   ../
--endif
--
--# gnatmake/link tools cannot always be built with gnatmake/link for bootstrap
--# reasons: gnatmake should be built with a recent compiler, a recent compiler
--# may not generate ALI files compatible with an old gnatmake so it is important
--# to be able to build gnatmake without a version of gnatmake around. Once
--# everything has been compiled once, gnatmake can be recompiled with itself
--# (see target gnattools1-re)
--gnattools1: ../stamp-tools ../stamp-gnatlib-$(RTSDIR)
--	$(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
--	  TOOLSCASE=native \
--	  ../../gnatmake$(exeext) ../../gnatlink$(exeext)
--
--# gnatmake/link can be built with recent gnatmake/link if they are available.
--# This is especially convenient for building cross tools or for rebuilding
--# the tools when the original bootstrap has already be done.
--gnattools1-re: ../stamp-tools
--	$(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
--	  TOOLSCASE=cross INCLUDES="" gnatmake-re gnatlink-re
--
--# these tools are built with gnatmake & are common to native and cross
--gnattools2: ../stamp-tools
--	$(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
--	  TOOLSCASE=native common-tools $(EXTRA_GNATTOOLS)
--
--# those tools are only built for the cross version
--gnattools4: ../stamp-tools
--ifeq ($(ENABLE_VXADDR2LINE),true)
--	$(MAKE) -C tools -f ../Makefile $(TOOLS_FLAGS_TO_PASS) \
--	  TOOLSCASE=cross top_buildir=../../.. \
--	  ../../vxaddr2line$(exeext)
--endif
--
- common-tools: ../stamp-tools
- 	$(GNATMAKE) -j0 -c -b $(ADA_INCLUDES) \
- 	  --GNATBIND="$(GNATBIND)" --GCC="$(CC) $(ALL_ADAFLAGS)" \
- 	  gnatchop gnatcmd gnatkr gnatls gnatprep gnatxref gnatfind gnatname \
- 	  gnatclean -bargs $(ADA_INCLUDES) $(GNATBIND_FLAGS)
- 	$(GNATLINK) -v gnatcmd -o ../../gnat$(exeext) \
--		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
-+	  $(LDFLAGS) $(TOOLS_LIBS)
- 	$(GNATLINK) -v gnatchop -o ../../gnatchop$(exeext) \
--		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
-+	  $(LDFLAGS) $(TOOLS_LIBS)
- 	$(GNATLINK) -v gnatkr -o ../../gnatkr$(exeext) \
--		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
-+	  $(LDFLAGS) $(TOOLS_LIBS)
- 	$(GNATLINK) -v gnatls -o ../../gnatls$(exeext) \
--		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
-+	  $(LDFLAGS) $(TOOLS_LIBS)
- 	$(GNATLINK) -v gnatprep -o ../../gnatprep$(exeext) \
--		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
-+	  $(LDFLAGS) $(TOOLS_LIBS)
- 	$(GNATLINK) -v gnatxref -o ../../gnatxref$(exeext) \
--		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
-+	  $(LDFLAGS) $(TOOLS_LIBS)
- 	$(GNATLINK) -v gnatfind -o ../../gnatfind$(exeext) \
--		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
-+	  $(LDFLAGS) $(TOOLS_LIBS)
- 	$(GNATLINK) -v gnatname -o ../../gnatname$(exeext) \
--		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
-+	  $(LDFLAGS) $(TOOLS_LIBS)
- 	$(GNATLINK) -v gnatclean -o ../../gnatclean$(exeext) \
--		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
--
--../../gnatdll$(exeext): ../stamp-tools
--	$(GNATMAKE) -c $(ADA_INCLUDES) gnatdll --GCC="$(CC) $(ALL_ADAFLAGS)"
--	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatdll
--	$(GNATLINK) -v gnatdll -o $@ --GCC="$(GCC_LINK)" $(TOOLS_LIBS)
--
--../../vxaddr2line$(exeext): ../stamp-tools
--	$(GNATMAKE) -c  $(ADA_INCLUDES) vxaddr2line --GCC="$(CC) $(ALL_ADAFLAGS)"
--	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) vxaddr2line
--	$(GNATLINK) -v vxaddr2line -o $@ --GCC="$(GCC_LINK)" ../targext.o $(CLIB)
-+	  $(LDFLAGS) $(TOOLS_LIBS)
- 
- gnatmake-re: ../stamp-tools
- 	$(GNATMAKE) -j0 $(ADA_INCLUDES) -u sdefault --GCC="$(CC) $(MOST_ADA_FLAGS)"
- 	$(GNATMAKE) -j0 -c $(ADA_INCLUDES) gnatmake --GCC="$(CC) $(ALL_ADAFLAGS)"
- 	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatmake
- 	$(GNATLINK) -v gnatmake -o ../../gnatmake$(exeext) \
--		--GCC="$(GCC_LINK)" $(TOOLS_LIBS)
-+	  $(LDFLAGS) $(TOOLS_LIBS)
- 
- # Note the use of the "mv" command in order to allow gnatlink to be linked with
- # with the former version of gnatlink itself which cannot override itself.
-@@ -2654,19 +2609,15 @@ gnatlink-re: ../stamp-tools gnatmake-re
- 	$(GNATMAKE) -j0 -c $(ADA_INCLUDES) gnatlink --GCC="$(CC) $(ALL_ADAFLAGS)"
- 	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatlink
- 	$(GNATLINK) -v gnatlink -o ../../gnatlinknew$(exeext) \
--		    --GCC="$(GCC_LINK)" $(TOOLS_LIBS)
-+	  $(LDFLAGS) $(TOOLS_LIBS)
+@@ -2644,6 +2649,20 @@
+ 		    --GCC="$(GCC_LINK)" $(TOOLS_LIBS)
  	$(MV)  ../../gnatlinknew$(exeext)  ../../gnatlink$(exeext)
  
--# Needs to be built with CC=gcc
--# Since the RTL should be built with the latest compiler, remove the
--#  stamp target in the parent directory whenever gnat1 is rebuilt
--
- # Likewise for the tools
- ../../gnatmake$(exeext): $(P) b_gnatm.o $(GNATMAKE_OBJS)
--	+$(GCC_LINK) $(ALL_CFLAGS) -o $@ b_gnatm.o $(GNATMAKE_OBJS) $(TOOLS_LIBS) $(TOOLS1_LIBS)
-+	+$(GCC_LINK) $(ALL_CFLAGS) -o $@ b_gnatm.o $(GNATMAKE_OBJS) $(TOOLS_LIBS)
- 
- ../../gnatlink$(exeext): $(P) b_gnatl.o $(GNATLINK_OBJS)
--	+$(GCC_LINK) $(ALL_CFLAGS) -o $@ b_gnatl.o $(GNATLINK_OBJS) $(TOOLS_LIBS) $(TOOLS1_LIBS)
-+	+$(GCC_LINK) $(ALL_CFLAGS) -o $@ b_gnatl.o $(GNATLINK_OBJS) $(TOOLS_LIBS)
- 
- ../stamp-gnatlib-$(RTSDIR):
- 	@if [ ! -f stamp-gnatlib-$(RTSDIR) ] ; \
++gnatbind-re: ../stamp-tools gnatmake-re gnatlink-re
++	$(GNATMAKE) -j0 -c $(ADA_INCLUDES) gnatbind --GCC="$(CC) $(ALL_ADAFLAGS)"
++	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) gnatbind
++	$(GNATLINK) -v gnatbind -o ../../gnatbind$(exeext) \
++		    --GCC="$(GCC_LINK)" $(TOOLS_LIBS)
++
++# When driven by gnattools/Makefile for a native build,
++# TOOLS_ALREADY_COMPILED will list objects in the target standard Ada
++# libraries, that Make should avoid rebuilding.
++# We cannot use recursive variables to avoid an infinite loop,
++# so we must put this after definition of EXTRA_GNATMAKE_OBJS.
++GNATLINK_OBJS := $(filter-out $(TOOLS_ALREADY_COMPILED),$(GNATLINK_OBJS))
++GNATMAKE_OBJS := $(filter-out $(TOOLS_ALREADY_COMPILED),$(GNATMAKE_OBJS))
++
+ # Needs to be built with CC=gcc
+ # Since the RTL should be built with the latest compiler, remove the
+ #  stamp target in the parent directory whenever gnat1 is rebuilt
 @@ -2706,14 +2657,10 @@ install-gnatlib: ../stamp-gnatlib-$(RTSD
  #     Also install the .dSYM directories if they exist (these directories
  #     contain the debug information for the shared libraries on darwin)
@@ -278,22 +79,10 @@ Index: b/src/gcc/ada/gcc-interface/Makefile.in
  	   if [ -d $(RTSDIR)/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext).dSYM ]; then \
  	      $(CP) -r $(RTSDIR)/lib$${file}$(hyphen)$(LIBRARY_VERSION)$(soext).dSYM \
  	        $(DESTDIR)$(ADA_RTL_OBJ_DIR); \
-@@ -2726,20 +2673,7 @@ install-gnatlib: ../stamp-gnatlib-$(RTSD
- 	cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.adb
- 	cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.ads
+@@ -2735,8 +2741,7 @@
+ 	touch ../stamp-gnatlib2-$(RTSDIR)
+ 	$(RM) ../stamp-gnatlib-$(RTSDIR)
  
--../stamp-gnatlib2-$(RTSDIR):
--	$(RM) $(RTSDIR)/s-*.ali
--	$(RM) $(RTSDIR)/s-*$(objext)
--	$(RM) $(RTSDIR)/a-*.ali
--	$(RM) $(RTSDIR)/a-*$(objext)
--	$(RM) $(RTSDIR)/*.ali
--	$(RM) $(RTSDIR)/*$(objext)
--	$(RM) $(RTSDIR)/*$(arext)
--	$(RM) $(RTSDIR)/*$(soext)
--	touch ../stamp-gnatlib2-$(RTSDIR)
--	$(RM) ../stamp-gnatlib-$(RTSDIR)
--
 -../stamp-gnatlib1-$(RTSDIR): Makefile ../stamp-gnatlib2-$(RTSDIR)
 -	$(RMDIR) $(RTSDIR)
 +../stamp-gnatlib1-$(RTSDIR): Makefile
@@ -309,7 +98,13 @@ Index: b/src/gcc/ada/gcc-interface/Makefile.in
  	test -f $(RTSDIR)/s-oscons.ads || exit 1
  # C files
  	$(MAKE) -C $(RTSDIR) \
-@@ -2841,32 +2775,45 @@ gnatlib: ../stamp-gnatlib1-$(RTSDIR) ../
+@@ -2837,36 +2842,51 @@ gnatlib: ../stamp-gnatlib1-$(RTSDIR) ../
+ 		$(RANLIB_FOR_TARGET) $(RTSDIR)/libgmem$(arext)
+         endif
+ 	$(CHMOD) a-wx $(RTSDIR)/*.ali
++# Provide .ads .adb (read-only).ali .so .a, but prevent direct use of .o.
++	$(RM) $(RTSDIR)/*.o
+ 	touch ../stamp-gnatlib-$(RTSDIR)
  
  # Warning: this target assumes that LIBRARY_VERSION has been set correctly.
  gnatlib-shared-default:
@@ -349,6 +144,8 @@ Index: b/src/gcc/ada/gcc-interface/Makefile.in
 -		$(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
 +		$(SO_OPTS)libgnat$(hyphen)$(LIBRARY_VERSION)$(soext).1 \
  		$(MISCLIB) -lm
++	cd $(RTSDIR) && $(LN_S) -f libgnat$(hyphen)$(LIBRARY_VERSION)$(soext).1 \
++		libgnat$(hyphen)$(LIBRARY_VERSION)$(soext)
  	cd $(RTSDIR); `echo "$(GCC_FOR_TARGET)" \
                  | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'` -shared $(GNATLIBCFLAGS) \
  		$(PICFLAG_FOR_TARGET) \
@@ -357,20 +154,27 @@ Index: b/src/gcc/ada/gcc-interface/Makefile.in
  		$(GNATRTL_TASKING_OBJS) \
 -		$(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
 +		$(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext).1 \
++		-L. -lgnat$(hyphen)$(LIBRARY_VERSION) \
  		$(THREADSLIB)
 -	cd $(RTSDIR); $(LN_S) libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
 -		libgnat$(soext)
 -	cd $(RTSDIR); $(LN_S) libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
 -		libgnarl$(soext)
-+	cd $(RTSDIR); for lib in gnat gnarl; do \
-+		ls -l *.so*; \
-+		l=lib$${lib}$(hyphen)$(LIBRARY_VERSION)$(soext); \
-+		$(LN_S) $$l.1 $$l; \
-+	done
++	cd $(RTSDIR) && $(LN_S) -f libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext).1 \
++		libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext)
 +	$(CHMOD) a-wx $(RTSDIR)/*.ali
  
  	# Create static libgnat and libgnarl compiled with -fPIC
  	$(RM) $(RTSDIR)/libgnat_pic$(arext) $(RTSDIR)/libgnarl_pic$(arext)
+@@ -2877,6 +2897,8 @@ gnatlib-shared-default:
+ 	   $(addprefix $(RTSDIR)/,$(GNATRTL_TASKING_OBJS))
+ 	$(RANLIB_FOR_TARGET) $(RTSDIR)/libgnarl_pic$(arext)
+ 
++# Provide .ads .adb (read-only).ali .so .a, but prevent direct use of .o.
++	$(RM) $(RTSDIR)/*.o
+ 
+ gnatlib-shared-dual:
+ 	$(MAKE) $(FLAGS_TO_PASS) \
 @@ -2885,21 +2832,15 @@ gnatlib-shared-dual:
  	     GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C)" \
  	     MULTISUBDIR="$(MULTISUBDIR)" \
@@ -421,227 +225,51 @@ Index: b/src/gnattools/Makefile.in
 ===================================================================
 --- a/src/gnattools/Makefile.in
 +++ b/src/gnattools/Makefile.in
-@@ -52,7 +52,7 @@ WARN_CFLAGS = @warn_cflags@
- ADA_CFLAGS=@ADA_CFLAGS@
- 
- # Variables for gnattools.
--ADAFLAGS= -gnatpg -gnata
-+ADAFLAGS= -gnatn
- 
- # For finding the GCC build dir, which is used far too much
- GCC_DIR=../gcc
-@@ -70,28 +70,167 @@ INCLUDES_FOR_SUBDIR = -iquote . -iquote
- ADA_INCLUDES_FOR_SUBDIR = -I. -I$(fsrcdir)/ada
- 
- CXX_LFLAGS = \
-- -B../../../$(target_noncanonical)/libstdc++-v3/src/.libs \
-- -B../../../$(target_noncanonical)/libstdc++-v3/libsupc++/.libs \
-- -L../../../$(target_noncanonical)/libstdc++-v3/src/.libs \
-- -L../../../$(target_noncanonical)/libstdc++-v3/libsupc++/.libs
-+ -B../$(target_noncanonical)/libstdc++-v3/src/.libs \
-+ -B../$(target_noncanonical)/libstdc++-v3/libsupc++/.libs \
-+ -L../$(target_noncanonical)/libstdc++-v3/src/.libs \
-+ -L../$(target_noncanonical)/libstdc++-v3/libsupc++/.libs \
-+ -L../$(target_noncanonical)/libatomic/.libs
-+
-+CFLAGS=-O2 -Wall
-+ADA_CFLAGS=-O2 -gnatn
-+VSN_DIR         := ../$(target_noncanonical)/libgnatvsn
-+RTS_DIR         := ../gcc/ada/rts
-+ADA_INCLUDES    := -nostdinc -I- -I. -I$(VSN_DIR) -I$(RTS_DIR)
-+LIB_VERSION     := $(shell sed s/[^0-9].*// $(srcdir)/../gcc/BASE-VER)
-+SHARED_ADA_LIBS := -L$(VSN_DIR) -lgnatvsn -L$(RTS_DIR) -lgnat-$(LIB_VERSION)
-+STATIC_ADA_LIBS := $(VSN_DIR)/libgnatvsn.a $(RTS_DIR)/libgnat.a
-+STATIC_GCC_LIBS := ../gcc/libcommon-target.a ../gcc/libcommon.a ../libcpp/libcpp.a \
-+../libbacktrace/.libs/libbacktrace.a ../libiberty/libiberty.a
-+
-+# We will use the just-built compiler to compile and link everything.
-+GCC=../gcc/xgcc -B../gcc/ -no-pie
-+GXX=../gcc/xg++ -B../gcc/ -no-pie
+@@ -75,15 +75,24 @@
+  -L../../../$(target_noncanonical)/libstdc++-v3/libsupc++/.libs
  
--# Variables for gnattools, native
--TOOLS_FLAGS_TO_PASS_NATIVE= \
--	"CC=../../xgcc -B../../" \
--	"CXX=../../xg++ -B../../ $(CXX_LFLAGS)" \
--	"CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
+ # Variables for gnattools, native
++rtsdir := $(abspath ../gcc/ada/rts)
++vsndir := $(abspath ../$(target_noncanonical)/libgnatvsn)
+ TOOLS_FLAGS_TO_PASS_NATIVE= \
+ 	"CC=../../xgcc -B../../" \
+ 	"CXX=../../xg++ -B../../ $(CXX_LFLAGS)" \
+ 	"CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
 -	"LDFLAGS=$(LDFLAGS)" \
 -	"ADAFLAGS=$(ADAFLAGS)" \
--	"ADA_CFLAGS=$(ADA_CFLAGS)" \
--	"INCLUDES=$(INCLUDES_FOR_SUBDIR)" \
++	"LDFLAGS=$(LDFLAGS) -Wl,--as-needed -Wl,-z,defs \
++	  $(shell dpkg-buildflags --get LDFLAGS)" \
++	"ADAFLAGS=$(ADAFLAGS) -gnatn \
++	  $(filter-out -Wformat -Werror=format-security, \
++	    $(shell dpkg-buildflags --get CFLAGS))" \
+ 	"ADA_CFLAGS=$(ADA_CFLAGS)" \
+ 	"INCLUDES=$(INCLUDES_FOR_SUBDIR)" \
 -	"ADA_INCLUDES=-I- -I../rts $(ADA_INCLUDES_FOR_SUBDIR)"\
--	"exeext=$(exeext)" \
--	"fsrcdir=$(fsrcdir)" \
--	"srcdir=$(fsrcdir)" \
--	"GNATMAKE=../../gnatmake" \
--	"GNATLINK=../../gnatlink" \
--	"GNATBIND=../../gnatbind" \
--	"TOOLSCASE=native"
-+# File lists
-+# ----------
-+
-+# File associations set by configure
-+EXTRA_GNATTOOLS = @EXTRA_GNATTOOLS@
-+TOOLS_TARGET_PAIRS = @TOOLS_TARGET_PAIRS@
-+
-+# Stage 1 builds xgcc and gnatbind; we can use them to build
-+# gnatmake-static and gnatlink-static, then use gnatmake-static and
-+# gnatlink-static to build the other tools.  The reason we first build
-+# statically-linked versions of gnatmake and gnatlink is so we can run
-+# them with confidence on all build platforms, without LD_LIBRARY_PATH
-+# or some such variable.
-+
-+# The tools we will build using gnatmake-static and gnatlink-static.
-+TOOLS := gnat gnatbind gnatchop gnatclean gnatfind gnatkr gnatls gnatlink
-+TOOLS += gnatmake gnatname gnatprep gnatxref
-+
-+# Since we don't have gnatmake, we must specify the full list of
-+# object files necessary to build gnatmake and gnatlink.
-+
-+GNATLINK_OBJS = gnatlink.o \
-+ a-except.o ali.o alloc.o butil.o casing.o csets.o debug.o fmap.o fname.o \
-+ gnatvsn.o hostparm.o indepsw.o interfac.o i-c.o i-cstrin.o namet.o opt.o \
-+ osint.o output.o rident.o s-exctab.o s-secsta.o s-stalib.o s-stoele.o \
-+ sdefault.o snames.o stylesw.o switch.o system.o table.o targparm.o tree_io.o \
-+ types.o validsw.o widechar.o
-+
-+GNATMAKE_OBJS = a-except.o ali.o ali-util.o aspects.o s-casuti.o alloc.o \
-+ atree.o binderr.o butil.o casing.o csets.o debug.o elists.o einfo.o errout.o \
-+ erroutc.o errutil.o err_vars.o fmap.o fname.o fname-uf.o fname-sf.o \
-+ gnatmake.o gnatvsn.o hostparm.o interfac.o i-c.o i-cstrin.o krunch.o lib.o \
-+ make.o makeusg.o makeutl.o mlib.o mlib-fil.o mlib-prj.o mlib-tgt.o \
-+ mlib-tgt-specific.o mlib-utl.o namet.o nlists.o opt.o osint.o osint-m.o \
-+ output.o prj.o prj-attr.o prj-attr-pm.o prj-com.o prj-dect.o prj-env.o \
-+ prj-conf.o prj-pp.o prj-err.o prj-ext.o prj-nmsc.o prj-pars.o prj-part.o \
-+ prj-proc.o prj-strt.o prj-tree.o prj-util.o restrict.o rident.o s-exctab.o \
-+ s-secsta.o s-stalib.o s-stoele.o scans.o scng.o sdefault.o sfn_scan.o \
-+ s-purexc.o s-htable.o scil_ll.o sem_aux.o sinfo.o sinput.o sinput-c.o \
-+ sinput-p.o snames.o stand.o stringt.o styleg.o stylesw.o system.o validsw.o \
-+ switch.o switch-m.o table.o targparm.o tempdir.o tree_io.o types.o uintp.o \
-+ uname.o urealp.o usage.o widechar.o \
-+ $(EXTRA_GNATMAKE_OBJS)
-+
-+# Remove unneeded objects or objects provided by a shared library.
-+RTS_OBJS := $(patsubst $(RTS_DIR)/%.ali,%.o,$(wildcard $(RTS_DIR)/*.ali))
-+VSN_OBJS := $(patsubst $(VSN_DIR)/%.ali,%.o,$(wildcard $(VSN_DIR)/*.ali))
-+GNATLINK_OBJS := $(filter-out $(VSN_OBJS) $(RTS_OBJS) \
-+  ali butil fmap osint rident sdefault stylesw switch targparm \
-+  ,$(GNATLINK_OBJS))
-+GNATMAKE_OBJS := $(filter-out $(VSN_OBJS) $(RTS_OBJS) \
-+  scil_ll \
-+  ,$(GNATMAKE_OBJS))
-+
-+# This list is duplicated in gcc/ada/gcc-interface/Makefile.in.
-+# EXTRA_GNATMAKE_OBJS should not be useful here.
-+
-+# TODO: understand why upstream does not need this.
-+GNATLINK_OBJS += link.o
-+GNATMAKE_OBJS += link.o
-+
-+# Makefile targets
-+# ----------------
-+
-+.PHONY: gnattools gnattools-native gnattools-cross regnattools
-+gnattools: @default_gnattools_target@
-+
-+SOURCES := ../gcc/ada/sdefault.adb \
-+  $(wildcard $(foreach u, $(basename $(GNATMAKE_OBJS) $(GNATLINK_OBJS)) \
-+                          bcheck binde bindgen bindusg osint-b switch-b \
-+                          clean \
-+                          xr_tabls xref_lib \
-+                          osint-l \
-+                          prj-makr \
-+                          gprep prep, \
-+                          @srcdir@/../gcc/ada/$(u).adb \
-+                          @srcdir@/../gcc/ada/$(u).ads)) \
-+
-+$(notdir $(SOURCES)): stamp-gnattools-sources
-+
-+stamp-gnattools-sources:
-+	for file in $(SOURCES); do \
-+	   $(LN_S) -f $$file .; \
-+	done
-+	$(foreach PAIR,$(TOOLS_TARGET_PAIRS), \
-+	          rm -f $(word 1,$(subst <, ,$(PAIR)));\
-+	          $(LN_S) @srcdir@/../gcc/ada/$(word 2,$(subst <, ,$(PAIR))) \
-+	                  $(word 1,$(subst <, ,$(PAIR)));)
-+	touch $@
-+
-+gnattools-native: $(RTS_DIR)/libgnat-$(LIB_VERSION).so
-+gnattools-native: $(VSN_DIR)/libgnatvsn.so
-+gnattools-native: stamp-gnattools-sources
-+gnattools-native: $(TOOLS)
-+	cp -lpf $(TOOLS) ../gcc
-+
-+$(TOOLS) gnatcmd: | gnatmake-static gnatlink-static
-+
-+vpath %.c @srcdir@/../gcc/ada:@srcdir@/../gcc
-+vpath %.h @srcdir@/../gcc/ada
-+
-+# gnatlink
-+
-+gnatlink-static: $(GNATLINK_OBJS) b_gnatl.o
-+	$(GXX) -o $@ $(ADA_CFLAGS) $^ \
-+	   $(LDFLAGS) $(STATIC_ADA_LIBS) $(STATIC_GCC_LIBS) $(CXX_LFLAGS)
-+
-+gnatlink: $(GNATLINK_OBJS) b_gnatl.o
-+	$(GXX) -o $@ $(ADA_CFLAGS) $^ \
-+	   $(LDFLAGS) $(SHARED_ADA_LIBS) $(STATIC_GCC_LIBS) $(CXX_LFLAGS)
-+
-+b_gnatl.adb: $(GNATLINK_OBJS)
-+	../gcc/gnatbind -o $@ $(ADA_INCLUDES) gnatlink.ali
-+
-+# gnatmake
-+
-+gnatmake-static: $(GNATMAKE_OBJS) b_gnatm.o
-+	$(GXX) -o $@ $(ADA_CFLAGS) $^ \
-+	   $(LDFLAGS) $(STATIC_ADA_LIBS) $(STATIC_GCC_LIBS) $(CXX_LFLAGS)
-+
-+gnatmake: $(GNATMAKE_OBJS) b_gnatm.o
-+	$(GXX) -o $@ $(ADA_CFLAGS) $^ \
-+	   $(LDFLAGS) $(SHARED_ADA_LIBS) $(STATIC_GCC_LIBS) $(CXX_LFLAGS)
-+
-+b_gnatm.adb: $(GNATMAKE_OBJS)
-+	../gcc/gnatbind -o $@ $(ADA_INCLUDES) gnatmake.ali
-+
-+# Other tools
-+gnat: gnatcmd
-+	cp -lp $< $@
-+
-+gnatbind gnatchop gnatclean gnatcmd gnatfind gnatkr gnatls gnatname gnatprep \
-+gnatxref: link.o
-+	if [ ! -f $@.adb ] ; then $(LN_S) ../../src/gcc/ada/$@.ad[bs] .; fi
-+	./gnatmake-static -c -b $@ $(ADA_CFLAGS) $(ADA_INCLUDES) \
-+	   --GCC="$(GCC)" \
-+	   --GNATBIND=../gcc/gnatbind
-+	./gnatlink-static -o $@ $@.ali $^ \
-+	   $(ADA_INCLUDES) $(LDFLAGS) $(SHARED_ADA_LIBS) $(STATIC_GCC_LIBS) $(CXX_LFLAGS) \
-+	   --GCC="$(GXX) $(ADA_INCLUDES)"
- 
- # Variables for regnattools
- TOOLS_FLAGS_TO_PASS_RE= \
-@@ -184,20 +323,11 @@ $(GCC_DIR)/stamp-tools:
- 	                $(GCC_DIR)/ada/tools/$(word 1,$(subst <, ,$(PAIR)));)
- 	touch $(GCC_DIR)/stamp-tools
- 
--# gnatmake/link tools cannot always be built with gnatmake/link for bootstrap 
--# reasons: gnatmake should be built with a recent compiler, a recent compiler
--# may not generate ALI files compatible with an old gnatmake so it is important
--# to be able to build gnatmake without a version of gnatmake around. Once 
--# everything has been compiled once, gnatmake can be recompiled with itself 
--# (see target regnattools) 
--gnattools-native: $(GCC_DIR)/stamp-tools $(GCC_DIR)/stamp-gnatlib-rts
--	# gnattools1
--	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
--	  $(TOOLS_FLAGS_TO_PASS_NATIVE) \
--	  ../../gnatmake$(exeext) ../../gnatlink$(exeext)
--	# gnattools2
--	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
++	"ADA_INCLUDES=-I- -nostdinc -I$(vsndir) -I$(rtsdir) $(ADA_INCLUDES_FOR_SUBDIR)" \
++	"TOOLS_ALREADY_COMPILED=$(foreach d, $(vsndir) $(rtsdir), \
++	  $(patsubst $(d)/%.ali,%.o, $(wildcard $(d)/*.ali)))" \
++	'LIBGNAT=-L$(vsndir) -lgnatvsn -L$(rtsdir) -lgnat-$$(LIB_VERSION)' \
++	"GNATBIND_FLAGS=-nostdlib -x" \
+ 	"exeext=$(exeext)" \
+ 	"fsrcdir=$(fsrcdir)" \
+ 	"srcdir=$(fsrcdir)" \
+@@ -192,12 +199,18 @@
+ # (see target regnattools) 
+ gnattools-native: $(GCC_DIR)/stamp-tools $(GCC_DIR)/stamp-gnatlib-rts
+ 	# gnattools1
++# The export is necessary in case the target is run twice.
++	LD_LIBRARY_PATH='$(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):)$(vsndir):$(rtsdir)' \
+ 	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
+ 	  $(TOOLS_FLAGS_TO_PASS_NATIVE) \
+ 	  ../../gnatmake$(exeext) ../../gnatlink$(exeext)
+ 	# gnattools2
++# The hard-coded object lists for gnatbind/make/link contain unneeded
++# objects. Use the fresh tools to recompute dependencies.
++	LD_LIBRARY_PATH='$(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):)$(vsndir):$(rtsdir)' \
+ 	$(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
 -	  $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools
-+%.o: %.adb
-+	$(GCC) -c -o $@ $< $(ADA_CFLAGS) $(ADA_INCLUDES)
-+
-+%.o: %.ads
-+	$(GCC) -c -o $@ $< $(ADA_CFLAGS) $(ADA_INCLUDES)
++	  $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools \
++	  gnatbind-re gnatmake-re gnatlink-re
  
  # gnatmake/link can be built with recent gnatmake/link if they are available.
  # This is especially convenient for building cross tools or for rebuilding
diff --git a/debian/patches/ada-gnattools-noparallel.diff b/debian/patches/ada-gnattools-noparallel.diff
deleted file mode 100644
index af6b1de..0000000
--- a/debian/patches/ada-gnattools-noparallel.diff
+++ /dev/null
@@ -1,14 +0,0 @@
-# DP: Build gnattools sequentially; see #857831
-
---- a/src/gnattools/Makefile.in
-+++ b/src/gnattools/Makefile.in
-@@ -18,6 +18,9 @@
- # Default target; must be first.
- all: gnattools
- 
-+# FIXME: Find out why .o files are built twice ...
-+.NOTPARALLEL:
-+
- # Standard autoconf-set variables.
- SHELL = @SHELL@
- srcdir = @srcdir@
diff --git a/debian/patches/ada-libgnatvsn.diff b/debian/patches/ada-libgnatvsn.diff
index f08513e..9d92d6e 100644
--- a/debian/patches/ada-libgnatvsn.diff
+++ b/debian/patches/ada-libgnatvsn.diff
@@ -46,7 +46,7 @@
 +} | tee -a config.log
 --- /dev/null
 +++ b/src/libgnatvsn/Makefile.in
-@@ -0,0 +1,140 @@
+@@ -0,0 +1,156 @@
 +# Makefile for libgnatvsn.
 +#   Copyright (c) 2006 Ludovic Brenta <ludovic at ludovic-brenta.org>
 +#   Copyright (c) 2017 Nicolas Boulenguez <nicolas at debian.org>
@@ -73,12 +73,10 @@
 +bugurl                                 := @bugurl@
 +
 +# Parameters expected in environment or command line
-+GCC:=$(CC)
-+CFLAGS   ?= -g -O2
-+ADAFLAGS ?= -g -O2 -gnatn
-+CPPFLAGS ?=
-+LDFLAGS  ?=
-+DESTDIR  ?=
++$(foreach v, \
++  ADA_CFLAGS ADAFLAGS CC CFLAGS CPPFLAGS DESTDIR INSTALL INSTALL_DATA LDFLAGS \
++ ,$(info $(v) ($(origin $(v))) = $($(v))))
++# It seems that both CFLAGS/ADA_CFLAGS should affect both Ada/C.
 +
 +# Parameters read from external files
 +BASEVER   := $(shell cat $(srcdir)/../gcc/BASE-VER)
@@ -97,12 +95,19 @@
 +ali_inst_dir := $(DESTDIR)$(prefix)/lib/ada/adalib/gnatvsn
 +lib_inst_dir := $(DESTDIR)$(libdir)
 +
++# Initial value of variables accumulationg build flags.
++adaflags := -gnatn
++cflags   :=
++cppflags :=
++ldflags  := -Wl,--as-needed -Wl,-z,defs
++ldlibs   :=
++
 +# For use in version.c - double quoted strings, with appropriate
 +# surrounding punctuation and spaces, and with the datestamp and
 +# development phase collapsed to the empty string in release mode
 +# (i.e. if DEVPHASE_c is empty).  The space immediately after the
 +# comma in the $(if ...) constructs is significant - do not remove it.
-+VERSION_CPP_DEFS := \
++cppflags += \
 +  -DBASEVER="\"$(BASEVER)\"" \
 +  -DDATESTAMP="\"$(if $(DEVPHASE), $(DATESTAMP))\"" \
 +  -DDEVPHASE="\"$(if $(DEVPHASE), ($(DEVPHASE)))\"" \
@@ -110,9 +115,22 @@
 +  -DBUGURL="\"$(bugurl)\"" \
 +  -DREVISION=
 +
-+# Include and link ../../gcc/ada/rts instead of the default.
-+LIBGNAT_JUST_BUILT := -nostdinc -I../../gcc/ada/rts
-+LDLIBS := -L../../gcc/ada/rts -lgnat-$(LIB_VERSION)
++# Include and link freshly built target RTL instead of the default.
++RTL_DIR := ../libada
++adaflags += -nostdinc -I$(RTL_DIR)/adainclude
++ldlibs   += -L$(RTL_DIR)/adalib -lgnat-$(LIB_VERSION)
++
++# Append user settings last, allowing them to take precedence.
++adaflags += $(CFLAGS) $(ADA_CFLAGS) $(ADAFLAGS)
++cflags   += $(CFLAGS) $(ADA_CFLAGS)
++cppflags += $(CPPFLAGS)
++ldflags  += $(LDFLAGS)
++
++deb_cflags := $(shell dpkg-buildflags --get CFLAGS)
++adaflags += $(filter-out -Wformat -Werror=format-security,$(deb_cflags))
++cflags   += $(deb_cflags)
++cppflags += $(shell dpkg-buildflags --get CPPFLAGS)
++ldflags  += $(shell dpkg-buildflags --get LDFLAGS)
 +
 +# Link wanted Ada sources from source tree, so that gnat fails when new
 +# dependencies are missing in the current directory, instead of silently
@@ -134,39 +152,37 @@
 +all: libgnatvsn.a libgnatvsn.so.$(LIB_VERSION)
 +
 +libgnatvsn.so.$(LIB_VERSION): $(addprefix obj-shared/,$(OBJECTS))
-+	: # Make libgnatvsn.so
-+	$(GCC) -o $@ -shared -fPIC -Wl,--soname,$@ $^ $(LDFLAGS) $(LDLIBS)
-+	ln -s libgnatvsn.so.$(LIB_VERSION) libgnatvsn.so
++	$(CC) -o $@ -shared -fPIC -Wl,--soname,$@ $^ $(ldflags) $(ldlibs)
++	ln -fs libgnatvsn.so.$(LIB_VERSION) libgnatvsn.so
 +	chmod a=r obj-shared/*.ali
 +# Make the .ali files, but not the .o files, visible to the gnat tools.
 +	cp -lp obj-shared/*.ali .
 +
 +$(foreach u, $(UNITS_BOTH) snames, obj-shared/$(u).o): \
 +obj-shared/%.o: %.adb $(ADA_SRC) snames.adb snames.ads | obj-shared
-+	$(GCC) -c -fPIC $(ADAFLAGS) $(LIBGNAT_JUST_BUILT) $< -o $@
++	$(CC) -c -fPIC $(adaflags) $< -o $@
 +
 +$(foreach u, $(UNITS_SPEC), obj-shared/$(u).o): \
 +obj-shared/%.o: %.ads $(ADA_SRC) snames.adb snames.ads | obj-shared
-+	$(GCC) -c -fPIC $(ADAFLAGS) $(LIBGNAT_JUST_BUILT) $< -o $@
++	$(CC) -c -fPIC $(adaflags) $< -o $@
 +
 +obj-shared/version.o: version.c version.h | obj-shared
-+	$(GCC) -c -fPIC $(CFLAGS) $(CPPFLAGS) $(VERSION_CPP_DEFS) $< -o $@
++	$(CC) -c -fPIC $(cflags) $(cppflags) $< -o $@
 +
 +libgnatvsn.a: $(addprefix obj-static/,$(OBJECTS))
-+	: # Make libgnatvsn.a
 +	ar rc $@ $^
 +	ranlib $@
 +
 +$(foreach u, $(UNITS_BOTH) snames, obj-static/$(u).o): \
 +obj-static/%.o: %.adb $(ADA_SRC) snames.adb snames.ads | obj-static
-+	$(GCC) -c $(ADAFLAGS) $(LIBGNAT_JUST_BUILT) $< -o $@
++	$(CC) -c $(adaflags) $< -o $@
 +
 +$(foreach u, $(UNITS_SPEC), obj-static/$(u).o): \
 +obj-static/%.o: %.ads $(ADA_SRC) snames.adb snames.ads | obj-static
-+	$(GCC) -c $(ADAFLAGS) $(LIBGNAT_JUST_BUILT) $< -o $@
++	$(CC) -c $(adaflags) $< -o $@
 +
 +obj-static/version.o: version.c version.h | obj-static
-+	$(GCC) -c $(CFLAGS) $(CPPFLAGS) $(VERSION_CPP_DEFS) $< -o $@
++	$(CC) -c $(cflags) $(cppflags) $< -o $@
 +
 +obj-shared obj-static:
 +	mkdir $@
@@ -181,7 +197,7 @@
 +install: all
 +	mkdir -p $(lib_inst_dir) $(src_inst_dir) $(ali_inst_dir)
 +	$(INSTALL_DATA) libgnatvsn.a libgnatvsn.so.* $(lib_inst_dir)
-+	cd $(lib_inst_dir) && ln -sf libgnatvsn.so.$(LIB_SOURCE) libgnatvsn.so
++	cd $(lib_inst_dir) && ln -sf libgnatvsn.so.$(LIB_VERSION) libgnatvsn.so
 +	$(INSTALL_DATA) *.adb *.ads *.c *.h $(src_inst_dir)
 +	$(INSTALL) -m 0444 *.ali $(ali_inst_dir)
 +
diff --git a/debian/patches/ada-link-lib.diff b/debian/patches/ada-link-lib.diff
index e7f91e3..034c84e 100644
--- a/debian/patches/ada-link-lib.diff
+++ b/debian/patches/ada-link-lib.diff
@@ -1,12 +1,13 @@
-# DP: - Install the shared Ada libraries as '.so.1', not '.so' to conform
-# DP:   to the Debian policy.
 # DP: - Don't include a runtime link path (-rpath), when linking binaries.
 # DP: - Build the shared libraries on hppa-linux.
 # DP: - Instead of building libada as a target library only, build it as
 # DP:   both a host and, if different, target library.
-# DP: - Build the GNAT tools in their top-level directory; do not use
-# DP:   recursive makefiles.
-# DP: - Link the GNAT tools dynamically.
+
+# Compile with -gnatn, link with --as-needed -z defs.
+
+# Force addition of the build flags from dpkg-buildflags.
+# One day they may be transmitted via *FLAGS_FOR_TARGET,
+# but at least this allows to set noopt for the Ada components.
 
 # Please read ada-changes-in-autogen-output.diff about src/Makefile.def.
 
@@ -60,6 +61,29 @@
  	-fexceptions -DIN_RTS @have_getipinfo@
  
  host_subdir = @host_subdir@
+@@ -78,14 +78,19 @@
+ # a *target* library, aren't we?!?  Likewise for CC.  Still, provide bogus
+ # definitions just in case something slips through the safety net provided
+ # by recursive make invocations in gcc/ada/Makefile.in
++deb_cflags := $(shell dpkg-buildflags --get CFLAGS)
+ LIBADA_FLAGS_TO_PASS = \
+         "MAKEOVERRIDES=" \
+-        "LDFLAGS=$(LDFLAGS)" \
++        "LDFLAGS=$(LDFLAGS) -Wl,--as-needed -Wl,-z,defs \
++          $(shell dpkg-buildflags --get LDFLAGS)" \
+         "LN_S=$(LN_S)" \
+         "SHELL=$(SHELL)" \
+-        "GNATLIBFLAGS=$(GNATLIBFLAGS) $(MULTIFLAGS)" \
++        "GNATLIBFLAGS=$(GNATLIBFLAGS) $(MULTIFLAGS) -gnatn \
++          $(filter-out -Wformat -Werror=format-security,$(deb_cflags))" \
+         "GNATLIBCFLAGS=$(GNATLIBCFLAGS) $(MULTIFLAGS)" \
+-        "GNATLIBCFLAGS_FOR_C=$(GNATLIBCFLAGS_FOR_C) $(MULTIFLAGS)" \
++        "GNATLIBCFLAGS_FOR_C=$(GNATLIBCFLAGS_FOR_C) $(MULTIFLAGS) \
++          $(deb_cflags) \
++          $(shell dpkg-buildflags --get CPPFLAGS)" \
+         "PICFLAG_FOR_TARGET=$(PICFLAG)" \
+         "THREAD_KIND=$(THREAD_KIND)" \
+         "TRACE=$(TRACE)" \
 @@ -122,7 +122,7 @@
  	$(MAKE) -C $(GCC_DIR)/ada $(LIBADA_FLAGS_TO_PASS) ./bldtools/oscons/xoscons
  
@@ -139,6 +163,17 @@
  # these tools are built using the target libraries, and are intended to
 --- a/src/gcc/ada/gcc-interface/Make-lang.in
 +++ b/src/gcc/ada/gcc-interface/Make-lang.in
+@@ -45,7 +45,9 @@
+ 

+ 
+ # Extra flags to pass to recursive makes.
+-COMMON_ADAFLAGS= -gnatpg
++deb_cflags := $(shell dpkg-buildflags --get CFLAGS)
++COMMON_ADAFLAGS= -gnatpgn \
++  $(filter-out -Wformat -Werror=format-security,$(deb_cflags))
+ ifeq ($(TREECHECKING),)
+ CHECKING_ADAFLAGS=
+ else
 @@ -58,11 +58,7 @@
  # need to be built by a recent/matching native so we might as well leave the
  # checks fully active.
@@ -151,6 +186,26 @@
  
  ALL_ADAFLAGS = \
    $(CFLAGS) $(ADA_CFLAGS) $(ADAFLAGS) $(CHECKING_ADAFLAGS) $(WARN_ADAFLAGS)
+@@ -98,7 +98,8 @@
+ ada/adaint.o-warn = -Wno-error
+ 
+ ada/%.o: ada/gcc-interface/%.c
+-	$(COMPILE) $<
++	$(COMPILE) $< \
++	  $(deb_cflags) $(shell dpkg-buildflags --get CPPFLAGS)
+ 	$(POSTCOMPILE)
+ 
+ # Function that dumps the dependencies of an Ada object file by parsing the
+@@ -211,7 +211,8 @@
+ endif
+ 
+ # Strip -Werror during linking for the LTO bootstrap
+-GCC_LINKERFLAGS = $(filter-out -Werror, $(ALL_LINKERFLAGS))
++GCC_LINKERFLAGS = $(filter-out -Werror, $(ALL_LINKERFLAGS)) -Wl,--as-needed -Wl,-z,defs \
++  $(shell dpkg-buildflags --get LDFLAGS)
+ 
+ GCC_LINK=$(LINKER) $(GCC_LINKERFLAGS) $(LDFLAGS)
+ GCC_LLINK=$(LLINKER) $(GCC_LINKERFLAGS) $(LDFLAGS)
 --- a/src/libada/configure.ac
 +++ b/src/libada/configure.ac
 @@ -127,8 +127,7 @@
diff --git a/debian/patches/ada-sjlj.diff b/debian/patches/ada-sjlj.diff
index 212bee5..0fef72b 100644
--- a/debian/patches/ada-sjlj.diff
+++ b/debian/patches/ada-sjlj.diff
@@ -443,9 +443,9 @@ Index: b/src/gcc/ada/gcc-interface/Makefile.in
 +	cd $(DESTDIR)$(ADA_INCLUDE_DIR_SJLJ); $(CHMOD) a-wx *.adb
 +	cd $(DESTDIR)$(ADA_INCLUDE_DIR_SJLJ); $(CHMOD) a-wx *.ads
 +
- ../stamp-gnatlib1-$(RTSDIR): Makefile
- 	$(MKDIR) $(RTSDIR)
- 	$(CHMOD) u+w $(RTSDIR)
+ ../stamp-gnatlib2-$(RTSDIR):
+ 	$(RM) $(RTSDIR)/s-*.ali
+ 	$(RM) $(RTSDIR)/s-*$(objext)
 @@ -2938,7 +2958,7 @@ gnatlib-shared:
  # commenting the pragma instead of deleting the line, as the latter might
  # result in getting multiple blank lines, hence possible style check errors.
diff --git a/debian/patches/ada-tools-move-ldflags.diff b/debian/patches/ada-tools-move-ldflags.diff
new file mode 100644
index 0000000..375a8f3
--- /dev/null
+++ b/debian/patches/ada-tools-move-ldflags.diff
@@ -0,0 +1,39 @@
+Description: For Ada tools, move LDFLAGS from GCC_LINK to TOOLS_LIBS.
+ Gnatlink moves GCC_LINK linker options after other options,
+ probably so that standard libraries come after user libraries
+ in case --as-needed is activated.
+ However, if --as-needed is activated via LDFLAGS, it is appended via
+ GCC_LINK and comes too late on the eventual command line.
+ All GCC_LINKS expansions but one are followed by an expansion of
+ TOOLS_LIBS, so TOOLS_LIBS seems to be the right place for LDFLAGS.
+Author: Nicolas Boulenguez <nicolas at debian.org>
+
+--- a/src/gcc/ada/gcc-interface/Makefile.in
++++ b/src/gcc/ada/gcc-interface/Makefile.in
+@@ -247,7 +247,7 @@
+ LIBDEPS = $(LIBINTL_DEP) $(LIBICONV_DEP) $(LIBBACKTRACE) $(LIBIBERTY)
+ # Default is no TGT_LIB; one might be passed down or something
+ TGT_LIB =
+-TOOLS_LIBS = ../link.o ../targext.o ../../ggc-none.o ../../libcommon-target.a \
++TOOLS_LIBS = $(LDFLAGS) ../link.o ../targext.o ../../ggc-none.o ../../libcommon-target.a \
+   ../../libcommon.a ../../../libcpp/libcpp.a $(LIBGNAT) $(LIBINTL) $(LIBICONV) \
+   ../$(LIBBACKTRACE) ../$(LIBIBERTY) $(SYSLIBS) $(TGT_LIB)
+ 
+@@ -2532,7 +2532,7 @@
+ 	"GNATLINK=$(GNATLINK)"	\
+ 	"GNATBIND=$(GNATBIND)"
+ 
+-GCC_LINK=$(CXX) $(GCC_LINK_FLAGS) $(ADA_INCLUDES) $(LDFLAGS)
++GCC_LINK=$(CXX) $(GCC_LINK_FLAGS) $(ADA_INCLUDES)
+ 
+ # Build directory for the tools. Let's copy the target-dependent
+ # sources using the same mechanism as for gnatlib. The other sources are
+@@ -2630,7 +2630,7 @@
+ ../../vxaddr2line$(exeext): ../stamp-tools
+ 	$(GNATMAKE) -c  $(ADA_INCLUDES) vxaddr2line --GCC="$(CC) $(ALL_ADAFLAGS)"
+ 	$(GNATBIND) $(ADA_INCLUDES) $(GNATBIND_FLAGS) vxaddr2line
+-	$(GNATLINK) -v vxaddr2line -o $@ --GCC="$(GCC_LINK)" ../targext.o $(CLIB)
++	$(GNATLINK) -v vxaddr2line -o $@ --GCC="$(GCC_LINK)" ../targext.o $(CLIB) $(LDFLAGS)
+ 
+ gnatmake-re: ../stamp-tools
+ 	$(GNATMAKE) -j0 $(ADA_INCLUDES) -u sdefault --GCC="$(CC) $(MOST_ADA_FLAGS)"
diff --git a/debian/rules.patch b/debian/rules.patch
index 20c191d..2e1992c 100644
--- a/debian/rules.patch
+++ b/debian/rules.patch
@@ -136,7 +136,7 @@ debian_patches += ada-arm
 	ada-link-lib \
 	ada-libgnatvsn \
 	ada-gnattools-cross \
-	ada-gnattools-noparallel \
+	ada-tools-move-ldflags \
 	ada-acats
   #endif
   #ifeq ($(with_gnatsjlj),yes)
diff --git a/debian/rules2 b/debian/rules2
index e3e4076..963a3a2 100644
--- a/debian/rules2
+++ b/debian/rules2
@@ -169,37 +169,8 @@ endif
 
 # set CFLAGS/LDFLAGS for the configure step only, maybe be modifed for some target
 # all other flags are passed to the make step.
-CFLAGS_TO_PASS = \
-	$(if $(CFLAGS),CFLAGS="$(CFLAGS)") \
-	$(if $(CXXFLAGS),CXXFLAGS="$(CXXFLAGS)") \
-	$(if $(LIBCFLAGS),LIBCFLAGS="$(LIBCFLAGS)") \
-	$(if $(LIBCXXFLAGS),LIBCXXFLAGS="$(LIBCXXFLAGS)")
-LDFLAGS_TO_PASS = \
-	$(if $(LDFLAGS),LDFLAGS="$(LDFLAGS)")
-
-STAGE1_CFLAGS_TO_PASS = \
-	$(if $(STAGE1_CFLAGS),STAGE1_CFLAGS="$(STAGE1_CFLAGS)")
-STAGE1_LDFLAGS_TO_PASS = \
-	$(if $(STAGE1_LDFLAGS),STAGE1_LDFLAGS="$(STAGE1_LDFLAGS)")
-
-BOOT_CFLAGS_TO_PASS = \
-	$(if $(BOOT_CFLAGS),BOOT_CFLAGS="$(BOOT_CFLAGS)")
-BOOT_LDFLAGS_TO_PASS = \
-	$(if $(BOOT_LDFLAGS),BOOT_LDFLAGS="$(BOOT_LDFLAGS)")
-
-CFLAGS_FOR_BUILD_TO_PASS = \
-	$(if $(CFLAGS_FOR_BUILD),CFLAGS_FOR_BUILD="$(CFLAGS_FOR_BUILD)")
-CXXFLAGS_FOR_BUILD_TO_PASS = \
-	$(if $(CXXFLAGS_FOR_BUILD),CXXFLAGS_FOR_BUILD="$(CXXFLAGS_FOR_BUILD)")
-LDFLAGS_FOR_BUILD_TO_PASS = \
-	$(if $(LDFLAGS_FOR_BUILD),LDFLAGS_FOR_BUILD="$(LDFLAGS_FOR_BUILD)")
-
-CFLAGS_FOR_TARGET_TO_PASS = \
-	$(if $(CFLAGS_FOR_TARGET),CFLAGS_FOR_TARGET="$(CFLAGS_FOR_TARGET)")
-CXXFLAGS_FOR_TARGET_TO_PASS = \
-	$(if $(CXXFLAGS_FOR_TARGET),CXXFLAGS_FOR_TARGET="$(CXXFLAGS_FOR_TARGET)")
-LDFLAGS_FOR_TARGET_TO_PASS = \
-	$(if $(LDFLAGS_FOR_TARGET),LDFLAGS_FOR_TARGET="$(LDFLAGS_FOR_TARGET)")
+pass_vars = $(foreach v,$(1),$(if $($(v)),$(v)="$($(v))"))
+flags_to_pass := CFLAGS CXXFLAGS LIBCFLAGS LIBCXXFLAGS LDFLAGS
 
 docdir		= usr/share/doc
 
@@ -1129,19 +1100,10 @@ endif
 	: # configure
 	cd $(builddir) \
 	  && $(SET_PATH) \
-		CC="$(CC)" \
-		CXX="$(CXX)" \
-		$(CFLAGS_TO_PASS) \
-		$(CXXFLAGS_TO_PASS) \
-		$(LDFLAGS_TO_PASS) \
-		$(CFLAGS_FOR_BUILD_TO_PASS) \
-		$(CXXFLAGS_FOR_BUILD_TO_PASS) \
-		$(LDFLAGS_FOR_BUILD_TO_PASS) \
-		$(CFLAGS_FOR_TARGET_TO_PASS) \
-		$(CXXFLAGS_FOR_TARGET_TO_PASS) \
-		$(LDFLAGS_FOR_TARGET_TO_PASS) \
+		$(call pass_vars, CC CXX $(flags_to_pass) \
+		  CFLAGS_FOR_BUILD  CXXFLAGS_FOR_BUILD  LDFLAGS_FOR_BUILD \
+		  CFLAGS_FOR_TARGET CXXFLAGS_FOR_TARGET LDFLAGS_FOR_TARGET) \
 		$(SET_SHELL) $(SET_TARGET_TOOLS) \
-	LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}$(builddir)/gcc/ada/rts \
 		../src/configure $(subst ___, ,$(CONFARGS))
 
 	: # multilib builds without b-d on gcc-multilib (used in FLAGS_FOR_TARGET)
@@ -1181,20 +1143,11 @@ ifeq ($(build_type),build-native)
 	  $(SET_SHELL) \
 	  $(SET_LOCPATH) \
 	    $(MAKE) -C $(builddir) $(bootstrap_target) \
-		CC="$(CC)" \
-		$(STAGE1_CFLAGS_TO_PASS) \
-		$(STAGE1_LDFLAGS_TO_PASS) \
-		$(BOOT_CFLAGS_TO_PASS) \
-		$(BOOT_LDFLAGS_TO_PASS) \
-		$(CFLAGS_TO_PASS) \
-		$(CXXFLAGS_TO_PASS) \
-		$(LDFLAGS_TO_PASS) \
-		$(CFLAGS_FOR_BUILD_TO_PASS) \
-		$(CXXFLAGS_FOR_BUILD_TO_PASS) \
-		$(LDFLAGS_FOR_BUILD_TO_PASS) \
-		$(CFLAGS_FOR_TARGET_TO_PASS) \
-		$(CXXFLAGS_FOR_TARGET_TO_PASS) \
-		$(LDFLAGS_FOR_TARGET_TO_PASS) \
+		$(call pass_vars, CC $(flags_to_pass) \
+		  STAGE1_CFLAGS                         STAGE1_LDFLAGS \
+		  BOOT_CFLAGS                           BOOT_LDFLAGS \
+		  CFLAGS_FOR_BUILD  CXXFLAGS_FOR_BUILD  LDFLAGS_FOR_BUILD \
+		  CFLAGS_FOR_TARGET CXXFLAGS_FOR_TARGET LDFLAGS_FOR_TARGET) \
 		; \
 	  echo $$? > status; \
 	) 2>&1 | tee bootstrap-protocol
@@ -1205,10 +1158,8 @@ else ifneq (,$(filter $(build_type),build-cross cross-build-native cross-build-c
 	  $(SET_PATH) \
 	  $(SET_LOCPATH) \
 	    $(MAKE) -C $(builddir) \
-		$(BOOT_CFLAGS_TO_PASS) \
-		$(BOOT_LDFLAGS_TO_PASS) \
-		$(CFLAGS_FOR_TARGET_TO_PASS) \
-		$(LDFLAGS_FOR_TARGET_TO_PASS) \
+		$(call pass_vars, BOOT_CFLAGS       BOOT_LDFLAGS \
+		                  CFLAGS_FOR_TARGET LDFLAGS_FOR_TARGET) \
 		; \
 	  echo $$? > status; \
 	) 2>&1 | tee bootstrap-protocol
@@ -1280,10 +1231,8 @@ $(build_jit_stamp): $(configure_jit_stamp)
 	  LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}$(builddir)/gcc \
 	  biarch_multidir_names=none \
 		$(MAKE) -C $(builddir_jit) \
-		$(BOOT_CFLAGS_TO_PASS) \
-		$(BOOT_LDFLAGS_TO_PASS) \
-		$(CFLAGS_FOR_TARGET_TO_PASS) \
-		$(LDFLAGS_FOR_TARGET_TO_PASS)
+		$(call pass_vars, BOOT_CFLAGS       BOOT_LDFLAGS \
+		                  CFLAGS_FOR_TARGET LDFLAGS_FOR_TARGET)
 
 ifeq ($(with_check),yes)
   # FIXME: #782444
@@ -1345,9 +1294,8 @@ $(build_nvptx_stamp): $(configure_nvptx_stamp) \
 	  LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}$(builddir)/gcc \
 	  biarch_multidir_names=none \
 		$(MAKE) -C $(builddir_nvptx) \
-		$(BOOT_CFLAGS_TO_PASS) \
-		$(BOOT_LDFLAGS_TO_PASS) \
-		$(CFLAGS_FOR_TARGET_TO_PASS)
+		$(call pass_vars, BOOT_CFLAGS       BOOT_LDFLAGS \
+		                  CFLAGS_FOR_TARGET)
 
 ifeq ($(with_check),yes)
 #	-$(MAKE) -C $(builddir_nvptx)/gcc check-jit \
@@ -1371,8 +1319,7 @@ $(configure_hppa64_stamp): $(build_stamp)
 	  $(SET_SHELL) \
 	  CC="$(BUILT_CC)" \
 	  CXX="$(BUILT_CXX)" \
-	  $(CFLAGS_TO_PASS) \
-	  $(LDFLAGS_TO_PASS) \
+	  $(call pass_vars, $(flags_to_pass)) \
 	     ../src/configure \
 		--enable-languages=c \
 		--prefix=/$(PF) \
@@ -1402,11 +1349,8 @@ $(build_hppa64_stamp): $(configure_hppa64_stamp)
 	  $(SET_LOCPATH) \
 	  LD_LIBRARY_PATH=$${LD_LIBRARY_PATH:+$$LD_LIBRARY_PATH:}$(builddir)/gcc \
 	    $(MAKE) -C $(builddir_hppa64) \
-		$(if $(CFLAGS_FOR_TARGET),CFLAGS="$(CFLAGS_FOR_TARGET)") \
-		$(if $(CXXFLAGS_FOR_TARGET),CXXFLAGS="$(CXXFLAGS_FOR_TARGET)") \
-		$(if $(LDFLAGS_FOR_TARGET),LDFLAGS="$(LDFLAGS_FOR_TARGET)") \
-		$(CFLAGS_FOR_TARGET_TO_PASS) \
-		$(LDFLAGS_FOR_TARGET_TO_PASS)
+		$(call pass_vars, \
+		  CFLAGS_FOR_TARGET CXXFLAGS_FOR_TARGET LDFLAGS_FOR_TARGET)
 	touch $(build_hppa64_stamp)
 
 $(configure_neon_stamp): $(build_stamp)
@@ -1418,8 +1362,7 @@ $(configure_neon_stamp): $(build_stamp)
 	cd $(builddir_neon) && \
 	  $(SET_PATH) \
 	  $(SET_SHELL) \
-	  $(CFLAGS_TO_PASS) \
-	  $(LDFLAGS_TO_PASS) \
+	  $(call pass_vars, $(flags_to_pass)) \
 	  CC="$(builddir)/gcc/xg++ -B$(builddir)/gcc/" \
 	     ../src/configure \
 		--disable-bootstrap \
@@ -1441,10 +1384,8 @@ $(build_neon_stamp): $(configure_neon_stamp)
 	  $(SET_SHELL) \
 	  $(SET_LOCPATH) \
 	    $(MAKE) -C $(builddir_neon) \
-		$(BOOT_CFLAGS_TO_PASS) \
-		$(BOOT_LDFLAGS_TO_PASS) \
-		$(CFLAGS_FOR_TARGET_TO_PASS) \
-		$(LDFLAGS_FOR_TARGET_TO_PASS)
+		$(call pass_vars, BOOT_CFLAGS       BOOT_LDFLAGS \
+		                  CFLAGS_FOR_TARGET LDFLAGS_FOR_TARGET)
 	touch $(build_neon_stamp)
 
 
@@ -2030,9 +1971,7 @@ ifeq ($(with_hppa64),yes)
 	: # Install hppa64
 	$(SET_PATH) \
 	    $(MAKE) -C $(builddir_hppa64) \
-		CC="$(CC)" \
-		$(CFLAGS_TO_PASS) \
-		$(LDFLAGS_TO_PASS) \
+		$(call pass_vars, CC $(flags_to_pass)) \
 		DESTDIR=$(CURDIR)/$(d) \
 		    install
 
@@ -2076,8 +2015,7 @@ endif
 	$(SET_PATH) \
 	$(SET_SHELL) \
 	  $(MAKE) -C $(builddir) \
-	    $(CFLAGS_TO_PASS) \
-	    $(LDFLAGS_TO_PASS) \
+	    $(call pass_vars, $(flags_to_pass)) \
 	    DESTDIR=$(CURDIR)/$(d) \
 	    infodir=/$(PF)/share/info \
 	    mandir=/$(PF)/share/man \
@@ -2170,8 +2108,7 @@ endif
 	$(SET_PATH) \
 	$(SET_SHELL) \
 	  $(MAKE) -C $(builddir) \
-	    $(CFLAGS_TO_PASS) \
-	    $(LDFLAGS_TO_PASS) \
+	    $(call pass_vars, $(flags_to_pass)) \
 	    DESTDIR=$(CURDIR)/$(d) \
 	    infodir=/$(PF)/share/info \
 	    mandir=/$(PF)/share/man \
@@ -2309,8 +2246,7 @@ $(install_jit_stamp): $(build_jit_stamp) $(install_stamp)
 	  biarch_multidir_names=none \
 	    $(MAKE) -C $(builddir_jit) \
 		CC="$(CC_FOR_TARGET)" \
-		$(CFLAGS_TO_PASS) \
-		$(LDFLAGS_TO_PASS) \
+		$(call pass_vars, $(flags_to_pass)) \
 		DESTDIR=$(CURDIR)/$(d)-jit \
 		    install
 
@@ -2338,8 +2274,7 @@ $(install_nvptx_stamp): $(build_nvptx_stamp) $(install_stamp) \
 	  biarch_multidir_names=none \
 	    $(MAKE) -C $(builddir_nvptx) \
 		CC="$(CC_FOR_TARGET)" \
-		$(CFLAGS_TO_PASS) \
-		$(LDFLAGS_TO_PASS) \
+		$(call pass_vars, $(flags_to_pass)) \
 		DESTDIR=$(CURDIR)/$(d)-nvptx \
 		    install
 
@@ -2380,9 +2315,7 @@ $(install_hppa64_stamp): $(build_hppa64_stamp)
 
 	$(SET_PATH) \
 	    $(MAKE) -C $(builddir_hppa64) \
-		CC="$(CC)" \
-		$(CFLAGS_TO_PASS) \
-		$(LDFLAGS_TO_PASS) \
+		$(call pass_vars, CC $(flags_to_pass)) \
 		DESTDIR=$(CURDIR)/$(d_hppa64) \
 		    install
 
@@ -2440,9 +2373,7 @@ $(install_neon_stamp): $(build_neon_stamp)
 
 	$(SET_PATH) \
 	    $(MAKE) -C $(builddir_neon) \
-		CC="$(CC)" \
-		$(CFLAGS_TO_PASS) \
-		$(LDFLAGS_TO_PASS) \
+		$(call pass_vars, CC $(flags_to_pass)) \
 		DESTDIR=$(CURDIR)/$(d_neon) \
 		    install
 	touch $(install_neon_stamp)

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/gcc-7.git



More information about the Reproducible-commits mailing list