summaryrefslogtreecommitdiffstats
path: root/debian/patches
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches')
-rw-r--r--debian/patches/ada-749574.diff114
-rw-r--r--debian/patches/ada-armel-libatomic.diff45
-rw-r--r--debian/patches/ada-gcc-name.diff292
-rw-r--r--debian/patches/ada-gnattools-cross.diff228
-rw-r--r--debian/patches/ada-lib-info-source-date-epoch.diff115
-rw-r--r--debian/patches/ada-link-lib.diff151
-rw-r--r--debian/patches/ada-nobiarch-check.diff21
-rw-r--r--debian/patches/ada-perl-shebang.diff10
-rw-r--r--debian/patches/ada-sjlj.diff493
-rw-r--r--debian/patches/ada-verbose.diff36
-rw-r--r--debian/patches/alpha-ieee-doc.diff26
-rw-r--r--debian/patches/alpha-ieee.diff17
-rw-r--r--debian/patches/alpha-no-ev4-directive.diff30
-rw-r--r--debian/patches/arc-stddef.diff29
-rw-r--r--debian/patches/arm-multilib-defaults.diff88
-rw-r--r--debian/patches/arm-multilib-soft-float.diff26
-rw-r--r--debian/patches/bootstrap-no-unneeded-libs.diff30
-rw-r--r--debian/patches/canonical-cpppath.diff34
-rw-r--r--debian/patches/config-ml.diff52
-rw-r--r--debian/patches/cross-biarch.diff89
-rw-r--r--debian/patches/cross-fixes.diff57
-rw-r--r--debian/patches/cross-install-location.diff497
-rw-r--r--debian/patches/cross-no-locale-include.diff17
-rw-r--r--debian/patches/cuda-float128.diff46
-rw-r--r--debian/patches/disable-gdc-tests.diff17
-rw-r--r--debian/patches/dwarf5-revert-default-doc.diff14
-rw-r--r--debian/patches/dwarf5-revert-default.diff24
-rw-r--r--debian/patches/g++-multiarch-incdir.diff109
-rw-r--r--debian/patches/gcc-arm-disable-guality-tests.diff44
-rw-r--r--debian/patches/gcc-as-needed-gold.diff85
-rw-r--r--debian/patches/gcc-as-needed.diff264
-rw-r--r--debian/patches/gcc-auto-build.diff13
-rw-r--r--debian/patches/gcc-distro-specs-ubuntu-doc.diff72
-rw-r--r--debian/patches/gcc-distro-specs.diff326
-rw-r--r--debian/patches/gcc-driver-extra-langs.diff20
-rw-r--r--debian/patches/gcc-foffload-default.diff120
-rw-r--r--debian/patches/gcc-force-cross-layout.diff49
-rw-r--r--debian/patches/gcc-gfdl-build.diff39
-rw-r--r--debian/patches/gcc-hash-style-gnu.diff164
-rw-r--r--debian/patches/gcc-ice-apport.diff39
-rw-r--r--debian/patches/gcc-ice-dump.diff111
-rw-r--r--debian/patches/gcc-multiarch.diff189
-rw-r--r--debian/patches/gcc-multilib-multiarch.diff85
-rw-r--r--debian/patches/gcc-search-prefixed-as-ld.diff37
-rw-r--r--debian/patches/gcc-target-include-asm.diff13
-rw-r--r--debian/patches/gcc-textdomain.diff86
-rw-r--r--debian/patches/gcc-verbose-lto-link.diff13
-rw-r--r--debian/patches/gccrs-bootstrap-mipsel.diff12
-rw-r--r--debian/patches/gdc-dynamic-link-phobos.diff17
-rw-r--r--debian/patches/gdc-multiarch.diff17
-rw-r--r--debian/patches/gdc-texinfo.diff53
-rw-r--r--debian/patches/git-doc-updates.diff7
-rw-r--r--debian/patches/git-updates.diff7
-rw-r--r--debian/patches/gm2-bootstrap-compare.diff12
-rw-r--r--debian/patches/gm2-texinfo.diff30
-rw-r--r--debian/patches/go-testsuite.diff19
-rw-r--r--debian/patches/hppa64-libgcov-fallback.diff15
-rw-r--r--debian/patches/hurd-changes.diff20
-rw-r--r--debian/patches/hurd-multiarch.diff16
-rw-r--r--debian/patches/hurd-multilib-multiarch.diff23
-rw-r--r--debian/patches/ia64-disable-selective-scheduling.diff16
-rw-r--r--debian/patches/ignore-pie-specs-when-not-enabled.diff56
-rw-r--r--debian/patches/libasan-sparc.diff163
-rw-r--r--debian/patches/libffi-race-condition.diff33
-rw-r--r--debian/patches/libffi-ro-eh_frame_sect.diff13
-rw-r--r--debian/patches/libgo-cleanfiles.diff26
-rw-r--r--debian/patches/libgo-hurd-hack.diff22
-rw-r--r--debian/patches/libgo-revert-timeout-exp.diff10
-rw-r--r--debian/patches/libgo-setcontext-config.diff19
-rw-r--r--debian/patches/libgo-soname.diff13
-rw-r--r--debian/patches/libgo-testsuite.diff66
-rw-r--r--debian/patches/libgomp-omp_h-multilib.diff32
-rw-r--r--debian/patches/libitm-no-fortify-source.diff17
-rw-r--r--debian/patches/libphobos-soname.diff13
-rw-r--r--debian/patches/libphobos-zlib.diff72
-rw-r--r--debian/patches/libstdc++-doclink.diff61
-rw-r--r--debian/patches/libstdc++-doxygen-SOURCE_DATE_EPOCH.diff13
-rw-r--r--debian/patches/libstdc++-hurd.diff48
-rw-r--r--debian/patches/libstdc++-man-3cxx.diff63
-rw-r--r--debian/patches/libstdc++-no-testsuite.diff12
-rw-r--r--debian/patches/libstdc++-nothumb-check.diff38
-rw-r--r--debian/patches/libstdc++-pic.diff91
-rw-r--r--debian/patches/libstdc++-pythondir.diff22
-rw-r--r--debian/patches/libstdc++-test-installed.diff76
-rw-r--r--debian/patches/musl-ssp.diff21
-rw-r--r--debian/patches/note-gnu-stack.diff125
-rw-r--r--debian/patches/pr104290-followup.diff14
-rw-r--r--debian/patches/pr107475.diff10
-rw-r--r--debian/patches/pr113336-proposed.diff24
-rw-r--r--debian/patches/pr113705.diff93
-rw-r--r--debian/patches/pr39491.diff132
-rw-r--r--debian/patches/pr66368.diff22
-rw-r--r--debian/patches/pr67590.diff36
-rw-r--r--debian/patches/pr67899.diff31
-rw-r--r--debian/patches/pr79724-revert.diff24
-rw-r--r--debian/patches/pr81829.diff308
-rw-r--r--debian/patches/pr87808.diff56
-rw-r--r--debian/patches/pr94253.diff48
-rw-r--r--debian/patches/rename-info-files.diff661
-rw-r--r--debian/patches/rust-enabled.diff23
-rw-r--r--debian/patches/skip-bootstrap-multilib.diff22
-rw-r--r--debian/patches/sparc64-biarch-long-double-128.diff33
-rw-r--r--debian/patches/sys-auxv-header.diff40
-rw-r--r--debian/patches/t-libunwind-elf-Wl-z-defs.diff13
-rw-r--r--debian/patches/testsuite-glibc-warnings.diff18
-rw-r--r--debian/patches/testsuite-hardening-format.diff304
-rw-r--r--debian/patches/testsuite-hardening-printf-types.diff667
-rw-r--r--debian/patches/testsuite-hardening-updates.diff84
108 files changed, 8528 insertions, 0 deletions
diff --git a/debian/patches/ada-749574.diff b/debian/patches/ada-749574.diff
new file mode 100644
index 0000000..cda98a8
--- /dev/null
+++ b/debian/patches/ada-749574.diff
@@ -0,0 +1,114 @@
+From: Ludovic Brenta <lbrenta@debian.org>
+From: Nicolas Boulenguez <nicolas@debian.org>
+Forwarded: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81087
+Bug-Debian: http://bugs.debian.org/749574
+Description: array index out of range in gnatlink
+ The procedure gnatlink assumes that the Linker_Options.Table contains access
+ values to strings whose 'First index is always 1. This assumption is wrong
+ for the string returned by function Base_Name.
+ .
+ The wrong indices are not detected because gnatlink is compiled with
+ -gnatp, but the test result is wrong.
+ .
+ The following program normally raises Constraint_Error, prints FALSE
+ if compiled with -gnatp, while the expected result is TRUE.
+ .
+ procedure A is
+ G : constant String (3 .. 5) := "abc";
+ begin
+ Ada.Text_IO.Put_Line (Boolean'Image (G (1 .. 2) = "ab"));
+ end A;
+
+--- a/src/gcc/ada/gnatlink.adb
++++ b/src/gcc/ada/gnatlink.adb
+@@ -238,6 +238,9 @@ procedure Gnatlink is
+ procedure Write_Usage;
+ -- Show user the program options
+
++ function Starts_With (Source, Pattern : String) return Boolean;
++ pragma Inline (Starts_With);
++
+ ---------------
+ -- Base_Name --
+ ---------------
+@@ -494,7 +497,7 @@ procedure Gnatlink is
+ Binder_Options.Table (Binder_Options.Last) :=
+ Linker_Options.Table (Linker_Options.Last);
+
+- elsif Arg'Length >= 7 and then Arg (1 .. 7) = "--LINK=" then
++ elsif Starts_With (Arg, "--LINK=") then
+ if Arg'Length = 7 then
+ Exit_With_Error ("Missing argument for --LINK=");
+ end if;
+@@ -528,7 +531,7 @@ procedure Gnatlink is
+ end loop;
+ end;
+
+- elsif Arg'Length >= 6 and then Arg (1 .. 6) = "--GCC=" then
++ elsif Starts_With (Arg, "--GCC=") then
+ if Arg'Length = 6 then
+ Exit_With_Error ("Missing argument for --GCC=");
+ end if;
+@@ -1255,13 +1258,9 @@ procedure Gnatlink is
+ 1 .. Linker_Options.Last
+ loop
+ if Linker_Options.Table (J) /= null
+- and then
+- Linker_Options.Table (J)'Length
+- > Run_Path_Opt'Length
+- and then
+- Linker_Options.Table (J)
+- (1 .. Run_Path_Opt'Length) =
+- Run_Path_Opt
++ and then Starts_With
++ (Linker_Options.Table (J).all,
++ Run_Path_Opt)
+ then
+ -- We have found an already
+ -- specified run_path_option:
+@@ -1378,6 +1377,17 @@ procedure Gnatlink is
+ Status := fclose (Fd);
+ end Process_Binder_File;
+
++ ----------------
++ -- StartsWith --
++ ----------------
++
++ function Starts_With (Source, Pattern : String) return Boolean is
++ Last : constant Natural := Source'First + Pattern'Length - 1;
++ begin
++ return Last <= Source'Last
++ and then Pattern = Source (Source'First .. Last);
++ end Starts_With;
++
+ -----------
+ -- Usage --
+ -----------
+@@ -1891,8 +1901,8 @@ begin
+ while J <= Linker_Options.Last loop
+ if Linker_Options.Table (J).all = "-Xlinker"
+ and then J < Linker_Options.Last
+- and then Linker_Options.Table (J + 1)'Length > 8
+- and then Linker_Options.Table (J + 1) (1 .. 8) = "--stack="
++ and then Starts_With (Linker_Options.Table (J + 1).all,
++ "--stack=")
+ then
+ if Stack_Op then
+ Linker_Options.Table (J .. Linker_Options.Last - 2) :=
+@@ -1937,13 +1947,9 @@ begin
+ -- Here we just check for a canonical form that matches the
+ -- pragma Linker_Options set in the NT runtime.
+
+- if (Linker_Options.Table (J)'Length > 17
+- and then Linker_Options.Table (J) (1 .. 17) =
+- "-Xlinker --stack=")
+- or else
+- (Linker_Options.Table (J)'Length > 12
+- and then Linker_Options.Table (J) (1 .. 12) =
+- "-Wl,--stack=")
++ if Starts_With (Linker_Options.Table (J).all, "-Xlinker --stack=")
++ or else Starts_With (Linker_Options.Table (J).all,
++ "-Wl,--stack=")
+ then
+ if Stack_Op then
+ Linker_Options.Table (J .. Linker_Options.Last - 1) :=
diff --git a/debian/patches/ada-armel-libatomic.diff b/debian/patches/ada-armel-libatomic.diff
new file mode 100644
index 0000000..bc917aa
--- /dev/null
+++ b/debian/patches/ada-armel-libatomic.diff
@@ -0,0 +1,45 @@
+Description: link libgnat with libatomic on armel
+ On other architectures, the library is ignored thanks to --as-needed.
+ .
+ Libatomic becomes an artificial dependency for Ada in Makefile.def,
+ so a better solution is welcome.
+ .
+ Please read ada-changes-in-autogen-output.diff about src/Makefile.def.
+ .
+ TODO: if this is caused by ada-arm.diff, merge the two patches.
+Bug-Debian: https://bugs.debian.org/861734
+Author: Matthias Klose <doko@debian.org>
+Author: Nicolas Boulenguez <nicolas@debian.org>
+
+--- a/src/gcc/ada/Makefile.rtl
++++ b/src/gcc/ada/Makefile.rtl
+@@ -2270,6 +2270,7 @@ endif
+
+ # ARM linux, GNU eabi
+ ifeq ($(strip $(filter-out arm% linux-gnueabi%,$(target_cpu) $(target_os))),)
++ MISCLIB = ../../../$(target_alias)/libatomic/.libs/libatomic.so
+ LIBGNAT_TARGET_PAIRS = \
+ a-intnam.ads<libgnarl/a-intnam__linux.ads \
+ s-inmaop.adb<libgnarl/s-inmaop__posix.adb \
+--- a/src/Makefile.def
++++ b/src/Makefile.def
+@@ -415,6 +415,8 @@ dependencies = { module=all-target-libad
+ dependencies = { module=all-gnattools; on=all-target-libada; };
+ dependencies = { module=all-gnattools; on=all-target-libstdc++-v3; };
+
++dependencies = { module=all-target-libada; on=all-target-libatomic; };
++
+ // Depending on the specific configuration, the LTO plugin will either use the
+ // generic libiberty build or the specific build for linker plugins.
+ dependencies = { module=all-lto-plugin; on=all-libiberty; };
+--- a/src/gcc/ada/gcc-interface/Makefile.in
++++ b/src/gcc/ada/gcc-interface/Makefile.in
+@@ -714,7 +714,7 @@ gnatlib-shared-default:
+ $(GNATRTL_TASKING_OBJS) \
+ $(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
+ libgnat$(hyphen)$(LIBRARY_VERSION).so \
+- $(THREADSLIB)
++ $(MISCLIB) $(THREADSLIB)
+ cd $(RTSDIR); $(LN_S) libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
+ libgnat$(soext)
+ cd $(RTSDIR); $(LN_S) libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
diff --git a/debian/patches/ada-gcc-name.diff b/debian/patches/ada-gcc-name.diff
new file mode 100644
index 0000000..4f309d1
--- /dev/null
+++ b/debian/patches/ada-gcc-name.diff
@@ -0,0 +1,292 @@
+Description: always call gcc with an explicit target and version
+ Many problems have been caused by the fact that tools like gnatmake
+ call other tools like gcc without an explicit target or version.
+ .
+ In order to solve this issue for all similar tools at once, AdaCore
+ has created the Osint.Program_Name function. When gnatmake launches a
+ gcc subprocess, this function computes the name of the right gcc
+ executable. This patch improves the function in four ways.
+ .
+ The previous algorithm wrongly tests "End_Of_Prefix > 1",
+ which may happen even if a match has been found.
+ This part will most probably be of interest for upstream.
+ .
+ Update the gnatchop tool to use this function.
+ This part will most probably be of interest for upstream.
+ .
+ Check that the target and version in the gnatmake program name, if
+ present, match the static constants inside the gnatmake program
+ itself. Also, knowing the length of the only allowed prefix and suffix
+ slightly improves performance by avoiding loops.
+ This part will most probably be of interest for upstream.
+ .
+ In Debian, gcc/gcc-version/target-gcc are symbolic links to the
+ target-gcc-version executable. The same holds for gnatmake, but the
+ target and version may differ. So "target-gcc-version" is the right
+ answer. It helps log checkers and humans debuggers, even if gnatmake
+ was invoked via a shortcut intended for human typers.
+ This part will probably be hard to merge for upstream, as some
+ distributions provide no "target-gcc-version".
+ .
+ Log for bug 903694 carries regression tests for both bugs.
+Forwarded: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87777
+Bug-Debian: https://bugs.debian.org/814977
+Bug-Debian: https://bugs.debian.org/814978
+Bug-Debian: https://bugs.debian.org/856274
+Bug-Debian: https://bugs.debian.org/881938
+Bug-Debian: https://bugs.debian.org/903694
+Author: Ludovic Brenta <lbrenta@debian.org>
+Author: Nicolas Boulenguez <nicolas@debian.org>
+Author: Svante Signell <svante.signell@gmail.com>
+Author: YunQiang Su <wzssyqa@gmail.com>
+
+--- a/src/gcc/ada/osint.ads
++++ b/src/gcc/ada/osint.ads
+@@ -144,14 +144,10 @@ package Osint is
+ -- path) in Name_Buffer, with the length in Name_Len.
+
+ function Program_Name (Nam : String; Prog : String) return String_Access;
+- -- In the native compilation case, creates a string containing Nam. In the
+- -- cross compilation case, looks at the prefix of the current program being
+- -- run and prepends it to Nam. For instance if the program being run is
+- -- <target>-gnatmake and Nam is "gcc", the returned value will be a pointer
+- -- to "<target>-gcc". This function clobbers Name_Buffer and Name_Len.
+- -- Also looks at any suffix, e.g. gnatmake-4.1 -> "gcc-4.1". Prog is the
+- -- default name of the current program being executed, e.g. "gnatmake",
+- -- "gnatlink".
++ -- On Debian, always create a string containing
++ -- Sdefault.Target_Name & '-' & Nam & '-' & Gnatvsn.Library_Version.
++ -- Fail if the program base name differs from Prog,
++ -- maybe extended with the same prefix or suffix.
+
+ procedure Write_Program_Name;
+ -- Writes name of program as invoked to the current output (normally
+--- a/src/gcc/ada/osint.adb
++++ b/src/gcc/ada/osint.adb
+@@ -2268,50 +2268,51 @@ package body Osint is
+ ------------------
+
+ function Program_Name (Nam : String; Prog : String) return String_Access is
+- End_Of_Prefix : Natural := 0;
+- Start_Of_Prefix : Positive := 1;
+- Start_Of_Suffix : Positive;
+-
++ -- Most of the work is to check that the current program name
++ -- is consistent with the two static constants below.
++ Suffix : constant String := '-' & Gnatvsn.Library_Version;
++ Prefix : Types.String_Ptr := Sdefault.Target_Name;
++ First : Integer;
++ Result : System.OS_Lib.String_Access;
+ begin
+ -- Get the name of the current program being executed
+-
+ Find_Program_Name;
+
+- Start_Of_Suffix := Name_Len + 1;
++ -- If our version is present, skip it.
++ First := Name_Len - Suffix'Length + 1;
++ if 0 < First and then Name_Buffer (First .. Name_Len) = Suffix then
++ Name_Len := First - 1;
++ end if;
++
++ -- The central part must be Prog.
++ First := Name_Len - Prog'Length + 1;
++ if First <= 0 or else Name_Buffer (First .. Name_Len) /= Prog then
++ Fail ("Osint.Program_Name: must end with " & Prog
++ & " or " & Prog & Suffix);
++ end if;
++ Name_Len := First - 1;
+
+- -- Find the target prefix if any, for the cross compilation case.
+- -- For instance in "powerpc-elf-gcc" the target prefix is
+- -- "powerpc-elf-"
+- -- Ditto for suffix, e.g. in "gcc-4.1", the suffix is "-4.1"
+-
+- for J in reverse 1 .. Name_Len loop
+- if Is_Directory_Separator (Name_Buffer (J))
+- or else Name_Buffer (J) = ':'
+- then
+- Start_Of_Prefix := J + 1;
+- exit;
+- end if;
+- end loop;
+-
+- -- Find End_Of_Prefix
+-
+- for J in Start_Of_Prefix .. Name_Len - Prog'Length + 1 loop
+- if Name_Buffer (J .. J + Prog'Length - 1) = Prog then
+- End_Of_Prefix := J - 1;
+- exit;
+- end if;
+- end loop;
++ -- According to Make-generated.in, this ends with a slash.
++ Prefix.all (Prefix.all'Last) := '-';
+
+- if End_Of_Prefix > 1 then
+- Start_Of_Suffix := End_Of_Prefix + Prog'Length + 1;
++ -- If our target is present, skip it.
++ First := Name_Len - Prefix.all'Length + 1;
++ if 0 < First and then Name_Buffer (First .. Name_Len) = Prefix.all then
++ Name_Len := First - 1;
+ end if;
+
+- -- Create the new program name
++ -- What remains must be the directory part.
++ if 0 < Name_Len
++ and then Name_Buffer (Name_Len) /= ':'
++ and then not Is_Directory_Separator (Name_Buffer (Name_Len))
++ then
++ Fail ("Osint.Program_Name: must start with " & Prog
++ & " or " & Prefix.all & Prog);
++ end if;
+
+- return new String'
+- (Name_Buffer (Start_Of_Prefix .. End_Of_Prefix)
+- & Nam
+- & Name_Buffer (Start_Of_Suffix .. Name_Len));
++ Result := new String'(Prefix.all & Nam & Suffix);
++ Types.Free (Prefix);
++ return Result;
+ end Program_Name;
+
+ ------------------------------
+--- a/src/gcc/ada/gnatchop.adb
++++ b/src/gcc/ada/gnatchop.adb
+@@ -36,6 +36,7 @@ with GNAT.OS_Lib; use GNA
+ with GNAT.Heap_Sort_G;
+ with GNAT.Table;
+
++with Osint;
+ with Switch; use Switch;
+ with Types;
+
+@@ -44,12 +45,9 @@ procedure Gnatchop is
+ Config_File_Name : constant String_Access := new String'("gnat.adc");
+ -- The name of the file holding the GNAT configuration pragmas
+
+- Gcc : String_Access := new String'("gcc");
++ Gcc : String_Access := null;
+ -- May be modified by switch --GCC=
+
+- Gcc_Set : Boolean := False;
+- -- True if a switch --GCC= is used
+-
+ Gnat_Cmd : String_Access;
+ -- Command to execute the GNAT compiler
+
+@@ -222,12 +220,6 @@ procedure Gnatchop is
+ Integer'Image
+ (Maximum_File_Name_Length);
+
+- function Locate_Executable
+- (Program_Name : String;
+- Look_For_Prefix : Boolean := True) return String_Access;
+- -- Locate executable for given program name. This takes into account
+- -- the target-prefix of the current command, if Look_For_Prefix is True.
+-
+ subtype EOL_Length is Natural range 0 .. 2;
+ -- Possible lengths of end of line sequence
+
+@@ -492,76 +484,6 @@ procedure Gnatchop is
+ Unit.Table (Sorted_Units.Table (U + 1)).File_Name.all;
+ end Is_Duplicated;
+
+- -----------------------
+- -- Locate_Executable --
+- -----------------------
+-
+- function Locate_Executable
+- (Program_Name : String;
+- Look_For_Prefix : Boolean := True) return String_Access
+- is
+- Gnatchop_Str : constant String := "gnatchop";
+- Current_Command : constant String := Normalize_Pathname (Command_Name);
+- End_Of_Prefix : Natural;
+- Start_Of_Prefix : Positive;
+- Start_Of_Suffix : Positive;
+- Result : String_Access;
+-
+- begin
+- Start_Of_Prefix := Current_Command'First;
+- Start_Of_Suffix := Current_Command'Last + 1;
+- End_Of_Prefix := Start_Of_Prefix - 1;
+-
+- if Look_For_Prefix then
+-
+- -- Find Start_Of_Prefix
+-
+- for J in reverse Current_Command'Range loop
+- if Current_Command (J) = '/' or else
+- Current_Command (J) = Directory_Separator or else
+- Current_Command (J) = ':'
+- then
+- Start_Of_Prefix := J + 1;
+- exit;
+- end if;
+- end loop;
+-
+- -- Find End_Of_Prefix
+-
+- for J in Start_Of_Prefix ..
+- Current_Command'Last - Gnatchop_Str'Length + 1
+- loop
+- if Current_Command (J .. J + Gnatchop_Str'Length - 1) =
+- Gnatchop_Str
+- then
+- End_Of_Prefix := J - 1;
+- exit;
+- end if;
+- end loop;
+- end if;
+-
+- if End_Of_Prefix > Current_Command'First then
+- Start_Of_Suffix := End_Of_Prefix + Gnatchop_Str'Length + 1;
+- end if;
+-
+- declare
+- Command : constant String :=
+- Current_Command (Start_Of_Prefix .. End_Of_Prefix)
+- & Program_Name
+- & Current_Command (Start_Of_Suffix ..
+- Current_Command'Last);
+- begin
+- Result := Locate_Exec_On_Path (Command);
+-
+- if Result = null then
+- Error_Msg
+- (Command & ": installation problem, executable not found");
+- end if;
+- end;
+-
+- return Result;
+- end Locate_Executable;
+-
+ ---------------
+ -- Parse_EOL --
+ ---------------
+@@ -1089,8 +1011,8 @@ procedure Gnatchop is
+ exit;
+
+ when '-' =>
+- Gcc := new String'(Parameter);
+- Gcc_Set := True;
++ Free (Gcc);
++ Gcc := new String'(Parameter);
+
+ when 'c' =>
+ Compilation_Mode := True;
+@@ -1768,9 +1690,13 @@ begin
+
+ -- Check presence of required executables
+
+- Gnat_Cmd := Locate_Executable (Gcc.all, not Gcc_Set);
++ if Gcc = null then
++ Gcc := Osint.Program_Name ("gcc", "gnatchop");
++ end if;
++ Gnat_Cmd := Locate_Exec_On_Path (Gcc.all);
+
+ if Gnat_Cmd = null then
++ Error_Msg (Gcc.all & ": installation problem, executable not found");
+ goto No_Files_Written;
+ end if;
+
diff --git a/debian/patches/ada-gnattools-cross.diff b/debian/patches/ada-gnattools-cross.diff
new file mode 100644
index 0000000..4f0fd9a
--- /dev/null
+++ b/debian/patches/ada-gnattools-cross.diff
@@ -0,0 +1,228 @@
+TODO: Check that the part removing the dependency from stamp-gnatlib1
+to stamp-gnatlib2 is not necessary anymore with gcc-9.
+
+* 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.
+* Link libgnat/gnarl with LDFLAGS.
+* Link libgnarl with an explicit path to a shared object.
+ This prevents undefined symbols or unwanted usage of host libgnat.
+* Compile with -gnatn for efficiency.
+ Double-check the link since Debian moves some symbols.
+* set LD_LIBRARY_PATH so that rebuilt tools can be executed.
+
+--- a/src/gcc/ada/Makefile.rtl
++++ b/src/gcc/ada/Makefile.rtl
+@@ -1845,6 +1845,11 @@ ifeq ($(strip $(filter-out s390% linux%,
+ LIBRARY_VERSION := $(LIB_VERSION)
+ endif
+
++ifeq ($(strip $(filter-out hppa% unknown linux gnu,$(targ))),)
++ GNATLIB_SHARED = gnatlib-shared-dual
++ LIBRARY_VERSION := $(LIB_VERSION)
++endif
++
+ # HP/PA HP-UX 10
+ ifeq ($(strip $(filter-out hppa% hp hpux10%,$(target_cpu) $(target_vendor) $(target_os))),)
+ LIBGNAT_TARGET_PAIRS = \
+--- a/src/gcc/ada/gcc-interface/Makefile.in
++++ b/src/gcc/ada/gcc-interface/Makefile.in
+@@ -503,6 +503,20 @@ gnatlink-re: ../stamp-tools gnatmake-re
+ --GCC="$(CC) $(ADA_INCLUDES)" --LINK="$(GCC_LINK)" $(TOOLS_LIBS)
+ $(MV) ../../gnatlinknew$(exeext) ../../gnatlink$(exeext)
+
++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="$(CC) $(ADA_INCLUDES)" --LINK="$(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
+@@ -630,7 +644,7 @@ $(RTSDIR)/s-oscons.ads: ../stamp-gnatlib
+ $(OSCONS_EXTRACT) ; \
+ ../bldtools/oscons/xoscons s-oscons)
+
+-gnatlib: ../stamp-gnatlib1-$(RTSDIR) ../stamp-gnatlib2-$(RTSDIR) $(RTSDIR)/s-oscons.ads
++gnatlib: ../stamp-gnatlib1-$(RTSDIR) $(RTSDIR)/s-oscons.ads
+ test -f $(RTSDIR)/s-oscons.ads || exit 1
+ # C files
+ $(MAKE) -C $(RTSDIR) \
+@@ -662,18 +676,30 @@ 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:
+- $(MAKE) $(FLAGS_TO_PASS) \
+- GNATLIBFLAGS="$(GNATLIBFLAGS)" \
+- GNATLIBCFLAGS="$(GNATLIBCFLAGS) $(PICFLAG_FOR_TARGET) -fno-lto" \
+- GNATLIBCFLAGS_FOR_C="$(GNATLIBCFLAGS_FOR_C) $(PICFLAG_FOR_TARGET) -fno-lto" \
+- MULTISUBDIR="$(MULTISUBDIR)" \
+- THREAD_KIND="$(THREAD_KIND)" \
+- LN_S="$(LN_S)" \
+- gnatlib
++ $(MAKE) -C $(RTSDIR) \
++ CC="`echo \"$(GCC_FOR_TARGET)\" \
++ | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \
++ INCLUDES="$(INCLUDES_FOR_SUBDIR) -I./../.." \
++ CFLAGS="$(GNATLIBCFLAGS_FOR_C) $(PICFLAG_FOR_TARGET) -fno-lto" \
++ FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \
++ srcdir=$(fsrcdir) \
++ -f ../Makefile $(LIBGNAT_OBJS)
++ $(MAKE) -C $(RTSDIR) \
++ CC="`echo \"$(GCC_FOR_TARGET)\" \
++ | sed -e 's,\./xgcc,../../xgcc,' -e 's,-B\./,-B../../,'`" \
++ ADA_INCLUDES="" \
++ CFLAGS="$(GNATLIBCFLAGS) $(PICFLAG_FOR_TARGET) -fno-lto" \
++ ADAFLAGS="$(GNATLIBFLAGS) $(PICFLAG_FOR_TARGET) -fno-lto" \
++ FORCE_DEBUG_ADAFLAGS="$(FORCE_DEBUG_ADAFLAGS)" \
++ srcdir=$(fsrcdir) \
++ -f ../Makefile \
++ $(GNATRTL_OBJS)
+ $(RM) $(RTSDIR)/libgna*$(soext)
+ cd $(RTSDIR); $(GCC_FOR_ADA_RTS) -shared $(GNATLIBCFLAGS) \
+ $(PICFLAG_FOR_TARGET) \
+@@ -684,8 +710,10 @@ gnatlib-shared-default:
+ cd $(RTSDIR); $(GCC_FOR_ADA_RTS) -shared $(GNATLIBCFLAGS) \
+ $(PICFLAG_FOR_TARGET) \
+ -o libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
++ $(LDFLAGS) \
+ $(GNATRTL_TASKING_OBJS) \
+ $(SO_OPTS)libgnarl$(hyphen)$(LIBRARY_VERSION)$(soext) \
++ libgnat$(hyphen)$(LIBRARY_VERSION).so \
+ $(THREADSLIB)
+ cd $(RTSDIR); $(LN_S) libgnat$(hyphen)$(LIBRARY_VERSION)$(soext) \
+ libgnat$(soext)
+@@ -701,6 +729,10 @@ 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.
++ $(CHMOD) a-wx $(RTSDIR)/*.ali
++ $(RM) $(RTSDIR)/*.o
++
+ gnatlib-shared-dual:
+ $(MAKE) $(FLAGS_TO_PASS) \
+ GNATLIBFLAGS="$(GNATLIBFLAGS)" \
+@@ -710,11 +742,8 @@ gnatlib-shared-dual:
+ MULTISUBDIR="$(MULTISUBDIR)" \
+ THREAD_KIND="$(THREAD_KIND)" \
+ LN_S="$(LN_S)" \
+- gnatlib-shared-default
+- $(MV) $(RTSDIR)/libgna*$(soext) .
+- $(MV) $(RTSDIR)/libgnat_pic$(arext) .
+- $(MV) $(RTSDIR)/libgnarl_pic$(arext) .
+- $(RM) ../stamp-gnatlib2-$(RTSDIR)
++ gnatlib
++ $(RM) $(RTSDIR)/*.o $(RTSDIR)/*.ali
+ $(MAKE) $(FLAGS_TO_PASS) \
+ GNATLIBFLAGS="$(GNATLIBFLAGS)" \
+ GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
+@@ -722,10 +751,7 @@ gnatlib-shared-dual:
+ MULTISUBDIR="$(MULTISUBDIR)" \
+ THREAD_KIND="$(THREAD_KIND)" \
+ LN_S="$(LN_S)" \
+- gnatlib
+- $(MV) libgna*$(soext) $(RTSDIR)
+- $(MV) libgnat_pic$(arext) $(RTSDIR)
+- $(MV) libgnarl_pic$(arext) $(RTSDIR)
++ gnatlib-shared-default
+
+ gnatlib-shared-dual-win32:
+ $(MAKE) $(FLAGS_TO_PASS) \
+@@ -736,9 +762,8 @@ gnatlib-shared-dual-win32:
+ MULTISUBDIR="$(MULTISUBDIR)" \
+ THREAD_KIND="$(THREAD_KIND)" \
+ LN_S="$(LN_S)" \
+- gnatlib-shared-win32
+- $(MV) $(RTSDIR)/libgna*$(soext) .
+- $(RM) ../stamp-gnatlib2-$(RTSDIR)
++ gnatlib
++ $(RM) $(RTSDIR)/*.o $(RTSDIR)/*.ali
+ $(MAKE) $(FLAGS_TO_PASS) \
+ GNATLIBFLAGS="$(GNATLIBFLAGS)" \
+ GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
+@@ -746,8 +771,7 @@ gnatlib-shared-dual-win32:
+ MULTISUBDIR="$(MULTISUBDIR)" \
+ THREAD_KIND="$(THREAD_KIND)" \
+ LN_S="$(LN_S)" \
+- gnatlib
+- $(MV) libgna*$(soext) $(RTSDIR)
++ gnatlib-shared-win32
+
+ # ??? we need to add the option to support auto-import of arrays/records to
+ # the GNATLIBFLAGS when this will be supported by GNAT. At this point we will
+--- a/src/gnattools/Makefile.in
++++ b/src/gnattools/Makefile.in
+@@ -75,16 +75,23 @@ CXX_LFLAGS = \
+ -L../../../$(target_noncanonical)/libstdc++-v3/src/.libs \
+ -L../../../$(target_noncanonical)/libstdc++-v3/libsupc++/.libs
+
++rtsdir := $(abspath ../gcc/ada/rts)
++
+ # Variables for gnattools, native
+ TOOLS_FLAGS_TO_PASS_NATIVE= \
+ "CC=../../xgcc -B../../" \
+ "CXX=../../xg++ -B../../ $(CXX_LFLAGS)" \
+ "CFLAGS=$(CFLAGS) $(WARN_CFLAGS)" \
+- "LDFLAGS=$(LDFLAGS)" \
+- "ADAFLAGS=$(ADAFLAGS)" \
++ "LDFLAGS=$(LDFLAGS) -Wl,--no-allow-shlib-undefined \
++ -Wl,--no-copy-dt-needed-entries -Wl,--no-undefined" \
++ "ADAFLAGS=$(ADAFLAGS) -gnatn" \
+ "ADA_CFLAGS=$(ADA_CFLAGS)" \
+ "INCLUDES=$(INCLUDES_FOR_SUBDIR)" \
+- "ADA_INCLUDES=-I- -I../rts $(ADA_INCLUDES_FOR_SUBDIR)"\
++ "ADA_INCLUDES=-I- -nostdinc -I$(rtsdir) $(ADA_INCLUDES_FOR_SUBDIR)" \
++ "TOOLS_ALREADY_COMPILED=$(foreach d, $(rtsdir), \
++ $(patsubst $(d)/%.ali,%.o, $(wildcard $(d)/*.ali)))" \
++ 'LIBGNAT=$(rtsdir)/libgnat-$$(LIB_VERSION).so' \
++ "GNATBIND_FLAGS=-nostdlib -x" \
+ "exeext=$(exeext)" \
+ "fsrcdir=$(fsrcdir)" \
+ "srcdir=$(fsrcdir)" \
+@@ -194,6 +201,10 @@ $(GCC_DIR)/stamp-tools:
+ # 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: export LD_LIBRARY_PATH := \
++ $(if $(LD_LIBRARY_PATH),$(LD_LIBRARY_PATH):)$(rtsdir)
++# Useful even for 1st pass, as ../../gnatmake may already be
++# dynamically linked in case this target has already been invoked.
+ gnattools-native: $(GCC_DIR)/stamp-tools $(GCC_DIR)/stamp-gnatlib-rts
+ # gnattools1
+ $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
+@@ -202,6 +213,13 @@ gnattools-native: $(GCC_DIR)/stamp-tools
+ # gnattools2
+ $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
+ $(TOOLS_FLAGS_TO_PASS_NATIVE) common-tools
++# The hard-coded object lists for gnatbind/make/link contain unneeded
++# objects. Use the fresh tools to recompute dependencies.
++# A separate Make run avoids race conditions between gnatmakes
++# building the same object for common-tools and gnat*-re.
++# (parallelism is already forbidden between gnat*-re targets)
++ $(MAKE) -C $(GCC_DIR)/ada/tools -f ../Makefile \
++ $(TOOLS_FLAGS_TO_PASS_NATIVE) 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-lib-info-source-date-epoch.diff b/debian/patches/ada-lib-info-source-date-epoch.diff
new file mode 100644
index 0000000..88e23ca
--- /dev/null
+++ b/debian/patches/ada-lib-info-source-date-epoch.diff
@@ -0,0 +1,115 @@
+Description: set ALI timestamps from SOURCE_DATE_EPOCH if available.
+ When the SOURCE_DATE_EPOCH environment variable is set,
+ replace timestamps more recent than its value with its value
+ when writing Ada Library Information (ALI) files.
+ This allow reproducible builds from generated or patched Ada sources.
+ https://reproducible-builds.org/specs/source-date-epoch/
+ .
+ Also see debian/ada/test_ada_source_date_epoch.sh.
+Author: Nicolas Boulenguez <nicolas@debian.org>
+
+--- a/src/gcc/ada/osint.adb
++++ b/src/gcc/ada/osint.adb
+@@ -64,6 +64,10 @@ package body Osint is
+ -- Used in Locate_File as a fake directory when Name is already an
+ -- absolute path.
+
++ Source_Date_Epoch : OS_Time := Invalid_Time;
++ -- Set at startup by the Initialize procedure.
++ -- See the specification of the File_Time_Stamp functions.
++
+ -------------------------------------
+ -- Use of Name_Find and Name_Enter --
+ -------------------------------------
+@@ -1126,8 +1130,14 @@ package body Osint is
+ is
+ function Internal (N : C_File_Name; A : System.Address) return OS_Time;
+ pragma Import (C, Internal, "__gnat_file_time_name_attr");
++ T : OS_Time := Internal (Name, Attr.all'Address);
+ begin
+- return Internal (Name, Attr.all'Address);
++ if Source_Date_Epoch /= Invalid_Time and then T /= Invalid_Time
++ and then Source_Date_Epoch < T
++ then
++ T := Source_Date_Epoch;
++ end if;
++ return T;
+ end File_Time_Stamp;
+
+ function File_Time_Stamp
+@@ -1150,6 +1160,7 @@ package body Osint is
+ ----------------
+
+ function File_Stamp (Name : File_Name_Type) return Time_Stamp_Type is
++ T : OS_Time;
+ begin
+ if Name = No_File then
+ return Empty_Time_Stamp;
+@@ -1161,9 +1172,13 @@ package body Osint is
+ -- not exist, and OS_Time_To_GNAT_Time will convert this value to
+ -- Empty_Time_Stamp. Therefore we do not need to first test whether
+ -- the file actually exists, which saves a system call.
+-
+- return OS_Time_To_GNAT_Time
+- (File_Time_Stamp (Name_Buffer (1 .. Name_Len)));
++ T := File_Time_Stamp (Name_Buffer (1 .. Name_Len));
++ if Source_Date_Epoch /= Invalid_Time and then T /= Invalid_Time
++ and then Source_Date_Epoch < T
++ then
++ T := Source_Date_Epoch;
++ end if;
++ return OS_Time_To_GNAT_Time (T);
+ end File_Stamp;
+
+ function File_Stamp (Name : Path_Name_Type) return Time_Stamp_Type is
+@@ -3261,4 +3276,28 @@ begin
+ Osint.Initialize;
+ end Initialization;
+
++ Set_Source_Date_Epoch : declare
++ Env_Var : String_Access := Getenv ("SOURCE_DATE_EPOCH");
++ Epoch : time_t range 0 .. time_t'Last := 0;
++ Digit : time_t range 0 .. 9;
++ begin
++ if 0 < Env_Var.all'Length then
++ -- Calling System.Val_LLI breaks the bootstrap sequence.
++ -- First convert to time_t because OS_Time is private.
++ for C of Env_Var.all loop
++ if C not in '0' .. '9' then
++ goto Finally;
++ end if;
++ Digit := time_t (Character'Pos (C) - Character'Pos ('0'));
++ if (time_t'Last - Digit) / 10 < Epoch then
++ goto Finally;
++ end if;
++ Epoch := Epoch * 10 + Digit;
++ end loop;
++ Source_Date_Epoch := To_Ada (Epoch);
++ end if;
++ <<Finally>>
++ Free (Env_Var);
++ end Set_Source_Date_Epoch;
++
+ end Osint;
+--- a/src/gcc/ada/osint.ads
++++ b/src/gcc/ada/osint.ads
+@@ -196,6 +196,7 @@ package Osint is
+ -- information in order to locate it. If the source file cannot be opened,
+ -- or Name = No_File, and all blank time stamp is returned (this is not an
+ -- error situation).
++ -- Handles SOURCE_DATE_EPOCH like File_Time_Stamp functions below.
+
+ function File_Stamp (Name : Path_Name_Type) return Time_Stamp_Type;
+ -- Same as above for a path name
+@@ -303,6 +304,11 @@ package Osint is
+ (Name : Path_Name_Type;
+ Attr : access File_Attributes) return Time_Stamp_Type;
+ -- Return the time stamp of the file
++ -- If the SOURCE_DATE_EPOCH environment variable exists and represents
++ -- an OS_Type value, any more recent file time stamp is truncated.
++ -- This ensures that gnat1 writes deterministic .ali files even in
++ -- the presence of patched or generated sources. See
++ -- https://reproducible-builds.org/specs/source-date-epoch.
+
+ function Is_Readable_File
+ (Name : C_File_Name;
diff --git a/debian/patches/ada-link-lib.diff b/debian/patches/ada-link-lib.diff
new file mode 100644
index 0000000..844dec8
--- /dev/null
+++ b/debian/patches/ada-link-lib.diff
@@ -0,0 +1,151 @@
+Description: adapt libgnat build for Debian
+ Don't include a runtime link path (-rpath), when linking binaries.
+ .
+ Build the shared libraries on hppa-linux (see #786692 below).
+ TODO: ask the reporter (no porterbox) to attempt a rebuild without this
+ chunk, now that we diverge less from upstream.
+ .
+ Instead of building libada as a target library only, build it as
+ both a host and, if different, target library.
+ .
+ Compile with -gnatn for efficiency.
+ Double-check the link since Debian moves some symbols.
+ .
+ Please read ada-changes-in-autogen-output.diff about src/Makefile.def.
+Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=786692
+Forwarded: not-needed
+Author: Ludovic Brenta <lbrenta@debian.org>
+Author: Nicolas Boulenguez <nicolas@debian.org>
+Author: Matthias Klose <doko@debian.org>
+
+--- a/src/gcc/ada/gcc-interface/config-lang.in
++++ b/src/gcc/ada/gcc-interface/config-lang.in
+@@ -44,7 +44,7 @@ if test "x$cross_compiling/$build/$host"
+ fi
+
+ target_libs="target-libada"
+-lang_dirs="gnattools"
++lang_dirs="libada gnattools"
+
+ # Ada is not enabled by default for the time being.
+ build_by_default=no
+--- a/src/gcc/ada/link.c
++++ b/src/gcc/ada/link.c
+@@ -107,9 +107,9 @@ const char *__gnat_default_libgcc_subdir
+ || defined (__NetBSD__) || defined (__OpenBSD__) \
+ || defined (__QNX__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
+@@ -129,9 +129,9 @@ const char *__gnat_default_libgcc_subdir
+
+ #elif defined (__linux__) || defined (__GLIBC__)
+ const char *__gnat_object_file_option = "-Wl,@";
+-const char *__gnat_run_path_option = "-Wl,-rpath,";
+-char __gnat_shared_libgnat_default = STATIC;
+-char __gnat_shared_libgcc_default = STATIC;
++const char *__gnat_run_path_option = "";
++char __gnat_shared_libgnat_default = SHARED;
++char __gnat_shared_libgcc_default = SHARED;
+ int __gnat_link_max = 8192;
+ unsigned char __gnat_objlist_file_supported = 1;
+ const char *__gnat_object_library_extension = ".a";
+--- a/src/libada/Makefile.in
++++ b/src/libada/Makefile.in
+@@ -79,10 +79,11 @@ ADA_RTS_DIR=$(GCC_DIR)/ada/rts$(subst /,
+ # by recursive make invocations in gcc/ada/Makefile.in
+ LIBADA_FLAGS_TO_PASS = \
+ "MAKEOVERRIDES=" \
+- "LDFLAGS=$(LDFLAGS)" \
++ "LDFLAGS=$(LDFLAGS) -Wl,--no-allow-shlib-undefined \
++ -Wl,--no-copy-dt-needed-entries -Wl,--no-undefined" \
+ "LN_S=$(LN_S)" \
+ "SHELL=$(SHELL)" \
+- "GNATLIBFLAGS=$(GNATLIBFLAGS) $(MULTIFLAGS)" \
++ "GNATLIBFLAGS=$(GNATLIBFLAGS) $(MULTIFLAGS) -gnatn" \
+ "GNATLIBCFLAGS=$(GNATLIBCFLAGS) $(MULTIFLAGS)" \
+ "GNATLIBCFLAGS_FOR_C=$(GNATLIBCFLAGS_FOR_C) $(MULTIFLAGS)" \
+ "PICFLAG_FOR_TARGET=$(PICFLAG)" \
+--- a/src/Makefile.def
++++ b/src/Makefile.def
+@@ -411,6 +411,7 @@ dependencies = { module=all-libcpp; on=a
+
+ dependencies = { module=all-fixincludes; on=all-libiberty; };
+
++dependencies = { module=all-target-libada; on=all-gcc; };
+ dependencies = { module=all-gnattools; on=all-target-libada; };
+ dependencies = { module=all-gnattools; on=all-target-libstdc++-v3; };
+
+--- a/src/configure.ac
++++ b/src/configure.ac
+@@ -143,6 +143,11 @@ host_libs="gettext libiberty opcodes bfd
+ # If --enable-gold is used, "gold" may replace "ld".
+ host_tools="texinfo flex bison binutils gas ld fixincludes gcc cgen sid sim gdb gdbserver gprof etc expect dejagnu m4 utils guile fastjar gnattools libcc1 gm2tools gotools c++tools"
+
++case "${target}" in
++ hppa64-*linux*) ;;
++ *) target_libiberty="target-libiberty";;
++esac
++
+ # these libraries are built for the target environment, and are built after
+ # the host libraries and the host tools (which may be a cross compiler)
+ # Note that libiberty is not a target library.
+@@ -162,6 +167,7 @@ target_libraries="target-libgcc \
+ target-libffi \
+ target-libobjc \
+ target-libada \
++ ${target_libiberty} \
+ target-libgm2 \
+ target-libgo \
+ target-libgrust \
+--- a/src/gcc/ada/gcc-interface/Make-lang.in
++++ b/src/gcc/ada/gcc-interface/Make-lang.in
+@@ -43,7 +43,7 @@ RMDIR = rm -rf
+
+
+ # Extra flags to pass to recursive makes.
+-COMMON_ADAFLAGS= -gnatpg
++COMMON_ADAFLAGS= -gnatpgn
+ ifeq ($(TREECHECKING),)
+ CHECKING_ADAFLAGS=
+ else
+@@ -267,7 +267,9 @@ GCC_LINKERFLAGS = $(filter-out -Werror -
+ GCC_LDFLAGS = $(filter-out -static-libgcc, $(LDFLAGS))
+ else
+ # Strip -Werror during linking for the LTO bootstrap
+-GCC_LINKERFLAGS = $(filter-out -Werror, $(ALL_LINKERFLAGS))
++GCC_LINKERFLAGS = $(filter-out -Werror, $(ALL_LINKERFLAGS)) \
++ -Wl,--no-allow-shlib-undefined -Wl,--no-copy-dt-needed-entries \
++ -Wl,--no-undefined
+ GCC_LDFLAGS = $(LDFLAGS)
+ endif
+
+--- a/src/gcc/testsuite/lib/gnat.exp
++++ b/src/gcc/testsuite/lib/gnat.exp
+@@ -115,6 +115,7 @@ proc gnat_target_compile { source dest t
+ global TOOL_OPTIONS
+ global gnat_target_current
+ global TEST_ALWAYS_FLAGS
++ global ld_library_path
+
+ # dg-require-effective-target tests must be compiled as C.
+ if [ string match "*.c" $source ] then {
+@@ -144,6 +145,11 @@ proc gnat_target_compile { source dest t
+ # Always log so compilations can be repeated manually.
+ verbose -log "ADA_INCLUDE_PATH=$rtsdir/adainclude"
+ verbose -log "ADA_OBJECTS_PATH=$rtsdir/adainclude"
++
++ if { ! [ string match "*/libada/adalib*" $ld_library_path ] } {
++ append ld_library_path ":$rtsdir/adalib"
++ set_ld_library_path_env_vars
++ }
+ }
+
+ lappend options "compiler=$GNAT_UNDER_TEST -q -f"
diff --git a/debian/patches/ada-nobiarch-check.diff b/debian/patches/ada-nobiarch-check.diff
new file mode 100644
index 0000000..35190a7
--- /dev/null
+++ b/debian/patches/ada-nobiarch-check.diff
@@ -0,0 +1,21 @@
+Description: For biarch builds, disable the gnat testsuite for the non-default
+ architecture (no biarch support in gnat yet).
+Author: Matthias Klose <doko@debian.org>
+
+Index: b/src/gcc/Makefile.in
+===================================================================
+--- a/src/gcc/Makefile.in
++++ b/src/gcc/Makefile.in
+@@ -4510,7 +4510,11 @@
+ if [ -f $${rootme}/../expect/expect ] ; then \
+ TCL_LIBRARY=`cd .. ; cd $${srcdir}/../tcl/library ; ${PWD_COMMAND}` ; \
+ export TCL_LIBRARY ; fi ; \
+- $(RUNTEST) --tool $* $(RUNTESTFLAGS))
++ if [ "$*" = gnat ]; then \
++ runtestflags="`echo '$(RUNTESTFLAGS)' | sed -r 's/,-m(32|64|x32)//g;s/,-mabi=(n32|64)//g'`"; \
++ case "$$runtestflags" in *\\{\\}) runtestflags=; esac; \
++ fi; \
++ $(RUNTEST) --tool $* $$runtestflags)
+
+ $(patsubst %,%-subtargets,$(filter-out $(lang_checks_parallelized),$(lang_checks))): check-%-subtargets:
+ @echo check-$*
diff --git a/debian/patches/ada-perl-shebang.diff b/debian/patches/ada-perl-shebang.diff
new file mode 100644
index 0000000..ea930b1
--- /dev/null
+++ b/debian/patches/ada-perl-shebang.diff
@@ -0,0 +1,10 @@
+# DP: Fix perl shebang for the gnathtml binary.
+
+--- a/src/gcc/ada/gnathtml.pl
++++ b/src/gcc/ada/gnathtml.pl
+@@ -1,4 +1,4 @@
+-#! /usr/bin/env perl
++#! /usr/bin/perl
+
+ #-----------------------------------------------------------------------------
+ #- --
diff --git a/debian/patches/ada-sjlj.diff b/debian/patches/ada-sjlj.diff
new file mode 100644
index 0000000..68861a1
--- /dev/null
+++ b/debian/patches/ada-sjlj.diff
@@ -0,0 +1,493 @@
+# Please read ada-changes-in-autogen-output.diff about src/Makefile.def.
+
+# !!! Must be applied after ada-libgnat_util.diff
+
+--- /dev/null
++++ b/src/libada-sjlj/Makefile.in
+@@ -0,0 +1,204 @@
++# Makefile for libada.
++# Copyright (C) 2003-2017 Free Software Foundation, Inc.
++#
++# This file 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 of the License, 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/>.
++
++# Default target; must be first.
++all: gnatlib
++ $(MULTIDO) $(AM_MAKEFLAGS) DO=all multi-do # $(MAKE)
++
++.PHONY: all
++
++## Multilib support variables.
++MULTISRCTOP =
++MULTIBUILDTOP =
++MULTIDIRS =
++MULTISUBDIR =
++MULTIDO = true
++MULTICLEAN = true
++
++# Standard autoconf-set variables.
++SHELL = @SHELL@
++srcdir = @srcdir@
++libdir = @libdir@
++build = @build@
++target = @target@
++prefix = @prefix@
++
++# Nonstandard autoconf-set variables.
++enable_shared = @enable_shared@
++
++LN_S=@LN_S@
++AWK=@AWK@
++
++ifeq (cp -p,$(LN_S))
++LN_S_RECURSIVE = cp -pR
++else
++LN_S_RECURSIVE = $(LN_S)
++endif
++
++# Variables for the user (or the top level) to override.
++objext=.o
++THREAD_KIND=native
++TRACE=no
++LDFLAGS=
++
++# The tedious process of getting CFLAGS right.
++CFLAGS=-g
++PICFLAG = @PICFLAG@
++GNATLIBFLAGS= -W -Wall -gnatpg -nostdinc
++GNATLIBCFLAGS= -g -O2
++GNATLIBCFLAGS_FOR_C = -W -Wall $(GNATLIBCFLAGS) $(CFLAGS_FOR_TARGET) \
++ -fexceptions -DIN_RTS @have_getipinfo@ @have_capability@
++
++host_subdir = @host_subdir@
++GCC_DIR=$(MULTIBUILDTOP)../../$(host_subdir)/gcc
++
++target_noncanonical:=@target_noncanonical@
++version := $(shell @get_gcc_base_ver@ $(srcdir)/../gcc/BASE-VER)
++libsubdir := $(libdir)/gcc/$(target_noncanonical)/$(version)$(MULTISUBDIR)
++ADA_RTS_DIR=$(GCC_DIR)/ada/rts$(subst /,_,$(MULTISUBDIR))
++ADA_RTS_SUBDIR=./rts$(subst /,_,$(MULTISUBDIR))
++
++# exeext should not be used because it's the *host* exeext. We're building
++# 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
++LIBADA_FLAGS_TO_PASS = \
++ "MAKEOVERRIDES=" \
++ "LDFLAGS=$(LDFLAGS) -Wl,--no-allow-shlib-undefined \
++ -Wl,--no-copy-dt-needed-entries -Wl,--no-undefined" \
++ "LN_S=$(LN_S)" \
++ "SHELL=$(SHELL)" \
++ "GNATLIBFLAGS=$(GNATLIBFLAGS) $(MULTIFLAGS) -gnatn" \
++ "GNATLIBCFLAGS=$(GNATLIBCFLAGS) $(MULTIFLAGS)" \
++ "GNATLIBCFLAGS_FOR_C=$(GNATLIBCFLAGS_FOR_C) $(MULTIFLAGS)" \
++ "PICFLAG_FOR_TARGET=$(PICFLAG)" \
++ "THREAD_KIND=$(THREAD_KIND)" \
++ "TRACE=$(TRACE)" \
++ "MULTISUBDIR=$(MULTISUBDIR)" \
++ "libsubdir=$(libsubdir)" \
++ "objext=$(objext)" \
++ "prefix=$(prefix)" \
++ "exeext=.exeext.should.not.be.used " \
++ 'CC=the.host.compiler.should.not.be.needed' \
++ "GCC_FOR_TARGET=$(CC)" \
++ "CFLAGS=$(CFLAGS)" \
++ "RTSDIR=rts-sjlj"
++
++# Rules to build gnatlib.
++.PHONY: gnatlib gnatlib-plain gnatlib-sjlj gnatlib-zcx gnatlib-shared osconstool
++gnatlib: gnatlib-sjlj
++
++gnatlib-plain: osconstool $(GCC_DIR)/ada/Makefile
++ test -f stamp-libada || \
++ $(MAKE) -C $(GCC_DIR)/ada $(LIBADA_FLAGS_TO_PASS) gnatlib \
++ && touch stamp-libada
++ -rm -rf adainclude
++ -rm -rf adalib
++ $(LN_S_RECURSIVE) $(ADA_RTS_DIR) adainclude
++ $(LN_S_RECURSIVE) $(ADA_RTS_DIR) adalib
++
++gnatlib-sjlj gnatlib-zcx gnatlib-shared: osconstool $(GCC_DIR)/ada/Makefile
++ test -f stamp-libada || \
++ $(MAKE) -C $(GCC_DIR)/ada $(LIBADA_FLAGS_TO_PASS) $@ \
++ && touch stamp-libada-sjlj
++ -rm -rf adainclude
++ -rm -rf adalib
++ $(LN_S_RECURSIVE) $(ADA_RTS_DIR) adainclude
++ $(LN_S_RECURSIVE) $(ADA_RTS_DIR) adalib
++
++osconstool:
++ $(MAKE) -C $(GCC_DIR)/ada $(LIBADA_FLAGS_TO_PASS) ./bldtools/oscons/xoscons
++
++install-gnatlib: $(GCC_DIR)/ada/Makefile
++ $(MAKE) -C $(GCC_DIR)/ada $(LIBADA_FLAGS_TO_PASS) install-gnatlib-sjlj
++
++# Check uninstalled version.
++check:
++
++# Check installed version.
++installcheck:
++
++# Build info (none here).
++info:
++
++# Build DVI (none here).
++dvi:
++
++# Build PDF (none here).
++pdf:
++
++# Build html (none here).
++html:
++
++# Build TAGS (none here).
++TAGS:
++
++.PHONY: check installcheck info dvi pdf html
++
++# Installation rules.
++install: install-gnatlib
++ $(MULTIDO) $(AM_MAKEFLAGS) DO=install multi-do # $(MAKE)
++
++install-strip: install
++
++install-info:
++
++install-pdf:
++
++install-html:
++
++.PHONY: install install-strip install-info install-pdf install-html
++
++# Cleaning rules.
++mostlyclean:
++ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=mostlyclean multi-clean # $(MAKE)
++
++clean:
++ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=clean multi-clean # $(MAKE)
++
++distclean:
++ $(MULTICLEAN) $(AM_MAKEFLAGS) DO=distclean multi-clean # $(MAKE)
++ $(RM) Makefile config.status config.log
++
++maintainer-clean:
++
++.PHONY: mostlyclean clean distclean maintainer-clean
++
++# Rules for rebuilding this Makefile.
++Makefile: $(srcdir)/Makefile.in config.status
++ CONFIG_FILES=$@ ; \
++ CONFIG_HEADERS= ; \
++ $(SHELL) ./config.status
++
++config.status: $(srcdir)/configure
++ $(SHELL) ./config.status --recheck
++
++AUTOCONF = autoconf
++configure_deps = \
++ $(srcdir)/configure.ac \
++ $(srcdir)/../config/acx.m4 \
++ $(srcdir)/../config/multi.m4 \
++ $(srcdir)/../config/override.m4 \
++ $(srcdir)/../config/picflag.m4 \
++ $(srcdir)/../config/unwind_ipinfo.m4
++
++$(srcdir)/configure: @MAINT@ $(configure_deps)
++ cd $(srcdir) && $(AUTOCONF)
++
++# Don't export variables to the environment, in order to not confuse
++# configure.
++.NOEXPORT:
+--- /dev/null
++++ b/src/libada-sjlj/configure.ac
+@@ -0,0 +1,156 @@
++# Configure script for libada.
++# Copyright (C) 2003-2017 Free Software Foundation, Inc.
++#
++# This file 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 of the License, 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/>.
++
++sinclude(../config/acx.m4)
++sinclude(../config/multi.m4)
++sinclude(../config/override.m4)
++sinclude(../config/picflag.m4)
++sinclude(../config/unwind_ipinfo.m4)
++
++AC_INIT
++AC_PREREQ([2.64])
++
++AC_CONFIG_SRCDIR([Makefile.in])
++
++# Determine the host, build, and target systems
++AC_CANONICAL_BUILD
++AC_CANONICAL_HOST
++AC_CANONICAL_TARGET
++target_alias=${target_alias-$host_alias}
++
++# Determine the noncanonical target name, for directory use.
++ACX_NONCANONICAL_TARGET
++
++# Determine the target- and build-specific subdirectories
++GCC_TOPLEV_SUBDIRS
++
++# Command-line options.
++# Very limited version of AC_MAINTAINER_MODE.
++AC_ARG_ENABLE([maintainer-mode],
++ [AC_HELP_STRING([--enable-maintainer-mode],
++ [enable make rules and dependencies not useful (and
++ sometimes confusing) to the casual installer])],
++ [case ${enable_maintainer_mode} in
++ yes) MAINT='' ;;
++ no) MAINT='#' ;;
++ *) AC_MSG_ERROR([--enable-maintainer-mode must be yes or no]) ;;
++ esac
++ maintainer_mode=${enableval}],
++ [MAINT='#'])
++AC_SUBST([MAINT])dnl
++
++AM_ENABLE_MULTILIB(, ..)
++# Calculate toolexeclibdir
++# Also toolexecdir, though it's only used in toolexeclibdir
++case ${enable_version_specific_runtime_libs} in
++ yes)
++ # Need the gcc compiler version to know where to install libraries
++ # and header files if --enable-version-specific-runtime-libs option
++ # is selected.
++ toolexecdir='$(libdir)/gcc/$(target_alias)'
++ toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
++ ;;
++ no)
++ if test -n "$with_cross_host" &&
++ test x"$with_cross_host" != x"no"; then
++ # Install a library built with a cross compiler in tooldir, not libdir.
++ toolexecdir='$(exec_prefix)/$(target_alias)'
++ toolexeclibdir='$(toolexecdir)/lib'
++ else
++ toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
++ toolexeclibdir='$(libdir)'
++ fi
++ multi_os_directory=`$CC -print-multi-os-directory`
++ case $multi_os_directory in
++ .) ;; # Avoid trailing /.
++ *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
++ esac
++ ;;
++esac
++AC_SUBST(toolexecdir)
++AC_SUBST(toolexeclibdir)
++#TODO: toolexeclibdir is currently disregarded
++
++# Check the compiler.
++# The same as in boehm-gc and libstdc++. Have to borrow it from there.
++# We must force CC to /not/ be precious variables; otherwise
++# the wrong, non-multilib-adjusted value will be used in multilibs.
++# As a side effect, we have to subst CFLAGS ourselves.
++
++m4_rename([_AC_ARG_VAR_PRECIOUS],[real_PRECIOUS])
++m4_define([_AC_ARG_VAR_PRECIOUS],[])
++AC_PROG_CC
++m4_rename_force([real_PRECIOUS],[_AC_ARG_VAR_PRECIOUS])
++
++AC_SUBST(CFLAGS)
++
++AC_ARG_ENABLE([shared],
++[AC_HELP_STRING([--disable-shared],
++ [don't provide a shared libgnat])],
++[
++case $enable_shared in
++ yes | no) ;;
++ *)
++ enable_shared=no
++ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:,"
++ for pkg in $enableval; do
++ case $pkg in
++ ada | libada)
++ enable_shared=yes ;;
++ esac
++ done
++ IFS="$ac_save_ifs"
++ ;;
++esac
++], [enable_shared=yes])
++AC_SUBST([enable_shared])
++
++GCC_PICFLAG
++AC_SUBST([PICFLAG])
++
++# These must be passed down, or are needed by gcc/libgcc.mvars
++AC_PROG_AWK
++AC_PROG_LN_S
++
++# Determine what to build for 'gnatlib'
++if test ${enable_shared} = yes; then
++ default_gnatlib_target="gnatlib-shared"
++else
++ default_gnatlib_target="gnatlib-plain"
++fi
++AC_SUBST([default_gnatlib_target])
++
++# Check for _Unwind_GetIPInfo
++GCC_CHECK_UNWIND_GETIPINFO
++if test x$have_unwind_getipinfo = xyes; then
++ have_getipinfo=-DHAVE_GETIPINFO
++else
++ have_getipinfo=
++fi
++AC_SUBST([have_getipinfo])
++
++# Check for <sys/capability.h>
++AC_CHECK_HEADER([sys/capability.h], have_capability=-DHAVE_CAPABILITY, have_capability=)
++AC_SUBST([have_capability])
++
++# Determine what GCC version number to use in filesystem paths.
++GCC_BASE_VER
++
++# Output: create a Makefile.
++AC_CONFIG_FILES([Makefile])
++
++AC_OUTPUT
+--- a/src/Makefile.def
++++ b/src/Makefile.def
+@@ -194,6 +194,7 @@ target_modules = { module= libgnatvsn; n
+ missing= TAGS;
+ missing= install-info;
+ missing= installcheck; };
++target_modules = { module= libada-sjlj; };
+ target_modules = { module= libgomp; bootstrap= true; lib_path=.libs; };
+ target_modules = { module= libitm; lib_path=.libs; };
+ target_modules = { module= libatomic; lib_path=.libs; };
+@@ -394,6 +395,7 @@ dependencies = { module=all-libcpp; on=a
+ dependencies = { module=all-fixincludes; on=all-libiberty; };
+
+ dependencies = { module=all-target-libada; on=all-gcc; };
++dependencies = { module=all-target-libada-sjlj; on=all-target-libada; };
+ dependencies = { module=all-gnattools; on=all-target-libada; };
+ dependencies = { module=all-gnattools; on=all-target-libstdc++-v3; };
+ dependencies = { module=all-gnattools; on=all-target-libgnat_util; };
+--- a/src/configure.ac
++++ b/src/configure.ac
+@@ -167,6 +167,7 @@ target_libraries="target-libgcc \
+ target-libffi \
+ target-libobjc \
+ target-libada \
++ target-libada-sjlj \
+ ${target_libiberty} \
+ target-libgnat_util \
+ target-libgo \
+@@ -454,7 +455,7 @@ AC_ARG_ENABLE(libada,
+ ENABLE_LIBADA=$enableval,
+ ENABLE_LIBADA=yes)
+ if test "${ENABLE_LIBADA}" != "yes" ; then
+- noconfigdirs="$noconfigdirs target-libgnat_util gnattools"
++ noconfigdirs="$noconfigdirs target-libgnat_util gnattools target-libada-sjlj"
+ fi
+
+ AC_ARG_ENABLE(libssp,
+--- a/src/gcc/ada/gcc-interface/Makefile.in
++++ b/src/gcc/ada/gcc-interface/Makefile.in
+@@ -193,7 +193,7 @@ GNAT_SRC=$(fsrcpfx)ada
+
+ # Multilib handling
+ MULTISUBDIR =
+-RTSDIR = rts$(subst /,_,$(MULTISUBDIR))
++RTSDIR := rts$(subst /,_,$(MULTISUBDIR))
+
+ # Link flags used to build gnat tools. By default we prefer to statically
+ # link with libgcc to avoid a dependency on shared libgcc (which is tricky
+@@ -561,6 +561,26 @@ install-gnatlib: ../stamp-gnatlib-$(RTSD
+ cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.adb
+ cd $(DESTDIR)$(ADA_INCLUDE_DIR); $(CHMOD) a-wx *.ads
+
++install-gnatlib-sjlj: ../stamp-gnatlib-$(RTSDIR)
++# Create the directory before deleting it, in case the directory is
++# a list of directories (as it may be on VMS). This ensures we are
++# deleting the right one.
++ -$(MKDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR_SJLJ)
++ -$(MKDIR) $(DESTDIR)$(ADA_INCLUDE_DIR_SJLJ)
++ $(RMDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR_SJLJ)
++ $(RMDIR) $(DESTDIR)$(ADA_INCLUDE_DIR_SJLJ)
++ -$(MKDIR) $(DESTDIR)$(ADA_RTL_OBJ_DIR_SJLJ)
++ -$(MKDIR) $(DESTDIR)$(ADA_INCLUDE_DIR_SJLJ)
++ for file in $(RTSDIR)/*.ali; do \
++ $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_RTL_OBJ_DIR_SJLJ); \
++ done
++ # This copy must be done preserving the date on the original file.
++ for file in $(RTSDIR)/*.ad?; do \
++ $(INSTALL_DATA_DATE) $$file $(DESTDIR)$(ADA_INCLUDE_DIR_SJLJ); \
++ done
++ cd $(DESTDIR)$(ADA_INCLUDE_DIR_SJLJ); $(CHMOD) a-wx *.adb
++ cd $(DESTDIR)$(ADA_INCLUDE_DIR_SJLJ); $(CHMOD) a-wx *.ads
++
+ ../stamp-gnatlib2-$(RTSDIR):
+ $(RM) $(RTSDIR)/s-*.ali
+ $(RM) $(RTSDIR)/s-*$(objext)
+@@ -826,6 +846,7 @@ gnatlib-shared:
+ gnatlib-sjlj:
+ $(MAKE) $(FLAGS_TO_PASS) \
+ EH_MECHANISM="" \
++ RTSDIR="$(RTSDIR)" \
+ MULTISUBDIR="$(MULTISUBDIR)" \
+ THREAD_KIND="$(THREAD_KIND)" \
+ ../stamp-gnatlib1-$(RTSDIR)
+@@ -835,6 +856,7 @@ gnatlib-sjlj:
+ $(RTSDIR)/system.ads > $(RTSDIR)/s.ads
+ $(MV) $(RTSDIR)/s.ads $(RTSDIR)/system.ads
+ $(MAKE) $(FLAGS_TO_PASS) \
++ RTSDIR="$(RTSDIR)" \
+ EH_MECHANISM="" \
+ GNATLIBFLAGS="$(GNATLIBFLAGS)" \
+ GNATLIBCFLAGS="$(GNATLIBCFLAGS)" \
+@@ -889,6 +911,8 @@ b_gnatm.o : b_gnatm.adb
+
+ ADA_INCLUDE_DIR = $(libsubdir)/adainclude
+ ADA_RTL_OBJ_DIR = $(libsubdir)/adalib
++ADA_INCLUDE_DIR_SJLJ = $(libsubdir)/rts-sjlj/adainclude
++ADA_RTL_OBJ_DIR_SJLJ = $(libsubdir)/rts-sjlj/adalib
+
+ # Special flags
+
+--- a/src/gcc/ada/gcc-interface/config-lang.in
++++ b/src/gcc/ada/gcc-interface/config-lang.in
+@@ -43,8 +43,8 @@ if test "x$cross_compiling/$build/$host"
+ lang_requires="c c++"
+ fi
+
+-target_libs="target-libada target-libgnat_util"
+-lang_dirs="libada gnattools"
++target_libs="target-libada target-libgnat_util target-libada-sjlj"
++lang_dirs="libada gnattools libada-sjlj"
+
+ # Ada is not enabled by default for the time being.
+ build_by_default=no
+--- a/src/gcc/ada/gcc-interface/Make-lang.in
++++ b/src/gcc/ada/gcc-interface/Make-lang.in
+@@ -837,6 +837,7 @@ ada.install-common:
+
+ install-gnatlib:
+ $(MAKE) -C ada $(COMMON_FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) install-gnatlib$(LIBGNAT_TARGET)
++ $(MAKE) -C ada $(COMMON_FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) RTSDIR="rts-sjlj" install-gnatlib-sjlj$(LIBGNAT_TARGET)
+
+ install-gnatlib-obj:
+ $(MAKE) -C ada $(COMMON_FLAGS_TO_PASS) $(ADA_FLAGS_TO_PASS) install-gnatlib-obj
diff --git a/debian/patches/ada-verbose.diff b/debian/patches/ada-verbose.diff
new file mode 100644
index 0000000..be0278e
--- /dev/null
+++ b/debian/patches/ada-verbose.diff
@@ -0,0 +1,36 @@
+Description: Display subprocess command lines when building Ada.
+ The log can be a page longer if it helps debugging.
+Forwarded: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87778
+Author: Nicolas Boulenguez <nicolas@debian.org>
+
+--- a/src/gcc/ada/Make-generated.in
++++ b/src/gcc/ada/Make-generated.in
+@@ -18,7 +18,7 @@ GEN_IL_FLAGS = -gnata -gnat2012 -gnatw.g
+ ada/seinfo_tables.ads ada/seinfo_tables.adb ada/sinfo.h ada/einfo.h ada/nmake.ads ada/nmake.adb ada/seinfo.ads ada/sinfo-nodes.ads ada/sinfo-nodes.adb ada/einfo-entities.ads ada/einfo-entities.adb: ada/stamp-gen_il ; @true
+ ada/stamp-gen_il: $(fsrcdir)/ada/gen_il*
+ $(MKDIR) ada/gen_il
+- cd ada/gen_il; gnatmake -q -g $(GEN_IL_FLAGS) gen_il-main
++ cd ada/gen_il; gnatmake -v -g $(GEN_IL_FLAGS) gen_il-main
+ # Ignore errors to work around finalization issues in older compilers
+ - cd ada/gen_il; ./gen_il-main
+ $(fsrcdir)/../move-if-change ada/gen_il/seinfo_tables.ads ada/seinfo_tables.ads
+@@ -46,7 +46,7 @@ ada/stamp-snames : ada/snames.ads-tmpl a
+ -$(MKDIR) ada/bldtools/snamest
+ $(RM) $(addprefix ada/bldtools/snamest/,$(notdir $^))
+ $(CP) $^ ada/bldtools/snamest
+- cd ada/bldtools/snamest && gnatmake -q xsnamest && ./xsnamest
++ cd ada/bldtools/snamest && gnatmake -v xsnamest && ./xsnamest
+ $(fsrcdir)/../move-if-change ada/bldtools/snamest/snames.ns ada/snames.ads
+ $(fsrcdir)/../move-if-change ada/bldtools/snamest/snames.nb ada/snames.adb
+ $(fsrcdir)/../move-if-change ada/bldtools/snamest/snames.nh ada/snames.h
+--- a/src/gcc/ada/gcc-interface/Makefile.in
++++ b/src/gcc/ada/gcc-interface/Makefile.in
+@@ -621,7 +621,7 @@ OSCONS_EXTRACT=$(GCC_FOR_ADA_RTS) $(GNAT
+ -$(MKDIR) ./bldtools/oscons
+ $(RM) $(addprefix ./bldtools/oscons/,$(notdir $^))
+ $(CP) $^ ./bldtools/oscons
+- (cd ./bldtools/oscons ; gnatmake -q xoscons)
++ (cd ./bldtools/oscons ; gnatmake -v xoscons)
+
+ $(RTSDIR)/s-oscons.ads: ../stamp-gnatlib1-$(RTSDIR) s-oscons-tmplt.c gsocket.h ./bldtools/oscons/xoscons
+ $(RM) $(RTSDIR)/s-oscons-tmplt.i $(RTSDIR)/s-oscons-tmplt.s
diff --git a/debian/patches/alpha-ieee-doc.diff b/debian/patches/alpha-ieee-doc.diff
new file mode 100644
index 0000000..526bde9
--- /dev/null
+++ b/debian/patches/alpha-ieee-doc.diff
@@ -0,0 +1,26 @@
+# DP: #212912
+# DP: on alpha-linux, make -mieee default and add -mieee-disable switch
+# DP: to turn default off (doc patch)
+
+---
+ gcc/doc/invoke.texi | 7 +++++++
+ 1 files changed, 7 insertions(+), 0 deletions(-)
+
+Index: b/src/gcc/doc/invoke.texi
+===================================================================
+--- a/src/gcc/doc/invoke.texi
++++ b/src/gcc/doc/invoke.texi
+@@ -24169,6 +24169,13 @@ able to correctly support denormalized n
+ values such as not-a-number and plus/minus infinity. Other Alpha
+ compilers call this option @option{-ieee_with_no_inexact}.
+
++DEBIAN SPECIFIC: This option is on by default for alpha-linux-gnu, unless
++@option{-ffinite-math-only} (which is part of the @option{-ffast-math}
++set) is specified, because the software functions in the GNU libc math
++libraries generate denormalized numbers, NaNs, and infs (all of which
++will cause a programs to SIGFPE when it attempts to use the results without
++@option{-mieee}).
++
+ @opindex mieee-with-inexact
+ @item -mieee-with-inexact
+ This is like @option{-mieee} except the generated code also maintains
diff --git a/debian/patches/alpha-ieee.diff b/debian/patches/alpha-ieee.diff
new file mode 100644
index 0000000..f80ffa3
--- /dev/null
+++ b/debian/patches/alpha-ieee.diff
@@ -0,0 +1,17 @@
+# DP: #212912
+# DP: on alpha-linux, make -mieee default and add -mieee-disable switch
+# DP: to turn default off
+
+--- a/src/gcc/config/alpha/alpha.cc
++++ b/src/gcc/config/alpha/alpha.cc
+@@ -384,6 +384,10 @@ alpha_option_override (void)
+ int line_size = 0, l1_size = 0, l2_size = 0;
+ int i;
+
++ /* If not -ffinite-math-only, enable -mieee*/
++ if (!flag_finite_math_only)
++ target_flags |= MASK_IEEE|MASK_IEEE_CONFORMANT;
++
+ #ifdef SUBTARGET_OVERRIDE_OPTIONS
+ SUBTARGET_OVERRIDE_OPTIONS;
+ #endif
diff --git a/debian/patches/alpha-no-ev4-directive.diff b/debian/patches/alpha-no-ev4-directive.diff
new file mode 100644
index 0000000..2b06a69
--- /dev/null
+++ b/debian/patches/alpha-no-ev4-directive.diff
@@ -0,0 +1,30 @@
+# DP: never emit .ev4 directive.
+
+---
+ gcc/config/alpha/alpha.c | 7 +++----
+ 1 files changed, 3 insertions(+), 4 deletions(-)
+
+--- a/src/gcc/config/alpha/alpha.cc
++++ b/src/gcc/config/alpha/alpha.cc
+@@ -9482,7 +9482,7 @@ alpha_file_start (void)
+ fputs ("\t.set nomacro\n", asm_out_file);
+ if (TARGET_SUPPORT_ARCH | TARGET_BWX | TARGET_MAX | TARGET_FIX | TARGET_CIX)
+ {
+- const char *arch;
++ const char *arch = NULL;
+
+ if (alpha_cpu == PROCESSOR_EV6 || TARGET_FIX || TARGET_CIX)
+ arch = "ev6";
+@@ -9492,10 +9492,9 @@ alpha_file_start (void)
+ arch = "ev56";
+ else if (alpha_cpu == PROCESSOR_EV5)
+ arch = "ev5";
+- else
+- arch = "ev4";
+
+- fprintf (asm_out_file, "\t.arch %s\n", arch);
++ if (arch)
++ fprintf (asm_out_file, "\t.arch %s\n", arch);
+ }
+ }
+
diff --git a/debian/patches/arc-stddef.diff b/debian/patches/arc-stddef.diff
new file mode 100644
index 0000000..af330f4
--- /dev/null
+++ b/debian/patches/arc-stddef.diff
@@ -0,0 +1,29 @@
+--- a/src/gcc/config/arc/arc-arch.h
++++ b/src/gcc/config/arc/arc-arch.h
+@@ -22,6 +22,8 @@ along with GCC; see the file COPYING3.
+ #ifndef GCC_ARC_ARCH_H
+ #define GCC_ARC_ARCH_H
+
++#include <stddef.h>
++
+ #ifndef IN_LIBGCC2
+ /* Architecture selection types. */
+
+@@ -116,7 +118,7 @@ typedef struct
+
+ } arc_cpu_t;
+
+-const arc_arch_t arc_arch_types[] =
++static const arc_arch_t arc_arch_types[] =
+ {
+ {"none", BASE_ARCH_NONE, 0, 0},
+ #define ARC_ARCH(NAME, ARCH, FLAGS, DFLAGS) \
+@@ -126,7 +128,7 @@ const arc_arch_t arc_arch_types[] =
+ {NULL, BASE_ARCH_END, 0, 0}
+ };
+
+-const arc_cpu_t arc_cpu_types[] =
++static const arc_cpu_t arc_cpu_types[] =
+ {
+ {"none", NULL, PROCESSOR_NONE, 0, HAS_NONE, ARC_TUNE_NONE},
+ #define ARC_CPU(NAME, ARCH, FLAGS, EXTRA, TUNE) \
diff --git a/debian/patches/arm-multilib-defaults.diff b/debian/patches/arm-multilib-defaults.diff
new file mode 100644
index 0000000..88b0279
--- /dev/null
+++ b/debian/patches/arm-multilib-defaults.diff
@@ -0,0 +1,88 @@
+# DP: Set MULTILIB_DEFAULTS for ARM multilib builds
+
+--- a/src/gcc/config.gcc
++++ b/src/gcc/config.gcc
+@@ -4342,10 +4342,18 @@ case "${target}" in
+ done
+
+ case "$with_float" in
+- "" \
+- | soft | hard | softfp)
++ "")
+ # OK
+ ;;
++ soft)
++ tm_defines="${tm_defines} TARGET_CONFIGURED_FLOAT_ABI=0"
++ ;;
++ softfp)
++ tm_defines="${tm_defines} TARGET_CONFIGURED_FLOAT_ABI=1"
++ ;;
++ hard)
++ tm_defines="${tm_defines} TARGET_CONFIGURED_FLOAT_ABI=2"
++ ;;
+ *)
+ echo "Unknown floating point type used in --with-float=$with_float" 1>&2
+ exit 1
+@@ -4380,6 +4388,9 @@ case "${target}" in
+ "" \
+ | arm | thumb )
+ #OK
++ if test "$with_mode" = thumb; then
++ tm_defines="${tm_defines} TARGET_CONFIGURED_THUMB_MODE=1"
++ fi
+ ;;
+ *)
+ echo "Unknown mode used in --with-mode=$with_mode"
+--- a/src/gcc/config/arm/linux-eabi.h
++++ b/src/gcc/config/arm/linux-eabi.h
+@@ -37,7 +37,21 @@
+ target hardware. If you override this to use the hard-float ABI then
+ change the setting of GLIBC_DYNAMIC_LINKER_DEFAULT as well. */
+ #undef TARGET_DEFAULT_FLOAT_ABI
++#ifdef TARGET_CONFIGURED_FLOAT_ABI
++#if TARGET_CONFIGURED_FLOAT_ABI == 2
++#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD
++#define MULTILIB_DEFAULT_FLOAT_ABI "mfloat-abi=hard"
++#elif TARGET_CONFIGURED_FLOAT_ABI == 1
++#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFTFP
++#define MULTILIB_DEFAULT_FLOAT_ABI "mfloat-abi=softfp"
++#else
++#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT
++#define MULTILIB_DEFAULT_FLOAT_ABI "mfloat-abi=soft"
++#endif
++#else
+ #define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT
++#define MULTILIB_DEFAULT_FLOAT_ABI "mfloat-abi=soft"
++#endif
+
+ /* We default to the "aapcs-linux" ABI so that enums are int-sized by
+ default. */
+@@ -91,6 +105,28 @@
+ #define MUSL_DYNAMIC_LINKER \
+ "/lib/ld-musl-arm" MUSL_DYNAMIC_LINKER_E "%{mfloat-abi=hard:hf}%{mfdpic:-fdpic}.so.1"
+
++/* Set the multilib defaults according the configuration, needed to
++ let gcc -print-multi-dir do the right thing. */
++
++#if TARGET_BIG_ENDIAN_DEFAULT
++#define MULTILIB_DEFAULT_ENDIAN "mbig-endian"
++#else
++#define MULTILIB_DEFAULT_ENDIAN "mlittle-endian"
++#endif
++
++#ifndef TARGET_CONFIGURED_THUMB_MODE
++#define MULTILIB_DEFAULT_MODE "marm"
++#elif TARGET_CONFIGURED_THUMB_MODE == 1
++#define MULTILIB_DEFAULT_MODE "mthumb"
++#else
++#define MULTILIB_DEFAULT_MODE "marm"
++#endif
++
++#undef MULTILIB_DEFAULTS
++#define MULTILIB_DEFAULTS \
++ { MULTILIB_DEFAULT_MODE, MULTILIB_DEFAULT_ENDIAN, \
++ MULTILIB_DEFAULT_FLOAT_ABI, "mno-thumb-interwork" }
++
+ /* At this point, bpabi.h will have clobbered LINK_SPEC. We want to
+ use the GNU/Linux version, not the generic BPABI version. */
+ #undef LINK_SPEC
diff --git a/debian/patches/arm-multilib-soft-float.diff b/debian/patches/arm-multilib-soft-float.diff
new file mode 100644
index 0000000..18f51fb
--- /dev/null
+++ b/debian/patches/arm-multilib-soft-float.diff
@@ -0,0 +1,26 @@
+--- a/src/gcc/config/arm/t-linux-eabi
++++ b/src/gcc/config/arm/t-linux-eabi
+@@ -24,6 +24,23 @@
+ MULTILIB_OPTIONS =
+ MULTILIB_DIRNAMES =
+
++ifneq (,$(findstring MULTIARCH_DEFAULTS,$(tm_defines)))
++ifneq (,$(findstring __arm_linux_gnueabi__,$(tm_defines)))
++ MULTILIB_OPTIONS = mfloat-abi=softfp/mfloat-abi=hard/mfloat-abi=soft
++ MULTILIB_DIRNAMES = . hf soft-float
++ MULTILIB_EXCEPTIONS =
++ MULTILIB_MATCHES = mfloat-abi?hard=mhard-float mfloat-abi?soft=msoft-float
++ MULTILIB_OSDIRNAMES = ../../lib/arm-linux-gnueabi ../../lib/arm-linux-gnueabihf soft-float
++endif
++ifneq (,$(findstring __arm_linux_gnueabihf__,$(tm_defines)))
++ MULTILIB_OPTIONS = mfloat-abi=hard/mfloat-abi=softfp/mfloat-abi=soft
++ MULTILIB_DIRNAMES = . sf soft-float
++ MULTILIB_EXCEPTIONS =
++ MULTILIB_MATCHES = mfloat-abi?hard=mhard-float mfloat-abi?soft=msoft-float
++ MULTILIB_OSDIRNAMES = ../../lib/arm-linux-gnueabihf ../../lib/arm-linux-gnueabi soft-float
++endif
++endif
++
+ #MULTILIB_OPTIONS += mcpu=fa606te/mcpu=fa626te/mcpu=fmp626/mcpu=fa726te
+ #MULTILIB_DIRNAMES += fa606te fa626te fmp626 fa726te
+ #MULTILIB_EXCEPTIONS += *mthumb/*mcpu=fa606te *mthumb/*mcpu=fa626te *mthumb/*mcpu=fmp626 *mthumb/*mcpu=fa726te*
diff --git a/debian/patches/bootstrap-no-unneeded-libs.diff b/debian/patches/bootstrap-no-unneeded-libs.diff
new file mode 100644
index 0000000..4939110
--- /dev/null
+++ b/debian/patches/bootstrap-no-unneeded-libs.diff
@@ -0,0 +1,30 @@
+# DP: For bootstrap builds, don't build unneeded libstdc++ things
+# DP: (debug library, PCH headers).
+
+# Please read ada-changes-in-autogen-output.diff about src/Makefile.[def|tpl].
+
+--- a/src/Makefile.tpl
++++ b/src/Makefile.tpl
+@@ -1060,7 +1060,9 @@
+ --target=[+target_alias+] $${srcdiroption} [+ IF prev +]\
+ --with-build-libsubdir=$(HOST_SUBDIR) [+ ENDIF prev +]\
+ $(STAGE[+id+]_CONFIGURE_FLAGS)[+ IF extra_configure_flags +] \
+- [+extra_configure_flags+][+ ENDIF extra_configure_flags +]
++ [+extra_configure_flags+][+ ENDIF extra_configure_flags +] \
++ [+ IF bootstrap_configure_flags +][+bootstrap_configure_flags+] \
++ [+ ENDIF bootstrap_configure_flags +]
+ @endif [+prefix+][+module+]-bootstrap
+ [+ ENDFOR bootstrap_stage +]
+ [+ ENDIF bootstrap +]
+--- a/src/Makefile.def
++++ b/src/Makefile.def
+@@ -117,7 +117,8 @@
+ target_modules = { module= libstdc++-v3;
+ bootstrap=true;
+ lib_path=src/.libs;
+- raw_cxx=true; };
++ raw_cxx=true;
++ bootstrap_configure_flags='--disable-libstdcxx-debug --disable-libstdcxx-pch'; };
+ target_modules = { module= libmudflap; lib_path=.libs; };
+ target_modules = { module= libsanitizer; lib_path=.libs; };
+ target_modules = { module= libssp; lib_path=.libs; };
diff --git a/debian/patches/canonical-cpppath.diff b/debian/patches/canonical-cpppath.diff
new file mode 100644
index 0000000..39969b7
--- /dev/null
+++ b/debian/patches/canonical-cpppath.diff
@@ -0,0 +1,34 @@
+# DP: Don't use any relative path names for the standard include paths.
+
+--- a/src/gcc/incpath.cc
++++ b/src/gcc/incpath.cc
+@@ -177,6 +177,14 @@ add_standard_paths (const char *sysroot,
+ str = reconcat (str, str, dir_separator_str,
+ imultiarch, NULL);
+ }
++ {
++ char *rp = lrealpath (str);
++ if (rp)
++ {
++ free (str);
++ str = rp;
++ }
++ }
+ add_path (str, INC_SYSTEM, p->cxx_aware, false);
+ }
+ }
+@@ -252,6 +260,14 @@ add_standard_paths (const char *sysroot,
+ else
+ str = reconcat (str, str, dir_separator_str, imultiarch, NULL);
+ }
++ {
++ char *rp = lrealpath (str);
++ if (rp)
++ {
++ free (str);
++ str = rp;
++ }
++ }
+
+ add_path (str, INC_SYSTEM, p->cxx_aware, false);
+ }
diff --git a/debian/patches/config-ml.diff b/debian/patches/config-ml.diff
new file mode 100644
index 0000000..6e4e870
--- /dev/null
+++ b/debian/patches/config-ml.diff
@@ -0,0 +1,52 @@
+# DP: - Disable some biarch libraries for biarch builds.
+# DP: - Fix multilib builds on kernels which don't support all multilibs.
+
+--- a/src/config-ml.in
++++ b/src/config-ml.in
+@@ -488,6 +488,25 @@ powerpc*-*-* | rs6000*-*-*)
+ ;;
+ esac
+
++if [ -z "$biarch_multidir_names" ]; then
++ biarch_multidir_names="libiberty libstdc++-v3 libgfortran libmudflap libssp libffi libobjc libgomp"
++ echo "WARNING: biarch_multidir_names is unset. Use default value:"
++ echo " $biarch_multidir_names"
++fi
++ml_srcbase=`basename $ml_realsrcdir`
++old_multidirs="${multidirs}"
++multidirs=""
++for x in ${old_multidirs}; do
++ case " $x " in
++ " 32 "|" n32 "|" x32 "|" 64 "|" hf "|" sf "|" m4-nofpu ")
++ case "$biarch_multidir_names" in
++ *"$ml_srcbase"*) multidirs="${multidirs} ${x}" ;;
++ esac
++ ;;
++ *) multidirs="${multidirs} ${x}" ;;
++ esac
++done
++
+ # Remove extraneous blanks from multidirs.
+ # Tests like `if [ -n "$multidirs" ]' require it.
+ multidirs=`echo "$multidirs" | sed -e 's/^[ ][ ]*//' -e 's/[ ][ ]*$//' -e 's/[ ][ ]*/ /g'`
+@@ -886,9 +905,19 @@ if [ -n "${multidirs}" ] && [ -z "${ml_n
+ fi
+ fi
+
++ ml_configure_args=
++ for arg in ${ac_configure_args}
++ do
++ case $arg in
++ *CC=*) ml_configure_args=${ml_config_env} ;;
++ *CXX=*) ml_configure_args=${ml_config_env} ;;
++ *) ;;
++ esac
++ done
++
+ if eval ${ml_config_env} ${ml_config_shell} ${ml_recprog} \
+ --with-multisubdir=${ml_dir} --with-multisrctop=${multisrctop} \
+- "${ac_configure_args}" ${ml_config_env} ${ml_srcdiroption} ; then
++ "${ac_configure_args}" ${ml_configure_args} ${ml_config_env} ${ml_srcdiroption} ; then
+ true
+ else
+ exit 1
diff --git a/debian/patches/cross-biarch.diff b/debian/patches/cross-biarch.diff
new file mode 100644
index 0000000..a62d4d7
--- /dev/null
+++ b/debian/patches/cross-biarch.diff
@@ -0,0 +1,89 @@
+# DP: Fix the location of target's libs in cross-build for biarch
+
+--- a/src/config-ml.in
++++ b/src/config-ml.in
+@@ -533,7 +533,13 @@ multi-do:
+ else \
+ if [ -d ../$${dir}/$${lib} ]; then \
+ flags=`echo $$i | sed -e 's/^[^;]*;//' -e 's/@/ -/g'`; \
+- if (cd ../$${dir}/$${lib}; $(MAKE) $(FLAGS_TO_PASS) \
++ libsuffix_="$${dir}"; \
++ if [ "$${dir}" = "n32" ]; then libsuffix_=32; fi; \
++ if [ -n "$$($${compiler} -v 2>&1 |grep '^Target: mips')" ] && [ "$${dir}" = "32" ]; then libsuffix_=o32; fi; \
++ if (cd ../$${dir}/$${lib}; $(MAKE) $(subst \
++ -B$(build_tooldir)/lib/, \
++ -B$(build_tooldir)/lib$${libsuffix_}/, \
++ $(FLAGS_TO_PASS)) \
+ CFLAGS="$(CFLAGS) $${flags}" \
+ CCASFLAGS="$(CCASFLAGS) $${flags}" \
+ FCFLAGS="$(FCFLAGS) $${flags}" \
+@@ -786,6 +792,15 @@ if [ -n "${multidirs}" ] && [ -z "${ml_n
+ GOC_=$GOC' '
+ GDC_=$GDC' '
+ else
++ if [ "${ml_dir}" = "." ]; then
++ FILTER_="s!X\\(.*\\)!\\1!p"
++ elif [ "${ml_dir}" = "n32" ]; then # mips n32 -> lib32
++ FILTER_="s!X\\(.*\\)/!\\132/!p"
++ elif [ "${ml_dir}" = "32" ] && [ "$(echo ${host} |grep '^mips')" ]; then # mips o32 -> libo32
++ FILTER_="s!X\\(.*\\)/!\\1o32/!p"
++ else
++ FILTER_="s!X\\(.*\\)/!\\1${ml_dir}/!p"
++ fi
+ # Create a regular expression that matches any string as long
+ # as ML_POPDIR.
+ popdir_rx=`echo "${ML_POPDIR}" | sed 's,.,.,g'`
+@@ -794,6 +809,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_n
+ case $arg in
+ -[BIL]"${ML_POPDIR}"/*)
+ CC_="${CC_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\1/p"`' ' ;;
++ -B*/lib/)
++ CC_="${CC_}"`echo "X${arg}" | sed -n "$FILTER_"`' ' ;;
+ "${ML_POPDIR}"/*)
+ CC_="${CC_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
+ *)
+@@ -806,6 +823,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_n
+ case $arg in
+ -[BIL]"${ML_POPDIR}"/*)
+ CXX_="${CXX_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
++ -B*/lib/)
++ CXX_="${CXX_}"`echo "X${arg}" | sed -n "$FILTER_"`' ' ;;
+ "${ML_POPDIR}"/*)
+ CXX_="${CXX_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
+ *)
+@@ -818,6 +837,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_n
+ case $arg in
+ -[BIL]"${ML_POPDIR}"/*)
+ F77_="${F77_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
++ -B*/lib/)
++ F77_="${F77_}"`echo "X${arg}" | sed -n "$FILTER_"`' ' ;;
+ "${ML_POPDIR}"/*)
+ F77_="${F77_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
+ *)
+@@ -830,6 +851,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_n
+ case $arg in
+ -[BIL]"${ML_POPDIR}"/*)
+ GFORTRAN_="${GFORTRAN_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
++ -B*/lib/)
++ GFORTRAN_="${GFORTRAN_}"`echo "X${arg}" | sed -n "$FILTER_"`' ' ;;
+ "${ML_POPDIR}"/*)
+ GFORTRAN_="${GFORTRAN_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
+ *)
+@@ -842,6 +865,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_n
+ case $arg in
+ -[BIL]"${ML_POPDIR}"/*)
+ GOC_="${GOC_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
++ -B*/lib/)
++ GOC_="${GOC_}"`echo "X${arg}" | sed -n "$FILTER_"`' ' ;;
+ "${ML_POPDIR}"/*)
+ GOC_="${GOC_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
+ *)
+@@ -854,6 +879,8 @@ if [ -n "${multidirs}" ] && [ -z "${ml_n
+ case $arg in
+ -[BIL]"${ML_POPDIR}"/*)
+ GDC_="${GDC_}"`echo "X${arg}" | sed -n "s/X\\(-[BIL]${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X-[BIL]${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
++ -B*/lib/)
++ GDC_="${GDC_}"`echo "X${arg}" | sed -n "$FILTER_"`' ' ;;
+ "${ML_POPDIR}"/*)
+ GDC_="${GDC_}"`echo "X${arg}" | sed -n "s/X\\(${popdir_rx}\\).*/\\1/p"`/${ml_dir}`echo "X${arg}" | sed -n "s/X${popdir_rx}\\(.*\\)/\\1/p"`' ' ;;
+ *)
diff --git a/debian/patches/cross-fixes.diff b/debian/patches/cross-fixes.diff
new file mode 100644
index 0000000..8844eaa
--- /dev/null
+++ b/debian/patches/cross-fixes.diff
@@ -0,0 +1,57 @@
+# DP: Fix the linker error when creating an xcc for ia64
+
+---
+ gcc/config/ia64/fde-glibc.c | 3 +++
+ gcc/config/ia64/unwind-ia64.c | 3 ++-
+ gcc/unwind-compat.c | 2 ++
+ gcc/unwind-generic.h | 2 ++
+ 6 files changed, 14 insertions(+), 1 deletions(-)
+
+--- a/src/libgcc/config/ia64/unwind-ia64.c
++++ b/src/libgcc/config/ia64/unwind-ia64.c
+@@ -26,6 +26,7 @@
+ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+ <http://www.gnu.org/licenses/>. */
+
++#ifndef inhibit_libc
+ #include "tconfig.h"
+ #include "tsystem.h"
+ #include "coretypes.h"
+@@ -2467,3 +2468,4 @@ alias (_Unwind_SetIP);
+ #endif
+
+ #endif
++#endif
+--- a/src/libgcc/unwind-compat.c
++++ b/src/libgcc/unwind-compat.c
+@@ -23,6 +23,7 @@
+ <http://www.gnu.org/licenses/>. */
+
+ #if defined (USE_GAS_SYMVER) && defined (USE_LIBUNWIND_EXCEPTIONS)
++#ifndef inhibit_libc
+ #include "tconfig.h"
+ #include "tsystem.h"
+ #include "unwind.h"
+@@ -207,3 +208,4 @@ _Unwind_SetIP (struct _Unwind_Context *c
+ }
+ symver (_Unwind_SetIP, GCC_3.0);
+ #endif
++#endif
+--- a/src/libgcc/unwind-generic.h
++++ b/src/libgcc/unwind-generic.h
+@@ -221,6 +221,7 @@ _Unwind_SjLj_Resume_or_Rethrow (struct _
+ compatible with the standard ABI for IA-64, we inline these. */
+
+ #ifdef __ia64__
++#ifndef inhibit_libc
+ static inline _Unwind_Ptr
+ _Unwind_GetDataRelBase (struct _Unwind_Context *_C)
+ {
+@@ -237,6 +238,7 @@ _Unwind_GetTextRelBase (struct _Unwind_C
+
+ /* @@@ Retrieve the Backing Store Pointer of the given context. */
+ extern _Unwind_Word _Unwind_GetBSP (struct _Unwind_Context *);
++#endif /* inhibit_libc */
+ #else
+ extern _Unwind_Ptr _Unwind_GetDataRelBase (struct _Unwind_Context *);
+ extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *);
diff --git a/debian/patches/cross-install-location.diff b/debian/patches/cross-install-location.diff
new file mode 100644
index 0000000..ef5f64b
--- /dev/null
+++ b/debian/patches/cross-install-location.diff
@@ -0,0 +1,497 @@
+--- a/src/fixincludes/Makefile.in
++++ b/src/fixincludes/Makefile.in
+@@ -52,9 +52,9 @@ target_noncanonical:=@target_noncanonica
+ gcc_version := $(shell @get_gcc_base_ver@ $(srcdir)/../gcc/BASE-VER)
+
+ # Directory in which the compiler finds libraries etc.
+-libsubdir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)
++libsubdir = $(libdir)/gcc-cross/$(target_noncanonical)/$(gcc_version)
+ # Directory in which the compiler finds executables
+-libexecsubdir = $(libexecdir)/gcc/$(target_noncanonical)/$(gcc_version)
++libexecsubdir = $(libexecdir)/gcc-cross/$(target_noncanonical)/$(gcc_version)
+ # Where our executable files go
+ itoolsdir = $(libexecsubdir)/install-tools
+ # Where our data files go
+--- a/src/libgfortran/Makefile.in
++++ b/src/libgfortran/Makefile.in
+@@ -750,7 +750,7 @@ gcc_version := $(shell @get_gcc_base_ver
+ @LIBGFOR_USE_SYMVER_GNU_TRUE@@LIBGFOR_USE_SYMVER_TRUE@version_dep = gfortran.ver
+ @LIBGFOR_USE_SYMVER_SUN_TRUE@@LIBGFOR_USE_SYMVER_TRUE@version_dep = gfortran.ver-sun gfortran.ver
+ gfor_c_HEADERS = ISO_Fortran_binding.h
+-gfor_cdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
++gfor_cdir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)/include
+ LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) \
+ $(lt_host_flags)
+
+@@ -765,12 +765,12 @@ libgfortran_la_LDFLAGS = -version-info `
+
+ libgfortran_la_DEPENDENCIES = $(version_dep) libgfortran.spec $(LIBQUADLIB_DEP)
+ cafexeclib_LTLIBRARIES = libcaf_single.la
+-cafexeclibdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)
++cafexeclibdir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)$(MULTISUBDIR)
+ libcaf_single_la_SOURCES = caf/single.c
+ libcaf_single_la_LDFLAGS = -static
+ libcaf_single_la_DEPENDENCIES = caf/libcaf.h
+ libcaf_single_la_LINK = $(LINK) $(libcaf_single_la_LDFLAGS)
+-@IEEE_SUPPORT_TRUE@fincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/finclude
++@IEEE_SUPPORT_TRUE@fincludedir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/finclude
+ @IEEE_SUPPORT_TRUE@nodist_finclude_HEADERS = ieee_arithmetic.mod ieee_exceptions.mod ieee_features.mod
+ AM_CPPFLAGS = -iquote$(srcdir)/io -I$(srcdir)/$(MULTISRCTOP)../gcc \
+ -I$(srcdir)/$(MULTISRCTOP)../gcc/config $(LIBQUADINCLUDE) \
+--- a/src/libgfortran/Makefile.am
++++ b/src/libgfortran/Makefile.am
+@@ -39,7 +39,7 @@ version_dep =
+ endif
+
+ gfor_c_HEADERS = ISO_Fortran_binding.h
+-gfor_cdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
++gfor_cdir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)/include
+
+ LTLDFLAGS = $(shell $(SHELL) $(top_srcdir)/../libtool-ldflags $(LDFLAGS)) \
+ $(lt_host_flags)
+@@ -55,14 +55,14 @@ libgfortran_la_LDFLAGS = -version-info `
+ libgfortran_la_DEPENDENCIES = $(version_dep) libgfortran.spec $(LIBQUADLIB_DEP)
+
+ cafexeclib_LTLIBRARIES = libcaf_single.la
+-cafexeclibdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)
++cafexeclibdir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)$(MULTISUBDIR)
+ libcaf_single_la_SOURCES = caf/single.c
+ libcaf_single_la_LDFLAGS = -static
+ libcaf_single_la_DEPENDENCIES = caf/libcaf.h
+ libcaf_single_la_LINK = $(LINK) $(libcaf_single_la_LDFLAGS)
+
+ if IEEE_SUPPORT
+-fincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/finclude
++fincludedir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/finclude
+ nodist_finclude_HEADERS = ieee_arithmetic.mod ieee_exceptions.mod ieee_features.mod
+ endif
+
+--- a/src/lto-plugin/Makefile.in
++++ b/src/lto-plugin/Makefile.in
+@@ -342,7 +342,7 @@ with_libiberty = @with_libiberty@
+ ACLOCAL_AMFLAGS = -I .. -I ../config
+ AUTOMAKE_OPTIONS = no-dependencies
+ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
+-libexecsubdir := $(libexecdir)/gcc/$(real_target_noncanonical)/$(gcc_version)$(accel_dir_suffix)
++libexecsubdir := $(libexecdir)/gcc-cross/$(real_target_noncanonical)/$(gcc_version)$(accel_dir_suffix)
+ AM_CPPFLAGS = -I$(top_srcdir)/../include $(DEFS)
+ AM_CFLAGS = @ac_lto_plugin_warn_cflags@ $(CET_HOST_FLAGS) -DBASE_VERSION='"$(gcc_version)"'
+ AM_LDFLAGS = @ac_lto_plugin_ldflags@ @ac_lto_plugin_extra_ldflags@
+--- a/src/lto-plugin/Makefile.am
++++ b/src/lto-plugin/Makefile.am
+@@ -5,7 +5,7 @@ AUTOMAKE_OPTIONS = no-dependencies
+
+ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
+ target_noncanonical := @target_noncanonical@
+-libexecsubdir := $(libexecdir)/gcc/$(real_target_noncanonical)/$(gcc_version)$(accel_dir_suffix)
++libexecsubdir := $(libexecdir)/gcc-cross/$(real_target_noncanonical)/$(gcc_version)$(accel_dir_suffix)
+
+ AM_CPPFLAGS = -I$(top_srcdir)/../include $(DEFS)
+ AM_CFLAGS = @ac_lto_plugin_warn_cflags@ $(CET_HOST_FLAGS) -DBASE_VERSION='"$(gcc_version)"'
+--- a/src/libitm/Makefile.in
++++ b/src/libitm/Makefile.in
+@@ -459,7 +459,7 @@ SUBDIRS = testsuite
+ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
+ abi_version = -fabi-version=4
+ search_path = $(addprefix $(top_srcdir)/config/, $(config_path)) $(top_srcdir)
+-libsubincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
++libsubincludedir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)/include
+ AM_CPPFLAGS = $(addprefix -I, $(search_path))
+ AM_CFLAGS = $(XCFLAGS)
+ AM_CXXFLAGS = $(XCFLAGS) -std=gnu++0x -funwind-tables -fno-exceptions \
+--- a/src/libitm/Makefile.am
++++ b/src/libitm/Makefile.am
+@@ -12,7 +12,7 @@ abi_version = -fabi-version=4
+ config_path = @config_path@
+ search_path = $(addprefix $(top_srcdir)/config/, $(config_path)) $(top_srcdir)
+
+-libsubincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
++libsubincludedir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)/include
+
+ vpath % $(strip $(search_path))
+
+--- a/src/gcc/gcc.cc
++++ b/src/gcc/gcc.cc
+@@ -4828,7 +4828,7 @@ process_command (unsigned int decoded_op
+ GCC_EXEC_PREFIX is typically a directory name with a trailing
+ / (which is ignored by make_relative_prefix), so append a
+ program name. */
+- char *tmp_prefix = concat (gcc_exec_prefix, "gcc", NULL);
++ char *tmp_prefix = concat (gcc_exec_prefix, "gcc-cross", NULL);
+ gcc_libexec_prefix = get_relative_prefix (tmp_prefix,
+ standard_exec_prefix,
+ standard_libexec_prefix);
+@@ -4854,15 +4854,15 @@ process_command (unsigned int decoded_op
+ {
+ int len = strlen (gcc_exec_prefix);
+
+- if (len > (int) sizeof ("/lib/gcc/") - 1
++ if (len > (int) sizeof ("/lib/gcc-cross/") - 1
+ && (IS_DIR_SEPARATOR (gcc_exec_prefix[len-1])))
+ {
+- temp = gcc_exec_prefix + len - sizeof ("/lib/gcc/") + 1;
++ temp = gcc_exec_prefix + len - sizeof ("/lib/gcc-cross/") + 1;
+ if (IS_DIR_SEPARATOR (*temp)
+ && filename_ncmp (temp + 1, "lib", 3) == 0
+ && IS_DIR_SEPARATOR (temp[4])
+- && filename_ncmp (temp + 5, "gcc", 3) == 0)
+- len -= sizeof ("/lib/gcc/") - 1;
++ && filename_ncmp (temp + 5, "gcc-cross", 3) == 0)
++ len -= sizeof ("/lib/gcc-cross/") - 1;
+ }
+
+ set_std_prefix (gcc_exec_prefix, len);
+--- a/src/gcc/Makefile.in
++++ b/src/gcc/Makefile.in
+@@ -635,9 +635,9 @@ libexecdir = @libexecdir@
+ # --------
+
+ # Directory in which the compiler finds libraries etc.
+-libsubdir = $(libdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix)
++libsubdir = $(libdir)/gcc-cross/$(real_target_noncanonical)/$(version)$(accel_dir_suffix)
+ # Directory in which the compiler finds executables
+-libexecsubdir = $(libexecdir)/gcc/$(real_target_noncanonical)/$(version)$(accel_dir_suffix)
++libexecsubdir = $(libexecdir)/gcc-cross/$(real_target_noncanonical)/$(version)$(accel_dir_suffix)
+ # Directory in which all plugin resources are installed
+ plugin_resourcesdir = $(libsubdir)/plugin
+ # Directory in which plugin headers are installed
+@@ -2318,8 +2318,8 @@ default-d.o: config/default-d.cc
+
+ DRIVER_DEFINES = \
+ -DSTANDARD_STARTFILE_PREFIX=\"$(unlibsubdir)/\" \
+- -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc/\" \
+- -DSTANDARD_LIBEXEC_PREFIX=\"$(libexecdir)/gcc/\" \
++ -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc-cross/\" \
++ -DSTANDARD_LIBEXEC_PREFIX=\"$(libexecdir)/gcc-cross/\" \
+ -DDEFAULT_TARGET_VERSION=\"$(version)\" \
+ -DDEFAULT_REAL_TARGET_MACHINE=\"$(real_target_noncanonical)\" \
+ -DDEFAULT_TARGET_MACHINE=\"$(target_noncanonical)\" \
+@@ -3039,7 +3039,7 @@ PREPROCESSOR_DEFINES = \
+ -DTOOL_INCLUDE_DIR=\"$(gcc_tooldir)/include\" \
+ -DNATIVE_SYSTEM_HEADER_DIR=\"$(NATIVE_SYSTEM_HEADER_DIR)\" \
+ -DPREFIX=\"$(prefix)/\" \
+- -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc/\" \
++ -DSTANDARD_EXEC_PREFIX=\"$(libdir)/gcc-cross/\" \
+ @TARGET_SYSTEM_ROOT_DEFINE@
+
+ CFLAGS-cppbuiltin.o += $(PREPROCESSOR_DEFINES) -DBASEVER=$(BASEVER_s)
+--- a/src/libssp/Makefile.in
++++ b/src/libssp/Makefile.in
+@@ -366,7 +366,7 @@ gcc_version := $(shell @get_gcc_base_ver
+ @LIBSSP_USE_SYMVER_SUN_TRUE@@LIBSSP_USE_SYMVER_TRUE@version_dep = ssp.map-sun
+ AM_CFLAGS = -Wall $(XCFLAGS)
+ toolexeclib_LTLIBRARIES = libssp.la libssp_nonshared.la
+-libsubincludedir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/include
++libsubincludedir = $(libdir)/gcc-cross/$(target_noncanonical)/$(gcc_version)/include
+ nobase_libsubinclude_HEADERS = ssp/ssp.h ssp/string.h ssp/stdio.h ssp/unistd.h
+ libssp_la_SOURCES = \
+ ssp.c gets-chk.c memcpy-chk.c memmove-chk.c mempcpy-chk.c \
+--- a/src/libssp/Makefile.am
++++ b/src/libssp/Makefile.am
+@@ -39,7 +39,7 @@ AM_CFLAGS += $(XCFLAGS)
+ toolexeclib_LTLIBRARIES = libssp.la libssp_nonshared.la
+
+ target_noncanonical = @target_noncanonical@
+-libsubincludedir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/include
++libsubincludedir = $(libdir)/gcc-cross/$(target_noncanonical)/$(gcc_version)/include
+ nobase_libsubinclude_HEADERS = ssp/ssp.h ssp/string.h ssp/stdio.h ssp/unistd.h
+
+ libssp_la_SOURCES = \
+--- a/src/libquadmath/Makefile.in
++++ b/src/libquadmath/Makefile.in
+@@ -468,7 +468,7 @@ AUTOMAKE_OPTIONS = foreign info-in-build
+
+ @BUILD_LIBQUADMATH_TRUE@libquadmath_la_DEPENDENCIES = $(version_dep) $(libquadmath_la_LIBADD)
+ @BUILD_LIBQUADMATH_TRUE@nodist_libsubinclude_HEADERS = quadmath.h quadmath_weak.h
+-@BUILD_LIBQUADMATH_TRUE@libsubincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
++@BUILD_LIBQUADMATH_TRUE@libsubincludedir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)/include
+ @BUILD_LIBQUADMATH_TRUE@libquadmath_la_SOURCES = \
+ @BUILD_LIBQUADMATH_TRUE@ math/x2y2m1q.c math/acoshq.c math/fmodq.c \
+ @BUILD_LIBQUADMATH_TRUE@ math/acosq.c math/frexpq.c \
+--- a/src/libquadmath/Makefile.am
++++ b/src/libquadmath/Makefile.am
+@@ -41,7 +41,7 @@ libquadmath_la_LDFLAGS = -version-info `
+ libquadmath_la_DEPENDENCIES = $(version_dep) $(libquadmath_la_LIBADD)
+
+ nodist_libsubinclude_HEADERS = quadmath.h quadmath_weak.h
+-libsubincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
++libsubincludedir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)/include
+
+ libquadmath_la_SOURCES = \
+ math/x2y2m1q.c math/acoshq.c math/fmodq.c \
+--- a/src/libobjc/Makefile.in
++++ b/src/libobjc/Makefile.in
+@@ -48,7 +48,7 @@ extra_ldflags_libobjc = @extra_ldflags_l
+ top_builddir = .
+
+ libdir = $(exec_prefix)/lib
+-libsubdir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)
++libsubdir = $(libdir)/gcc-cross/$(target_noncanonical)/$(gcc_version)
+
+ # Multilib support variables.
+ MULTISRCTOP =
+--- a/src/libada/Makefile.in
++++ b/src/libada/Makefile.in
+@@ -70,7 +70,7 @@ GCC_DIR=$(MULTIBUILDTOP)../../$(host_sub
+
+ target_noncanonical:=@target_noncanonical@
+ version := $(shell @get_gcc_base_ver@ $(srcdir)/../gcc/BASE-VER)
+-libsubdir := $(libdir)/gcc/$(target_noncanonical)/$(version)$(MULTISUBDIR)
++libsubdir := $(libdir)/gcc-cross/$(target_noncanonical)/$(version)$(MULTISUBDIR)
+ ADA_RTS_DIR=$(GCC_DIR)/ada/rts$(subst /,_,$(MULTISUBDIR))
+
+ # exeext should not be used because it's the *host* exeext. We're building
+--- a/src/libgomp/Makefile.in
++++ b/src/libgomp/Makefile.in
+@@ -516,8 +516,8 @@ gcc_version := $(shell @get_gcc_base_ver
+ search_path = $(addprefix $(top_srcdir)/config/, $(config_path)) $(top_srcdir) \
+ $(top_srcdir)/../include
+
+-fincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/finclude
+-libsubincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
++fincludedir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/finclude
++libsubincludedir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)/include
+ AM_CPPFLAGS = $(addprefix -I, $(search_path))
+ AM_CFLAGS = $(XCFLAGS)
+ AM_LDFLAGS = $(XLDFLAGS) $(SECTION_LDFLAGS) $(OPT_LDFLAGS)
+--- a/src/libgomp/Makefile.am
++++ b/src/libgomp/Makefile.am
+@@ -11,8 +11,8 @@ config_path = @config_path@
+ search_path = $(addprefix $(top_srcdir)/config/, $(config_path)) $(top_srcdir) \
+ $(top_srcdir)/../include
+
+-fincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/finclude
+-libsubincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
++fincludedir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)$(MULTISUBDIR)/finclude
++libsubincludedir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)/include
+
+ vpath % $(strip $(search_path))
+
+--- a/src/libgcc/Makefile.in
++++ b/src/libgcc/Makefile.in
+@@ -200,7 +200,7 @@ STRIP = @STRIP@
+ STRIP_FOR_TARGET = $(STRIP)
+
+ # Directory in which the compiler finds libraries etc.
+-libsubdir = $(libdir)/gcc/$(real_host_noncanonical)/$(version)@accel_dir_suffix@
++libsubdir = $(libdir)/gcc-cross/$(real_host_noncanonical)/$(version)@accel_dir_suffix@
+ # Used to install the shared libgcc.
+ slibdir = @slibdir@
+ # Maybe used for DLLs on Windows targets.
+--- a/src/libffi/include/Makefile.am
++++ b/src/libffi/include/Makefile.am
+@@ -8,6 +8,6 @@ EXTRA_DIST=ffi.h.in
+
+ # Where generated headers like ffitarget.h get installed.
+ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
+-toollibffidir := $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
++toollibffidir := $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)/include
+
+ toollibffi_HEADERS = ffi.h ffitarget.h
+--- a/src/libffi/include/Makefile.in
++++ b/src/libffi/include/Makefile.in
+@@ -326,7 +326,7 @@ EXTRA_DIST = ffi.h.in
+
+ # Where generated headers like ffitarget.h get installed.
+ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
+-toollibffidir := $(libdir)/gcc/$(target_alias)/$(gcc_version)/include
++toollibffidir := $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)/include
+ toollibffi_HEADERS = ffi.h ffitarget.h
+ all: all-am
+
+--- a/src/libcc1/Makefile.am
++++ b/src/libcc1/Makefile.am
+@@ -40,7 +40,7 @@ libiberty = $(if $(wildcard $(libiberty_
+ $(Wc)$(libiberty_normal)))
+ libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty))
+
+-plugindir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/plugin
++plugindir = $(libdir)/gcc-cross/$(target_noncanonical)/$(gcc_version)/plugin
+ cc1libdir = $(libdir)/$(libsuffix)
+
+ if ENABLE_PLUGIN
+--- a/src/libcc1/Makefile.in
++++ b/src/libcc1/Makefile.in
+@@ -396,7 +396,7 @@ libiberty = $(if $(wildcard $(libiberty_
+ $(Wc)$(libiberty_normal)))
+
+ libiberty_dep = $(patsubst $(Wc)%,%,$(libiberty))
+-plugindir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)/plugin
++plugindir = $(libdir)/gcc-cross/$(target_noncanonical)/$(gcc_version)/plugin
+ cc1libdir = $(libdir)/$(libsuffix)
+ @ENABLE_PLUGIN_TRUE@plugin_LTLIBRARIES = libcc1plugin.la libcp1plugin.la
+ @ENABLE_PLUGIN_TRUE@cc1lib_LTLIBRARIES = libcc1.la
+--- a/src/libsanitizer/Makefile.am
++++ b/src/libsanitizer/Makefile.am
+@@ -1,6 +1,6 @@
+ ACLOCAL_AMFLAGS = -I .. -I ../config
+
+-sanincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include/sanitizer
++sanincludedir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)/include/sanitizer
+
+ nodist_saninclude_HEADERS =
+
+--- a/src/libsanitizer/Makefile.in
++++ b/src/libsanitizer/Makefile.in
+@@ -361,7 +361,7 @@ top_build_prefix = @top_build_prefix@
+ top_builddir = @top_builddir@
+ top_srcdir = @top_srcdir@
+ ACLOCAL_AMFLAGS = -I .. -I ../config
+-sanincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/include/sanitizer
++sanincludedir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)/include/sanitizer
+ nodist_saninclude_HEADERS = $(am__append_1)
+ @SANITIZER_SUPPORTED_TRUE@SUBDIRS = sanitizer_common $(am__append_2) \
+ @SANITIZER_SUPPORTED_TRUE@ $(am__append_3) lsan asan ubsan \
+--- a/src/libphobos/configure.ac
++++ b/src/libphobos/configure.ac
+@@ -256,6 +256,8 @@ AC_SUBST(SPEC_PHOBOS_DEPS)
+ libtool_VERSION=4:0:0
+ AC_SUBST(libtool_VERSION)
+
++# trigger rebuild of the configure file
++
+ # Set default flags (after DRUNTIME_WERROR!)
+ if test -z "$GDCFLAGS"; then
+ GDCFLAGS="-g -O2"
+--- a/src/libphobos/m4/druntime.m4
++++ b/src/libphobos/m4/druntime.m4
+@@ -114,6 +114,7 @@ AC_DEFUN([DRUNTIME_INSTALL_DIRECTORIES],
+
+ # Default case for install directory for D sources files.
+ gdc_include_dir='$(libdir)/gcc/${target_alias}/${gcc_version}/include/d'
++ gdc_include_dir='${libdir}/gcc-cross/${target_alias}'/${gcc_version}/include/d
+ AC_SUBST(gdc_include_dir)
+ ])
+
+--- a/src/gcc/ada/gcc-interface/Makefile.in
++++ b/src/gcc/ada/gcc-interface/Makefile.in
+@@ -921,7 +921,7 @@ toolexeclibdir = $(ADA_RTL_OBJ_DIR)
+
+ ADA_INCLUDE_DIR = $(libsubdir)/adainclude
+ ADA_RTL_OBJ_DIR = $(libsubdir)/adalib
+-ADA_RTL_DSO_DIR = $(toolexeclibdir)
++ADA_RTL_DSO_DIR = $(subst /gcc/,/gcc-cross/,$(toolexeclibdir))
+
+ # Special flags
+
+--- a/src/c++tools/Makefile.in
++++ b/src/c++tools/Makefile.in
+@@ -21,7 +21,7 @@ bindir := @bindir@
+ libexecdir := @libexecdir@
+ target_noncanonical := @target_noncanonical@
+ gcc_version := $(shell @get_gcc_base_ver@ $(srcdir)/../gcc/BASE-VER)
+-libexecsubdir := $(libexecdir)/gcc/$(target_noncanonical)/$(gcc_version)
++libexecsubdir := $(libexecdir)/gcc-cross/$(target_noncanonical)/$(gcc_version)
+ INSTALL := @INSTALL@
+ INSTALL_PROGRAM := @INSTALL_PROGRAM@
+ INSTALL_STRIP_PROGRAM := $(srcdir)/../install-sh -c -s
+--- a/src/libgm2/libm2cor/Makefile.am
++++ b/src/libgm2/libm2cor/Makefile.am
+@@ -27,7 +27,7 @@ MAKEOVERRIDES=
+ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
+
+ # Directory in which the compiler finds libraries etc.
+-libsubdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)
++libsubdir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)
+ # Used to install the shared libgcc.
+ slibdir = @slibdir@
+
+--- a/src/libgm2/libm2cor/Makefile.in
++++ b/src/libgm2/libm2cor/Makefile.in
+@@ -391,7 +391,7 @@ MAKEOVERRIDES =
+ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
+
+ # Directory in which the compiler finds libraries etc.
+-libsubdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)
++libsubdir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)
+ MULTIDIR := $(shell $(CC) $(CFLAGS) -print-multi-directory)
+ MULTIOSDIR := $(shell $(CC) $(CFLAGS) -print-multi-os-directory)
+ MULTIOSSUBDIR := $(shell if test x$(MULTIOSDIR) != x.; then echo /$(MULTIOSDIR); fi)
+--- a/src/libgm2/libm2iso/Makefile.am
++++ b/src/libgm2/libm2iso/Makefile.am
+@@ -27,7 +27,7 @@ MAKEOVERRIDES=
+ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
+
+ # Directory in which the compiler finds libraries etc.
+-libsubdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)
++libsubdir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)
+ # Used to install the shared libgcc.
+ # was slibdir = @slibdir@
+ slibdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)$(MULTISUBDIR)
+--- a/src/libgm2/libm2iso/Makefile.in
++++ b/src/libgm2/libm2iso/Makefile.in
+@@ -416,7 +416,7 @@ MAKEOVERRIDES =
+ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
+
+ # Directory in which the compiler finds libraries etc.
+-libsubdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)
++libsubdir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)
+ MULTIDIR := $(shell $(CC) $(CFLAGS) -print-multi-directory)
+ MULTIOSDIR := $(shell $(CC) $(CFLAGS) -print-multi-os-directory)
+ MULTIOSSUBDIR := $(shell if test x$(MULTIOSDIR) != x.; then echo /$(MULTIOSDIR); fi)
+--- a/src/libgm2/libm2log/Makefile.am
++++ b/src/libgm2/libm2log/Makefile.am
+@@ -27,7 +27,7 @@ MAKEOVERRIDES=
+ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
+
+ # Directory in which the compiler finds libraries etc.
+-libsubdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)
++libsubdir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)
+ # Used to install the shared libgcc.
+ slibdir = @slibdir@
+
+--- a/src/libgm2/libm2log/Makefile.in
++++ b/src/libgm2/libm2log/Makefile.in
+@@ -380,7 +380,7 @@ MAKEOVERRIDES =
+ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
+
+ # Directory in which the compiler finds libraries etc.
+-libsubdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)
++libsubdir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)
+ MULTIDIR := $(shell $(CC) $(CFLAGS) -print-multi-directory)
+ MULTIOSDIR := $(shell $(CC) $(CFLAGS) -print-multi-os-directory)
+ MULTIOSSUBDIR := $(shell if test x$(MULTIOSDIR) != x.; then echo /$(MULTIOSDIR); fi)
+--- a/src/libgm2/libm2min/Makefile.am
++++ b/src/libgm2/libm2min/Makefile.am
+@@ -27,7 +27,7 @@ MAKEOVERRIDES=
+ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
+
+ # Directory in which the compiler finds libraries etc.
+-libsubdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)
++libsubdir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)
+ # Used to install the shared libgcc.
+ slibdir = @slibdir@
+
+--- a/src/libgm2/libm2min/Makefile.in
++++ b/src/libgm2/libm2min/Makefile.in
+@@ -370,7 +370,7 @@ MAKEOVERRIDES =
+ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
+
+ # Directory in which the compiler finds libraries etc.
+-libsubdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)
++libsubdir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)
+ MULTIDIR := $(shell $(CC) $(CFLAGS) -print-multi-directory)
+ MULTIOSDIR := $(shell $(CC) $(CFLAGS) -print-multi-os-directory)
+ MULTIOSSUBDIR := $(shell if test x$(MULTIOSDIR) != x.; then echo /$(MULTIOSDIR); fi)
+--- a/src/libgm2/libm2pim/Makefile.am
++++ b/src/libgm2/libm2pim/Makefile.am
+@@ -27,7 +27,7 @@ MAKEOVERRIDES=
+ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
+
+ # Directory in which the compiler finds libraries etc.
+-libsubdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)
++libsubdir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)
+ # Used to install the shared libgcc.
+ slibdir = @slibdir@
+
+--- a/src/libgm2/libm2pim/Makefile.in
++++ b/src/libgm2/libm2pim/Makefile.in
+@@ -405,7 +405,7 @@ MAKEOVERRIDES =
+ gcc_version := $(shell @get_gcc_base_ver@ $(top_srcdir)/../gcc/BASE-VER)
+
+ # Directory in which the compiler finds libraries etc.
+-libsubdir = $(libdir)/gcc/$(target_alias)/$(gcc_version)
++libsubdir = $(libdir)/gcc-cross/$(target_alias)/$(gcc_version)
+ MULTIDIR := $(shell $(CC) $(CFLAGS) -print-multi-directory)
+ MULTIOSDIR := $(shell $(CC) $(CFLAGS) -print-multi-os-directory)
+ MULTIOSSUBDIR := $(shell if test x$(MULTIOSDIR) != x.; then echo /$(MULTIOSDIR); fi)
diff --git a/debian/patches/cross-no-locale-include.diff b/debian/patches/cross-no-locale-include.diff
new file mode 100644
index 0000000..c728316
--- /dev/null
+++ b/debian/patches/cross-no-locale-include.diff
@@ -0,0 +1,17 @@
+# DP: Don't add /usr/local/include for cross compilers. Assume that
+# DP: /usr/include is ready for multiarch, but not /usr/local/include.
+
+--- a/src/gcc/cppdefault.cc
++++ b/src/gcc/cppdefault.cc
+@@ -66,8 +66,11 @@
+ #ifdef LOCAL_INCLUDE_DIR
+ /* /usr/local/include comes before the fixincluded header files. */
+ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 2 },
++#if 0
++ /* Unsafe to assume that /usr/local/include is ready for multiarch. */
+ { LOCAL_INCLUDE_DIR, 0, 0, 1, 1, 0 },
+ #endif
++#endif
+ #ifdef PREFIX_INCLUDE_DIR
+ { PREFIX_INCLUDE_DIR, 0, 0, 1, 0, 0 },
+ #endif
diff --git a/debian/patches/cuda-float128.diff b/debian/patches/cuda-float128.diff
new file mode 100644
index 0000000..0fdaf12
--- /dev/null
+++ b/debian/patches/cuda-float128.diff
@@ -0,0 +1,46 @@
+# Mask __float128 types from CUDA compilers (LP: #1717257)
+
+--- a/src/libstdc++-v3/include/std/type_traits
++++ b/src/libstdc++-v3/include/std/type_traits
+@@ -509,7 +509,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+ : public true_type { };
+ #endif
+
+-#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
++#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) && !defined(__CUDACC__)
+ template<>
+ struct __is_floating_point_helper<__float128>
+ : public true_type { };
+--- a/src/libstdc++-v3/include/bits/std_abs.h
++++ b/src/libstdc++-v3/include/bits/std_abs.h
+@@ -131,7 +131,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
+ { return __gnu_cxx::__bfloat16_t(__builtin_fabsf(__x)); }
+ #endif
+
+-#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
++#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) && !defined(__CUDACC__)
+ __extension__ inline _GLIBCXX_CONSTEXPR
+ __float128
+ abs(__float128 __x)
+--- a/src/libstdc++-v3/include/bits/stl_algobase.h
++++ b/src/libstdc++-v3/include/bits/stl_algobase.h
+@@ -1060,7 +1060,7 @@ _GLIBCXX_END_NAMESPACE_CONTAINER
+ __size_to_integer(double __n) { return (long long)__n; }
+ inline _GLIBCXX_CONSTEXPR long long
+ __size_to_integer(long double __n) { return (long long)__n; }
+-#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
++#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) && !defined(__CUDACC__)
+ __extension__ inline _GLIBCXX_CONSTEXPR long long
+ __size_to_integer(__float128 __n) { return (long long)__n; }
+ #endif
+--- a/src/libstdc++-v3/include/std/numbers
++++ b/src/libstdc++-v3/include/std/numbers
+@@ -221,7 +221,7 @@ __glibcxx_numbers (_Float128, F128);
+ __glibcxx_numbers (__gnu_cxx::__bfloat16_t, BF16);
+ #endif
+
+-#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128)
++#if !defined(__STRICT_ANSI__) && defined(_GLIBCXX_USE_FLOAT128) && !defined(__CUDACC__)
+ __glibcxx_numbers (__float128, Q);
+ #endif // USE_FLOAT128
+
diff --git a/debian/patches/disable-gdc-tests.diff b/debian/patches/disable-gdc-tests.diff
new file mode 100644
index 0000000..626f6bd
--- /dev/null
+++ b/debian/patches/disable-gdc-tests.diff
@@ -0,0 +1,17 @@
+# DP: Disable D tests, hang on many buildds
+
+--- a/src/gcc/d/Make-lang.in
++++ b/src/gcc/d/Make-lang.in
+@@ -206,9 +206,9 @@ d.srcman: doc/gdc.1
+ # check targets. However, our DejaGNU framework requires 'check-gdc' as its
+ # entry point. We feed the former to the latter here.
+ check-d: check-gdc
+-lang_checks += check-gdc
+-lang_checks_parallelized += check-gdc
+-check_gdc_parallelize = 10
++#lang_checks += check-gdc
++#lang_checks_parallelized += check-gdc
++#check_gdc_parallelize = 10
+
+ # No D-specific selftests.
+ selftest-d:
diff --git a/debian/patches/dwarf5-revert-default-doc.diff b/debian/patches/dwarf5-revert-default-doc.diff
new file mode 100644
index 0000000..c8a6e4b
--- /dev/null
+++ b/debian/patches/dwarf5-revert-default-doc.diff
@@ -0,0 +1,14 @@
+# DP: Don't turn on DWARF 5 by default, where GCC 11 is not the default.
+
+--- a/src/gcc/doc/invoke.texi
++++ b/src/gcc/doc/invoke.texi
+@@ -9630,6 +9630,9 @@ version for most targets is 5 (with the
+ Darwin/Mac OS X, which default to version 2, and AIX, which defaults
+ to version 4).
+
++NOTE: On Ubuntu release, where GCC 11 is not used as the default (21.04
++and earlier releases), it defaults to version 4.
++
+ Note that with DWARF Version 2, some ports require and always
+ use some non-conflicting DWARF 3 extensions in the unwind tables.
+
diff --git a/debian/patches/dwarf5-revert-default.diff b/debian/patches/dwarf5-revert-default.diff
new file mode 100644
index 0000000..5d596c2
--- /dev/null
+++ b/debian/patches/dwarf5-revert-default.diff
@@ -0,0 +1,24 @@
+# DP: Don't turn on DWARF 5 by default, where GCC 11 is not the default.
+
+--- a/src/gcc/common.opt
++++ b/src/gcc/common.opt
+@@ -3353,7 +3353,7 @@ Common Driver JoinedOrMissing RejectNega
+ Generate debug information in default version of DWARF format.
+
+ gdwarf-
+-Common Driver Joined UInteger Var(dwarf_version) Init(DWARF_VERSION_DEFAULT) RejectNegative
++Common Driver Joined UInteger Var(dwarf_version) Init(4) RejectNegative
+ Generate debug information in DWARF v2 (or later) format.
+
+ gdwarf32
+--- a/src/gcc/defaults.h
++++ b/src/gcc/defaults.h
+@@ -1444,7 +1444,7 @@ see the files COPYING3 and COPYING.RUNTI
+ /* When generating dwarf info, the default standard version we'll honor
+ and advertise in absence of -gdwarf-<N> on the command line. */
+ #ifndef DWARF_VERSION_DEFAULT
+-#define DWARF_VERSION_DEFAULT 5
++#define DWARF_VERSION_DEFAULT 4
+ #endif
+
+ #ifndef USED_FOR_TARGET
diff --git a/debian/patches/g++-multiarch-incdir.diff b/debian/patches/g++-multiarch-incdir.diff
new file mode 100644
index 0000000..a9d283d
--- /dev/null
+++ b/debian/patches/g++-multiarch-incdir.diff
@@ -0,0 +1,109 @@
+# DP: Use /usr/include/<multiarch>/c++/4.x as the include directory
+# DP: for host dependent c++ header files.
+
+--- a/src/libstdc++-v3/include/Makefile.am
++++ b/src/libstdc++-v3/include/Makefile.am
+@@ -1036,7 +1036,7 @@ endif
+
+ host_srcdir = ${glibcxx_srcdir}/$(OS_INC_SRCDIR)
+ host_builddir = ./${host_alias}/bits
+-host_installdir = ${gxx_include_dir}/${host_alias}$(MULTISUBDIR)/bits
++host_installdir = $(if $(shell $(CC) -print-multiarch),/usr/include/$(shell $(filter-out -m%,$(CC)) -print-multiarch)/c++/$(notdir ${gxx_include_dir})$(MULTISUBDIR)/bits,${gxx_include_dir}/${default_host_alias}$(MULTISUBDIR)/bits)
+ host_headers = \
+ ${host_srcdir}/ctype_base.h \
+ ${host_srcdir}/ctype_inline.h \
+--- a/src/libstdc++-v3/include/Makefile.in
++++ b/src/libstdc++-v3/include/Makefile.in
+@@ -1367,7 +1367,7 @@ parallel_headers = \
+ @GLIBCXX_C_HEADERS_COMPATIBILITY_TRUE@c_compatibility_headers_extra = ${c_compatibility_headers}
+ host_srcdir = ${glibcxx_srcdir}/$(OS_INC_SRCDIR)
+ host_builddir = ./${host_alias}/bits
+-host_installdir = ${gxx_include_dir}/${host_alias}$(MULTISUBDIR)/bits
++host_installdir = $(if $(shell $(CC) -print-multiarch),/usr/include/$(shell $(filter-out -m%,$(CC)) -print-multiarch)/c++/$(notdir ${gxx_include_dir})$(MULTISUBDIR)/bits,${gxx_include_dir}/${default_host_alias}$(MULTISUBDIR)/bits)
+ host_headers = \
+ ${host_srcdir}/ctype_base.h \
+ ${host_srcdir}/ctype_inline.h \
+--- a/src/gcc/Makefile.in
++++ b/src/gcc/Makefile.in
+@@ -1258,6 +1258,7 @@ FLAGS_TO_PASS = \
+ "prefix=$(prefix)" \
+ "local_prefix=$(local_prefix)" \
+ "gxx_include_dir=$(gcc_gxx_include_dir)" \
++ "gxx_tool_include_dir=$(gcc_gxx_tool_include_dir)" \
+ "gxx_libcxx_include_dir=$(gcc_gxx_libcxx_include_dir)" \
+ "build_tooldir=$(build_tooldir)" \
+ "gcc_tooldir=$(gcc_tooldir)" \
+@@ -1954,6 +1955,14 @@ gnat_install_lib = @gnat_install_lib@
+ # host overrides
+ -include $(xmake_file)
+
++# Directory in which the compiler finds target-dependent g++ includes.
++ifneq ($(call if_multiarch,non-empty),)
++ gcc_gxx_tool_include_dir = $(libsubdir)/$(libsubdir_to_prefix)include/$(MULTIARCH_DIRNAME)/c++/$(version)
++else
++ gcc_gxx_tool_include_dir = $(gcc_gxx_include_dir)/$(target_noncanonical)
++endif
++
++
+ # all-tree.def includes all the tree.def files.
+ all-tree.def: s-alltree; @true
+ s-alltree: Makefile
+@@ -3168,7 +3177,7 @@ PREPROCESSOR_DEFINES = \
+ -DFIXED_INCLUDE_DIR=\"$(libsubdir)/include-fixed\" \
+ -DGPLUSPLUS_INCLUDE_DIR=\"$(gcc_gxx_include_dir)\" \
+ -DGPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_include_dir_add_sysroot) \
+- -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/$(target_noncanonical)\" \
++ -DGPLUSPLUS_TOOL_INCLUDE_DIR=\"$(gcc_gxx_tool_include_dir)\" \
+ -DGPLUSPLUS_BACKWARD_INCLUDE_DIR=\"$(gcc_gxx_include_dir)/backward\" \
+ -DGPLUSPLUS_LIBCXX_INCLUDE_DIR=\"$(gcc_gxx_libcxx_include_dir)\" \
+ -DGPLUSPLUS_LIBCXX_INCLUDE_DIR_ADD_SYSROOT=$(gcc_gxx_libcxx_include_dir_add_sysroot) \
+--- a/src/gcc/cppdefault.cc
++++ b/src/gcc/cppdefault.cc
+@@ -49,6 +49,8 @@ const struct default_include cpp_include
+ /* Pick up GNU C++ target-dependent include files. */
+ { GPLUSPLUS_TOOL_INCLUDE_DIR, "G++", 1, 1,
+ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 1 },
++ { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1,
++ GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 2 },
+ #endif
+ #ifdef GPLUSPLUS_BACKWARD_INCLUDE_DIR
+ /* Pick up GNU C++ backward and deprecated include files. */
+--- a/src/gcc/incpath.cc
++++ b/src/gcc/incpath.cc
+@@ -164,6 +164,18 @@ add_standard_paths (const char *sysroot,
+ }
+ str = reconcat (str, str, dir_separator_str,
+ imultiarch, NULL);
++ if (p->cplusplus && strstr (str, "/c++/"))
++ {
++ char *suffix = strstr (str, "/c++/");
++ *suffix++ = '\0';
++ suffix = xstrdup (suffix);
++ str = reconcat (str, str, dir_separator_str,
++ imultiarch,
++ dir_separator_str, suffix, NULL);
++ }
++ else
++ str = reconcat (str, str, dir_separator_str,
++ imultiarch, NULL);
+ }
+ add_path (str, INC_SYSTEM, p->cxx_aware, false);
+ }
+@@ -229,7 +241,16 @@ add_standard_paths (const char *sysroot,
+ free (str);
+ continue;
+ }
+- str = reconcat (str, str, dir_separator_str, imultiarch, NULL);
++ if (p->cplusplus && strstr (str, "/c++/"))
++ {
++ char *suffix = strstr (str, "/c++/");
++ *suffix++ = '\0';
++ suffix = xstrdup (suffix);
++ str = reconcat (str, str, dir_separator_str, imultiarch,
++ dir_separator_str, suffix, NULL);
++ }
++ else
++ str = reconcat (str, str, dir_separator_str, imultiarch, NULL);
+ }
+
+ add_path (str, INC_SYSTEM, p->cxx_aware, false);
diff --git a/debian/patches/gcc-arm-disable-guality-tests.diff b/debian/patches/gcc-arm-disable-guality-tests.diff
new file mode 100644
index 0000000..bc43363
--- /dev/null
+++ b/debian/patches/gcc-arm-disable-guality-tests.diff
@@ -0,0 +1,44 @@
+# DP: Don't run some tests from the guality test suite on armhf. These fail
+# DP: on every target, but seem to hang on the buildds occasionally on armhf.
+
+--- a/src/gcc/testsuite/gcc.dg/guality/guality.exp
++++ b/src/gcc/testsuite/gcc.dg/guality/guality.exp
+@@ -93,7 +93,37 @@ if {[check_guality "
+ }
+ }
+
+- gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] "" ""
++ # FIXME: these seem to hang on the buildds, and gdb always times out
++ # trying to run them.
++ if { [istarget arm-*-linux-gnueabi*] } {
++ set guality [list]
++ foreach file [lsort [glob $srcdir/$subdir/*.c]] {
++ switch -glob -- [file tail $file] {
++ pr36728-*.c -
++ pr41616-1.c -
++ pr43051-1.c -
++ pr54200.c -
++ pr54519-*.c -
++ pr54551.c -
++ pr54693-2.c -
++ pr54796.c -
++ pr56154-1.c -
++ pr58791-3.c -
++ pr58791-5.c -
++ pr68860-1.c -
++ pr68860-2.c -
++ pr78726.c -
++ pr89528.c -
++ pr90074.c -
++ pr90716.c { }
++ * { lappend guality $file }
++ }
++ }
++ } {
++ set guality [lsort [glob $srcdir/$subdir/*.c]]
++ }
++
++ gcc-dg-runtest $guality "" ""
+ gcc-dg-runtest $general "" "-Wc++-compat"
+ set-torture-options \
+ [list "-O0" "-Og"] \
diff --git a/debian/patches/gcc-as-needed-gold.diff b/debian/patches/gcc-as-needed-gold.diff
new file mode 100644
index 0000000..5fc611a
--- /dev/null
+++ b/debian/patches/gcc-as-needed-gold.diff
@@ -0,0 +1,85 @@
+# DP: Use --push-state/--pop-state for gold as well when linking libtsan.
+
+--- a/src/gcc/gcc.cc
++++ b/src/gcc/gcc.cc
+@@ -773,10 +773,10 @@ proper position among the other output f
+ #define LIBASAN_SPEC STATIC_LIBASAN_LIBS
+ #elif defined(HAVE_LD_STATIC_DYNAMIC)
+ #define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION "}" \
+- " %{!static-libasan:%{!fuse-ld=gold:--push-state} --no-as-needed}" \
++ " %{!static-libasan:--push-state --no-as-needed}" \
+ " -lasan " \
+ " %{static-libasan:" LD_DYNAMIC_OPTION "}" \
+- " %{!static-libasan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
++ " %{!static-libasan:--pop-state}" \
+ STATIC_LIBASAN_LIBS
+ #else
+ #define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS
+@@ -812,10 +812,10 @@ proper position among the other output f
+ #define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS
+ #elif defined(HAVE_LD_STATIC_DYNAMIC)
+ #define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION "}" \
+- " %{!static-libtsan:%{!fuse-ld=gold:--push-state} --no-as-needed}" \
++ " %{!static-libtsan:--push-state --no-as-needed}" \
+ " -ltsan " \
+ " %{static-libtsan:" LD_DYNAMIC_OPTION "}" \
+- " %{!static-libtsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
++ " %{!static-libtsan:--pop-state}" \
+ STATIC_LIBTSAN_LIBS
+ #else
+ #define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS
+@@ -833,10 +833,10 @@ proper position among the other output f
+ #define LIBLSAN_SPEC STATIC_LIBLSAN_LIBS
+ #elif defined(HAVE_LD_STATIC_DYNAMIC)
+ #define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION "}" \
+- " %{!static-liblsan:%{!fuse-ld=gold:--push-state} --no-as-needed}" \
++ " %{!static-liblsan:--push-state --no-as-needed}" \
+ " -llsan " \
+ " %{static-liblsan:" LD_DYNAMIC_OPTION "}" \
+- " %{!static-liblsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
++ " %{!static-liblsan:--pop-state}" \
+ STATIC_LIBLSAN_LIBS
+ #else
+ #define LIBLSAN_SPEC "-llsan" STATIC_LIBLSAN_LIBS
+@@ -852,10 +852,10 @@ proper position among the other output f
+ " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}"
+ #ifdef HAVE_LD_STATIC_DYNAMIC
+ #define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION "}" \
+- " %{!static-libubsan:%{!fuse-ld=gold:--push-state} --no-as-needed}" \
++ " %{!static-libubsan:--push-state --no-as-needed}" \
+ " -lubsan " \
+ " %{static-libubsan:" LD_DYNAMIC_OPTION "}" \
+- " %{!static-libubsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
++ " %{!static-libubsan:--pop-state}" \
+ STATIC_LIBUBSAN_LIBS
+ #else
+ #define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS
+--- a/src/gcc/config/gnu-user.h
++++ b/src/gcc/config/gnu-user.h
+@@ -136,22 +136,22 @@ see the files COPYING3 and COPYING.RUNTI
+ #define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \
+ "%{static-libasan:%{!shared:" \
+ LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \
+- LD_DYNAMIC_OPTION "}}%{!static-libasan:%{!fuse-ld=gold:--push-state} --no-as-needed -lasan %{fuse-ld=gold:--as-needed;:--pop-state}}"
++ LD_DYNAMIC_OPTION "}}%{!static-libasan:--push-state --no-as-needed -lasan --pop-state}"
+ #undef LIBHWASAN_EARLY_SPEC
+ #define LIBHWASAN_EARLY_SPEC "%{!shared:libhwasan_preinit%O%s} " \
+ "%{static-libhwasan:%{!shared:" \
+ LD_STATIC_OPTION " --whole-archive -lhwasan --no-whole-archive " \
+- LD_DYNAMIC_OPTION "}}%{!static-libhwasan:%{!fuse-ld=gold:--push-state} --no-as-needed -lhwasan %{fuse-ld=gold:--as-needed;:--pop-state}}"
++ LD_DYNAMIC_OPTION "}}%{!static-libhwasan:--push-state --no-as-needed -lhwasan --pop-state}"
+ #undef LIBTSAN_EARLY_SPEC
+ #define LIBTSAN_EARLY_SPEC "%{!shared:libtsan_preinit%O%s} " \
+ "%{static-libtsan:%{!shared:" \
+ LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \
+- LD_DYNAMIC_OPTION "}}%{!static-libtsan:%{!fuse-ld=gold:--push-state} --no-as-needed -ltsan %{fuse-ld=gold:--as-needed;:--pop-state}}"
++ LD_DYNAMIC_OPTION "}}%{!static-libtsan:--push-state --no-as-needed -ltsan --pop-state}"
+ #undef LIBLSAN_EARLY_SPEC
+ #define LIBLSAN_EARLY_SPEC "%{!shared:liblsan_preinit%O%s} " \
+ "%{static-liblsan:%{!shared:" \
+ LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \
+- LD_DYNAMIC_OPTION "}}%{!static-liblsan:%{!fuse-ld=gold:--push-state} --no-as-needed -llsan %{fuse-ld=gold:--as-needed;:--pop-state}}"
++ LD_DYNAMIC_OPTION "}}%{!static-liblsan:--push-state --no-as-needed -llsan --pop-state}"
+ #endif
+
+ #undef TARGET_F951_OPTIONS
diff --git a/debian/patches/gcc-as-needed.diff b/debian/patches/gcc-as-needed.diff
new file mode 100644
index 0000000..f6568bd
--- /dev/null
+++ b/debian/patches/gcc-as-needed.diff
@@ -0,0 +1,264 @@
+# DP: On linux targets pass --as-needed by default to the linker, but always
+# DP: link the sanitizer libraries with --no-as-needed.
+
+--- a/src/gcc/gcc.cc
++++ b/src/gcc/gcc.cc
+@@ -772,8 +772,11 @@ proper position among the other output f
+ #ifdef LIBASAN_EARLY_SPEC
+ #define LIBASAN_SPEC STATIC_LIBASAN_LIBS
+ #elif defined(HAVE_LD_STATIC_DYNAMIC)
+-#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION \
+- "} -lasan %{static-libasan:" LD_DYNAMIC_OPTION "}" \
++#define LIBASAN_SPEC "%{static-libasan:" LD_STATIC_OPTION "}" \
++ " %{!static-libasan:%{!fuse-ld=gold:--push-state} --no-as-needed}" \
++ " -lasan " \
++ " %{static-libasan:" LD_DYNAMIC_OPTION "}" \
++ " %{!static-libasan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
+ STATIC_LIBASAN_LIBS
+ #else
+ #define LIBASAN_SPEC "-lasan" STATIC_LIBASAN_LIBS
+@@ -808,8 +811,11 @@ proper position among the other output f
+ #ifdef LIBTSAN_EARLY_SPEC
+ #define LIBTSAN_SPEC STATIC_LIBTSAN_LIBS
+ #elif defined(HAVE_LD_STATIC_DYNAMIC)
+-#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION \
+- "} -ltsan %{static-libtsan:" LD_DYNAMIC_OPTION "}" \
++#define LIBTSAN_SPEC "%{static-libtsan:" LD_STATIC_OPTION "}" \
++ " %{!static-libtsan:%{!fuse-ld=gold:--push-state} --no-as-needed}" \
++ " -ltsan " \
++ " %{static-libtsan:" LD_DYNAMIC_OPTION "}" \
++ " %{!static-libtsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
+ STATIC_LIBTSAN_LIBS
+ #else
+ #define LIBTSAN_SPEC "-ltsan" STATIC_LIBTSAN_LIBS
+@@ -826,8 +832,11 @@ proper position among the other output f
+ #ifdef LIBLSAN_EARLY_SPEC
+ #define LIBLSAN_SPEC STATIC_LIBLSAN_LIBS
+ #elif defined(HAVE_LD_STATIC_DYNAMIC)
+-#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION \
+- "} -llsan %{static-liblsan:" LD_DYNAMIC_OPTION "}" \
++#define LIBLSAN_SPEC "%{static-liblsan:" LD_STATIC_OPTION "}" \
++ " %{!static-liblsan:%{!fuse-ld=gold:--push-state} --no-as-needed}" \
++ " -llsan " \
++ " %{static-liblsan:" LD_DYNAMIC_OPTION "}" \
++ " %{!static-liblsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
+ STATIC_LIBLSAN_LIBS
+ #else
+ #define LIBLSAN_SPEC "-llsan" STATIC_LIBLSAN_LIBS
+@@ -842,8 +851,11 @@ proper position among the other output f
+ #define STATIC_LIBUBSAN_LIBS \
+ " %{static-libubsan|static:%:include(libsanitizer.spec)%(link_libubsan)}"
+ #ifdef HAVE_LD_STATIC_DYNAMIC
+-#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION \
+- "} -lubsan %{static-libubsan:" LD_DYNAMIC_OPTION "}" \
++#define LIBUBSAN_SPEC "%{static-libubsan:" LD_STATIC_OPTION "}" \
++ " %{!static-libubsan:%{!fuse-ld=gold:--push-state} --no-as-needed}" \
++ " -lubsan " \
++ " %{static-libubsan:" LD_DYNAMIC_OPTION "}" \
++ " %{!static-libubsan:%{fuse-ld=gold:--as-needed;:--pop-state}}" \
+ STATIC_LIBUBSAN_LIBS
+ #else
+ #define LIBUBSAN_SPEC "-lubsan" STATIC_LIBUBSAN_LIBS
+--- a/src/gcc/config/gnu-user.h
++++ b/src/gcc/config/gnu-user.h
+@@ -136,22 +136,22 @@ see the files COPYING3 and COPYING.RUNTI
+ #define LIBASAN_EARLY_SPEC "%{!shared:libasan_preinit%O%s} " \
+ "%{static-libasan:%{!shared:" \
+ LD_STATIC_OPTION " --whole-archive -lasan --no-whole-archive " \
+- LD_DYNAMIC_OPTION "}}%{!static-libasan:-lasan}"
++ LD_DYNAMIC_OPTION "}}%{!static-libasan:%{!fuse-ld=gold:--push-state} --no-as-needed -lasan %{fuse-ld=gold:--as-needed;:--pop-state}}"
+ #undef LIBHWASAN_EARLY_SPEC
+ #define LIBHWASAN_EARLY_SPEC "%{!shared:libhwasan_preinit%O%s} " \
+ "%{static-libhwasan:%{!shared:" \
+ LD_STATIC_OPTION " --whole-archive -lhwasan --no-whole-archive " \
+- LD_DYNAMIC_OPTION "}}%{!static-libhwasan:-lhwasan}"
++ LD_DYNAMIC_OPTION "}}%{!static-libhwasan:%{!fuse-ld=gold:--push-state} --no-as-needed -lhwasan %{fuse-ld=gold:--as-needed;:--pop-state}}"
+ #undef LIBTSAN_EARLY_SPEC
+ #define LIBTSAN_EARLY_SPEC "%{!shared:libtsan_preinit%O%s} " \
+ "%{static-libtsan:%{!shared:" \
+ LD_STATIC_OPTION " --whole-archive -ltsan --no-whole-archive " \
+- LD_DYNAMIC_OPTION "}}%{!static-libtsan:-ltsan}"
++ LD_DYNAMIC_OPTION "}}%{!static-libtsan:%{!fuse-ld=gold:--push-state} --no-as-needed -ltsan %{fuse-ld=gold:--as-needed;:--pop-state}}"
+ #undef LIBLSAN_EARLY_SPEC
+ #define LIBLSAN_EARLY_SPEC "%{!shared:liblsan_preinit%O%s} " \
+ "%{static-liblsan:%{!shared:" \
+ LD_STATIC_OPTION " --whole-archive -llsan --no-whole-archive " \
+- LD_DYNAMIC_OPTION "}}%{!static-liblsan:-llsan}"
++ LD_DYNAMIC_OPTION "}}%{!static-liblsan:%{!fuse-ld=gold:--push-state} --no-as-needed -llsan %{fuse-ld=gold:--as-needed;:--pop-state}}"
+ #endif
+
+ #undef TARGET_F951_OPTIONS
+--- a/src/gcc/config/aarch64/aarch64-linux.h
++++ b/src/gcc/config/aarch64/aarch64-linux.h
+@@ -36,6 +36,7 @@
+
+ #define LINUX_TARGET_LINK_SPEC "%{h*} \
+ --hash-style=gnu \
++ %{!fsanitize=*:--as-needed} \
+ %{static:-Bstatic} \
+ %{shared:-shared} \
+ %{symbolic:-Bsymbolic} \
+--- a/src/gcc/config/ia64/linux.h
++++ b/src/gcc/config/ia64/linux.h
+@@ -58,7 +58,7 @@ do { \
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-ia64.so.2"
+
+ #undef LINK_SPEC
+-#define LINK_SPEC " --hash-style=gnu \
++#define LINK_SPEC " --hash-style=gnu %{!fsanitize=*:--as-needed} \
+ %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+--- a/src/gcc/config/sparc/linux.h
++++ b/src/gcc/config/sparc/linux.h
+@@ -81,7 +81,7 @@ extern const char *host_detect_local_cpu
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+ #undef LINK_SPEC
+-#define LINK_SPEC "-m elf32_sparc --hash-style=gnu %{shared:-shared} \
++#define LINK_SPEC "-m elf32_sparc --hash-style=gnu %{!fsanitize=*:--as-needed} %{shared:-shared} \
+ %{!mno-relax:%{!r:-relax}} \
+ %{!shared: \
+ %{!static: \
+--- a/src/gcc/config/s390/linux.h
++++ b/src/gcc/config/s390/linux.h
+@@ -82,7 +82,7 @@ along with GCC; see the file COPYING3.
+
+ #undef LINK_SPEC
+ #define LINK_SPEC \
+- "%{m31:-m elf_s390}%{m64:-m elf64_s390} --hash-style=gnu \
++ "%{m31:-m elf_s390}%{m64:-m elf64_s390} --hash-style=gnu %{!fsanitize=*:--as-needed} \
+ %{shared:-shared} \
+ %{!shared: \
+ %{static:-static} \
+--- a/src/gcc/config/rs6000/linux64.h
++++ b/src/gcc/config/rs6000/linux64.h
+@@ -378,13 +378,13 @@ extern int dot_symbols;
+ " -m elf64ppc")
+ #endif
+
+-#define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " --hash-style=gnu %{!shared: %{!static: \
++#define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " --hash-style=gnu %{!fsanitize=*:--as-needed} %{!shared: %{!static: \
+ %{!static-pie: \
+ %{rdynamic:-export-dynamic} \
+ -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}}} \
+ %(link_os_extra_spec32)"
+
+-#define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " --hash-style=gnu %{!shared: %{!static: \
++#define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " --hash-style=gnu %{!fsanitize=*:--as-needed} %{!shared: %{!static: \
+ %{!static-pie: \
+ %{rdynamic:-export-dynamic} \
+ -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}} \
+--- a/src/gcc/config/rs6000/sysv4.h
++++ b/src/gcc/config/rs6000/sysv4.h
+@@ -780,7 +780,7 @@ GNU_USER_TARGET_CC1_SPEC
+ #define GNU_USER_DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
+ #endif
+
+-#define LINK_OS_LINUX_SPEC "-m elf32ppclinux --hash-style=gnu %{!shared: %{!static: \
++#define LINK_OS_LINUX_SPEC "-m elf32ppclinux --hash-style=gnu %{!fsanitize=*:--as-needed} %{!shared: %{!static: \
+ %{rdynamic:-export-dynamic} \
+ -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}"
+
+--- a/src/gcc/config/i386/gnu-user64.h
++++ b/src/gcc/config/i386/gnu-user64.h
+@@ -57,6 +57,7 @@ see the files COPYING3 and COPYING.RUNTI
+ %{" SPEC_32 ":-m " GNU_USER_LINK_EMULATION32 "} \
+ %{" SPEC_X32 ":-m " GNU_USER_LINK_EMULATIONX32 "} \
+ --hash-style=gnu \
++ %{!fsanitize=*:--as-needed} \
+ %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+--- a/src/gcc/config/i386/gnu-user.h
++++ b/src/gcc/config/i386/gnu-user.h
+@@ -68,7 +68,7 @@ along with GCC; see the file COPYING3.
+ { "link_emulation", GNU_USER_LINK_EMULATION },\
+ { "dynamic_linker", GNU_USER_DYNAMIC_LINKER }
+
+-#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) --hash-style=gnu %{shared:-shared} \
++#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) --hash-style=gnu %{!fsanitize=*:--as-needed} %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+ %{!static-pie: \
+--- a/src/gcc/config/alpha/linux-elf.h
++++ b/src/gcc/config/alpha/linux-elf.h
+@@ -37,7 +37,7 @@ along with GCC; see the file COPYING3.
+
+ #define ELF_DYNAMIC_LINKER GNU_USER_DYNAMIC_LINKER
+
+-#define LINK_SPEC "-m elf64alpha --hash-style=gnu %{G*} %{relax:-relax} \
++#define LINK_SPEC "-m elf64alpha --hash-style=gnu %{!fsanitize=*:--as-needed} %{G*} %{relax:-relax} \
+ %{O*:-O3} %{!O*:-O1} \
+ %{shared:-shared} \
+ %{!shared: \
+--- a/src/gcc/config/arm/linux-elf.h
++++ b/src/gcc/config/arm/linux-elf.h
+@@ -71,6 +71,7 @@
+ %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \
+ -X \
+ --hash-style=gnu \
++ %{!fsanitize=*:--as-needed} \
+ %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
+ SUBTARGET_EXTRA_LINK_SPEC
+
+--- a/src/gcc/config/mips/gnu-user.h
++++ b/src/gcc/config/mips/gnu-user.h
+@@ -55,6 +55,7 @@ along with GCC; see the file COPYING3.
+ #undef GNU_USER_TARGET_LINK_SPEC
+ #define GNU_USER_TARGET_LINK_SPEC "\
+ %{G*} %{EB} %{EL} %{mips*} %{shared} \
++ %{!fsanitize=*:--as-needed} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+--- a/src/gcc/config/riscv/linux.h
++++ b/src/gcc/config/riscv/linux.h
+@@ -49,6 +49,7 @@ along with GCC; see the file COPYING3.
+
+ #define LINK_SPEC "\
+ -hash-style=gnu \
++%{!fsanitize=*:--as-needed} \
+ -melf" XLEN_SPEC DEFAULT_ENDIAN_SPEC "riscv" LD_EMUL_SUFFIX " \
+ %{mno-relax:--no-relax} \
+ %{mbig-endian:-EB} \
+--- a/src/gcc/config/m68k/linux.h
++++ b/src/gcc/config/m68k/linux.h
+@@ -78,6 +78,7 @@ along with GCC; see the file COPYING3.
+
+ #undef LINK_SPEC
+ #define LINK_SPEC "-m m68kelf %{shared} \
++ %{!fsanitize=*:--as-needed} \
+ %{!shared: \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+--- a/src/gcc/config/sh/linux.h
++++ b/src/gcc/config/sh/linux.h
+@@ -72,6 +72,7 @@ along with GCC; see the file COPYING3.
+ #undef SUBTARGET_LINK_SPEC
+ #define SUBTARGET_LINK_SPEC \
+ "%{shared:-shared} \
++ %{!fsanitize=*:--as-needed} \
+ %{!static: \
+ %{rdynamic:-export-dynamic} \
+ -dynamic-linker " GNU_USER_DYNAMIC_LINKER "} \
+--- a/src/gcc/config/pa/pa-linux.h
++++ b/src/gcc/config/pa/pa-linux.h
+@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3.
+
+ #undef LINK_SPEC
+ #define LINK_SPEC "\
++ %{!fsanitize=*:--as-needed} \
+ %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+--- a/src/gcc/config/loongarch/gnu-user.h
++++ b/src/gcc/config/loongarch/gnu-user.h
+@@ -45,6 +45,7 @@ along with GCC; see the file COPYING3.
+ #undef GNU_USER_TARGET_LINK_SPEC
+ #define GNU_USER_TARGET_LINK_SPEC \
+ "%{G*} %{shared} -m " GNU_USER_LINK_EMULATION \
++ " %{!fsanitize=*:--as-needed} " \
+ "%{!shared: %{static} " \
+ "%{!static: %{!static-pie: %{rdynamic:-export-dynamic} " \
+ "-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} " \
diff --git a/debian/patches/gcc-auto-build.diff b/debian/patches/gcc-auto-build.diff
new file mode 100644
index 0000000..2f2d5ab
--- /dev/null
+++ b/debian/patches/gcc-auto-build.diff
@@ -0,0 +1,13 @@
+# DP: Fix cross building a native compiler.
+
+--- a/src/gcc/configure.ac
++++ b/src/gcc/configure.ac
+@@ -2141,7 +2141,7 @@ else
+ # Clearing GMPINC is necessary to prevent host headers being
+ # used by the build compiler. Defining GENERATOR_FILE stops
+ # system.h from including gmp.h.
+- CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD}" \
++ CC="${CC_FOR_BUILD}" CFLAGS="${CFLAGS_FOR_BUILD} -DGENERATOR_FILE" \
+ CXX="${CXX_FOR_BUILD}" CXXFLAGS="${CXXFLAGS_FOR_BUILD}" \
+ LD="${LD_FOR_BUILD}" LDFLAGS="${LDFLAGS_FOR_BUILD}" \
+ GMPINC="" CPPFLAGS="${CPPFLAGS_FOR_BUILD} -DGENERATOR_FILE" \
diff --git a/debian/patches/gcc-distro-specs-ubuntu-doc.diff b/debian/patches/gcc-distro-specs-ubuntu-doc.diff
new file mode 100644
index 0000000..aea24e8
--- /dev/null
+++ b/debian/patches/gcc-distro-specs-ubuntu-doc.diff
@@ -0,0 +1,72 @@
+# DP: Document distro specific compiler flags turned on by default
+
+--- a/src/gcc/doc/invoke.texi
++++ b/src/gcc/doc/invoke.texi
+@@ -12349,6 +12349,13 @@ also turns on the following optimization
+ Please note the warning under @option{-fgcse} about
+ invoking @option{-O2} on programs that use computed gotos.
+
++NOTE: In Ubuntu 8.10 and later versions, @option{-D_FORTIFY_SOURCE=2},
++in Ubuntu 24.04 and later versions, @option{-D_FORTIFY_SOURCE=3}, is
++set by default, and is activated when @option{-O} is set to 2 or higher.
++This enables additional compile-time and run-time checks for several libc
++functions. To disable, specify either @option{-U_FORTIFY_SOURCE} or
++@option{-D_FORTIFY_SOURCE=0}.
++
+ @opindex O3
+ @item -O3
+ Optimize yet more. @option{-O3} turns on all optimizations specified
+@@ -15955,6 +15962,9 @@ value of a shared integer constant.
+ The minimum size of buffers (i.e.@: arrays) that receive stack smashing
+ protection when @option{-fstack-protector} is used.
+
++This default before Ubuntu 10.10 was "8". Currently it is "4", to increase
++the number of functions protected by the stack protector.
++
+ @item min-size-for-stack-sharing
+ The minimum size of variables taking part in stack slot sharing when not
+ optimizing.
+@@ -17743,6 +17753,10 @@ Currently the x86 GNU/Linux target provi
+ on Intel Control-flow Enforcement Technology (CET) which works for
+ i686 processor or newer.
+
++NOTE: In Ubuntu 19.10 and later versions, @option{-fcf-protection}
++is enabled by default for C, C++, ObjC, ObjC++, if none of
++@option{-fno-cf-protection} nor @option{-fcf-protection=*} are found.
++
+ @opindex fharden-compares
+ @item -fharden-compares
+ For every logical test that survives gimple optimizations and is
+@@ -17898,6 +17912,11 @@ references to local frame addresses. On
+ allocated on the stack are considered, optimized away variables or variables
+ allocated in registers don't count.
+
++NOTE: In Ubuntu 14.10 and later versions,
++@option{-fstack-protector-strong} is enabled by default for C,
++C++, ObjC, ObjC++, if none of @option{-fno-stack-protector},
++@option{-nostdlib}, nor @option{-ffreestanding} are found.
++
+ @opindex fstack-protector-explicit
+ @item -fstack-protector-explicit
+ Like @option{-fstack-protector} but only protects those functions which
+@@ -17961,6 +17980,10 @@ allocations. @option{-fstack-clash-prot
+ protection for static stack allocations if the target supports
+ @option{-fstack-check=specific}.
+
++NOTE: In Ubuntu 19.10 and later versions,
++@option{-fstack-clash-protection} is enabled by default for C,
++C++, ObjC, ObjC++, unless @option{-fno-stack-clash-protection} is found.
++
+ @opindex fstack-limit-register
+ @opindex fstack-limit-symbol
+ @opindex fno-stack-limit
+@@ -18738,6 +18761,9 @@ For example, @option{-Wl,-Map,output.map
+ linker. When using the GNU linker, you can also get the same effect with
+ @option{-Wl,-Map=output.map}.
+
++NOTE: In Ubuntu 8.10 and later versions, for LDFLAGS, the option
++@option{-Wl,-z,relro} is used. To disable, use @option{-Wl,-z,norelro}.
++
+ @opindex u
+ @item -u @var{symbol}
+ Pretend the symbol @var{symbol} is undefined, to force linking of
diff --git a/debian/patches/gcc-distro-specs.diff b/debian/patches/gcc-distro-specs.diff
new file mode 100644
index 0000000..098d181
--- /dev/null
+++ b/debian/patches/gcc-distro-specs.diff
@@ -0,0 +1,326 @@
+# DP: Add empty distro and hardening specs
+
+--- a/src/gcc/gcc.cc
++++ b/src/gcc/gcc.cc
+@@ -27,6 +27,11 @@ CC recognizes how to compile each input
+ Once it knows which kind of compilation to perform, the procedure for
+ compilation is specified by a string called a "spec". */
+
++/* Inject some default compilation flags which are used as the default.
++ Done by the packaging build system. Should that be done in the headers
++ gcc/config/<arch>/*.h instead? */
++#include "distro-defaults.h"
++
+ #define INCLUDE_STRING
+ #include "config.h"
+ #include "system.h"
+@@ -984,6 +989,90 @@ proper position among the other output f
+ #define LINK_GCC_C_SEQUENCE_SPEC "%G %{!nolibc:%L %G}"
+ #endif
+
++/* Generate full unwind information covering all program points.
++ Only needed for some architectures. */
++#ifndef ASYNC_UNWIND_SPEC
++# ifdef DIST_DEFAULT_ASYNC_UNWIND
++# define ASYNC_UNWIND_SPEC "%{!fno-asynchronous-unwind-tables:-fasynchronous-unwind-tables}"
++# else
++# define ASYNC_UNWIND_SPEC ""
++# endif
++#endif
++
++/* Turn on stack protector.
++ */
++#ifndef SSP_DEFAULT_SPEC
++# ifdef DIST_DEFAULT_SSP
++# ifdef DIST_DEFAULT_SSP_STRONG
++# define SSP_DEFAULT_SPEC " %{!fno-stack-protector:%{!fstack-protector-all:%{!ffreestanding:%{!nostdlib:%{!fstack-protector:-fstack-protector-strong}}}}}"
++# else
++# define SSP_DEFAULT_SPEC " %{!fno-stack-protector:%{!fstack-protector-all:%{!ffreestanding:%{!nostdlib:-fstack-protector}}}}"
++# endif
++# else
++# define SSP_DEFAULT_SPEC ""
++# endif
++#endif
++
++/* Turn on -Wformat -Wformat-security by default for C, C++,
++ ObjC, ObjC++. */
++#ifndef FORMAT_SECURITY_SPEC
++# ifdef DIST_DEFAULT_FORMAT_SECURITY
++# define FORMAT_SECURITY_SPEC " %{!Wformat:%{!Wformat=2:%{!Wformat=0:%{!Wall:-Wformat} %{!Wno-format-security:-Wformat-security}}}}"
++# else
++# define FORMAT_SECURITY_SPEC ""
++# endif
++#endif
++
++/* Enable -fstack-clash-protection by default. Only available
++ on some targets. */
++#ifndef STACK_CLASH_SPEC
++# ifdef DIST_DEFAULT_STACK_CLASH
++# define STACK_CLASH_SPEC " %{!fno-stack-clash-protection:-fstack-clash-protection}"
++# else
++# define STACK_CLASH_SPEC ""
++# endif
++#endif
++
++/* Enable code instrumentation of control-flow transfers.
++ Available on x86 and x86_64. */
++#ifndef CF_PROTECTION_SPEC
++# ifdef DIST_DEFAULT_CF_PROTECTION
++# define CF_PROTECTION_SPEC " %{!m16:%{!m32:%{!fcf-protection*:%{!fno-cf-protection:-fcf-protection}}}}"
++# else
++# define CF_PROTECTION_SPEC ""
++# endif
++#endif
++
++#ifndef BIND_NOW_SPEC
++# if defined(DIST_DEFAULT_BIND_NOW) && !defined(ACCEL_COMPILER)
++# define BIND_NOW_SPEC " -z now"
++# else
++# define BIND_NOW_SPEC ""
++# endif
++#endif
++
++#ifndef RELRO_SPEC
++# ifdef DIST_DEFAULT_RELRO
++# define RELRO_SPEC " -z relro "
++# else
++# define RELRO_SPEC ""
++# endif
++#endif
++
++/* Don't enable any of those for the offload compilers,
++ unsupported. */
++#if !defined(DISTRO_DEFAULT_SPEC) && !defined(ACCEL_COMPILER)
++# define DISTRO_DEFAULT_SPEC ASYNC_UNWIND_SPEC SSP_DEFAULT_SPEC \
++ FORMAT_SECURITY_SPEC STACK_CLASH_SPEC CF_PROTECTION_SPEC
++#else
++# define DISTRO_DEFAULT_SPEC ""
++#endif
++#if !defined(DISTRO_DEFAULT_LINK_SPEC) && !defined(ACCEL_COMPILER)
++# define DISTRO_DEFAULT_LINK_SPEC RELRO_SPEC
++#else
++# define DISTRO_DEFAULT_LINK_SPEC ""
++#endif
++
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+@@ -1040,7 +1129,7 @@ proper position among the other output f
+ #ifndef LINK_PIE_SPEC
+ #ifdef HAVE_LD_PIE
+ #ifndef LD_PIE_SPEC
+-#define LD_PIE_SPEC "-pie"
++#define LD_PIE_SPEC "-pie" BIND_NOW_SPEC
+ #endif
+ #else
+ #define LD_PIE_SPEC ""
+@@ -1157,6 +1246,7 @@ proper position among the other output f
+ "%{flto|flto=*:%<fcompare-debug*} \
+ %{flto} %{fno-lto} %{flto=*} %l " LINK_PIE_SPEC \
+ "%{fuse-ld=*:-fuse-ld=%*} " LINK_COMPRESS_DEBUG_SPEC \
++ DISTRO_DEFAULT_LINK_SPEC \
+ "%X %{o*} %{e*} %{N} %{n} %{r}\
+ %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!r:%{!nostartfiles:%S}}} \
+ %{static|no-pie|static-pie:} %@{L*} %(link_libgcc) " \
+@@ -1201,6 +1291,7 @@ static const char *cpp_spec = CPP_SPEC;
+ static const char *cc1_spec = CC1_SPEC OS_CC1_SPEC;
+ static const char *cc1plus_spec = CC1PLUS_SPEC;
+ static const char *link_gcc_c_sequence_spec = LINK_GCC_C_SEQUENCE_SPEC;
++static const char *distro_default_spec = DISTRO_DEFAULT_SPEC;
+ static const char *link_ssp_spec = LINK_SSP_SPEC;
+ static const char *asm_spec = ASM_SPEC;
+ static const char *asm_final_spec = ASM_FINAL_SPEC;
+@@ -1261,7 +1352,7 @@ static const char *cpp_options =
+ "%(cpp_unique_options) %1 %{m*} %{std*&ansi&trigraphs} %{W*&pedantic*} %{w}\
+ %{f*} %{g*:%{%:debug-level-gt(0):%{g*}\
+ %{!fno-working-directory:-fworking-directory}}} %{O*}\
+- %{undef} %{save-temps*:-fpch-preprocess}";
++ %{undef} %{save-temps*:-fpch-preprocess} %(distro_defaults)";
+
+ /* Pass -d* flags, possibly modifying -dumpdir, -dumpbase et al.
+
+@@ -1455,9 +1546,9 @@ static const struct compiler default_com
+ %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \
+ %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\
+ cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \
+- %(cc1_options)}\
++ %(cc1_options)%(distro_defaults)}\
+ %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\
+- cc1 %(cpp_unique_options) %(cc1_options)}}}\
++ cc1 %(cpp_unique_options) %(cc1_options) %(distro_defaults)}}}\
+ %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 1},
+ {"-",
+ "%{!E:%e-E or -x required when input is from standard input}\
+@@ -1471,18 +1562,18 @@ static const struct compiler default_com
+ %{save-temps*|traditional-cpp|no-integrated-cpp:%(trad_capable_cpp) \
+ %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\
+ cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \
+- %(cc1_options)\
++ %(cc1_options) %(distro_defaults)\
+ %{!fsyntax-only:%{!S:-o %g.s} \
+ %{!fdump-ada-spec*:%{!o*:--output-pch %w%i.gch}\
+ %W{o*:--output-pch %w%*}}%{!S:%V}}}\
+ %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\
+- cc1 %(cpp_unique_options) %(cc1_options)\
++ cc1 %(cpp_unique_options) %(cc1_options) %(distro_defaults)\
+ %{!fsyntax-only:%{!S:-o %g.s} \
+ %{!fdump-ada-spec*:%{!o*:--output-pch %w%i.gch}\
+ %W{o*:--output-pch %w%*}}%{!S:%V}}}}}}}}", 0, 0, 0},
+ {".i", "@cpp-output", 0, 0, 0},
+ {"@cpp-output",
+- "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
++ "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %(distro_defaults) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
+ {".s", "@assembler", 0, 0, 0},
+ {"@assembler",
+ "%{!M:%{!MM:%{!E:%{!S:as %(asm_debug) %(asm_options) %i %A }}}}", 0, 0, 0},
+@@ -1714,6 +1805,7 @@ static struct spec_list static_specs[] =
+ INIT_STATIC_SPEC ("cc1_options", &cc1_options),
+ INIT_STATIC_SPEC ("cc1plus", &cc1plus_spec),
+ INIT_STATIC_SPEC ("link_gcc_c_sequence", &link_gcc_c_sequence_spec),
++ INIT_STATIC_SPEC ("distro_defaults", &distro_default_spec),
+ INIT_STATIC_SPEC ("link_ssp", &link_ssp_spec),
+ INIT_STATIC_SPEC ("endfile", &endfile_spec),
+ INIT_STATIC_SPEC ("link", &link_spec),
+--- a/src/gcc/cp/lang-specs.h
++++ b/src/gcc/cp/lang-specs.h
+@@ -51,7 +51,7 @@ along with GCC; see the file COPYING3.
+ " %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}"
+ " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}"
+ " %{fmodules-ts:-fmodule-header %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(distro_defaults) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -72,7 +72,7 @@ along with GCC; see the file COPYING3.
+ " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}"
+ " %{fmodules-ts:-fmodule-header=system"
+ " %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(distro_defaults) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -92,7 +92,7 @@ along with GCC; see the file COPYING3.
+ " %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}"
+ " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}"
+ " %{fmodules-ts:-fmodule-header=user %{fpreprocessed:-fdirectives-only}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(distro_defaults) %2"
+ " %{!fsyntax-only:"
+ " %{!S:-o %g.s}"
+ " %{!fmodule-*:%{!fmodules-*:%{!fdump-ada-spec*:"
+@@ -107,7 +107,7 @@ along with GCC; see the file COPYING3.
+ " cc1plus %{save-temps*|no-integrated-cpp:-fpreprocessed"
+ " %{save-temps*:%b.ii} %{!save-temps*:%g.ii}}"
+ " %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}"
+- " %(cc1_options) %2"
++ " %(cc1_options) %(distro_defaults) %2"
+ " %{!fsyntax-only:"
+ " %{fmodule-only:%{!S:-o %g.s%V}}"
+ " %{!fmodule-only:%(invoke_as)}}"
+@@ -116,7 +116,7 @@ along with GCC; see the file COPYING3.
+ {".ii", "@c++-cpp-output", 0, 0, 0},
+ {"@c++-cpp-output",
+ "%{!E:%{!M:%{!MM:"
+- " cc1plus -fpreprocessed %i %(cc1_options) %2"
++ " cc1plus -fpreprocessed %i %(cc1_options) %(distro_defaults) %2"
+ " %{!fsyntax-only:"
+ " %{fmodule-only:%{!S:-o %g.s%V}}"
+ " %{!fmodule-only:%{!fmodule-header*:%(invoke_as)}}}"
+--- a/src/gcc/objc/lang-specs.h
++++ b/src/gcc/objc/lang-specs.h
+@@ -29,9 +29,9 @@ along with GCC; see the file COPYING3.
+ %{traditional|traditional-cpp:\
+ %eGNU Objective C no longer supports traditional compilation}\
+ %{save-temps*|no-integrated-cpp:cc1obj -E %(cpp_options) -o %{save-temps*:%b.mi} %{!save-temps*:%g.mi} \n\
+- cc1obj -fpreprocessed %{save-temps*:%b.mi} %{!save-temps*:%g.mi} %(cc1_options) %{print-objc-runtime-info} %{gen-decls}}\
++ cc1obj -fpreprocessed %{save-temps*:%b.mi} %{!save-temps*:%g.mi} %(cc1_options) %(distro_defaults) %{print-objc-runtime-info} %{gen-decls}}\
+ %{!save-temps*:%{!no-integrated-cpp:\
+- cc1obj %(cpp_unique_options) %(cc1_options) %{print-objc-runtime-info} %{gen-decls}}}\
++ cc1obj %(cpp_unique_options) %(cc1_options) %(distro_defaults) %{print-objc-runtime-info} %{gen-decls}}}\
+ %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
+ {"@objective-c-header",
+ "%{E|M|MM:cc1obj -E %{traditional|traditional-cpp:-traditional-cpp}\
+@@ -40,7 +40,7 @@ along with GCC; see the file COPYING3.
+ %{traditional|traditional-cpp:\
+ %eGNU Objective C no longer supports traditional compilation}\
+ %{save-temps*|no-integrated-cpp:cc1obj -E %(cpp_options) -o %{save-temps*:%b.mi} %{!save-temps*:%g.mi} \n\
+- cc1obj -fpreprocessed %b.mi %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\
++ cc1obj -fpreprocessed %b.mi %(cc1_options) %(distro_defaults) %{print-objc-runtime-info} %{gen-decls}\
+ -o %g.s %{!o*:--output-pch %i.gch}\
+ %W{o*:--output-pch %*}%V}\
+ %{!save-temps*:%{!no-integrated-cpp:\
+@@ -49,9 +49,9 @@ along with GCC; see the file COPYING3.
+ %W{o*:--output-pch %*}%V}}}}}", 0, 0, 0},
+ {".mi", "@objective-c-cpp-output", 0, 0, 0},
+ {"@objective-c-cpp-output",
+- "%{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\
++ "%{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %(distro_defaults) %{print-objc-runtime-info} %{gen-decls}\
+ %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
+ {"@objc-cpp-output",
+ "%nobjc-cpp-output is deprecated; please use objective-c-cpp-output instead\n\
+- %{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %{print-objc-runtime-info} %{gen-decls}\
++ %{!M:%{!MM:%{!E:cc1obj -fpreprocessed %i %(cc1_options) %(distro_defaults) %{print-objc-runtime-info} %{gen-decls}\
+ %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
+--- a/src/gcc/objcp/lang-specs.h
++++ b/src/gcc/objcp/lang-specs.h
+@@ -36,7 +36,7 @@ along with GCC; see the file COPYING3.
+ %(cpp_options) %2 -o %{save-temps*:%b.mii} %{!save-temps*:%g.mii} \n}\
+ cc1objplus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.mii} %{!save-temps*:%g.mii}}\
+ %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\
+- %(cc1_options) %2\
++ %(cc1_options) %(distro_defaults) %2\
+ -o %g.s %{!o*:--output-pch %i.gch} %W{o*:--output-pch %*}%V}}}",
+ CPLUSPLUS_CPP_SPEC, 0, 0},
+ {"@objective-c++",
+@@ -46,16 +46,16 @@ along with GCC; see the file COPYING3.
+ %(cpp_options) %2 -o %{save-temps*:%b.mii} %{!save-temps*:%g.mii} \n}\
+ cc1objplus %{save-temps*|no-integrated-cpp:-fpreprocessed %{save-temps*:%b.mii} %{!save-temps*:%g.mii}}\
+ %{!save-temps*:%{!no-integrated-cpp:%(cpp_unique_options)}}\
+- %(cc1_options) %2\
++ %(cc1_options) %(distro_defaults) %2\
+ %{!fsyntax-only:%(invoke_as)}}}}",
+ CPLUSPLUS_CPP_SPEC, 0, 0},
+ {".mii", "@objective-c++-cpp-output", 0, 0, 0},
+ {"@objective-c++-cpp-output",
+ "%{!M:%{!MM:%{!E:\
+- cc1objplus -fpreprocessed %i %(cc1_options) %2\
++ cc1objplus -fpreprocessed %i %(cc1_options) %(distro_defaults) %2\
+ %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
+ {"@objc++-cpp-output",
+ "%nobjc++-cpp-output is deprecated; please use objective-c++-cpp-output instead\n\
+ %{!M:%{!MM:%{!E:\
+- cc1objplus -fpreprocessed %i %(cc1_options) %2\
++ cc1objplus -fpreprocessed %i %(cc1_options) %(distro_defaults) %2\
+ %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
+--- a/src/gcc/c-family/c-cppbuiltin.cc
++++ b/src/gcc/c-family/c-cppbuiltin.cc
+@@ -34,6 +34,11 @@ along with GCC; see the file COPYING3.
+ #include "cppbuiltin.h"
+ #include "configargs.h"
+
++/* Inject some default compilation flags which are used as the default.
++ Done by the packaging build system. Should that be done in the headers
++ in gcc/config/<arch>/ instead? */
++#include "distro-defaults.h"
++
+ #ifndef TARGET_OS_CPP_BUILTINS
+ # define TARGET_OS_CPP_BUILTINS()
+ #endif
+@@ -1578,6 +1583,15 @@ c_cpp_builtins (cpp_reader *pfile)
+ builtin_define_with_value ("__REGISTER_PREFIX__", REGISTER_PREFIX, 0);
+ builtin_define_with_value ("__USER_LABEL_PREFIX__", user_label_prefix, 0);
+
++#ifdef DIST_DEFAULT_FORTIFY_SOURCE
++ /* Fortify Source enabled by default for optimization levels > 0 */
++ if (optimize &&
++ !cpp_defined(parse_in,
++ (const unsigned char *) "_FORTIFY_SOURCE",
++ strlen("_FORTIFY_SOURCE")))
++ builtin_define_with_int_value ("_FORTIFY_SOURCE", DIST_DEFAULT_FORTIFY_SOURCE);
++#endif
++
+ /* Misc. */
+ if (flag_gnu89_inline)
+ cpp_define (pfile, "__GNUC_GNU_INLINE__");
diff --git a/debian/patches/gcc-driver-extra-langs.diff b/debian/patches/gcc-driver-extra-langs.diff
new file mode 100644
index 0000000..5620382
--- /dev/null
+++ b/debian/patches/gcc-driver-extra-langs.diff
@@ -0,0 +1,20 @@
+# DP: Add options and specs for languages that are not built from a source
+# DP: (but built from separate sources).
+
+---
+ gcc/Makefile.in | 4 ++--
+ 1 files changed, 2 insertions(+), 2 deletions(-)
+
+--- a/src/gcc/Makefile.in
++++ b/src/gcc/Makefile.in
+@@ -620,8 +620,8 @@ xm_include_list=@xm_include_list@
+ xm_defines=@xm_defines@
+ lang_checks=
+ lang_checks_parallelized=
+-lang_opt_files=@lang_opt_files@ $(srcdir)/c-family/c.opt $(srcdir)/common.opt $(srcdir)/params.opt $(srcdir)/analyzer/analyzer.opt
+-lang_specs_files=@lang_specs_files@
++lang_opt_files=@lang_opt_files@ $(srcdir)/c-family/c.opt $(srcdir)/common.opt $(srcdir)/params.opt $(srcdir)/analyzer/analyzer.opt $(foreach lang,$(subst ada,ada/gcc-interface,$(debian_extra_langs)),$(srcdir)/$(lang)/lang.opt)
++lang_specs_files=@lang_specs_files@ $(foreach lang,$(subst ada,ada/gcc-interface,$(debian_extra_langs)),$(srcdir)/$(lang)/lang-specs.h)
+ lang_tree_files=@lang_tree_files@
+ target_cpu_default=@target_cpu_default@
+ OBJC_BOEHM_GC=@objc_boehm_gc@
diff --git a/debian/patches/gcc-foffload-default.diff b/debian/patches/gcc-foffload-default.diff
new file mode 100644
index 0000000..644c3fa
--- /dev/null
+++ b/debian/patches/gcc-foffload-default.diff
@@ -0,0 +1,120 @@
+# DP: Allow setting offload targets by OFFLOAD_TARGET_DEFAULT
+
+https://src.fedoraproject.org/rpms/gcc/raw/rawhide/f/gcc11-foffload-default.patch
+
+2019-01-17 Jakub Jelinek <jakub@redhat.com>
+
+ * gcc.c (offload_targets_default): New variable.
+ (process_command): Set it if -foffload is defaulted.
+ (driver::maybe_putenv_OFFLOAD_TARGETS): Add OFFLOAD_TARGET_DEFAULT=1
+ into environment if -foffload has been defaulted.
+ * lto-wrapper.c (OFFLOAD_TARGET_DEFAULT_ENV): Define.
+ (compile_offload_image): If OFFLOAD_TARGET_DEFAULT
+ is in the environment, don't fail if corresponding mkoffload
+ can't be found.
+ (compile_images_for_offload_targets): Likewise. Free and clear
+ offload_names if no valid offload is found.
+libgomp/
+ * target.c (gomp_load_plugin_for_device): If a plugin can't be
+ dlopened, assume it has no devices silently.
+
+--- a/src/gcc/gcc.c
++++ b/src/gcc/gcc.c
+@@ -324,6 +324,10 @@ static const char *spec_host_machine = D
+
+ static char *offload_targets = NULL;
+
++/* Set to true if -foffload has not been used and offload_targets
++ is set to the configured in default. */
++static bool offload_targets_default;
++
+ /* Nonzero if cross-compiling.
+ When -b is used, the value comes from the `specs' file. */
+
+@@ -5058,7 +5062,10 @@ process_command (unsigned int decoded_op
+ /* If the user didn't specify any, default to all configured offload
+ targets. */
+ if (ENABLE_OFFLOADING && offload_targets == NULL)
+- handle_foffload_option (OFFLOAD_TARGETS);
++ {
++ handle_foffload_option (OFFLOAD_TARGETS);
++ offload_targets_default = true;
++ }
+
+ /* Handle -gtoggle as it would later in toplev.c:process_options to
+ make the debug-level-gt spec function work as expected. */
+@@ -8758,6 +8765,8 @@ driver::maybe_putenv_OFFLOAD_TARGETS ()
+ obstack_grow (&collect_obstack, offload_targets,
+ strlen (offload_targets) + 1);
+ xputenv (XOBFINISH (&collect_obstack, char *));
++ if (offload_targets_default)
++ xputenv ("OFFLOAD_TARGET_DEFAULT=1");
+ }
+
+ free (offload_targets);
+--- a/src/gcc/lto-wrapper.c
++++ b/src/gcc/lto-wrapper.c
+@@ -52,6 +52,7 @@ along with GCC; see the file COPYING3.
+ /* Environment variable, used for passing the names of offload targets from GCC
+ driver to lto-wrapper. */
+ #define OFFLOAD_TARGET_NAMES_ENV "OFFLOAD_TARGET_NAMES"
++#define OFFLOAD_TARGET_DEFAULT_ENV "OFFLOAD_TARGET_DEFAULT"
+
+ /* By default there is no special suffix for target executables. */
+ #ifdef TARGET_EXECUTABLE_SUFFIX
+@@ -907,6 +908,12 @@ compile_offload_image (const char *targe
+ break;
+ }
+
++ if (!compiler && getenv (OFFLOAD_TARGET_DEFAULT_ENV))
++ {
++ free_array_of_ptrs ((void **) paths, n_paths);
++ return NULL;
++ }
++
+ if (!compiler)
+ fatal_error (input_location,
+ "could not find %s in %s (consider using %<-B%>)",
+@@ -976,6 +983,7 @@ compile_images_for_offload_targets (unsi
+ if (!target_names)
+ return;
+ unsigned num_targets = parse_env_var (target_names, &names, NULL);
++ int next_name_entry = 0;
+
+ const char *compiler_path = getenv ("COMPILER_PATH");
+ if (!compiler_path)
+@@ -986,13 +994,19 @@ compile_images_for_offload_targets (unsi
+ offload_names = XCNEWVEC (char *, num_targets + 1);
+ for (unsigned i = 0; i < num_targets; i++)
+ {
+- offload_names[i]
++ offload_names[next_name_entry]
+ = compile_offload_image (names[i], compiler_path, in_argc, in_argv,
+ compiler_opts, compiler_opt_count,
+ linker_opts, linker_opt_count);
+- if (!offload_names[i])
+- fatal_error (input_location,
+- "problem with building target image for %s", names[i]);
++ if (!offload_names[next_name_entry])
++ continue;
++ next_name_entry++;
++ }
++
++ if (next_name_entry == 0)
++ {
++ free (offload_names);
++ offload_names = NULL;
+ }
+
+ out:
+--- a/src/libgomp/target.c
++++ b/src/libgomp/target.c
+@@ -3173,7 +3173,7 @@ gomp_load_plugin_for_device (struct gomp
+
+ void *plugin_handle = dlopen (plugin_name, RTLD_LAZY);
+ if (!plugin_handle)
+- goto dl_fail;
++ return 0;
+
+ /* Check if all required functions are available in the plugin and store
+ their handlers. None of the symbols can legitimately be NULL,
diff --git a/debian/patches/gcc-force-cross-layout.diff b/debian/patches/gcc-force-cross-layout.diff
new file mode 100644
index 0000000..3f969e8
--- /dev/null
+++ b/debian/patches/gcc-force-cross-layout.diff
@@ -0,0 +1,49 @@
+# DP: Add FORCE_CROSS_LAYOUT env var to force a cross directory layout.
+
+--- a/src/configure.ac
++++ b/src/configure.ac
+@@ -3460,7 +3460,7 @@ target_configargs="$target_configargs ${
+ # native. However, it would be better to use other mechanisms to make the
+ # sorts of decisions they want to make on this basis. Please consider
+ # this option to be deprecated. FIXME.
+-if test x${is_cross_compiler} = xyes ; then
++if test x${is_cross_compiler} = xyes || test x${FORCE_CROSS_LAYOUT} = xyes; then
+ target_configargs="--with-cross-host=${host_noncanonical} ${target_configargs}"
+ fi
+
+--- a/src/gcc/configure.ac
++++ b/src/gcc/configure.ac
+@@ -2494,14 +2494,14 @@ SYSTEM_HEADER_DIR='$(NATIVE_SYSTEM_HEADE
+ BUILD_SYSTEM_HEADER_DIR=$SYSTEM_HEADER_DIR AC_SUBST(BUILD_SYSTEM_HEADER_DIR)
+
+ if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x ||
+- test x$build != x$host || test "x$with_build_sysroot" != x; then
++ test x$build != x$host || test "x$with_build_sysroot" != x || test x$FORCE_CROSS_LAYOUT = xyes; then
+ if test "x$with_build_sysroot" != x; then
+ BUILD_SYSTEM_HEADER_DIR=$with_build_sysroot'$${sysroot_headers_suffix}$(NATIVE_SYSTEM_HEADER_DIR)'
+ else
+ BUILD_SYSTEM_HEADER_DIR='$(CROSS_SYSTEM_HEADER_DIR)'
+ fi
+
+- if test x$host != x$target
++ if test x$host != x$target || test x$FORCE_CROSS_LAYOUT = xyes
+ then
+ CROSS="-DCROSS_DIRECTORY_STRUCTURE"
+ ALL=all.cross
+@@ -7497,14 +7497,14 @@ AC_SUBST_FILE(language_hooks)
+
+ # Echo link setup.
+ if test x${build} = x${host} ; then
+- if test x${host} = x${target} ; then
++ if test x${host} = x${target} && test x$FORCE_CROSS_LAYOUT != xyes ; then
+ echo "Links are now set up to build a native compiler for ${target}." 1>&2
+ else
+ echo "Links are now set up to build a cross-compiler" 1>&2
+ echo " from ${host} to ${target}." 1>&2
+ fi
+ else
+- if test x${host} = x${target} ; then
++ if test x${host} = x${target} && test x$FORCE_CROSS_LAYOUT != xyes ; then
+ echo "Links are now set up to build (on ${build}) a native compiler" 1>&2
+ echo " for ${target}." 1>&2
+ else
diff --git a/debian/patches/gcc-gfdl-build.diff b/debian/patches/gcc-gfdl-build.diff
new file mode 100644
index 0000000..bce5776
--- /dev/null
+++ b/debian/patches/gcc-gfdl-build.diff
@@ -0,0 +1,39 @@
+# DP: Build a dummy s-tm-texi without access to the texinfo sources
+
+--- a/src/gcc/Makefile.in
++++ b/src/gcc/Makefile.in
+@@ -2746,32 +2746,8 @@ s-tm-texi: $(srcdir)/doc/../doc/tm.texi
+ # \r is not portable to Solaris tr, therefore we have a special
+ # case for ASCII. We use \r for other encodings like EBCDIC.
+ s-tm-texi: build/genhooks$(build_exeext) $(srcdir)/doc/tm.texi.in
+- $(RUN_GEN) build/genhooks$(build_exeext) -d \
+- $(srcdir)/doc/tm.texi.in > tmp-tm.texi
+- case `echo X|tr X '\101'` in \
+- A) tr -d '\015' < tmp-tm.texi > tmp2-tm.texi ;; \
+- *) tr -d '\r' < tmp-tm.texi > tmp2-tm.texi ;; \
+- esac
+- mv tmp2-tm.texi tmp-tm.texi
+- $(SHELL) $(srcdir)/../move-if-change tmp-tm.texi tm.texi
+- @if cmp -s $(srcdir)/doc/tm.texi tm.texi; then \
+- $(STAMP) $@; \
+- 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 \
+- || test $(srcdir)/doc/tm.texi -nt $(srcdir)/d/d-target.def \
+- || test $(srcdir)/doc/tm.texi -nt $(srcdir)/rust/rust-target.def \
+- ); then \
+- echo >&2 ; \
+- echo You should edit $(srcdir)/doc/tm.texi.in rather than $(srcdir)/doc/tm.texi . >&2 ; \
+- false; \
+- else \
+- echo >&2 ; \
+- echo Verify that you have permission to grant a GFDL license for all >&2 ; \
+- echo new text in $(objdir)/tm.texi, then copy it to $(srcdir)/doc/tm.texi. >&2 ; \
+- false; \
+- fi
++ cat $(srcdir)/doc/tm.texi.in > tmp-tm.texi
++ $(STAMP) $@
+
+ $(GIMPLE_MATCH_PD_SEQ_SRC): s-gimple-match gimple-match-head.cc; @true
+ gimple-match-auto.h: s-gimple-match; @true
diff --git a/debian/patches/gcc-hash-style-gnu.diff b/debian/patches/gcc-hash-style-gnu.diff
new file mode 100644
index 0000000..a6e0c85
--- /dev/null
+++ b/debian/patches/gcc-hash-style-gnu.diff
@@ -0,0 +1,164 @@
+# DP: Link using --hash-style=gnu (aarch64, alpha, amd64, armel, armhf, ia64,
+# DP: i386, powerpc, ppc64, riscv64, s390, sparc)
+
+2006-07-11 Jakub Jelinek <jakub@redhat.com>
+
+ * config/i386/linux.h (LINK_SPEC): Add --hash-style=gnu.
+ * config/i386/linux64.h (LINK_SPEC): Likewise.
+ * config/rs6000/sysv4.h (LINK_OS_LINUX_SPEC): Likewise.
+ * config/rs6000/linux64.h (LINK_OS_LINUX_SPEC32,
+ LINK_OS_LINUX_SPEC64): Likewise.
+ * config/s390/linux.h (LINK_SPEC): Likewise.
+ * config/ia64/linux.h (LINK_SPEC): Likewise.
+ * config/sparc/linux.h (LINK_SPEC): Likewise.
+ * config/sparc/linux64.h (LINK_SPEC, LINK_ARCH32_SPEC,
+ LINK_ARCH64_SPEC): Likewise.
+ * config/alpha/linux-elf.h (LINK_SPEC): Likewise.
+
+2009-12-21 Matthias Klose <doko@ubuntu.com>
+
+ * config/arm/linux-elf.h (LINK_SPEC): Add --hash-style=gnu.
+
+2012-11-17 Matthias Klose <doko@ubuntu.com>
+
+ * config/aarch64/aarch64-linux.h (LINK_SPEC): Add --hash-style=gnu.
+
+2018-03-02 Aurelien Jarno <aurelien@aurel32.net>
+
+ * config/riscv/linux.h (LINK_SPEC): Add --hash-style=gnu.
+
+---
+ gcc/config/alpha/linux-elf.h | 2 +-
+ gcc/config/i386/linux.h | 2 +-
+ gcc/config/i386/linux64.h | 2 +-
+ gcc/config/ia64/linux.h | 2 +-
+ gcc/config/rs6000/linux64.h | 4 ++--
+ gcc/config/rs6000/sysv4.h | 2 +-
+ gcc/config/s390/linux.h | 2 +-
+ gcc/config/sparc/linux.h | 2 +-
+ 8 files changed, 9 insertions(+), 9 deletions(-)
+
+--- a/src/gcc/config/alpha/linux-elf.h
++++ b/src/gcc/config/alpha/linux-elf.h
+@@ -37,7 +37,7 @@ along with GCC; see the file COPYING3.
+
+ #define ELF_DYNAMIC_LINKER GNU_USER_DYNAMIC_LINKER
+
+-#define LINK_SPEC "-m elf64alpha %{G*} %{relax:-relax} \
++#define LINK_SPEC "-m elf64alpha --hash-style=gnu %{G*} %{relax:-relax} \
+ %{O*:-O3} %{!O*:-O1} \
+ %{shared:-shared} \
+ %{!shared: \
+--- a/src/gcc/config/ia64/linux.h
++++ b/src/gcc/config/ia64/linux.h
+@@ -58,7 +58,7 @@ do { \
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux-ia64.so.2"
+
+ #undef LINK_SPEC
+-#define LINK_SPEC "\
++#define LINK_SPEC " --hash-style=gnu \
+ %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+--- a/src/gcc/config/rs6000/linux64.h
++++ b/src/gcc/config/rs6000/linux64.h
+@@ -378,13 +378,13 @@ extern int dot_symbols;
+ " -m elf64ppc")
+ #endif
+
+-#define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " %{!shared: %{!static: \
++#define LINK_OS_LINUX_SPEC32 LINK_OS_LINUX_EMUL32 " --hash-style=gnu %{!shared: %{!static: \
+ %{!static-pie: \
+ %{rdynamic:-export-dynamic} \
+ -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}}} \
+ %(link_os_extra_spec32)"
+
+-#define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " %{!shared: %{!static: \
++#define LINK_OS_LINUX_SPEC64 LINK_OS_LINUX_EMUL64 " --hash-style=gnu %{!shared: %{!static: \
+ %{!static-pie: \
+ %{rdynamic:-export-dynamic} \
+ -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "}}} \
+--- a/src/gcc/config/rs6000/sysv4.h
++++ b/src/gcc/config/rs6000/sysv4.h
+@@ -780,7 +780,7 @@ GNU_USER_TARGET_CC1_SPEC
+ #define GNU_USER_DYNAMIC_LINKER GLIBC_DYNAMIC_LINKER
+ #endif
+
+-#define LINK_OS_LINUX_SPEC "-m elf32ppclinux %{!shared: %{!static: \
++#define LINK_OS_LINUX_SPEC "-m elf32ppclinux --hash-style=gnu %{!shared: %{!static: \
+ %{rdynamic:-export-dynamic} \
+ -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}"
+
+--- a/src/gcc/config/s390/linux.h
++++ b/src/gcc/config/s390/linux.h
+@@ -82,7 +82,7 @@ along with GCC; see the file COPYING3.
+
+ #undef LINK_SPEC
+ #define LINK_SPEC \
+- "%{m31:-m elf_s390}%{m64:-m elf64_s390} \
++ "%{m31:-m elf_s390}%{m64:-m elf64_s390} --hash-style=gnu \
+ %{shared:-shared} \
+ %{!shared: \
+ %{static:-static} \
+--- a/src/gcc/config/sparc/linux.h
++++ b/src/gcc/config/sparc/linux.h
+@@ -81,7 +81,7 @@ extern const char *host_detect_local_cpu
+ #define GLIBC_DYNAMIC_LINKER "/lib/ld-linux.so.2"
+
+ #undef LINK_SPEC
+-#define LINK_SPEC "-m elf32_sparc %{shared:-shared} \
++#define LINK_SPEC "-m elf32_sparc --hash-style=gnu %{shared:-shared} \
+ %{!mno-relax:%{!r:-relax}} \
+ %{!shared: \
+ %{!static: \
+--- a/src/gcc/config/arm/linux-elf.h
++++ b/src/gcc/config/arm/linux-elf.h
+@@ -70,6 +70,7 @@
+ %{rdynamic:-export-dynamic} \
+ %{!shared:-dynamic-linker " GNU_USER_DYNAMIC_LINKER "}} \
+ -X \
++ --hash-style=gnu \
+ %{mbig-endian:-EB} %{mlittle-endian:-EL}" \
+ SUBTARGET_EXTRA_LINK_SPEC
+
+--- a/src/gcc/config/i386/gnu-user.h
++++ b/src/gcc/config/i386/gnu-user.h
+@@ -68,7 +68,7 @@ along with GCC; see the file COPYING3.
+ { "link_emulation", GNU_USER_LINK_EMULATION },\
+ { "dynamic_linker", GNU_USER_DYNAMIC_LINKER }
+
+-#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) %{shared:-shared} \
++#define GNU_USER_TARGET_LINK_SPEC "-m %(link_emulation) --hash-style=gnu %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+ %{!static-pie: \
+--- a/src/gcc/config/i386/gnu-user64.h
++++ b/src/gcc/config/i386/gnu-user64.h
+@@ -56,6 +56,7 @@ see the files COPYING3 and COPYING.RUNTI
+ "%{" SPEC_64 ":-m " GNU_USER_LINK_EMULATION64 "} \
+ %{" SPEC_32 ":-m " GNU_USER_LINK_EMULATION32 "} \
+ %{" SPEC_X32 ":-m " GNU_USER_LINK_EMULATIONX32 "} \
++ --hash-style=gnu \
+ %{shared:-shared} \
+ %{!shared: \
+ %{!static: \
+--- a/src/gcc/config/aarch64/aarch64-linux.h
++++ b/src/gcc/config/aarch64/aarch64-linux.h
+@@ -35,6 +35,7 @@
+ #define CPP_SPEC "%{pthread:-D_REENTRANT}"
+
+ #define LINUX_TARGET_LINK_SPEC "%{h*} \
++ --hash-style=gnu \
+ %{static:-Bstatic} \
+ %{shared:-shared} \
+ %{symbolic:-Bsymbolic} \
+--- a/src/gcc/config/riscv/linux.h
++++ b/src/gcc/config/riscv/linux.h
+@@ -48,6 +48,7 @@ along with GCC; see the file COPYING3.
+ "%{mabi=ilp32:_ilp32}"
+
+ #define LINK_SPEC "\
++-hash-style=gnu \
+ -melf" XLEN_SPEC DEFAULT_ENDIAN_SPEC "riscv" LD_EMUL_SUFFIX " \
+ %{mno-relax:--no-relax} \
+ %{mbig-endian:-EB} \
diff --git a/debian/patches/gcc-ice-apport.diff b/debian/patches/gcc-ice-apport.diff
new file mode 100644
index 0000000..fca0d23
--- /dev/null
+++ b/debian/patches/gcc-ice-apport.diff
@@ -0,0 +1,39 @@
+# DP: Report an ICE to apport (if apport is available
+# DP: and the environment variable GCC_NOAPPORT is not set)
+
+--- a/src/gcc/gcc.cc
++++ b/src/gcc/gcc.cc
+@@ -8090,13 +8090,16 @@ do_report_bug (const char **new_argv, co
+ if (status == ATTEMPT_STATUS_SUCCESS)
+ {
+ const bool gcc_dump = has_deb_build_options ("gcc-ice", "nodump");
++ const bool gcc_apport
++ = !env.get ("GCC_NOAPPORT")
++ && !access ("/usr/share/apport/gcc_ice_hook", R_OK | X_OK);
+
+ if (gcc_dump)
+ fnotice (stderr,
+ "Preprocessed source stored into %s file,"
+ " please attach this to your bugreport.\n",
+ *out_file);
+- if (gcc_dump)
++ if (gcc_dump || gcc_apport)
+ {
+ char *cmd = XNEWVEC (char, 50 + strlen (*out_file));
+
+@@ -8110,6 +8113,15 @@ do_report_bug (const char **new_argv, co
+ fflush (stderr);
+ free (cmd);
+ }
++ if (gcc_apport)
++ {
++ char *cmd
++ = XNEWVEC (char, 50 + strlen (*out_file) + strlen (new_argv[0]));
++ sprintf (cmd, "/usr/share/apport/gcc_ice_hook %s %s", new_argv[0],
++ *out_file);
++ system (cmd);
++ free (cmd);
++ }
+ /* Make sure it is not deleted. */
+ free (*out_file);
+ *out_file = NULL;
diff --git a/debian/patches/gcc-ice-dump.diff b/debian/patches/gcc-ice-dump.diff
new file mode 100644
index 0000000..c58b54b
--- /dev/null
+++ b/debian/patches/gcc-ice-dump.diff
@@ -0,0 +1,111 @@
+# DP: For ICEs, dump the preprocessed source file to stderr
+# DP: when in a distro build environment.
+
+--- a/src/gcc/gcc.cc
++++ b/src/gcc/gcc.cc
+@@ -3117,6 +3117,61 @@ access_check (const char *name, int mode
+ return access (name, mode);
+ }
+
++/* Check whether options line contains the specified variable, and
++ optionally set to the supplied value */
++
++static bool
++check_options (const char *options, const char *var = nullptr,
++ const char *val = nullptr)
++{
++ if (!var)
++ return false;
++
++ const char *const var_found = strstr (options, var);
++ if (!var_found)
++ return false;
++
++ if (val)
++ {
++ if (var_found[strlen (var)] != '=')
++ return false;
++
++ const char *var_end = strchr (var_found, ' ');
++ if (!var_end)
++ var_end = strchr (var_found, '\0');
++
++ const char *const val_found = strstr (var_found, val);
++ if (!val_found || val_found > var_end)
++ return false;
++
++ const char c0 = val_found[-1];
++ const char c1 = val_found[strlen (val)];
++ if ((c0 == '=' || c0 == ',') && (c1 == ',' || c1 == ' ' || c1 == '\0'))
++ return true;
++ }
++ else
++ {
++ const char c1 = var_found[strlen (var)];
++ if (c1 == ' ' || c1 == '\0')
++ return true;
++ }
++ return false;
++}
++
++/* Check whether DEB_BUILD_OPTIONS environment variable is set, and
++ that it does not contain the specified exclusion keyword. */
++
++static bool
++has_deb_build_options (const char *exclude_var = nullptr,
++ const char *exclude_val = nullptr)
++{
++ const char *const deb_build_options = env.get ("DEB_BUILD_OPTIONS");
++ if (!deb_build_options)
++ return false;
++
++ return !check_options (deb_build_options, exclude_var, exclude_val);
++}
++
+ /* Callback for find_a_file. Appends the file name to the directory
+ path. If the resulting file exists in the right mode, return the
+ full pathname to the file. */
+@@ -3643,9 +3698,10 @@ execute (void)
+ /* For ICEs in cc1, cc1obj, cc1plus see if it is
+ reproducible or not. */
+ const char *p;
+- if (flag_report_bug
+- && WEXITSTATUS (status) == ICE_EXIT_CODE
+- && i == 0
++ const bool deb_build_options
++ = has_deb_build_options ("gcc-ice", "norepro");
++ if ((flag_report_bug || deb_build_options)
++ && WEXITSTATUS (status) == ICE_EXIT_CODE && i == 0
+ && (p = strrchr (commands[0].argv[0], DIR_SEPARATOR))
+ && startswith (p + 1, "cc1"))
+ try_generate_repro (commands[0].argv);
+@@ -8033,8 +8089,27 @@ do_report_bug (const char **new_argv, co
+
+ if (status == ATTEMPT_STATUS_SUCCESS)
+ {
+- fnotice (stderr, "Preprocessed source stored into %s file,"
+- " please attach this to your bugreport.\n", *out_file);
++ const bool gcc_dump = has_deb_build_options ("gcc-ice", "nodump");
++
++ if (gcc_dump)
++ fnotice (stderr,
++ "Preprocessed source stored into %s file,"
++ " please attach this to your bugreport.\n",
++ *out_file);
++ if (gcc_dump)
++ {
++ char *cmd = XNEWVEC (char, 50 + strlen (*out_file));
++
++ sprintf (cmd, "/usr/bin/awk '{print \"%d:\", $0}' %s >&2", getpid (),
++ *out_file);
++ fprintf (stderr, "=== BEGIN GCC DUMP ===\n");
++ fflush (stderr);
++ system (cmd);
++ fflush (stderr);
++ fprintf (stderr, "=== END GCC DUMP ===\n");
++ fflush (stderr);
++ free (cmd);
++ }
+ /* Make sure it is not deleted. */
+ free (*out_file);
+ *out_file = NULL;
diff --git a/debian/patches/gcc-multiarch.diff b/debian/patches/gcc-multiarch.diff
new file mode 100644
index 0000000..ba386fc
--- /dev/null
+++ b/debian/patches/gcc-multiarch.diff
@@ -0,0 +1,189 @@
+# DP: - Remaining multiarch patches, not yet submitted upstream.
+# DP: - Add MULTIARCH_DIRNAME definitions for multilib configurations,
+# DP: which are used for the non-multilib builds.
+
+2013-06-12 Matthias Klose <doko@ubuntu.com>
+
+ * config/i386/t-linux64: Set MULTIARCH_DIRNAME.
+ * config.gcc (i[34567]86-*-linux* | x86_64-*-linux*): Prepend
+ i386/t-linux to $tmake_file;
+ set default ABI to N64 for mips64el.
+ * config/mips/t-linux64: Set MULTIARCH_DIRNAME.
+ * config/rs6000/t-linux64: Set MULTIARCH_DIRNAME.
+ * config/s390/t-linux64: Set MULTIARCH_DIRNAME.
+ * config/sparc/t-linux64: Set MULTIARCH_DIRNAME.
+ * src/gcc/config/mips/mips.h: (/usr)/lib as default path.
+
+--- a/src/gcc/config/sh/t-linux
++++ b/src/gcc/config/sh/t-linux
+@@ -1,3 +1,11 @@
+ MULTILIB_DIRNAMES=
+ MULTILIB_MATCHES=
++
++ifneq (,$(findstring sh4,$(target)))
++MULTILIB_OSDIRNAMES = .:sh4-linux-gnu sh4_nofpu-linux-gnu:sh4-linux-gnu
++MULTIARCH_DIRNAME = $(call if_multiarch,sh4-linux-gnu)
++else
++MULTILIB_OSDIRNAMES = .:sh3-linux-gnu sh3_nofpu-linux-gnu:sh3-linux-gnu
++MULTIARCH_DIRNAME = $(call if_multiarch,sh3-linux-gnu)
++endif
+ MULTILIB_EXCEPTIONS=m1 mb/m1 m2a
+--- a/src/gcc/config/sparc/t-linux64
++++ b/src/gcc/config/sparc/t-linux64
+@@ -27,3 +27,5 @@ MULTILIB_OPTIONS = m64/m32
+ MULTILIB_DIRNAMES = 64 32
+ MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:sparc64-linux-gnu)
+ MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:sparc-linux-gnu)
++
++MULTIARCH_DIRNAME = $(call if_multiarch,sparc$(if $(findstring 64,$(target)),64)-linux-gnu)
+--- a/src/gcc/config/s390/t-linux64
++++ b/src/gcc/config/s390/t-linux64
+@@ -9,3 +9,5 @@ MULTILIB_OPTIONS = m64/m31
+ MULTILIB_DIRNAMES = 64 32
+ MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
+ MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
++
++MULTIARCH_DIRNAME = $(call if_multiarch,s390$(if $(findstring s390x,$(target)),x)-linux-gnu)
+--- a/src/gcc/config/rs6000/t-linux64
++++ b/src/gcc/config/rs6000/t-linux64
+@@ -31,6 +31,8 @@ MULTILIB_EXTRA_OPTS :=
+ MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+ MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
+
++MULTIARCH_DIRNAME = $(call if_multiarch,powerpc$(if $(findstring 64,$(target)),64)-linux-gnu)
++
+ rs6000-linux.o: $(srcdir)/config/rs6000/rs6000-linux.cc
+ $(COMPILE) $<
+ $(POSTCOMPILE)
+--- a/src/gcc/config/i386/t-linux64
++++ b/src/gcc/config/i386/t-linux64
+@@ -36,3 +36,13 @@ MULTILIB_DIRNAMES = $(patsubst m%, %,
+ MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+ MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
+ MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
++
++ifneq (,$(findstring x86_64,$(target)))
++ ifneq (,$(findstring biarchx32.h,$(tm_include_list)))
++ MULTIARCH_DIRNAME = $(call if_multiarch,x86_64-linux-gnux32)
++ else
++ MULTIARCH_DIRNAME = $(call if_multiarch,x86_64-linux-gnu)
++ endif
++else
++ MULTIARCH_DIRNAME = $(call if_multiarch,i386-linux-gnu)
++endif
+--- a/src/gcc/config/mips/t-linux64
++++ b/src/gcc/config/mips/t-linux64
+@@ -18,24 +18,28 @@
+
+ MULTILIB_OPTIONS = mabi=n32/mabi=32/mabi=64
+ MULTILIB_DIRNAMES = n32 32 64
++MIPS_R6 = $(if $(findstring r6, $(firstword $(subst -, ,$(target)))),r6)
++MIPS_32 = $(if $(findstring r6, $(firstword $(subst -, ,$(target)))),32)
++MIPS_ISA = $(if $(findstring r6, $(firstword $(subst -, ,$(target)))),isa)
+ MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
+ MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
++
+ ifeq (yes,$(enable_multiarch))
+ ifneq (,$(findstring gnuabi64,$(target)))
+ MULTILIB_OSDIRNAMES = \
+- ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+- ../libo32$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+- ../lib$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++ ../lib32$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
++ ../libo32$(call if_multiarch,:mips$(MIPS_ISA)$(MIPS_32)$(MIPS_R6)$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
++ ../lib$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
+ else ifneq (,$(findstring gnuabin32,$(target)))
+ MULTILIB_OSDIRNAMES = \
+- ../lib$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+- ../libo32$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+- ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++ ../lib$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
++ ../libo32$(call if_multiarch,:mips$(MIPS_ISA)$(MIPS_32)$(MIPS_R6)$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
++ ../lib64$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
+ else
+ MULTILIB_OSDIRNAMES = \
+- ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+- ../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+- ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++ ../lib32$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
++ ../lib$(call if_multiarch,:mips$(MIPS_ISA)$(MIPS_32)$(MIPS_R6)$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
++ ../lib64$(call if_multiarch,:mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
+ endif
+ else
+ MULTILIB_OSDIRNAMES = \
+@@ -43,3 +47,13 @@ else
+ ../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+ ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
+ endif
++
++ifneq (,$(findstring abin32,$(target)))
++MULTIARCH_DIRNAME = $(call if_multiarch,mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT))
++else
++ifneq (,$(findstring abi64,$(target)))
++MULTIARCH_DIRNAME = $(call if_multiarch,mips$(MIPS_ISA)64$(MIPS_R6)$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
++else
++MULTIARCH_DIRNAME = $(call if_multiarch,mips$(MIPS_ISA)$(MIPS_32)$(MIPS_R6)$(MIPS_EL)-linux-gnu$(MIPS_SOFT))
++endif
++endif
+--- a/src/gcc/config.gcc
++++ b/src/gcc/config.gcc
+@@ -2590,7 +2590,8 @@ mips*-*-linux*) # Linux MIPS, either
+ extra_options="${extra_options} linux-android.opt"
+ case ${target} in
+ mipsisa32r6*)
+- default_mips_arch=mips32r6
++ with_arch_32="mips32r6"
++ with_arch_64="mips64r6"
+ ;;
+ mipsisa32r2*)
+ default_mips_arch=mips32r2
+@@ -2612,7 +2613,8 @@ mips*-*-linux*) # Linux MIPS, either
+ ;;
+ mipsisa64r6*-*-linux-gnuabi64)
+ default_mips_abi=64
+- default_mips_arch=mips64r6
++ with_arch_32="mips32r6"
++ with_arch_64="mips64r6"
+ enable_mips_multilibs="yes"
+ ;;
+ mipsisa64r6*-*-linux*)
+@@ -5798,7 +5800,7 @@ case ${target} in
+ ;;
+ i[34567]86-*-linux* | x86_64-*-linux*)
+ extra_objs="${extra_objs} gnu-property.o"
+- tmake_file="$tmake_file i386/t-linux i386/t-gnu-property"
++ tmake_file="i386/t-linux $tmake_file i386/t-gnu-property"
+ ;;
+ i[34567]86-*-kfreebsd*-gnu | x86_64-*-kfreebsd*-gnu)
+ tmake_file="$tmake_file i386/t-kfreebsd"
+--- a/src/gcc/Makefile.in
++++ b/src/gcc/Makefile.in
+@@ -582,7 +582,7 @@ BUILD_SYSTEM_HEADER_DIR = `echo @BUILD_S
+ STMP_FIXINC = @STMP_FIXINC@
+
+ # Test to see whether <limits.h> exists in the system header files.
+-LIMITS_H_TEST = [ -f $(BUILD_SYSTEM_HEADER_DIR)/limits.h ]
++LIMITS_H_TEST = [ -f $(BUILD_SYSTEM_HEADER_DIR)/limits.h -o -f $(BUILD_SYSTEM_HEADER_DIR)/$(MULTIARCH_DIRNAME)/limits.h ]
+
+ # Directory for prefix to system directories, for
+ # each of $(system_prefix)/usr/include, $(system_prefix)/usr/lib, etc.
+--- a/src/gcc/config/aarch64/t-aarch64-linux
++++ b/src/gcc/config/aarch64/t-aarch64-linux
+@@ -22,7 +22,7 @@ LIB1ASMSRC = aarch64/lib1funcs.asm
+ LIB1ASMFUNCS = _aarch64_sync_cache_range
+
+ AARCH_BE = $(if $(findstring TARGET_BIG_ENDIAN_DEFAULT=1, $(tm_defines)),_be)
+-MULTILIB_OSDIRNAMES = mabi.lp64=../lib64$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
++MULTILIB_OSDIRNAMES = mabi.lp64=../lib$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu)
+ MULTIARCH_DIRNAME = $(call if_multiarch,aarch64$(AARCH_BE)-linux-gnu)
+
+ MULTILIB_OSDIRNAMES += mabi.ilp32=../libilp32$(call if_multiarch,:aarch64$(AARCH_BE)-linux-gnu_ilp32)
+--- a/src/gcc/config/arc/t-multilib-linux
++++ b/src/gcc/config/arc/t-multilib-linux
+@@ -23,3 +23,6 @@ MULTILIB_DIRNAMES = hs archs hs38 hs38_l
+ # Aliases:
+ MULTILIB_MATCHES += mcpu?arc700=mA7
+ MULTILIB_MATCHES += mcpu?arc700=mARC700
++
++MULTILIB_OSDIRNAMES =
++MULTIARCH_DIRNAME = $(call if_multiarch,arc-linux-gnu)
diff --git a/debian/patches/gcc-multilib-multiarch.diff b/debian/patches/gcc-multilib-multiarch.diff
new file mode 100644
index 0000000..9660580
--- /dev/null
+++ b/debian/patches/gcc-multilib-multiarch.diff
@@ -0,0 +1,85 @@
+# DP: Don't auto-detect multilib osdirnames.
+
+--- a/src/gcc/config/sparc/t-linux64
++++ b/src/gcc/config/sparc/t-linux64
+@@ -25,7 +25,12 @@
+
+ MULTILIB_OPTIONS = m64/m32
+ MULTILIB_DIRNAMES = 64 32
++ifneq (,$(findstring sparc64,$(target)))
++MULTILIB_OSDIRNAMES = ../lib$(call if_multiarch,:sparc64-linux-gnu)
++MULTILIB_OSDIRNAMES += ../lib32$(call if_multiarch,:sparc-linux-gnu)
++else
+ MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:sparc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:sparc-linux-gnu)
++MULTILIB_OSDIRNAMES += ../lib$(call if_multiarch,:sparc-linux-gnu)
++endif
+
+ MULTIARCH_DIRNAME = $(call if_multiarch,sparc$(if $(findstring 64,$(target)),64)-linux-gnu)
+--- a/src/gcc/config/s390/t-linux64
++++ b/src/gcc/config/s390/t-linux64
+@@ -7,7 +7,12 @@
+
+ MULTILIB_OPTIONS = m64/m31
+ MULTILIB_DIRNAMES = 64 32
++ifneq (,$(findstring s390x,$(target)))
++MULTILIB_OSDIRNAMES = ../lib$(call if_multiarch,:s390x-linux-gnu)
++MULTILIB_OSDIRNAMES += ../lib32$(call if_multiarch,:s390-linux-gnu)
++else
+ MULTILIB_OSDIRNAMES = ../lib64$(call if_multiarch,:s390x-linux-gnu)
+-MULTILIB_OSDIRNAMES += $(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:s390-linux-gnu)
++MULTILIB_OSDIRNAMES += ../lib$(call if_multiarch,:s390-linux-gnu)
++endif
+
+ MULTIARCH_DIRNAME = $(call if_multiarch,s390$(if $(findstring s390x,$(target)),x)-linux-gnu)
+--- a/src/gcc/config/rs6000/t-linux64
++++ b/src/gcc/config/rs6000/t-linux64
+@@ -28,8 +28,13 @@
+ MULTILIB_OPTIONS := m64/m32
+ MULTILIB_DIRNAMES := 64 32
+ MULTILIB_EXTRA_OPTS :=
++ifneq (,$(findstring powerpc64,$(target)))
++MULTILIB_OSDIRNAMES := m64=../lib$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES += m32=../lib32$(call if_multiarch,:powerpc-linux-gnu)
++else
+ MULTILIB_OSDIRNAMES := m64=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
+-MULTILIB_OSDIRNAMES += m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:powerpc-linux-gnu)
++MULTILIB_OSDIRNAMES += m32=../lib$(call if_multiarch,:powerpc-linux-gnu)
++endif
+
+ MULTIARCH_DIRNAME = $(call if_multiarch,powerpc$(if $(findstring 64,$(target)),64)-linux-gnu)
+
+--- a/src/gcc/config/i386/t-linux64
++++ b/src/gcc/config/i386/t-linux64
+@@ -33,9 +33,19 @@
+ comma=,
+ MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
++ifneq (,$(findstring gnux32,$(target)))
+ MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-linux-gnu)
++MULTILIB_OSDIRNAMES+= m32=../lib32$(call if_multiarch,:i386-linux-gnu)
++MULTILIB_OSDIRNAMES+= mx32=../lib$(call if_multiarch,:x86_64-linux-gnux32)
++else ifneq (,$(findstring x86_64,$(target)))
++MULTILIB_OSDIRNAMES = m64=../lib$(call if_multiarch,:x86_64-linux-gnu)
++MULTILIB_OSDIRNAMES+= m32=../lib32$(call if_multiarch,:i386-linux-gnu)
+ MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
++else
++MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-linux-gnu)
++MULTILIB_OSDIRNAMES+= m32=../lib$(call if_multiarch,:i386-linux-gnu)
++MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-linux-gnux32)
++endif
+
+ ifneq (,$(findstring x86_64,$(target)))
+ ifneq (,$(findstring biarchx32.h,$(tm_include_list)))
+--- a/src/gcc/config/rs6000/t-linux
++++ b/src/gcc/config/rs6000/t-linux
+@@ -2,7 +2,7 @@
+ # or soft-float.
+ ifeq (,$(filter $(with_cpu),$(SOFT_FLOAT_CPUS))$(findstring soft,$(with_float)))
+ ifneq (,$(findstring powerpc64,$(target)))
+-MULTILIB_OSDIRNAMES := .=../lib64$(call if_multiarch,:powerpc64-linux-gnu)
++MULTILIB_OSDIRNAMES := .=../lib$(call if_multiarch,:powerpc64-linux-gnu)
+ else
+ MULTIARCH_DIRNAME := $(call if_multiarch,powerpc-linux-gnu)
+ endif
diff --git a/debian/patches/gcc-search-prefixed-as-ld.diff b/debian/patches/gcc-search-prefixed-as-ld.diff
new file mode 100644
index 0000000..77d5af9
--- /dev/null
+++ b/debian/patches/gcc-search-prefixed-as-ld.diff
@@ -0,0 +1,37 @@
+# DP: Search for the <triplet>-as / -ld before serching for as / ld.
+
+--- a/src/gcc/gcc.cc
++++ b/src/gcc/gcc.cc
+@@ -2914,6 +2914,7 @@ for_each_path (const struct path_prefix
+ {
+ len = paths->max_len + extra_space + 1;
+ len += MAX (MAX (suffix_len, multi_os_dir_len), multiarch_len);
++ len += MAX (strlen(DEFAULT_REAL_TARGET_MACHINE), multiarch_len) + 2; /* triplet prefix for as, ld. */
+ path = XNEWVEC (char, len);
+ }
+
+@@ -3127,6 +3128,24 @@ file_at_path (char *path, void *data)
+ struct file_at_path_info *info = (struct file_at_path_info *) data;
+ size_t len = strlen (path);
+
++ /* search for the <triplet>-as / -ld first. */
++ if (! strcmp (info->name, "as") || ! strcmp (info->name, "ld"))
++ {
++ struct file_at_path_info prefix_info = *info;
++ char *prefixed_name = XNEWVEC (char, info->name_len + 2
++ + strlen (DEFAULT_REAL_TARGET_MACHINE));
++ strcpy (prefixed_name, DEFAULT_REAL_TARGET_MACHINE);
++ strcat (prefixed_name, "-");
++ strcat (prefixed_name, info->name);
++ prefix_info.name = (const char *) prefixed_name;
++ prefix_info.name_len = strlen (prefixed_name);
++ if (file_at_path (path, &prefix_info))
++ {
++ XDELETEVEC (prefixed_name);
++ return path;
++ }
++ XDELETEVEC (prefixed_name);
++ }
+ memcpy (path + len, info->name, info->name_len);
+ len += info->name_len;
+
diff --git a/debian/patches/gcc-target-include-asm.diff b/debian/patches/gcc-target-include-asm.diff
new file mode 100644
index 0000000..7a27a8b
--- /dev/null
+++ b/debian/patches/gcc-target-include-asm.diff
@@ -0,0 +1,13 @@
+# DP: Search $(builddir)/sys-include for the asm header files
+
+--- a/src/configure.ac
++++ b/src/configure.ac
+@@ -3601,7 +3601,7 @@ fi
+ # being built; programs in there won't even run.
+ if test "${build}" = "${host}" && test -d ${srcdir}/gcc; then
+ # Search for pre-installed headers if nothing else fits.
+- FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$(build_tooldir)/bin/ -B$(build_tooldir)/lib/ -isystem $(build_tooldir)/include -isystem $(build_tooldir)/sys-include'
++ FLAGS_FOR_TARGET=$FLAGS_FOR_TARGET' -B$(build_tooldir)/bin/ -B$(build_tooldir)/lib/ -isystem $(build_tooldir)/include -isystem $(build_tooldir)/sys-include -isystem $(CURDIR)/sys-include'
+ fi
+
+ if test "x${use_gnu_ld}" = x &&
diff --git a/debian/patches/gcc-textdomain.diff b/debian/patches/gcc-textdomain.diff
new file mode 100644
index 0000000..76099a4
--- /dev/null
+++ b/debian/patches/gcc-textdomain.diff
@@ -0,0 +1,86 @@
+# DP: Set gettext's domain and textdomain to the versioned package name.
+
+--- a/src/gcc/intl.cc
++++ b/src/gcc/intl.cc
+@@ -55,8 +55,8 @@ gcc_init_libintl (void)
+ setlocale (LC_ALL, "");
+ #endif
+
+- (void) bindtextdomain ("gcc", LOCALEDIR);
+- (void) textdomain ("gcc");
++ (void) bindtextdomain ("gcc-14", LOCALEDIR);
++ (void) textdomain ("gcc-14");
+
+ /* Opening quotation mark. */
+ open_quote = _("`");
+--- a/src/gcc/Makefile.in
++++ b/src/gcc/Makefile.in
+@@ -4482,8 +4482,8 @@ install-po:
+ dir=$(localedir)/$$lang/LC_MESSAGES; \
+ echo $(mkinstalldirs) $(DESTDIR)$$dir; \
+ $(mkinstalldirs) $(DESTDIR)$$dir || exit 1; \
+- echo $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/gcc.mo; \
+- $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/gcc.mo; \
++ echo $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/gcc-14.mo; \
++ $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/gcc-14.mo; \
+ done
+
+ # Rule for regenerating the message template (gcc.pot).
+--- a/src/libcpp/init.cc
++++ b/src/libcpp/init.cc
+@@ -183,7 +183,7 @@ init_library (void)
+ init_trigraph_map ();
+
+ #ifdef ENABLE_NLS
+- (void) bindtextdomain (PACKAGE, LOCALEDIR);
++ (void) bindtextdomain (PACKAGE PACKAGE_SUFFIX, LOCALEDIR);
+ #endif
+ }
+ }
+--- a/src/libcpp/system.h
++++ b/src/libcpp/system.h
+@@ -284,7 +284,7 @@ extern int errno;
+ #endif
+
+ #ifndef _
+-# define _(msgid) dgettext (PACKAGE, msgid)
++# define _(msgid) dgettext (PACKAGE PACKAGE_SUFFIX, msgid)
+ #endif
+
+ #ifndef N_
+--- a/src/libcpp/Makefile.in
++++ b/src/libcpp/Makefile.in
+@@ -49,6 +49,7 @@ LDFLAGS = @LDFLAGS@
+ LIBICONV = @LIBICONV@
+ LIBINTL = @LIBINTL@
+ PACKAGE = @PACKAGE@
++PACKAGE_SUFFIX = -14
+ RANLIB = @RANLIB@
+ SHELL = @SHELL@
+ USED_CATALOGS = @USED_CATALOGS@
+@@ -73,11 +74,12 @@ depcomp = $(SHELL) $(srcdir)/../depcomp
+
+ INCLUDES = -I$(srcdir) -I. -I$(srcdir)/../include @INCINTL@ \
+ -I$(srcdir)/include
++DEBCPPFLAGS += -DPACKAGE_SUFFIX=\"$(strip $(PACKAGE_SUFFIX))\"
+
+ ALL_CFLAGS = $(CFLAGS) $(WARN_CFLAGS) $(INCLUDES) $(CPPFLAGS) $(PICFLAG) \
+- $(CET_HOST_FLAGS)
++ $(CET_HOST_FLAGS) $(DEBCPPFLAGS)
+ ALL_CXXFLAGS = $(CXXFLAGS) $(WARN_CXXFLAGS) $(NOEXCEPTION_FLAGS) $(INCLUDES) \
+- $(CPPFLAGS) $(PICFLAG) $(CET_HOST_FLAGS)
++ $(CPPFLAGS) $(PICFLAG) $(CET_HOST_FLAGS) $(DEBCPPFLAGS)
+
+ # The name of the compiler to use.
+ COMPILER = $(CXX)
+@@ -166,8 +168,8 @@ install-strip install: all installdirs
+ else continue; \
+ fi; \
+ dir=$(localedir)/$$lang/LC_MESSAGES; \
+- echo $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(PACKAGE).mo; \
+- $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(PACKAGE).mo; \
++ echo $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(PACKAGE)$(PACKAGE_SUFFIX).mo; \
++ $(INSTALL_DATA) $$cat $(DESTDIR)$$dir/$(PACKAGE)$(PACKAGE_SUFFIX).mo; \
+ done
+
+ mostlyclean:
diff --git a/debian/patches/gcc-verbose-lto-link.diff b/debian/patches/gcc-verbose-lto-link.diff
new file mode 100644
index 0000000..46cf1a4
--- /dev/null
+++ b/debian/patches/gcc-verbose-lto-link.diff
@@ -0,0 +1,13 @@
+# DP: Prefix LLINKER with /usr/bin/time -v
+
+--- a/src/gcc/Makefile.in
++++ b/src/gcc/Makefile.in
+@@ -312,7 +312,7 @@ LINKER += $(LD_PICFLAG)
+ ifeq (@DO_LINK_MUTEX@,true)
+ LLINKER = $(SHELL) $(srcdir)/lock-and-run.sh linkfe.lck $(LINKER)
+ else
+-LLINKER = $(LINKER)
++LLINKER = /usr/bin/time -v $(LINKER)
+ endif
+
+ THIN_ARCHIVE_SUPPORT = @thin_archive_support@
diff --git a/debian/patches/gccrs-bootstrap-mipsel.diff b/debian/patches/gccrs-bootstrap-mipsel.diff
new file mode 100644
index 0000000..8c60ec5
--- /dev/null
+++ b/debian/patches/gccrs-bootstrap-mipsel.diff
@@ -0,0 +1,12 @@
+# DP: Ignore gccrs bootstrap comparison failures on mipsel.
+
+--- a/src/configure.ac
++++ b/src/configure.ac
+@@ -3979,6 +3979,7 @@ compare_exclusions="$compare_exclusions
+ compare_exclusions="$compare_exclusions | gcc/m2/gm2version*"
+ case "$target" in
+ hppa*64*-*-hpux*) ;;
++ mipsel-*linux-gnu) compare_exclusions="$compare_exclusions | gcc/rust/rust-macro-builtins.o | gcc/rust/rust-session-manager.o | gcc/rust/rust-cfg-parser.o | gcc/rust/rust-lex.o" ;;
+ powerpc*-ibm-aix*) compare_exclusions="$compare_exclusions | *libgomp*\$(objext)" ;;
+ esac
+ AC_SUBST(compare_exclusions)
diff --git a/debian/patches/gdc-dynamic-link-phobos.diff b/debian/patches/gdc-dynamic-link-phobos.diff
new file mode 100644
index 0000000..f8ccec9
--- /dev/null
+++ b/debian/patches/gdc-dynamic-link-phobos.diff
@@ -0,0 +1,17 @@
+# DP: Dynamically link the phobos library.
+
+--- a/src/gcc/d/d-spec.cc
++++ b/src/gcc/d/d-spec.cc
+@@ -426,9 +426,9 @@ lang_specific_driver (cl_decoded_option
+ /* Add `-lgphobos' if we haven't already done so. */
+ if (phobos_library != PHOBOS_NOLINK)
+ {
+- /* Default to static linking. */
+- if (phobos_library != PHOBOS_DYNAMIC)
+- phobos_library = PHOBOS_STATIC;
++ /* Default to dynamic linking. */
++ if (phobos_library != PHOBOS_STATIC)
++ phobos_library = PHOBOS_DYNAMIC;
+
+ #ifdef HAVE_LD_STATIC_DYNAMIC
+ if (phobos_library == PHOBOS_STATIC && !static_link)
diff --git a/debian/patches/gdc-multiarch.diff b/debian/patches/gdc-multiarch.diff
new file mode 100644
index 0000000..1925e1a
--- /dev/null
+++ b/debian/patches/gdc-multiarch.diff
@@ -0,0 +1,17 @@
+# DP: Set the D target include directory to a multiarch location.
+
+--- a/src/gcc/d/Make-lang.in
++++ b/src/gcc/d/Make-lang.in
+@@ -61,7 +61,11 @@
+ $(D_DMD_H)
+
+
+-gcc_d_target_include_dir=$(gcc_d_include_dir)/$(target_noncanonical)
++ifneq (,$(MULTIARCH_DIRNAME))
++ gcc_d_target_include_dir = /usr/include/$(MULTIARCH_DIRNAME)/d/$(version)
++else
++ gcc_d_target_include_dir=$(gcc_d_include_dir)/$(target_noncanonical)
++endif
+
+ # Name of phobos library
+ D_LIBPHOBOS = -DLIBPHOBOS=\"gphobos2\"
diff --git a/debian/patches/gdc-texinfo.diff b/debian/patches/gdc-texinfo.diff
new file mode 100644
index 0000000..a024daf
--- /dev/null
+++ b/debian/patches/gdc-texinfo.diff
@@ -0,0 +1,53 @@
+# DP: Add macros for the gdc texinfo documentation.
+
+--- a/src/gcc/d/gdc.texi
++++ b/src/gcc/d/gdc.texi
+@@ -45,6 +45,22 @@ man page gfdl(7).
+ @insertcopying
+ @end ifinfo
+
++@macro versionsubtitle
++@ifclear DEVELOPMENT
++@subtitle For @sc{gcc} version @value{version-GCC}
++@end ifclear
++@ifset DEVELOPMENT
++@subtitle For @sc{gcc} version @value{version-GCC} (pre-release)
++@end ifset
++@ifset VERSION_PACKAGE
++@sp 1
++@subtitle @value{VERSION_PACKAGE}
++@end ifset
++@c Even if there are no authors, the second titlepage line should be
++@c forced to the bottom of the page.
++@vskip 0pt plus 1filll
++@end macro
++
+ @titlepage
+ @title The GNU D Compiler
+ @versionsubtitle
+@@ -123,6 +139,25 @@ This manual only documents the options s
+ * Developer Options:: Options useful for developers of gdc
+ @end menu
+
++@macro gcctabopt{body}
++@code{\body\}
++@end macro
++@macro gccoptlist{body}
++@smallexample
++\body\
++@end smallexample
++@end macro
++@c Makeinfo handles the above macro OK, TeX needs manual line breaks;
++@c they get lost at some point in handling the macro. But if @macro is
++@c used here rather than @alias, it produces double line breaks.
++@iftex
++@alias gol = *
++@end iftex
++@ifnottex
++@macro gol
++@end macro
++@end ifnottex
++
+ @c man begin OPTIONS
+
+ @node Input and Output files
diff --git a/debian/patches/git-doc-updates.diff b/debian/patches/git-doc-updates.diff
new file mode 100644
index 0000000..72c9a86
--- /dev/null
+++ b/debian/patches/git-doc-updates.diff
@@ -0,0 +1,7 @@
+# DP: updates from the 13 branch upto 20231005 (documentation).
+
+LANG=C git diff --no-renames --src-prefix=a/src/ --dst-prefix=b/src/ \
+ c891d8dc23e1a46ad9f3e757d09e57b500d40044 2ef5adc5f5a7a5046964276e4354e47eedc96620 \
+ | awk '/^diff .*\.texi/ {skip=0; print; next} /^diff / {skip=1; next} skip==0' \
+ | grep -v -E '^(diff|index)'
+
diff --git a/debian/patches/git-updates.diff b/debian/patches/git-updates.diff
new file mode 100644
index 0000000..3b1c894
--- /dev/null
+++ b/debian/patches/git-updates.diff
@@ -0,0 +1,7 @@
+# DP: updates from the 13 branch upto 20231005 (2ef5adc5f5a).
+
+LANG=C git diff --no-renames --src-prefix=a/src/ --dst-prefix=b/src/ \
+ c891d8dc23e1a46ad9f3e757d09e57b500d40044 2ef5adc5f5a7a5046964276e4354e47eedc96620 \
+ | awk '/^diff .*\.texi/ {skip=1; next} /^diff / { skip=0 } skip==0' \
+ | grep -v -E '^(diff|index)'
+
diff --git a/debian/patches/gm2-bootstrap-compare.diff b/debian/patches/gm2-bootstrap-compare.diff
new file mode 100644
index 0000000..5edd82d
--- /dev/null
+++ b/debian/patches/gm2-bootstrap-compare.diff
@@ -0,0 +1,12 @@
+# DP: ignore gm2version.o stage diff on some archtectures (m68k, riscv64)
+
+--- a/src/configure.ac
++++ b/src/configure.ac
+@@ -3678,6 +3678,7 @@ AC_SUBST(stage2_werror_flag)
+ compare_exclusions="gcc/cc*-checksum\$(objext) | gcc/ada/*tools/*"
+ compare_exclusions="$compare_exclusions | gcc/m2/gm2-compiler-boot/M2Version*"
+ compare_exclusions="$compare_exclusions | gcc/m2/gm2-compiler-boot/SYSTEM*"
++compare_exclusions="$compare_exclusions | *m2/gm2version\$(objext)"
+ case "$target" in
+ hppa*64*-*-hpux*) ;;
+ hppa*-*-hpux*) compare_exclusions="$compare_exclusions | */libgcc/lib2funcs* | gcc/function-tests.o" ;;
diff --git a/debian/patches/gm2-texinfo.diff b/debian/patches/gm2-texinfo.diff
new file mode 100644
index 0000000..b7c1505
--- /dev/null
+++ b/debian/patches/gm2-texinfo.diff
@@ -0,0 +1,30 @@
+# DP: gm2.texi: Define our own gcctabopt macro, needed for dfsg builds.
+
+--- a/src/gcc/doc/gm2.texi
++++ b/src/gcc/doc/gm2.texi
+@@ -51,6 +51,25 @@ man page gfdl(7).
+ @versionsubtitle
+ @author Gaius Mulley
+
++@macro gcctabopt{body}
++@code{\body\}
++@end macro
++@macro gccoptlist{body}
++@smallexample
++\body\
++@end smallexample
++@end macro
++@c Makeinfo handles the above macro OK, TeX needs manual line breaks;
++@c they get lost at some point in handling the macro. But if @macro is
++@c used here rather than @alias, it produces double line breaks.
++@iftex
++@alias gol = *
++@end iftex
++@ifnottex
++@macro gol
++@end macro
++@end ifnottex
++
+ @page
+ @vskip 0pt plus 1filll
+ Published by the Free Software Foundation @*
diff --git a/debian/patches/go-testsuite.diff b/debian/patches/go-testsuite.diff
new file mode 100644
index 0000000..b424eb5
--- /dev/null
+++ b/debian/patches/go-testsuite.diff
@@ -0,0 +1,19 @@
+# DP: Skip Go testcase on AArch64 which hangs on the buildds.
+
+--- a/src/gcc/testsuite/go.test/go-test.exp
++++ b/src/gcc/testsuite/go.test/go-test.exp
+@@ -460,6 +460,14 @@ proc go-gc-tests { } {
+ continue
+ }
+
++ # Hangs on the buildds
++ if { [istarget "aarch64*-*-*"] } {
++ if { [file tail $test] == "pprof.go" } {
++ untested $test
++ continue
++ }
++ }
++
+ if { [file tail $test] == "init1.go" } {
+ # This tests whether GC runs during init, which for gccgo
+ # it currently does not.
diff --git a/debian/patches/hppa64-libgcov-fallback.diff b/debian/patches/hppa64-libgcov-fallback.diff
new file mode 100644
index 0000000..58e4410
--- /dev/null
+++ b/debian/patches/hppa64-libgcov-fallback.diff
@@ -0,0 +1,15 @@
+--- a/src/libgcc/libgcov.h
++++ b/src/libgcc/libgcov.h
+@@ -45,6 +45,12 @@
+ #include "libgcc_tm.h"
+ #include "gcov.h"
+
++/* hppa64-linux-gnu does not have this header, use the fallback. */
++#if defined(__LP64__) && defined(_PA_RISC2_0)
++#undef HAVE_SYS_MMAN_H
++#define HAVE_SYS_MMAN_H 0
++#endif
++
+ #if HAVE_SYS_MMAN_H
+ #include <sys/mman.h>
+ #endif
diff --git a/debian/patches/hurd-changes.diff b/debian/patches/hurd-changes.diff
new file mode 100644
index 0000000..ca4d820
--- /dev/null
+++ b/debian/patches/hurd-changes.diff
@@ -0,0 +1,20 @@
+# DP: Traditional GNU systems don't have a /usr directory. However, Debian
+# DP: systems do, and we support both having a /usr -> . symlink, and having a
+# DP: /usr directory like the other ports. So this patch should NOT go
+# DP: upstream.
+
+---
+ config.gcc | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/src/gcc/config.gcc
++++ b/src/gcc/config.gcc
+@@ -583,7 +583,7 @@
+ *-*-linux* | frv-*-*linux* | *-*-kfreebsd*-gnu | *-*-knetbsd*-gnu | *-*-kopensolaris*-gnu)
+ :;;
+ *-*-gnu*)
+- native_system_header_dir=/include
++ # native_system_header_dir=/include
+ ;;
+ esac
+ # glibc / uclibc / bionic switch.
diff --git a/debian/patches/hurd-multiarch.diff b/debian/patches/hurd-multiarch.diff
new file mode 100644
index 0000000..d814c6e
--- /dev/null
+++ b/debian/patches/hurd-multiarch.diff
@@ -0,0 +1,16 @@
+--- a/src/gcc/config/i386/t-gnu64 2023-05-06 22:43:39.395795420 +0200
++++ b/src/gcc/config/i386/t-gnu64 2023-05-06 22:43:39.395795420 +0200
+@@ -36,3 +36,13 @@
+ MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-gnu)
+ MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-gnu)
+ MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-gnux32)
++
++ifneq (,$(findstring x86_64,$(target)))
++ ifneq (,$(findstring biarchx32.h,$(tm_include_list)))
++ MULTIARCH_DIRNAME = $(call if_multiarch,x86_64-gnux32)
++ else
++ MULTIARCH_DIRNAME = $(call if_multiarch,x86_64-gnu)
++ endif
++else
++ MULTIARCH_DIRNAME = $(call if_multiarch,i386-gnu)
++endif
diff --git a/debian/patches/hurd-multilib-multiarch.diff b/debian/patches/hurd-multilib-multiarch.diff
new file mode 100644
index 0000000..6975ce8
--- /dev/null
+++ b/debian/patches/hurd-multilib-multiarch.diff
@@ -0,0 +1,23 @@
+--- a/src/gcc/config/i386/t-gnu64 2023-05-06 22:43:39.395795420 +0200
++++ b/src/gcc/config/i386/t-gnu64 2023-05-06 22:43:39.395795420 +0200
+@@ -33,9 +33,19 @@
+ comma=,
+ MULTILIB_OPTIONS = $(subst $(comma),/,$(TM_MULTILIB_CONFIG))
+ MULTILIB_DIRNAMES = $(patsubst m%, %, $(subst /, ,$(MULTILIB_OPTIONS)))
++ifneq (,$(findstring gnux32,$(target)))
+ MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-gnu)
+-MULTILIB_OSDIRNAMES+= m32=$(if $(wildcard $(shell echo $(SYSTEM_HEADER_DIR))/../../usr/lib32),../lib32,../lib)$(call if_multiarch,:i386-gnu)
++MULTILIB_OSDIRNAMES+= m32=../lib32$(call if_multiarch,:i386-gnu)
++MULTILIB_OSDIRNAMES+= mx32=../lib$(call if_multiarch,:x86_64-gnux32)
++else ifneq (,$(findstring x86_64,$(target)))
++MULTILIB_OSDIRNAMES = m64=../lib$(call if_multiarch,:x86_64-gnu)
++MULTILIB_OSDIRNAMES+= m32=../lib32$(call if_multiarch,:i386-gnu)
+ MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-gnux32)
++else
++MULTILIB_OSDIRNAMES = m64=../lib64$(call if_multiarch,:x86_64-gnu)
++MULTILIB_OSDIRNAMES+= m32=../lib$(call if_multiarch,:i386-gnu)
++MULTILIB_OSDIRNAMES+= mx32=../libx32$(call if_multiarch,:x86_64-gnux32)
++endif
+
+ ifneq (,$(findstring x86_64,$(target)))
+ ifneq (,$(findstring biarchx32.h,$(tm_include_list)))
diff --git a/debian/patches/ia64-disable-selective-scheduling.diff b/debian/patches/ia64-disable-selective-scheduling.diff
new file mode 100644
index 0000000..4a92405
--- /dev/null
+++ b/debian/patches/ia64-disable-selective-scheduling.diff
@@ -0,0 +1,16 @@
+--- a/src/gcc/config/ia64/ia64.cc
++++ b/src/gcc/config/ia64/ia64.cc
+@@ -6130,13 +6130,6 @@ ia64_option_override (void)
+ static void
+ ia64_override_options_after_change (void)
+ {
+- if (optimize >= 3
+- && !OPTION_SET_P (flag_selective_scheduling)
+- && !OPTION_SET_P (flag_selective_scheduling2))
+- {
+- flag_selective_scheduling2 = 1;
+- flag_sel_sched_pipelining = 1;
+- }
+ if (mflag_sched_control_spec == 2)
+ {
+ /* Control speculation is on by default for the selective scheduler,
diff --git a/debian/patches/ignore-pie-specs-when-not-enabled.diff b/debian/patches/ignore-pie-specs-when-not-enabled.diff
new file mode 100644
index 0000000..8f5cc09
--- /dev/null
+++ b/debian/patches/ignore-pie-specs-when-not-enabled.diff
@@ -0,0 +1,56 @@
+# DP: Ignore dpkg's pie specs when pie is not enabled.
+
+Index: b/src/gcc/gcc.c
+===================================================================
+--- a/src/gcc/gcc.c
++++ b/src/gcc/gcc.c
+@@ -3715,6 +3715,36 @@ handle_foffload_option (const char *arg)
+ }
+ }
+
++static bool ignore_pie_specs_when_not_enabled(const char *envvar,
++ const char *specname)
++{
++ const char *envval = secure_getenv(envvar);
++ char *hardening;
++ bool ignore;
++
++ if (strstr (specname, "/pie-compile.specs") == NULL
++ && strstr (specname, "/pie-link.specs") == NULL)
++ return false;
++ if (envval == NULL || strstr (envval, "hardening=") == NULL)
++ return true;
++ ignore = true;
++ hardening = (char *) xmalloc (strlen(envval) + 1);
++ strcpy (hardening, strstr (envval, "hardening="));
++ if (strchr (hardening, ' '))
++ *strchr (hardening, ' ') = '\0';
++ if (strstr(hardening, "+all"))
++ {
++ if (strstr(hardening, "-pie") == NULL)
++ ignore = false;
++ }
++ else if (strstr(hardening, "+pie"))
++ {
++ ignore = false;
++ }
++ free (hardening);
++ return ignore;
++}
++
+ /* Handle a driver option; arguments and return value as for
+ handle_option. */
+
+@@ -3989,6 +4019,12 @@ driver_handle_option (struct gcc_options
+ break;
+
+ case OPT_specs_:
++ if (ignore_pie_specs_when_not_enabled("DEB_BUILD_MAINT_OPTIONS", arg)
++ && ignore_pie_specs_when_not_enabled("DEB_BUILD_OPTIONS", arg))
++ {
++ inform (0, "pie specs %s ignored when pie is not enabled", arg);
++ return true;
++ }
+ {
+ struct user_specs *user = XNEW (struct user_specs);
+
diff --git a/debian/patches/libasan-sparc.diff b/debian/patches/libasan-sparc.diff
new file mode 100644
index 0000000..4b52ac2
--- /dev/null
+++ b/debian/patches/libasan-sparc.diff
@@ -0,0 +1,163 @@
+# DP: Re-apply sanitizer patch for sparc, dropped upstream
+
+# don't remove, this is regularly overwritten, see PR sanitizer/63958.
+
+libsanitizer/
+
+2014-10-14 David S. Miller <davem@davemloft.net>
+
+ * sanitizer_common/sanitizer_platform_limits_linux.cc (time_t):
+ Define at __kernel_time_t, as needed for sparc.
+ (struct __old_kernel_stat): Don't check if __sparc__ is defined.
+ * libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+ (__sanitizer): Define struct___old_kernel_stat_sz,
+ struct_kernel_stat_sz, and struct_kernel_stat64_sz for sparc.
+ (__sanitizer_ipc_perm): Adjust for sparc targets.
+ (__sanitizer_shmid_ds): Likewsie.
+ (__sanitizer_sigaction): Likewsie.
+ (IOC_SIZE): Likewsie.
+
+Index: libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+===================================================================
+--- a/src/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h (revision 216223)
++++ a/src/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h (revision 216224)
+@@ -72,6 +72,14 @@
+ const unsigned struct_kernel_stat_sz = 144;
+ #endif
+ const unsigned struct_kernel_stat64_sz = 104;
++#elif defined(__sparc__) && defined(__arch64__)
++ const unsigned struct___old_kernel_stat_sz = 0;
++ const unsigned struct_kernel_stat_sz = 104;
++ const unsigned struct_kernel_stat64_sz = 144;
++#elif defined(__sparc__) && !defined(__arch64__)
++ const unsigned struct___old_kernel_stat_sz = 0;
++ const unsigned struct_kernel_stat_sz = 64;
++ const unsigned struct_kernel_stat64_sz = 104;
+ #endif
+ struct __sanitizer_perf_event_attr {
+ unsigned type;
+@@ -94,7 +102,7 @@
+
+ #if defined(__powerpc64__)
+ const unsigned struct___old_kernel_stat_sz = 0;
+-#else
++#elif !defined(__sparc__)
+ const unsigned struct___old_kernel_stat_sz = 32;
+ #endif
+
+@@ -173,6 +181,18 @@
+ unsigned short __pad1;
+ unsigned long __unused1;
+ unsigned long __unused2;
++#elif defined(__sparc__)
++# if defined(__arch64__)
++ unsigned mode;
++ unsigned short __pad1;
++# else
++ unsigned short __pad1;
++ unsigned short mode;
++ unsigned short __pad2;
++# endif
++ unsigned short __seq;
++ unsigned long long __unused1;
++ unsigned long long __unused2;
+ #else
+ unsigned short mode;
+ unsigned short __pad1;
+@@ -190,6 +210,26 @@
+
+ struct __sanitizer_shmid_ds {
+ __sanitizer_ipc_perm shm_perm;
++ #if defined(__sparc__)
++ # if !defined(__arch64__)
++ u32 __pad1;
++ # endif
++ long shm_atime;
++ # if !defined(__arch64__)
++ u32 __pad2;
++ # endif
++ long shm_dtime;
++ # if !defined(__arch64__)
++ u32 __pad3;
++ # endif
++ long shm_ctime;
++ uptr shm_segsz;
++ int shm_cpid;
++ int shm_lpid;
++ unsigned long shm_nattch;
++ unsigned long __glibc_reserved1;
++ unsigned long __glibc_reserved2;
++ #else
+ #ifndef __powerpc__
+ uptr shm_segsz;
+ #elif !defined(__powerpc64__)
+@@ -227,6 +267,7 @@
+ uptr __unused4;
+ uptr __unused5;
+ #endif
++#endif
+ };
+ #elif SANITIZER_FREEBSD
+ struct __sanitizer_ipc_perm {
+@@ -523,9 +564,13 @@
+ #else
+ __sanitizer_sigset_t sa_mask;
+ #ifndef __mips__
++#if defined(__sparc__)
++ unsigned long sa_flags;
++#else
+ int sa_flags;
+ #endif
+ #endif
++#endif
+ #if SANITIZER_LINUX
+ void (*sa_restorer)();
+ #endif
+@@ -745,7 +790,7 @@
+
+ #define IOC_NRBITS 8
+ #define IOC_TYPEBITS 8
+-#if defined(__powerpc__) || defined(__powerpc64__) || defined(__mips__)
++#if defined(__powerpc__) || defined(__powerpc64__) || defined(__mips__) || defined(__sparc__)
+ #define IOC_SIZEBITS 13
+ #define IOC_DIRBITS 3
+ #define IOC_NONE 1U
+@@ -775,7 +820,17 @@
+ #define IOC_DIR(nr) (((nr) >> IOC_DIRSHIFT) & IOC_DIRMASK)
+ #define IOC_TYPE(nr) (((nr) >> IOC_TYPESHIFT) & IOC_TYPEMASK)
+ #define IOC_NR(nr) (((nr) >> IOC_NRSHIFT) & IOC_NRMASK)
++
++#if defined(__sparc__)
++// In sparc the 14 bits SIZE field overlaps with the
++// least significant bit of DIR, so either IOC_READ or
++// IOC_WRITE shall be 1 in order to get a non-zero SIZE.
++# define IOC_SIZE(nr) \
++ ((((((nr) >> 29) & 0x7) & (4U|2U)) == 0)? \
++ 0 : (((nr) >> 16) & 0x3fff))
++#else
+ #define IOC_SIZE(nr) (((nr) >> IOC_SIZESHIFT) & IOC_SIZEMASK)
++#endif
+
+ extern unsigned struct_arpreq_sz;
+ extern unsigned struct_ifreq_sz;
+Index: libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc
+===================================================================
+--- a/src/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc (revision 216223)
++++ a/src/libsanitizer/sanitizer_common/sanitizer_platform_limits_linux.cc (revision 216224)
+@@ -36,6 +36,7 @@
+ #define uid_t __kernel_uid_t
+ #define gid_t __kernel_gid_t
+ #define off_t __kernel_off_t
++#define time_t __kernel_time_t
+ // This header seems to contain the definitions of _kernel_ stat* structs.
+ #include <asm/stat.h>
+ #undef ino_t
+@@ -60,7 +61,7 @@
+ } // namespace __sanitizer
+
+ #if !defined(__powerpc64__) && !defined(__x86_64__) && !defined(__aarch64__)\
+- && !defined(__mips__)
++ && !defined(__mips__) && !defined(__sparc__)
+ COMPILER_CHECK(struct___old_kernel_stat_sz == sizeof(struct __old_kernel_stat));
+ #endif
+
diff --git a/debian/patches/libffi-race-condition.diff b/debian/patches/libffi-race-condition.diff
new file mode 100644
index 0000000..4e18c82
--- /dev/null
+++ b/debian/patches/libffi-race-condition.diff
@@ -0,0 +1,33 @@
+From 48d2e46528fb6e621d95a7fa194069fd136b712d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Stefan=20B=C3=BChler?= <buehler@cert.uni-stuttgart.de>
+Date: Wed, 7 Sep 2016 15:49:48 +0200
+Subject: [PATCH 1/2] dlmmap_locked always needs locking as it always modifies
+ execsize
+
+---
+ src/closures.c | 13 ++++---------
+ 1 file changed, 4 insertions(+), 9 deletions(-)
+
+--- a/src/libffi/src/closures.c
++++ b/src/libffi/src/closures.c
+@@ -897,16 +897,11 @@ dlmmap (void *start, size_t length, int
+ MREMAP_DUP and prot at this point. */
+ }
+
+- if (execsize == 0 || execfd == -1)
+- {
+- pthread_mutex_lock (&open_temp_exec_file_mutex);
+- ptr = dlmmap_locked (start, length, prot, flags, offset);
+- pthread_mutex_unlock (&open_temp_exec_file_mutex);
++ pthread_mutex_lock (&open_temp_exec_file_mutex);
++ ptr = dlmmap_locked (start, length, prot, flags, offset);
++ pthread_mutex_unlock (&open_temp_exec_file_mutex);
+
+- return ptr;
+- }
+-
+- return dlmmap_locked (start, length, prot, flags, offset);
++ return ptr;
+ }
+
+ /* Release memory at the given address, as well as the corresponding
diff --git a/debian/patches/libffi-ro-eh_frame_sect.diff b/debian/patches/libffi-ro-eh_frame_sect.diff
new file mode 100644
index 0000000..3653876
--- /dev/null
+++ b/debian/patches/libffi-ro-eh_frame_sect.diff
@@ -0,0 +1,13 @@
+# DP: PR libffi/47248, force a read only eh frame section.
+
+--- a/src/libffi/configure.ac
++++ b/src/libffi/configure.ac
+@@ -296,6 +296,8 @@ if test "x$GCC" = "xyes"; then
+ libffi_cv_hidden_visibility_attribute=yes
+ fi
+ fi
++ # FIXME: see PR libffi/47248
++ libffi_cv_ro_eh_frame=yes
+ rm -f conftest.*
+ ])
+ if test $libffi_cv_hidden_visibility_attribute = yes; then
diff --git a/debian/patches/libgo-cleanfiles.diff b/debian/patches/libgo-cleanfiles.diff
new file mode 100644
index 0000000..71a075b
--- /dev/null
+++ b/debian/patches/libgo-cleanfiles.diff
@@ -0,0 +1,26 @@
+--- a/src/libgo/Makefile.am
++++ b/src/libgo/Makefile.am
+@@ -1364,7 +1364,9 @@ mostlyclean-local:
+ find . -name '*-testsum' -print | xargs rm -f
+ find . -name '*-testlog' -print | xargs rm -f
+
+-CLEANFILES = *.go *.c s-* libgo.sum libgo.log runtime.inc
++CLEANFILES = *.go *.c s-* libgo.sum libgo.log runtime.inc \
++ *.dep */*.dep */*/*.dep */*/*/*.dep */*/*.dep */*/*/*/*.dep \
++ */*/*/*/*/*.dep
+
+ clean-local:
+ find . -name '*.la' -print | xargs $(LIBTOOL) --mode=clean rm -f
+--- a/src/libgo/Makefile.in
++++ b/src/libgo/Makefile.in
+@@ -1206,7 +1206,9 @@ MOSTLYCLEANFILES = \
+ libcalls-list \
+ runtime.inc runtime.inc.tmp2 runtime.inc.tmp3 runtime.inc.raw
+
+-CLEANFILES = *.go *.c s-* libgo.sum libgo.log runtime.inc
++CLEANFILES = *.go *.c s-* libgo.sum libgo.log runtime.inc \
++ *.dep */*.dep */*/*.dep */*/*/*.dep */*/*.dep */*/*/*/*.dep \
++ */*/*/*/*/*.dep
+ MULTISRCTOP =
+ MULTIBUILDTOP =
+ MULTIDIRS =
diff --git a/debian/patches/libgo-hurd-hack.diff b/debian/patches/libgo-hurd-hack.diff
new file mode 100644
index 0000000..c25f8c1
--- /dev/null
+++ b/debian/patches/libgo-hurd-hack.diff
@@ -0,0 +1,22 @@
+# FIXME: #1005297, PR 104660
+
+--- a/src/Makefile.in
++++ b/src/Makefile.in
+@@ -67372,6 +67372,8 @@ all-flex: maybe-all-build-texinfo
+ all-m4: maybe-all-build-texinfo
+ configure-target-libgo: maybe-configure-target-libffi
+ all-target-libgo: maybe-all-target-libffi
++all-target-libgo: maybe-all-target-libbacktrace
++all-target-libgo: maybe-all-target-libatomic
+ configure-target-libphobos: maybe-configure-target-libbacktrace
+ configure-stage1-target-libphobos: maybe-configure-stage1-target-libbacktrace
+ configure-stage2-target-libphobos: maybe-configure-stage2-target-libbacktrace
+@@ -67539,8 +67541,6 @@ all-m4: maybe-all-intl
+ configure-target-fastjar: maybe-configure-target-zlib
+ all-target-fastjar: maybe-all-target-zlib
+ configure-target-libgo: maybe-all-target-libstdc++-v3
+-all-target-libgo: maybe-all-target-libbacktrace
+-all-target-libgo: maybe-all-target-libatomic
+ configure-target-libgm2: maybe-all-target-libstdc++-v3
+ all-target-libgm2: maybe-all-target-libatomic
+ configure-target-liboffloadmic: maybe-configure-target-libgomp
diff --git a/debian/patches/libgo-revert-timeout-exp.diff b/debian/patches/libgo-revert-timeout-exp.diff
new file mode 100644
index 0000000..af0b838
--- /dev/null
+++ b/debian/patches/libgo-revert-timeout-exp.diff
@@ -0,0 +1,10 @@
+--- a/src/libgo/testsuite/lib/libgo.exp
++++ b/src/libgo/testsuite/lib/libgo.exp
+@@ -49,7 +49,6 @@ load_gcc_lib wrapper.exp
+ load_gcc_lib target-supports.exp
+ load_gcc_lib target-utils.exp
+ load_gcc_lib gcc-defs.exp
+-load_gcc_lib timeout.exp
+ load_gcc_lib go.exp
+
+ proc libgo_init { args } {
diff --git a/debian/patches/libgo-setcontext-config.diff b/debian/patches/libgo-setcontext-config.diff
new file mode 100644
index 0000000..b866e2d
--- /dev/null
+++ b/debian/patches/libgo-setcontext-config.diff
@@ -0,0 +1,19 @@
+# DP: libgo: Overwrite the setcontext_clobbers_tls check on mips*
+
+--- a/src/libgo/configure.ac
++++ b/src/libgo/configure.ac
+@@ -794,6 +794,14 @@ main ()
+ CFLAGS="$CFLAGS_hold"
+ LIBS="$LIBS_hold"
+ ])
++dnl overwrite for the mips* 64bit multilibs, fails on some buildds
++if test "$libgo_cv_lib_setcontext_clobbers_tls" = "yes"; then
++ case "$target" in
++ mips*-linux-*)
++ AC_MSG_WARN([FIXME: overwrite setcontext_clobbers_tls for $target:$ptr_type_size])
++ libgo_cv_lib_setcontext_clobbers_tls=no ;;
++ esac
++fi
+ if test "$libgo_cv_lib_setcontext_clobbers_tls" = "yes"; then
+ AC_DEFINE(SETCONTEXT_CLOBBERS_TLS, 1,
+ [Define if setcontext clobbers TLS variables])
diff --git a/debian/patches/libgo-soname.diff b/debian/patches/libgo-soname.diff
new file mode 100644
index 0000000..74297a7
--- /dev/null
+++ b/debian/patches/libgo-soname.diff
@@ -0,0 +1,13 @@
+# DP: Bump the libgo soname to distinguish from GCC 13 (local patch)
+
+--- a/src/libgo/configure.ac
++++ b/src/libgo/configure.ac
+@@ -10,7 +10,7 @@
+ AC_CONFIG_SRCDIR(Makefile.am)
+ AC_CONFIG_HEADER(config.h)
+
+-libtool_VERSION=22:0:0
++libtool_VERSION=42:0:0
+ AC_SUBST(libtool_VERSION)
+
+ AM_ENABLE_MULTILIB(, ..)
diff --git a/debian/patches/libgo-testsuite.diff b/debian/patches/libgo-testsuite.diff
new file mode 100644
index 0000000..bb42677
--- /dev/null
+++ b/debian/patches/libgo-testsuite.diff
@@ -0,0 +1,66 @@
+# DP: Only run the libgo testsuite for flags configured in RUNTESTFLAGS
+
+--- a/src/libgo/Makefile.am
++++ b/src/libgo/Makefile.am
+@@ -922,7 +922,7 @@ BUILDGOX = \
+ $(SHELL) $(srcdir)/mvifdiff.sh $@.tmp `echo $@ | sed -e 's/s-gox/gox/'`
+
+ GOTESTFLAGS =
+-GOBENCH =
++GOBENCH =
+
+ # Check a package.
+ CHECK = \
+@@ -943,6 +943,12 @@ CHECK = \
+ $(MKDIR_P) $(@D); \
+ rm -f $@-testsum $@-testlog; \
+ files=`$(SHELL) $(srcdir)/match.sh --goarch=$(GOARCH) --goos=$(GOOS) --srcdir=$(srcdir)/go/$(@D) --extrafiles="$(extra_go_files_$(subst .,_,$(subst /,_,$(@D))))" $(matchargs_$(subst /,_,$(@D)))`; \
++ run_check=yes; \
++ MULTILIBDIR="$(MULTILIBDIR)"; \
++ case "$$MULTILIBDIR" in /64|/x32) \
++ echo "$$RUNTESTFLAGS" | grep -q "$${MULTILIBDIR\#/*}" || run_check=; \
++ esac; \
++ if test "$$run_check" = "yes"; then \
+ if test "$(USE_DEJAGNU)" = "yes"; then \
+ $(SHELL) $(srcdir)/testsuite/gotest --goarch=$(GOARCH) --goos=$(GOOS) --dejagnu=yes --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$$files" --testname="$(@D)" $(GOTESTFLAGS); \
+ elif test "$(GOBENCH)" != ""; then \
+@@ -958,6 +964,7 @@ CHECK = \
+ echo "FAIL: $(@D)" > $@-testsum; \
+ exit 1; \
+ fi; \
++ fi; \
+ fi
+
+ # Build all packages before checking any.
+--- a/src/libgo/Makefile.in
++++ b/src/libgo/Makefile.in
+@@ -1044,7 +1044,7 @@ BUILDGOX = \
+ $(SHELL) $(srcdir)/mvifdiff.sh $@.tmp `echo $@ | sed -e 's/s-gox/gox/'`
+
+ GOTESTFLAGS =
+-GOBENCH =
++GOBENCH =
+
+ # Check a package.
+ CHECK = \
+@@ -1065,6 +1065,12 @@ CHECK = \
+ $(MKDIR_P) $(@D); \
+ rm -f $@-testsum $@-testlog; \
+ files=`$(SHELL) $(srcdir)/match.sh --goarch=$(GOARCH) --goos=$(GOOS) --srcdir=$(srcdir)/go/$(@D) --extrafiles="$(extra_go_files_$(subst .,_,$(subst /,_,$(@D))))" $(matchargs_$(subst /,_,$(@D)))`; \
++ run_check=yes; \
++ MULTILIBDIR="$(MULTILIBDIR)"; \
++ case "$$MULTILIBDIR" in /64|/x32) \
++ echo "$$RUNTESTFLAGS" | grep -q "$${MULTILIBDIR\#/*}" || run_check=; \
++ esac; \
++ if test "$$run_check" = "yes"; then \
+ if test "$(USE_DEJAGNU)" = "yes"; then \
+ $(SHELL) $(srcdir)/testsuite/gotest --goarch=$(GOARCH) --goos=$(GOOS) --dejagnu=yes --basedir=$(srcdir) --srcdir=$(srcdir)/go/$(@D) --pkgpath="$(@D)" --pkgfiles="$$files" --testname="$(@D)" $(GOTESTFLAGS); \
+ elif test "$(GOBENCH)" != ""; then \
+@@ -1080,6 +1086,7 @@ CHECK = \
+ echo "FAIL: $(@D)" > $@-testsum; \
+ exit 1; \
+ fi; \
++ fi; \
+ fi
+
+
diff --git a/debian/patches/libgomp-omp_h-multilib.diff b/debian/patches/libgomp-omp_h-multilib.diff
new file mode 100644
index 0000000..7f2cfa2
--- /dev/null
+++ b/debian/patches/libgomp-omp_h-multilib.diff
@@ -0,0 +1,32 @@
+# DP: Fix up omp.h for multilibs.
+
+2008-06-09 Jakub Jelinek <jakub@redhat.com>
+
+ * omp.h.in (omp_nest_lock_t): Fix up for Linux multilibs.
+
+2015-03-25 Matthias Klose <doko@ubuntu.com>
+
+ * omp.h.in (omp_nest_lock_t): Limit the fix Linux.
+
+--- a/src/libgomp/omp.h.in
++++ b/src/libgomp/omp.h.in
+@@ -52,8 +52,19 @@ typedef struct
+
+ typedef struct
+ {
++ /*
++ Derive OMP_NEST_LOCK_SIZE and OMP_NEST_LOCK_ALIGN, don't hard
++ code the values because the header is used for all multilibs.
++ OMP_NEST_LOCK_SIZE = @OMP_NEST_LOCK_SIZE@
++ OMP_NEST_LOCK_ALIGN = @OMP_NEST_LOCK_ALIGN@
++ */
++#if defined(__linux__) && !(defined(__hppa__) || defined(__alpha__))
++ unsigned char _x[8 + sizeof (void *)]
++ __attribute__((__aligned__(sizeof (void *))));
++#else
+ unsigned char _x[@OMP_NEST_LOCK_SIZE@]
+ __attribute__((__aligned__(@OMP_NEST_LOCK_ALIGN@)));
++#endif
+ } omp_nest_lock_t;
+ #endif
+
diff --git a/debian/patches/libitm-no-fortify-source.diff b/debian/patches/libitm-no-fortify-source.diff
new file mode 100644
index 0000000..fe0c705
--- /dev/null
+++ b/debian/patches/libitm-no-fortify-source.diff
@@ -0,0 +1,17 @@
+# DP: Build libitm with -U_FORTIFY_SOURCE on x86 and x86_64.
+
+--- a/src/libitm/configure.tgt
++++ b/src/libitm/configure.tgt
+@@ -124,6 +124,12 @@ EOF
+ ;;
+ esac
+
++# FIXME: ftbfs with -D_FORTIFY_SOURCE (error: invalid use of '__builtin_va_arg_pack ())
++case "${target}" in
++ *-*-linux*)
++ XCFLAGS="${XCFLAGS} -U_FORTIFY_SOURCE"
++esac
++
+ # For the benefit of top-level configure, determine if the cpu is supported.
+ test -d ${srcdir}/config/$ARCH || UNSUPPORTED=1
+
diff --git a/debian/patches/libphobos-soname.diff b/debian/patches/libphobos-soname.diff
new file mode 100644
index 0000000..a47c5ba
--- /dev/null
+++ b/debian/patches/libphobos-soname.diff
@@ -0,0 +1,13 @@
+# DP: Bump the libphobos soname to distinguish from GCC 13 (local patch)
+
+--- a/src/libphobos/configure.ac
++++ b/src/libphobos/configure.ac
+@@ -258,7 +258,7 @@
+ AC_SUBST(SPEC_PHOBOS_DEPS)
+
+ # Libdruntime / phobos soname version
+-libtool_VERSION=4:0:0
++libtool_VERSION=5:0:0
+ AC_SUBST(libtool_VERSION)
+
+ # Set default flags (after DRUNTIME_WERROR!)
diff --git a/debian/patches/libphobos-zlib.diff b/debian/patches/libphobos-zlib.diff
new file mode 100644
index 0000000..ddf7c95
--- /dev/null
+++ b/debian/patches/libphobos-zlib.diff
@@ -0,0 +1,72 @@
+# DP: Build zlib in any case to have a fall back for missing libz multilibs
+
+--- a/src/libphobos/configure.ac
++++ b/src/libphobos/configure.ac
+@@ -142,6 +142,7 @@ DRUNTIME_LIBRARIES_BACKTRACE
+ DRUNTIME_LIBRARIES_DLOPEN
+ DRUNTIME_LIBRARIES_ZLIB
+ DRUNTIME_INSTALL_DIRECTORIES
++dnl fake change to regenerate the configure file
+
+ # Add dependencies for libgphobos.spec file
+ SPEC_PHOBOS_DEPS="$LIBS"
+--- a/src/libphobos/m4/druntime/libraries.m4
++++ b/src/libphobos/m4/druntime/libraries.m4
+@@ -52,19 +52,45 @@ AC_DEFUN([DRUNTIME_LIBRARIES_ZLIB],
+ [
+ AC_ARG_WITH(target-system-zlib,
+ AS_HELP_STRING([--with-target-system-zlib],
+- [use installed libz (default: no)]))
++ [use installed libz (default: no)]),
++ [system_zlib=yes],[system_zlib=no])
+
+- system_zlib=false
+- AS_IF([test "x$with_target_system_zlib" = "xyes"], [
+- AC_CHECK_LIB([z], [deflate], [
+- system_zlib=yes
+- ], [
+- AC_MSG_ERROR([System zlib not found])
+- ])
+- ], [
+- AC_MSG_CHECKING([for zlib])
+- AC_MSG_RESULT([just compiled])
+- ])
++ AC_MSG_CHECKING([for system zlib])
++ save_LIBS=$LIBS
++ LIBS="$LIBS -lz"
++ dnl the link test is not good enough for ARM32 multilib detection,
++ dnl first check to link, then to run
++ AC_LANG_PUSH(C)
++ AC_LINK_IFELSE(
++ [AC_LANG_PROGRAM([#include <zlib.h>],[gzopen("none", "rb")])],
++ [
++ AC_RUN_IFELSE([AC_LANG_SOURCE([[
++ #include <zlib.h>
++ int main() {
++ gzFile file = gzopen("none", "rb");
++ return 0;
++ }
++ ]])],
++ [system_zlib_found=yes],
++ [system_zlib_found=no],
++ dnl no system zlib for cross builds ...
++ [system_zlib_found=no]
++ )
++ ],
++ [system_zlib_found=no])
++ if test x$system_zlib = xyes; then
++ if test x$system_zlib_found = xyes; then
++ AC_MSG_RESULT([found])
++ else
++ LIBS=$save_LIBS
++ AC_MSG_RESULT([not found, disabled])
++ system_zlib=no
++ fi
++ else
++ LIBS=$save_LIBS
++ AC_MSG_RESULT([not enabled])
++ fi
++ AC_LANG_POP
+
+ AM_CONDITIONAL([DRUNTIME_ZLIB_SYSTEM], [test "$with_target_system_zlib" = yes])
+ ])
diff --git a/debian/patches/libstdc++-doclink.diff b/debian/patches/libstdc++-doclink.diff
new file mode 100644
index 0000000..f209cf7
--- /dev/null
+++ b/debian/patches/libstdc++-doclink.diff
@@ -0,0 +1,61 @@
+# DP: adjust hrefs to point to the local documentation
+
+---
+ libstdc++-v3/doc/doxygen/mainpage.html | 10 +++++-----
+ 1 files changed, 5 insertions(+), 5 deletions(-)
+
+--- a/src/libstdc++-v3/doc/doxygen/mainpage.html
++++ b/src/libstdc++-v3/doc/doxygen/mainpage.html
+@@ -27,10 +27,10 @@
+ <p class="smallertext">Generated on @DATE@.</p>
+
+ <p>There are two types of documentation for libstdc++. One is the
+- distribution documentation, which can be read online
+- <a href="https://gcc.gnu.org/onlinedocs/libstdc++/index.html">here</a>
+- or offline from the file doc/html/index.html in the library source
+- directory.
++ distribution documentation, which can be read
++ <a href="../index.html">offline in the documentation directory</a>
++ or
++ <a href="https://gcc.gnu.org/onlinedocs/libstdc++/index.html">online</a>.
+ </p>
+
+ <p>The other type is the source documentation, of which this is the first page.
+@@ -82,8 +82,11 @@
+
+ <h2>License, Copyright, and Other Lawyerly Verbosity</h2>
+ <p>The libstdc++ documentation is released under
++ these terms
++ (<a href="../manual/appendix_gpl.html">read offline</a> or
+ <a href="https://gcc.gnu.org/onlinedocs/libstdc++/manual/appendix_gpl.html">
+- these terms</a>.
++ read online</a>.
++ ).
+ </p>
+ <p>Part of the generated documentation involved comments and notes from
+ SGI, who says we gotta say this:
+--- a/src/libstdc++-v3/doc/html/api.html
++++ b/src/libstdc++-v3/doc/html/api.html
+@@ -20,6 +20,8 @@
+ member functions for the library classes, finding out what is in a
+ particular include file, looking at inheritance diagrams, etc.
+ </p><p>
++<a class="link" href="user/index.html">The API documentation, rendered into HTML, can be viewed offline.</a>
++</p><p>
+ The API documentation, rendered into HTML, can be viewed online
+ <a class="link" href="http://gcc.gnu.org/onlinedocs/" target="_top">for each GCC release</a>
+ and
+--- a/src/libstdc++-v3/doc/xml/api.xml
++++ b/src/libstdc++-v3/doc/xml/api.xml
+@@ -40,6 +40,11 @@
+ </para>
+
+ <para>
++ <ulink url="user/index.html">The source-level documentation for this release can be viewed offline.
++ </ulink>
++</para>
++
++<para>
+ The API documentation, rendered into HTML, can be viewed online
+ <link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://gcc.gnu.org/onlinedocs/">for each GCC release</link>
+ and
diff --git a/debian/patches/libstdc++-doxygen-SOURCE_DATE_EPOCH.diff b/debian/patches/libstdc++-doxygen-SOURCE_DATE_EPOCH.diff
new file mode 100644
index 0000000..1636c08
--- /dev/null
+++ b/debian/patches/libstdc++-doxygen-SOURCE_DATE_EPOCH.diff
@@ -0,0 +1,13 @@
+--- gcc-13.1.0/src/libstdc++-v3/scripts/run_doxygen 2023-04-26 00:09:43.000000000 -0700
++++ gcc-13.1.0/src/libstdc++-v3/scripts/run_doxygen.new 2023-04-30 14:34:47.513318389 -0700
+@@ -130,7 +130,9 @@
+ latex_cmd=
+ enabled_sections=
+ generate_tagfile=
+-DATEtext=`date '+%Y-%m-%d'`
++DATE_FMT="+%Y-%m-%d"
++SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:-$(date +%s)}"
++DATEtext=`date -u -d "@$SOURCE_DATE_EPOCH" "$DATE_FMT" 2>/dev/null || date -u -r "$SOURCE_DATE_EPOCH" "$DATE_FMT" 2>/dev/null || date -u "$DATE_FMT"`
+
+ # Show how this script is called.
+ echo run_doxygen $*
diff --git a/debian/patches/libstdc++-hurd.diff b/debian/patches/libstdc++-hurd.diff
new file mode 100644
index 0000000..278d83a
--- /dev/null
+++ b/debian/patches/libstdc++-hurd.diff
@@ -0,0 +1,48 @@
+This is notably needed because in glibc 2.34, the move of pthread functions
+into libc.so happened for Linux only, not GNU/Hurd.
+
+The pthread_self() function can also always be used fine as it is on
+GNU/Hurd.
+
+libstdc++-v3/ChangeLog:
+
+ * config/os/gnu-linux/os_defines.h [!__linux__]
+ (_GLIBCXX_NATIVE_THREAD_ID, _GLIBCXX_GTHREAD_USE_WEAK): Do not define.
+
+--- a/src/libstdc++-v3/config/os/gnu-linux/os_defines.h
++++ b/src/libstdc++-v3/config/os/gnu-linux/os_defines.h
+@@ -60,22 +60,24 @@
+ # define _GLIBCXX_HAVE_FLOAT128_MATH 1
+ #endif
+
+-#if __GLIBC_PREREQ(2, 27)
+-// Since glibc 2.27 pthread_self() is usable without linking to libpthread.
+-# define _GLIBCXX_NATIVE_THREAD_ID pthread_self()
+-#else
++#ifdef __linux__
++# if __GLIBC_PREREQ(2, 27)
++// Since glibc 2.27 Linux' pthread_self() is usable without linking to libpthread.
++# define _GLIBCXX_NATIVE_THREAD_ID pthread_self()
++# else
+ // Before then it was in libc.so.6 but not libc.a, and always returns 0,
+ // which breaks the invariant this_thread::get_id() != thread::id{}.
+ // So only use it if we know the libpthread version is available.
+ // Otherwise use (__gthread_t)1 as the ID of the main (and only) thread.
+-# define _GLIBCXX_NATIVE_THREAD_ID \
+- (__gthread_active_p() ? __gthread_self() : (__gthread_t)1)
+-#endif
++# define _GLIBCXX_NATIVE_THREAD_ID \
++ (__gthread_active_p() ? __gthread_self() : (__gthread_t)1)
++# endif
+
+-#if __GLIBC_PREREQ(2, 34)
+-// Since glibc 2.34 all pthreads functions are usable without linking to
++# if __GLIBC_PREREQ(2, 34)
++// Since glibc 2.34 all Linux pthreads functions are usable without linking to
+ // libpthread.
+-# define _GLIBCXX_GTHREAD_USE_WEAK 0
++# define _GLIBCXX_GTHREAD_USE_WEAK 0
++# endif
+ #endif
+
+ #endif
diff --git a/debian/patches/libstdc++-man-3cxx.diff b/debian/patches/libstdc++-man-3cxx.diff
new file mode 100644
index 0000000..f0b9c11
--- /dev/null
+++ b/debian/patches/libstdc++-man-3cxx.diff
@@ -0,0 +1,63 @@
+# DP: Install libstdc++ man pages with suffix .3cxx instead of .3
+
+--- a/src/libstdc++-v3/doc/doxygen/user.cfg.in
++++ b/src/libstdc++-v3/doc/doxygen/user.cfg.in
+@@ -2135,7 +2135,7 @@ MAN_OUTPUT = man
+ # The default value is: .3.
+ # This tag requires that the tag GENERATE_MAN is set to YES.
+
+-MAN_EXTENSION = .3
++MAN_EXTENSION = .3cxx
+
+ # The MAN_SUBDIR tag determines the name of the directory created within
+ # MAN_OUTPUT in which the man pages are placed. If defaults to man followed by
+--- a/src/libstdc++-v3/scripts/run_doxygen
++++ b/src/libstdc++-v3/scripts/run_doxygen
+@@ -262,6 +262,9 @@ fi
+ if $do_man; then
+ echo ::
+ echo :: Fixing up the man pages...
++mkdir -p $outdir/man/man3
++mv $outdir/man/man3cxx/* $outdir/man/man3/
++rmdir $outdir/man/man3cxx
+ cd $outdir/man/man3
+
+ # File names with embedded spaces (EVIL!) need to be....? renamed or removed?
+@@ -291,7 +294,7 @@ cxxflags="-Og -g -std=gnu++23"
+ $gxx $cppflags $cxxflags ${srcdir}/doc/doxygen/stdheader.cc -o ./stdheader || exit 1
+ # Doxygen outputs something like "\fC#include <unique_lock\&.h>\fP" and
+ # we want that internal header to be replaced with something like <mutex>.
+-problematic=`grep -E -l '#include <.*h>' [a-z]*.3`
++problematic=`grep -E -l '#include <.*h>' [a-z]*.3 [a-z]*.3cxx`
+ for f in $problematic; do
+ # this is also slow, but safe and easy to debug
+ oldh=`sed -n '/fC#include </s/.*<\(.*\)>.*/\1/p' $f`
+@@ -303,7 +306,7 @@ rm stdheader
+ # Some of the pages for generated modules have text that confuses certain
+ # implementations of man(1), e.g. on GNU/Linux. We need to have another
+ # top-level *roff tag to /stop/ the .SH NAME entry.
+-problematic=`grep -E --files-without-match '^\.SH SYNOPSIS' [A-Z]*.3`
++problematic=`grep -E --files-without-match '^\.SH SYNOPSIS' [A-Z]*.3cxx`
+ #problematic='Containers.3 Sequences.3 Assoc_containers.3 Iterator_types.3'
+
+ for f in $problematic; do
+@@ -317,7 +320,7 @@ a\
+ done
+
+ # Also, break this (generated) line up. It's ugly as sin.
+-problematic=`grep -l '[^^]Definition at line' *.3`
++problematic=`grep -l '[^^]Definition at line' *.3 *.3cxx`
+ for f in $problematic; do
+ sed 's/Definition at line/\
+ .PP\
+@@ -435,8 +438,8 @@ for f in ios streambuf istream ostream i
+ istringstream ostringstream stringstream filebuf ifstream \
+ ofstream fstream string
+ do
+- echo ".so man3/std::basic_${f}.3" > std::${f}.3
+- echo ".so man3/std::basic_${f}.3" > std::w${f}.3
++ echo ".so man3/std::basic_${f}.3cxx" > std::${f}.3cxx
++ echo ".so man3/std::basic_${f}.3cxx" > std::w${f}.3cxx
+ done
+
+ echo ::
diff --git a/debian/patches/libstdc++-no-testsuite.diff b/debian/patches/libstdc++-no-testsuite.diff
new file mode 100644
index 0000000..771bf7a
--- /dev/null
+++ b/debian/patches/libstdc++-no-testsuite.diff
@@ -0,0 +1,12 @@
+# DP: Don't run the libstdc++ testsuite on arm, hppa and mipsel (timeouts on the buildds)
+
+--- a/src/libstdc++-v3/testsuite/Makefile.in
++++ b/src/libstdc++-v3/testsuite/Makefile.in
+@@ -567,6 +567,7 @@
+
+ # Run the testsuite in normal mode.
+ check-DEJAGNU $(check_DEJAGNU_normal_targets): check-DEJAGNU%: site.exp
++ case "$(target)" in arm*|hppa*|mipsel*) exit 0;; esac; \
+ $(if $*,@)AR="$(AR)"; export AR; \
+ RANLIB="$(RANLIB)"; export RANLIB; \
+ if [ -z "$*" ] && [ "$(filter -j, $(MFLAGS))" = "-j" ]; then \
diff --git a/debian/patches/libstdc++-nothumb-check.diff b/debian/patches/libstdc++-nothumb-check.diff
new file mode 100644
index 0000000..6c665a2
--- /dev/null
+++ b/debian/patches/libstdc++-nothumb-check.diff
@@ -0,0 +1,38 @@
+# DP: Don't run the libstdc++-v3 testsuite in thumb mode on armel
+
+Index: testsuite/Makefile.in
+===================================================================
+--- a/src/libstdc++-v3/testsuite/Makefile.in (revision 156820)
++++ b/src/libstdc++-v3/testsuite/Makefile.in (working copy)
+@@ -583,6 +583,8 @@
+ srcdir=`$(am__cd) $(srcdir) && pwd`; export srcdir; \
+ EXPECT=$(EXPECT); export EXPECT; \
+ runtest=$(RUNTEST); \
++ runtestflags="`echo '$(RUNTESTFLAGS)' | sed 's/,-marm/-marm/'`"; \
++ case "$$runtestflags" in *\\{\\}) runtestflags=; esac; \
+ if [ -z "$$runtest" ]; then runtest=runtest; fi; \
+ tool=libstdc++; \
+ dirs=; \
+@@ -590,7 +592,7 @@
+ normal0) \
+ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
+ $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) \
+- $(RUNTESTFLAGS) abi.exp; \
++ $$runtestflags abi.exp; \
+ else echo "WARNING: could not find \`runtest'" 1>&2; :;\
+ fi; \
+ dirs="`cd $$srcdir; echo [013-9][0-9]_*/* [abep]*/*`";; \
+@@ -605,11 +607,11 @@
+ if $(SHELL) -c "$$runtest --version" > /dev/null 2>&1; then \
+ if [ -n "$$dirs" ]; then \
+ $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) \
+- $(RUNTESTFLAGS) \
++ $$runtestflags \
+ "conformance.exp=`echo $$dirs | sed 's/ /* /g;s/$$/*/'`"; \
+ else \
+ $$runtest $(AM_RUNTESTFLAGS) $(RUNTESTDEFAULTFLAGS) \
+- $(RUNTESTFLAGS); \
++ $$runtestflags; \
+ fi; \
+ else echo "WARNING: could not find \`runtest'" 1>&2; :;\
+ fi
diff --git a/debian/patches/libstdc++-pic.diff b/debian/patches/libstdc++-pic.diff
new file mode 100644
index 0000000..6adac41
--- /dev/null
+++ b/debian/patches/libstdc++-pic.diff
@@ -0,0 +1,91 @@
+# DP: Build and install libstdc++_pic.a library.
+
+--- a/src/libstdc++-v3/src/Makefile.am
++++ b/src/libstdc++-v3/src/Makefile.am
+@@ -379,10 +379,12 @@ if GLIBCXX_BUILD_DEBUG
+ STAMP_DEBUG = build-debug
+ STAMP_INSTALL_DEBUG = install-debug
+ CLEAN_DEBUG = debug
++STAMP_INSTALL_PIC = install-pic
+ else
+ STAMP_DEBUG =
+ STAMP_INSTALL_DEBUG =
+ CLEAN_DEBUG =
++STAMP_INSTALL_PIC =
+ endif
+
+ # Build a debug variant.
+@@ -425,6 +427,7 @@ build-debug: stamp-debug $(debug_backtra
+ mv Makefile Makefile.tmp; \
+ sed -e 's,all-local: all-once,all-local:,' \
+ -e 's,install-data-local: install-data-once,install-data-local:,' \
++ -e 's,install-exec-local:.*,install-exec-local:,' \
+ -e '/vpath/!s,src/c,src/debug/c,' \
+ < Makefile.tmp > Makefile ; \
+ rm -f Makefile.tmp ; \
+@@ -435,3 +438,8 @@ build-debug: stamp-debug $(debug_backtra
+ install-debug: build-debug
+ (cd ${debugdir} && $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
+ toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install) ;
++
++install-exec-local: $(STAMP_INSTALL_PIC)
++$(STAMP_INSTALL_PIC):
++ $(MKDIR_P) $(DESTDIR)$(toolexeclibdir)
++ $(INSTALL_DATA) .libs/libstdc++convenience.a $(DESTDIR)$(toolexeclibdir)/libstdc++_pic.a
+--- a/src/libstdc++-v3/src/Makefile.in
++++ b/src/libstdc++-v3/src/Makefile.in
+@@ -676,6 +676,8 @@ CXXLINK = \
+ @GLIBCXX_BUILD_DEBUG_TRUE@STAMP_INSTALL_DEBUG = install-debug
+ @GLIBCXX_BUILD_DEBUG_FALSE@CLEAN_DEBUG =
+ @GLIBCXX_BUILD_DEBUG_TRUE@CLEAN_DEBUG = debug
++@GLIBCXX_BUILD_DEBUG_FALSE@STAMP_INSTALL_PIC =
++@GLIBCXX_BUILD_DEBUG_TRUE@STAMP_INSTALL_PIC = install-pic
+
+ # Build a debug variant.
+ # Take care to fix all possibly-relative paths.
+@@ -944,7 +946,7 @@ install-dvi: install-dvi-recursive
+
+ install-dvi-am:
+
+-install-exec-am: install-toolexeclibLTLIBRARIES
++install-exec-am: install-exec-local install-toolexeclibLTLIBRARIES
+
+ install-html: install-html-recursive
+
+@@ -994,11 +996,11 @@ uninstall-am: uninstall-toolexeclibLTLIB
+ distclean-libtool distclean-tags dvi dvi-am html html-am info \
+ info-am install install-am install-data install-data-am \
+ install-data-local install-dvi install-dvi-am install-exec \
+- install-exec-am install-html install-html-am install-info \
+- install-info-am install-man install-pdf install-pdf-am \
+- install-ps install-ps-am install-strip \
+- install-toolexeclibLTLIBRARIES installcheck installcheck-am \
+- installdirs installdirs-am maintainer-clean \
++ install-exec-am install-exec-local install-html \
++ install-html-am install-info install-info-am install-man \
++ install-pdf install-pdf-am install-ps install-ps-am \
++ install-strip install-toolexeclibLTLIBRARIES installcheck \
++ installcheck-am installdirs installdirs-am maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags tags-am uninstall uninstall-am \
+@@ -1147,6 +1149,7 @@ build-debug: stamp-debug $(debug_backtra
+ mv Makefile Makefile.tmp; \
+ sed -e 's,all-local: all-once,all-local:,' \
+ -e 's,install-data-local: install-data-once,install-data-local:,' \
++ -e 's,install-exec-local:.*,install-exec-local:,' \
+ -e '/vpath/!s,src/c,src/debug/c,' \
+ < Makefile.tmp > Makefile ; \
+ rm -f Makefile.tmp ; \
+@@ -1158,6 +1161,11 @@ install-debug: build-debug
+ (cd ${debugdir} && $(MAKE) CXXFLAGS='$(DEBUG_FLAGS)' \
+ toolexeclibdir=$(glibcxx_toolexeclibdir)/debug install) ;
+
++install-exec-local: $(STAMP_INSTALL_PIC)
++$(STAMP_INSTALL_PIC):
++ $(MKDIR_P) $(DESTDIR)$(toolexeclibdir)
++ $(INSTALL_DATA) .libs/libstdc++convenience.a $(DESTDIR)$(toolexeclibdir)/libstdc++_pic.a
++
+ # Tell versions [3.59,3.63) of GNU make to not export all variables.
+ # Otherwise a system limit (for SysV at least) may be exceeded.
+ .NOEXPORT:
diff --git a/debian/patches/libstdc++-pythondir.diff b/debian/patches/libstdc++-pythondir.diff
new file mode 100644
index 0000000..325020c
--- /dev/null
+++ b/debian/patches/libstdc++-pythondir.diff
@@ -0,0 +1,22 @@
+--- a/src/libstdc++-v3/python/Makefile.am
++++ b/src/libstdc++-v3/python/Makefile.am
+@@ -26,7 +26,7 @@ include $(top_srcdir)/fragment.am
+ if ENABLE_PYTHONDIR
+ pythondir = $(prefix)/$(python_mod_dir)
+ else
+-pythondir = $(datadir)/gcc-$(gcc_version)/python
++pythondir = $(datadir)/gcc/python
+ endif
+
+ if GLIBCXX_BUILD_DEBUG
+--- a/src/libstdc++-v3/python/Makefile.in
++++ b/src/libstdc++-v3/python/Makefile.in
+@@ -409,7 +409,7 @@ WARN_CXXFLAGS = \
+
+ # -I/-D flags to pass when compiling.
+ AM_CPPFLAGS = $(GLIBCXX_INCLUDES) $(CPPFLAGS)
+-@ENABLE_PYTHONDIR_FALSE@pythondir = $(datadir)/gcc-$(gcc_version)/python
++@ENABLE_PYTHONDIR_FALSE@pythondir = $(datadir)/gcc/python
+ @ENABLE_PYTHONDIR_TRUE@pythondir = $(prefix)/$(python_mod_dir)
+ @GLIBCXX_BUILD_DEBUG_FALSE@debug_gdb_py =
+ @GLIBCXX_BUILD_DEBUG_TRUE@debug_gdb_py = YES
diff --git a/debian/patches/libstdc++-test-installed.diff b/debian/patches/libstdc++-test-installed.diff
new file mode 100644
index 0000000..298b229
--- /dev/null
+++ b/debian/patches/libstdc++-test-installed.diff
@@ -0,0 +1,76 @@
+# DP: Add support to run the libstdc++-v3 testsuite using the
+# DP: installed shared libraries.
+
+--- a/src/libstdc++-v3/testsuite/lib/libstdc++.exp
++++ b/src/libstdc++-v3/testsuite/lib/libstdc++.exp
+@@ -37,6 +37,12 @@
+ # the last thing before testing begins. This can be defined in, e.g.,
+ # ~/.dejagnurc or $DEJAGNU.
+
++set test_installed 0
++if [info exists env(TEST_INSTALLED)] {
++ verbose -log "test installed libstdc++-v3"
++ set test_installed 1
++}
++
+ proc load_gcc_lib { filename } {
+ global srcdir loaded_libs
+
+@@ -116,6 +122,7 @@ proc libstdc++_init { testfile } {
+ global tool_timeout
+ global DEFAULT_CXXFLAGS
+ global STATIC_LIBCXXFLAGS
++ global test_installed
+
+ # We set LC_ALL and LANG to C so that we get the same error
+ # messages as expected.
+@@ -135,6 +142,9 @@ proc libstdc++_init { testfile } {
+
+ set blddir [lookfor_file [get_multilibs] libstdc++-v3]
+ set flags_file "${blddir}/scripts/testsuite_flags"
++ if {$test_installed} {
++ set flags_file "${blddir}/scripts/testsuite_flags.installed"
++ }
+ set shlib_ext [get_shlib_extension]
+ v3track flags_file 2
+
+@@ -167,7 +177,11 @@ proc libstdc++_init { testfile } {
+
+ # Locate libgcc.a so we don't need to account for different values of
+ # SHLIB_EXT on different platforms
+- set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
++ if {$test_installed} {
++ set gccdir ""
++ } else {
++ set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
++ }
+ if {$gccdir != ""} {
+ set gccdir [file dirname $gccdir]
+ append ld_library_path_tmp ":${gccdir}"
+@@ -187,7 +201,11 @@ proc libstdc++_init { testfile } {
+
+ # Locate libgomp. This is only required for parallel mode.
+ set v3-libgomp 0
+- set libgompdir [lookfor_file $blddir/../libgomp .libs/libgomp.$shlib_ext]
++ if {$test_installed} {
++ set libgompdir ""
++ } else {
++ set libgompdir [lookfor_file $blddir/../libgomp .libs/libgomp.$shlib_ext]
++ }
+ if {$libgompdir != ""} {
+ set v3-libgomp 1
+ set libgompdir [file dirname $libgompdir]
+@@ -209,7 +227,12 @@ proc libstdc++_init { testfile } {
+
+ # Locate libstdc++ shared library. (ie libstdc++.so.)
+ set v3-sharedlib 0
+- set sharedlibdir [lookfor_file $blddir src/.libs/libstdc++.$shlib_ext]
++ if {$test_installed} {
++ set sharedlibdir ""
++ set v3-sharedlib 1
++ } else {
++ set sharedlibdir [lookfor_file $blddir src/.libs/libstdc++.$shlib_ext]
++ }
+ if {$sharedlibdir != ""} {
+ if { ([string match "*-*-gnu*" $target_triplet]
+ || [string match "*-*-linux*" $target_triplet]
diff --git a/debian/patches/musl-ssp.diff b/debian/patches/musl-ssp.diff
new file mode 100644
index 0000000..1cb23bc
--- /dev/null
+++ b/debian/patches/musl-ssp.diff
@@ -0,0 +1,21 @@
+See https://git.alpinelinux.org/aports/commit/?id=d307f133de1f8a9993ab0d6fd51176b9373df4c3
+and https://www.openwall.com/lists/musl/2014/11/05/3
+
+--- a/src/gcc/gcc.cc
++++ b/src/gcc/gcc.cc
+@@ -1075,8 +1075,15 @@ proper position among the other output f
+
+ #ifndef LINK_SSP_SPEC
+ #ifdef TARGET_LIBC_PROVIDES_SSP
++#if DEFAULT_LIBC == LIBC_MUSL
++/* When linking without -fstack-protector-something but including objects that
++ were built with -fstack-protector-something, calls to __stack_chk_fail_local
++ can be emitted. Thus -lssp_nonshared must be linked unconditionally. */
++#define LINK_SSP_SPEC "-lssp_nonshared"
++#else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit:}"
++#endif
+ #else
+ #define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+ "|fstack-protector-strong|fstack-protector-explicit" \
diff --git a/debian/patches/note-gnu-stack.diff b/debian/patches/note-gnu-stack.diff
new file mode 100644
index 0000000..b1aec35
--- /dev/null
+++ b/debian/patches/note-gnu-stack.diff
@@ -0,0 +1,125 @@
+# DP: Add .note.GNU-stack sections for gcc's crt files, libffi and boehm-gc
+# DP: Taken from FC.
+
+gcc/
+
+2004-09-20 Jakub Jelinek <jakub@redhat.com>
+
+ * config/rs6000/ppc-asm.h: Add .note.GNU-stack section also
+ on ppc64-linux.
+
+ * config/ia64/lib1funcs.asm: Add .note.GNU-stack section on
+ ia64-linux.
+ * config/ia64/crtbegin.asm: Likewise.
+ * config/ia64/crtend.asm: Likewise.
+ * config/ia64/crti.asm: Likewise.
+ * config/ia64/crtn.asm: Likewise.
+
+2004-05-14 Jakub Jelinek <jakub@redhat.com>
+
+ * config/ia64/linux.h (TARGET_ASM_FILE_END): Define.
+
+libffi/
+
+2007-05-11 Daniel Jacobowitz <dan@debian.org>
+
+ * src/arm/sysv.S: Fix ARM comment marker.
+
+2005-02-08 Jakub Jelinek <jakub@redhat.com>
+
+ * src/alpha/osf.S: Add .note.GNU-stack on Linux.
+ * src/s390/sysv.S: Likewise.
+ * src/powerpc/linux64.S: Likewise.
+ * src/powerpc/linux64_closure.S: Likewise.
+ * src/powerpc/ppc_closure.S: Likewise.
+ * src/powerpc/sysv.S: Likewise.
+ * src/x86/unix64.S: Likewise.
+ * src/x86/sysv.S: Likewise.
+ * src/sparc/v8.S: Likewise.
+ * src/sparc/v9.S: Likewise.
+ * src/m68k/sysv.S: Likewise.
+ * src/ia64/unix.S: Likewise.
+ * src/arm/sysv.S: Likewise.
+
+---
+ gcc/config/ia64/linux.h | 3 +++
+ gcc/config/rs6000/ppc-asm.h | 2 +-
+ libgcc/config/ia64/crtbegin.S | 4 ++++
+ libgcc/config/ia64/crtend.S | 4 ++++
+ libgcc/config/ia64/crti.S | 4 ++++
+ libgcc/config/ia64/crtn.S | 4 ++++
+ libgcc/config/ia64/lib1funcs.S | 4 ++++
+ 9 files changed, 39 insertions(+), 13 deletions(-)
+
+--- a/src/libgcc/config/ia64/crtbegin.S
++++ b/src/libgcc/config/ia64/crtbegin.S
+@@ -185,3 +185,7 @@ __do_global_dtors_aux:
+ .weak __cxa_finalize
+ #endif
+ .weak _Jv_RegisterClasses
++
++#ifdef __linux__
++.section .note.GNU-stack; .previous
++#endif
+--- a/src/libgcc/config/ia64/crtend.S
++++ b/src/libgcc/config/ia64/crtend.S
+@@ -114,3 +114,7 @@ __do_global_ctors_aux:
+
+ br.ret.sptk.many rp
+ .endp __do_global_ctors_aux
++
++#ifdef __linux__
++.section .note.GNU-stack; .previous
++#endif
+--- a/src/libgcc/config/ia64/crti.S
++++ b/src/libgcc/config/ia64/crti.S
+@@ -51,3 +51,7 @@ _fini:
+ .body
+
+ # end of crti.S
++
++#ifdef __linux__
++.section .note.GNU-stack; .previous
++#endif
+--- a/src/libgcc/config/ia64/crtn.S
++++ b/src/libgcc/config/ia64/crtn.S
+@@ -41,3 +41,7 @@
+ br.ret.sptk.many b0
+
+ # end of crtn.S
++
++#ifdef __linux__
++.section .note.GNU-stack; .previous
++#endif
+--- a/src/libgcc/config/ia64/lib1funcs.S
++++ b/src/libgcc/config/ia64/lib1funcs.S
+@@ -793,3 +793,7 @@ __floattitf:
+ .endp __floattitf
+ #endif
+ #endif
++
++#ifdef __linux__
++.section .note.GNU-stack; .previous
++#endif
+--- a/src/gcc/config/ia64/linux.h
++++ b/src/gcc/config/ia64/linux.h
+@@ -79,5 +79,8 @@ do { \
+ #undef TARGET_INIT_LIBFUNCS
+ #define TARGET_INIT_LIBFUNCS ia64_soft_fp_init_libfuncs
+
++#undef TARGET_ASM_FILE_END
++#define TARGET_ASM_FILE_END file_end_indicate_exec_stack
++
+ /* Define this to be nonzero if static stack checking is supported. */
+ #define STACK_CHECK_STATIC_BUILTIN 1
+--- a/src/gcc/config/rs6000/ppc-asm.h
++++ b/src/gcc/config/rs6000/ppc-asm.h
+@@ -384,7 +384,7 @@ GLUE(.L,name): \
+ #endif
+ #endif
+
+-#if defined __linux__ && !defined __powerpc64__
++#if defined __linux__
+ .section .note.GNU-stack
+ .previous
+ #endif
diff --git a/debian/patches/pr104290-followup.diff b/debian/patches/pr104290-followup.diff
new file mode 100644
index 0000000..abc8468
--- /dev/null
+++ b/debian/patches/pr104290-followup.diff
@@ -0,0 +1,14 @@
+# DP: Follow-up patch for PR go/104290 (Hurd)
+
+--- a/src/gcc/config/gnu.h 2022-02-06 11:59:41.000000000 +0100
++++ b/src/gcc/config/gnu.h 2022-02-06 12:00:19.000000000 +0100
+@@ -19,6 +19,9 @@
+ along with GCC. If not, see <http://www.gnu.org/licenses/>.
+ */
+
++#define OPTION_GLIBC_P(opts) (DEFAULT_LIBC == LIBC_GLIBC)
++#define OPTION_GLIBC OPTION_GLIBC_P (&global_options)
++
+ #undef GNU_USER_TARGET_OS_CPP_BUILTINS
+ #define GNU_USER_TARGET_OS_CPP_BUILTINS() \
+ do { \
diff --git a/debian/patches/pr107475.diff b/debian/patches/pr107475.diff
new file mode 100644
index 0000000..dbf2810
--- /dev/null
+++ b/debian/patches/pr107475.diff
@@ -0,0 +1,10 @@
+--- a/src/gcc/ada/Makefile.rtl
++++ b/src/gcc/ada/Makefile.rtl
+@@ -2645,6 +2645,7 @@ ifeq ($(strip $(filter-out %x32 linux%,$
+ EXTRA_GNATRTL_TASKING_OBJS=s-linux.o a-exetim.o
+ EH_MECHANISM=-gcc
+ THREADSLIB=-lpthread -lrt
++ MISCLIB = -ldl
+ GNATLIB_SHARED=gnatlib-shared-dual
+ GMEM_LIB = gmemlib
+ LIBRARY_VERSION := $(LIB_VERSION)
diff --git a/debian/patches/pr113336-proposed.diff b/debian/patches/pr113336-proposed.diff
new file mode 100644
index 0000000..c5a574d
--- /dev/null
+++ b/debian/patches/pr113336-proposed.diff
@@ -0,0 +1,24 @@
+# DP: Proposed patch for PR target/113336
+
+--- a/src/libatomic/Makefile.am
++++ b/src/libatomic/Makefile.am
+@@ -139,6 +139,7 @@ if ARCH_ARM_LINUX
+ IFUNC_OPTIONS = -march=armv7-a+fp -DHAVE_KERNEL64
+ libatomic_la_LIBADD += $(foreach s,$(SIZES),$(addsuffix _$(s)_1_.lo,$(SIZEOBJS)))
+ libatomic_la_LIBADD += $(addsuffix _8_2_.lo,$(SIZEOBJS))
++libatomic_la_LIBADD += tas_1_2_.lo
+ endif
+ if ARCH_I386
+ IFUNC_OPTIONS = -march=i586
+--- a/src/libatomic/Makefile.in
++++ b/src/libatomic/Makefile.in
+@@ -95,7 +95,8 @@ target_triplet = @target@
+ @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ s,$(SIZES),$(addsuffix \
+ @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ _$(s)_1_.lo,$(SIZEOBJS))) \
+ @ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ $(addsuffix \
+-@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ _8_2_.lo,$(SIZEOBJS))
++@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ _8_2_.lo,$(SIZEOBJS)) \
++@ARCH_ARM_LINUX_TRUE@@HAVE_IFUNC_TRUE@ tas_1_2_.lo
+ @ARCH_I386_TRUE@@HAVE_IFUNC_TRUE@am__append_4 = $(addsuffix _8_1_.lo,$(SIZEOBJS))
+ @ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@am__append_5 = $(addsuffix _16_1_.lo,$(SIZEOBJS)) \
+ @ARCH_X86_64_TRUE@@HAVE_IFUNC_TRUE@ $(addsuffix _16_2_.lo,$(SIZEOBJS))
diff --git a/debian/patches/pr113705.diff b/debian/patches/pr113705.diff
new file mode 100644
index 0000000..8ca12df
--- /dev/null
+++ b/debian/patches/pr113705.diff
@@ -0,0 +1,93 @@
+# DP: Proposed patch for PR middle-end/113705
+
+2024-02-01 Jakub Jelinek <jakub@redhat.com>
+
+ PR middle-end/113705
+ * tree-ssa-math-opts.cc (is_widening_mult_rhs_p): Use wide_int_from
+ around wi::to_wide in order to compare value in prec precision.
+
+ * g++.dg/opt/pr113705.C: New test.
+
+--- a/src/gcc/tree-ssa-math-opts.cc
++++ b/src/gcc/tree-ssa-math-opts.cc
+@@ -2572,7 +2572,8 @@ is_widening_mult_rhs_p (tree type, tree
+ if (is_gimple_assign (stmt)
+ && gimple_assign_rhs_code (stmt) == BIT_AND_EXPR
+ && TREE_CODE (gimple_assign_rhs2 (stmt)) == INTEGER_CST
+- && wi::to_wide (gimple_assign_rhs2 (stmt))
++ && wide_int::from (wi::to_wide (gimple_assign_rhs2 (stmt)),
++ prec, TYPE_SIGN (TREE_TYPE (rhs)))
+ == wi::mask (hprec, false, prec))
+ *new_rhs_out = gimple_assign_rhs1 (stmt);
+ else
+--- a/src/gcc/testsuite/g++.dg/opt/pr113705.C
++++ b/src/gcc/testsuite/g++.dg/opt/pr113705.C
+@@ -0,0 +1,68 @@
++// PR middle-end/113705
++// { dg-do compile { target c++17 } }
++// { dg-options "-O2 -w" }
++
++void foo ();
++template <typename T> struct A : T { long bar () const; };
++int a;
++
++template <typename T>
++long
++A<T>::bar () const
++{
++ return this->baz ()[a];
++}
++
++struct B {
++ struct { long b[1]; long c; } u;
++ unsigned d;
++ int e;
++ B (const B &);
++ ~B ();
++ const long *baz () const;
++ unsigned qux () const;
++};
++
++B::B (const B &)
++{
++ if (__builtin_expect (e, 0))
++ u.c = 0;
++}
++
++B::~B ()
++{
++ if (__builtin_expect (e, 0))
++ foo ();
++}
++
++const long *
++B::baz () const
++{
++ return u.b;
++}
++
++unsigned
++B::qux () const
++{
++ return d;
++}
++
++struct C { A<B> corge () const; A<B> *f; };
++
++A<B>
++C::corge () const
++{
++ return f[1];
++}
++
++void
++test (C r, long *h, unsigned short *d)
++{
++ for (int j = 0; j < 8; ++j)
++ {
++ A g = r.corge ();
++ *d = g.qux ();
++ for (unsigned i = 0; i < *d; ++i)
++ *h++ = g.bar ();
++ }
++}
diff --git a/debian/patches/pr39491.diff b/debian/patches/pr39491.diff
new file mode 100644
index 0000000..4c51820
--- /dev/null
+++ b/debian/patches/pr39491.diff
@@ -0,0 +1,132 @@
+# DP: Proposed patch for PR libstdc++/39491.
+
+2009-04-16 Benjamin Kosnik <bkoz@redhat.com>
+
+ * src/math_stubs_long_double.cc (__signbitl): Add for hppa linux only.
+
+Index: a/src/libstdc++-v3/src/math_stubs_long_double.cc
+===================================================================
+--- a/src/libstdc++-v3/src/math_stubs_long_double.cc (revision 146216)
++++ b/src/libstdc++-v3/src/math_stubs_long_double.cc (working copy)
+@@ -213,4 +221,111 @@
+ return tanh((double) x);
+ }
+ #endif
++
++ // From libmath/signbitl.c
++ // XXX ABI mistakenly exported
++#if defined (__hppa__) && defined (__linux__)
++# include <endian.h>
++# include <float.h>
++
++typedef unsigned int U_int32_t __attribute ((mode (SI)));
++typedef int Int32_t __attribute ((mode (SI)));
++typedef unsigned int U_int64_t __attribute ((mode (DI)));
++typedef int Int64_t __attribute ((mode (DI)));
++
++#if BYTE_ORDER == BIG_ENDIAN
++typedef union
++{
++ long double value;
++ struct
++ {
++ unsigned int sign_exponent:16;
++ unsigned int empty:16;
++ U_int32_t msw;
++ U_int32_t lsw;
++ } parts;
++} ieee_long_double_shape_type;
++#endif
++#if BYTE_ORDER == LITTLE_ENDIAN
++typedef union
++{
++ long double value;
++ struct
++ {
++ U_int32_t lsw;
++ U_int32_t msw;
++ unsigned int sign_exponent:16;
++ unsigned int empty:16;
++ } parts;
++} ieee_long_double_shape_type;
++#endif
++
++/* Get int from the exponent of a long double. */
++#define GET_LDOUBLE_EXP(exp,d) \
++do { \
++ ieee_long_double_shape_type ge_u; \
++ ge_u.value = (d); \
++ (exp) = ge_u.parts.sign_exponent; \
++} while (0)
++
++#if BYTE_ORDER == BIG_ENDIAN
++typedef union
++{
++ long double value;
++ struct
++ {
++ U_int64_t msw;
++ U_int64_t lsw;
++ } parts64;
++ struct
++ {
++ U_int32_t w0, w1, w2, w3;
++ } parts32;
++} ieee_quad_double_shape_type;
++#endif
++
++#if BYTE_ORDER == LITTLE_ENDIAN
++typedef union
++{
++ long double value;
++ struct
++ {
++ U_int64_t lsw;
++ U_int64_t msw;
++ } parts64;
++ struct
++ {
++ U_int32_t w3, w2, w1, w0;
++ } parts32;
++} ieee_quad_double_shape_type;
++#endif
++
++/* Get most significant 64 bit int from a quad long double. */
++#define GET_LDOUBLE_MSW64(msw,d) \
++do { \
++ ieee_quad_double_shape_type qw_u; \
++ qw_u.value = (d); \
++ (msw) = qw_u.parts64.msw; \
++} while (0)
++
++int
++__signbitl (long double x)
++{
++#if LDBL_MANT_DIG == 113
++ Int64_t msw;
++
++ GET_LDOUBLE_MSW64 (msw, x);
++ return msw < 0;
++#else
++ Int32_t e;
++
++ GET_LDOUBLE_EXP (e, x);
++ return e & 0x8000;
++#endif
++}
++#endif
++
++#ifndef _GLIBCXX_HAVE___SIGNBITL
++
++#endif
+ } // extern "C"
+--- a/src/libstdc++-v3/config/abi/pre/gnu.ver~ 2009-04-10 01:23:07.000000000 +0200
++++ b/src/libstdc++-v3/config/abi/pre/gnu.ver 2009-04-21 16:24:24.000000000 +0200
+@@ -635,6 +635,7 @@
+ sqrtf;
+ sqrtl;
+ copysignf;
++ __signbitl;
+
+ # GLIBCXX_ABI compatibility only.
+ # std::string
diff --git a/debian/patches/pr66368.diff b/debian/patches/pr66368.diff
new file mode 100644
index 0000000..c2ec875
--- /dev/null
+++ b/debian/patches/pr66368.diff
@@ -0,0 +1,22 @@
+# DP: PR go/66368, build libgo with -fno-stack-protector
+
+--- a/src/libgo/Makefile.am
++++ b/src/libgo/Makefile.am
+@@ -47,6 +47,7 @@ AM_CPPFLAGS = -I $(srcdir)/runtime $(LIB
+ ACLOCAL_AMFLAGS = -I ./config -I ../config
+
+ AM_CFLAGS = -fexceptions -fnon-call-exceptions \
++ -fno-stack-protector \
+ $(SPLIT_STACK) $(WARN_CFLAGS) \
+ $(STRINGOPS_FLAG) $(HWCAP_CFLAGS) $(OSCFLAGS) \
+ -I $(srcdir)/../libgcc -I $(srcdir)/../libbacktrace \
+--- a/src/libgo/Makefile.in
++++ b/src/libgo/Makefile.in
+@@ -564,6 +564,7 @@ WARN_CFLAGS = $(WARN_FLAGS) $(WERROR)
+ AM_CPPFLAGS = -I $(srcdir)/runtime $(LIBFFIINCS) $(PTHREAD_CFLAGS)
+ ACLOCAL_AMFLAGS = -I ./config -I ../config
+ AM_CFLAGS = -fexceptions -fnon-call-exceptions \
++ -fno-stack-protector \
+ $(SPLIT_STACK) $(WARN_CFLAGS) \
+ $(STRINGOPS_FLAG) $(HWCAP_CFLAGS) $(OSCFLAGS) \
+ -I $(srcdir)/../libgcc -I $(srcdir)/../libbacktrace \
diff --git a/debian/patches/pr67590.diff b/debian/patches/pr67590.diff
new file mode 100644
index 0000000..0b3adfa
--- /dev/null
+++ b/debian/patches/pr67590.diff
@@ -0,0 +1,36 @@
+# DP: Fix PR67590, setting objdump macro.
+
+--- a/src/libcc1/configure.ac
++++ b/src/libcc1/configure.ac
+@@ -74,6 +74,31 @@ if test "$GXX" = yes; then
+ fi
+ AC_SUBST(libsuffix)
+
++# Figure out what objdump we will be using.
++AS_VAR_SET_IF(gcc_cv_objdump,, [
++if test -f $gcc_cv_binutils_srcdir/configure.ac \
++ && test -f ../binutils/Makefile \
++ && test x$build = x$host; then
++ # Single tree build which includes binutils.
++ gcc_cv_objdump=../binutils/objdump$build_exeext
++elif test -x objdump$build_exeext; then
++ gcc_cv_objdump=./objdump$build_exeext
++elif ( set dummy $OBJDUMP_FOR_TARGET; test -x $[2] ); then
++ gcc_cv_objdump="$OBJDUMP_FOR_TARGET"
++else
++ AC_PATH_PROG(gcc_cv_objdump, $OBJDUMP_FOR_TARGET)
++fi])
++
++AC_MSG_CHECKING(what objdump to use)
++if test "$gcc_cv_objdump" = ../binutils/objdump$build_exeext; then
++ # Single tree build which includes binutils.
++ AC_MSG_RESULT(newly built objdump)
++elif test x$gcc_cv_objdump = x; then
++ AC_MSG_RESULT(not found)
++else
++ AC_MSG_RESULT($gcc_cv_objdump)
++fi
++
+ dnl Test for -lsocket and -lnsl. Copied from libgo/configure.ac.
+ AC_CACHE_CHECK([for socket libraries], libcc1_cv_lib_sockets,
+ [libcc1_cv_lib_sockets=
diff --git a/debian/patches/pr67899.diff b/debian/patches/pr67899.diff
new file mode 100644
index 0000000..0f2ebd0
--- /dev/null
+++ b/debian/patches/pr67899.diff
@@ -0,0 +1,31 @@
+# DP: Proposed patch for PR sanitizer/67899
+
+Index: b/src/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+===================================================================
+--- a/src/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
++++ b/src/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.h
+@@ -606,11 +606,10 @@ namespace __sanitizer {
+ #else
+ __sanitizer_sigset_t sa_mask;
+ #ifndef __mips__
+-#if defined(__sparc__)
+- unsigned long sa_flags;
+-#else
+- int sa_flags;
++#if defined(__sparc__) && defined(__arch64__)
++ int __pad;
+ #endif
++ int sa_flags;
+ #endif
+ #endif
+ #if SANITIZER_LINUX
+@@ -640,7 +639,8 @@ namespace __sanitizer {
+ void (*handler)(int signo);
+ void (*sigaction)(int signo, void *info, void *ctx);
+ };
+- unsigned long sa_flags;
++ int __pad;
++ int sa_flags;
+ void (*sa_restorer)(void);
+ __sanitizer_kernel_sigset_t sa_mask;
+ };
diff --git a/debian/patches/pr79724-revert.diff b/debian/patches/pr79724-revert.diff
new file mode 100644
index 0000000..1bfbc0e
--- /dev/null
+++ b/debian/patches/pr79724-revert.diff
@@ -0,0 +1,24 @@
+# DP: Revert PR ada/79724, handling of suffixes (conflicts with local ada-gcc-name patch)
+
+--- a/src/gcc/ada/osint.adb
++++ b/src/gcc/ada/osint.adb
+@@ -2277,6 +2277,8 @@ package body Osint is
+
+ Find_Program_Name;
+
++ Start_Of_Suffix := Name_Len + 1;
++
+ -- Find the target prefix if any, for the cross compilation case.
+ -- For instance in "powerpc-elf-gcc" the target prefix is
+ -- "powerpc-elf-"
+@@ -2300,7 +2302,9 @@ package body Osint is
+ end if;
+ end loop;
+
+- Start_Of_Suffix := End_Of_Prefix + Prog'Length + 1;
++ if End_Of_Prefix > 1 then
++ Start_Of_Suffix := End_Of_Prefix + Prog'Length + 1;
++ end if;
+
+ -- Create the new program name
+
diff --git a/debian/patches/pr81829.diff b/debian/patches/pr81829.diff
new file mode 100644
index 0000000..472e3d0
--- /dev/null
+++ b/debian/patches/pr81829.diff
@@ -0,0 +1,308 @@
+From f8029ed6d3dd444ee2608146118f2189cf9ef0d8 Mon Sep 17 00:00:00 2001
+From: marxin <mliska@suse.cz>
+Date: Mon, 14 Aug 2017 13:56:32 +0200
+Subject: [PATCH] Fix file find utils and add unit tests (PR driver/81829).
+
+gcc/ChangeLog:
+
+2017-08-14 Martin Liska <mliska@suse.cz>
+
+ PR driver/81829
+ * file-find.c (do_add_prefix): Always append DIR_SEPARATOR
+ at the end of a prefix.
+ (remove_prefix): Properly remove elements and accept also
+ path without a trailing DIR_SEPARATOR.
+ (purge): New function.
+ (file_find_verify_prefix_creation): Likewise.
+ (file_find_verify_prefix_add): Likewise.
+ (file_find_verify_prefix_removal): Likewise.
+ (file_find_c_tests): Likewise.
+ * selftest-run-tests.c (selftest::run_tests): Add new
+ file_find_c_tests.
+ * selftest.h (file_find_c_tests): Likewise.
+---
+ gcc/file-find.c | 182 ++++++++++++++++++++++++++++++++++++++++++-----
+ gcc/gcc-ar.c | 19 +++--
+ gcc/selftest-run-tests.c | 1 +
+ gcc/selftest.h | 1 +
+ 4 files changed, 179 insertions(+), 24 deletions(-)
+
+Index: b/src/gcc/file-find.c
+===================================================================
+--- a/src/gcc/file-find.c
++++ b/src/gcc/file-find.c
+@@ -21,6 +21,7 @@ along with GCC; see the file COPYING3.
+ #include "system.h"
+ #include "filenames.h"
+ #include "file-find.h"
++#include "selftest.h"
+
+ static bool debug = false;
+
+@@ -126,11 +127,22 @@ do_add_prefix (struct path_prefix *ppref
+ /* Keep track of the longest prefix. */
+
+ len = strlen (prefix);
++ bool append_separator = !IS_DIR_SEPARATOR (prefix[len - 1]);
++ if (append_separator)
++ len++;
++
+ if (len > pprefix->max_len)
+ pprefix->max_len = len;
+
+ pl = XNEW (struct prefix_list);
+- pl->prefix = xstrdup (prefix);
++ char *dup = XCNEWVEC (char, len + 1);
++ memcpy (dup, prefix, append_separator ? len - 1 : len);
++ if (append_separator)
++ {
++ dup[len - 1] = DIR_SEPARATOR;
++ dup[len] = '\0';
++ }
++ pl->prefix = dup;
+
+ if (*prev)
+ pl->next = *prev;
+@@ -212,34 +224,170 @@ prefix_from_string (const char *p, struc
+ void
+ remove_prefix (const char *prefix, struct path_prefix *pprefix)
+ {
+- struct prefix_list *remove, **prev, **remove_prev = NULL;
++ char *dup = NULL;
+ int max_len = 0;
++ size_t len = strlen (prefix);
++ if (prefix[len - 1] != DIR_SEPARATOR)
++ {
++ char *dup = XNEWVEC (char, len + 2);
++ memcpy (dup, prefix, len);
++ dup[len] = DIR_SEPARATOR;
++ dup[len + 1] = '\0';
++ prefix = dup;
++ }
+
+ if (pprefix->plist)
+ {
+- prev = &pprefix->plist;
+- for (struct prefix_list *pl = pprefix->plist; pl->next; pl = pl->next)
++ prefix_list *prev = NULL;
++ for (struct prefix_list *pl = pprefix->plist; pl;)
+ {
+ if (strcmp (prefix, pl->prefix) == 0)
+ {
+- remove = pl;
+- remove_prev = prev;
+- continue;
++ if (prev == NULL)
++ pprefix->plist = pl->next;
++ else
++ prev->next = pl->next;
++
++ prefix_list *remove = pl;
++ free (remove);
++ pl = pl->next;
+ }
++ else
++ {
++ prev = pl;
+
+- int l = strlen (pl->prefix);
+- if (l > max_len)
+- max_len = l;
++ int l = strlen (pl->prefix);
++ if (l > max_len)
++ max_len = l;
+
+- prev = &pl;
+- }
+-
+- if (remove_prev)
+- {
+- *remove_prev = remove->next;
+- free (remove);
++ pl = pl->next;
++ }
+ }
+
+ pprefix->max_len = max_len;
+ }
++
++ if (dup)
++ free (dup);
++}
++
++#if CHECKING_P
++
++namespace selftest {
++
++/* Encode '#' and '_' to path and dir separators in order to test portability
++ of the test-cases. */
++
++static char *
++purge (const char *input)
++{
++ char *s = xstrdup (input);
++ for (char *c = s; *c != '\0'; c++)
++ switch (*c)
++ {
++ case '/':
++ case ':':
++ *c = 'a'; /* Poison default string values. */
++ break;
++ case '_':
++ *c = PATH_SEPARATOR;
++ break;
++ case '#':
++ *c = DIR_SEPARATOR;
++ break;
++ default:
++ break;
++ }
++
++ return s;
++}
++
++const char *env1 = purge ("#home#user#bin_#home#user#bin_#bin_#usr#bin");
++const char *env2 = purge ("#root_#root_#root");
++
++/* Verify creation of prefix. */
++
++static void
++file_find_verify_prefix_creation (void)
++{
++ path_prefix prefix;
++ memset (&prefix, 0, sizeof (prefix));
++ prefix_from_string (env1, &prefix);
++
++ ASSERT_EQ (15, prefix.max_len);
++
++ /* All prefixes end with DIR_SEPARATOR. */
++ ASSERT_STREQ (purge ("#home#user#bin#"), prefix.plist->prefix);
++ ASSERT_STREQ (purge ("#home#user#bin#"), prefix.plist->next->prefix);
++ ASSERT_STREQ (purge ("#bin#"), prefix.plist->next->next->prefix);
++ ASSERT_STREQ (purge ("#usr#bin#"), prefix.plist->next->next->next->prefix);
++ ASSERT_EQ (NULL, prefix.plist->next->next->next->next);
++}
++
++/* Verify adding a prefix. */
++
++static void
++file_find_verify_prefix_add (void)
++{
++ path_prefix prefix;
++ memset (&prefix, 0, sizeof (prefix));
++ prefix_from_string (env1, &prefix);
++
++ add_prefix (&prefix, purge ("#root"));
++ ASSERT_STREQ (purge ("#home#user#bin#"), prefix.plist->prefix);
++ ASSERT_STREQ (purge ("#root#"),
++ prefix.plist->next->next->next->next->prefix);
++
++ add_prefix_begin (&prefix, purge ("#var"));
++ ASSERT_STREQ (purge ("#var#"), prefix.plist->prefix);
++}
++
++/* Verify adding a prefix. */
++
++static void
++file_find_verify_prefix_removal (void)
++{
++ path_prefix prefix;
++ memset (&prefix, 0, sizeof (prefix));
++ prefix_from_string (env1, &prefix);
++
++ /* All occurences of a prefix should be removed. */
++ remove_prefix (purge ("#home#user#bin"), &prefix);
++
++ ASSERT_EQ (9, prefix.max_len);
++ ASSERT_STREQ (purge ("#bin#"), prefix.plist->prefix);
++ ASSERT_STREQ (purge ("#usr#bin#"), prefix.plist->next->prefix);
++ ASSERT_EQ (NULL, prefix.plist->next->next);
++
++ remove_prefix (purge ("#usr#bin#"), &prefix);
++ ASSERT_EQ (5, prefix.max_len);
++ ASSERT_STREQ (purge ("#bin#"), prefix.plist->prefix);
++ ASSERT_EQ (NULL, prefix.plist->next);
++
++ remove_prefix (purge ("#dev#random#"), &prefix);
++ remove_prefix (purge ("#bi#"), &prefix);
++
++ remove_prefix (purge ("#bin#"), &prefix);
++ ASSERT_EQ (NULL, prefix.plist);
++ ASSERT_EQ (0, prefix.max_len);
++
++ memset (&prefix, 0, sizeof (prefix));
++ prefix_from_string (env2, &prefix);
++ ASSERT_EQ (6, prefix.max_len);
++
++ remove_prefix (purge ("#root#"), &prefix);
++ ASSERT_EQ (NULL, prefix.plist);
++ ASSERT_EQ (0, prefix.max_len);
+ }
++
++/* Run all of the selftests within this file. */
++
++void file_find_c_tests ()
++{
++ file_find_verify_prefix_creation ();
++ file_find_verify_prefix_add ();
++ file_find_verify_prefix_removal ();
++}
++
++} // namespace selftest
++#endif /* CHECKING_P */
+Index: b/src/gcc/gcc-ar.c
+===================================================================
+--- a/src/gcc/gcc-ar.c
++++ b/src/gcc/gcc-ar.c
+@@ -194,15 +194,20 @@ main (int ac, char **av)
+ #ifdef CROSS_DIRECTORY_STRUCTURE
+ real_exe_name = concat (target_machine, "-", PERSONALITY, NULL);
+ #endif
+- /* Do not search original location in the same folder. */
+- char *exe_folder = lrealpath (av[0]);
+- exe_folder[strlen (exe_folder) - strlen (lbasename (exe_folder))] = '\0';
+- char *location = concat (exe_folder, PERSONALITY, NULL);
++ char *wrapper_file = lrealpath (av[0]);
++ exe_name = lrealpath (find_a_file (&path, real_exe_name, X_OK));
+
+- if (access (location, X_OK) == 0)
+- remove_prefix (exe_folder, &path);
++ /* If the exe_name points to the wrapper, remove folder of the wrapper
++ from prefix and try search again. */
++ if (strcmp (exe_name, wrapper_file) == 0)
++ {
++ char *exe_folder = wrapper_file;
++ exe_folder[strlen (exe_folder) - strlen (lbasename (exe_folder))] = '\0';
++ remove_prefix (exe_folder, &path);
++
++ exe_name = find_a_file (&path, real_exe_name, X_OK);
++ }
+
+- exe_name = find_a_file (&path, real_exe_name, X_OK);
+ if (!exe_name)
+ {
+ fprintf (stderr, "%s: Cannot find binary '%s'\n", av[0],
+Index: b/src/gcc/selftest-run-tests.c
+===================================================================
+--- a/src/gcc/selftest-run-tests.c
++++ b/src/gcc/selftest-run-tests.c
+@@ -66,6 +66,7 @@ selftest::run_tests ()
+ sreal_c_tests ();
+ fibonacci_heap_c_tests ();
+ typed_splay_tree_c_tests ();
++ file_find_c_tests ();
+
+ /* Mid-level data structures. */
+ input_c_tests ();
+Index: b/src/gcc/selftest.h
+===================================================================
+--- a/src/gcc/selftest.h
++++ b/src/gcc/selftest.h
+@@ -196,6 +196,7 @@ extern void tree_c_tests ();
+ extern void tree_cfg_c_tests ();
+ extern void vec_c_tests ();
+ extern void wide_int_cc_tests ();
++extern void file_find_c_tests ();
+
+ extern int num_passes;
+
diff --git a/debian/patches/pr87808.diff b/debian/patches/pr87808.diff
new file mode 100644
index 0000000..7f9e7d0
--- /dev/null
+++ b/debian/patches/pr87808.diff
@@ -0,0 +1,56 @@
+# DP: Fix PR jit/87808.
+
+--- a/src/gcc/jit/Make-lang.in
++++ b/src/gcc/jit/Make-lang.in
+@@ -136,6 +136,9 @@ ifneq (,$(findstring mingw,$(target)))
+ jit_OBJS += jit/jit-w32.o
+ endif
+
++CFLAGS-jit/jit-playback.o += \
++ -DFALLBACK_GCC_EXEC_PREFIX=\"$(libdir)/gcc/$(target_subdir)/$(version)\"
++
+ # Use strict warnings for this front end.
+ jit-warn = $(STRICT_WARN)
+
+--- a/src/gcc/jit/jit-playback.cc
++++ b/src/gcc/jit/jit-playback.cc
+@@ -41,6 +41,7 @@ along with GCC; see the file COPYING3.
+ #include "gcc.h"
+ #include "diagnostic.h"
+ #include "stmt.h"
++#include "file-find.h"
+
+ #include "jit-playback.h"
+ #include "jit-result.h"
+@@ -3058,7 +3059,31 @@ void
+ playback::context::
+ invoke_embedded_driver (const vec <char *> *argvec)
+ {
++ static char* gcc_driver_file = NULL;
++
+ JIT_LOG_SCOPE (get_logger ());
++
++ /* process_command(), uses make_relative_prefix(), searches PATH
++ for the external driver, which might not be found. In this case
++ fall back to the configured default. */
++#ifdef FALLBACK_GCC_EXEC_PREFIX
++ if (gcc_driver_file == NULL && ::getenv ("GCC_EXEC_PREFIX") == NULL)
++ {
++ struct path_prefix path = { 0, 0, "exec" };
++
++ prefix_from_env ("PATH", &path);
++ gcc_driver_file = find_a_file (&path, gcc_driver_name, X_OK);
++ if (gcc_driver_file == NULL)
++ {
++ char *str = concat ("GCC_EXEC_PREFIX=",
++ FALLBACK_GCC_EXEC_PREFIX, NULL);
++ ::putenv (str);
++ log ("gcc driver %s not found, using fallback GCC_EXEC_PREFIX=%s",
++ gcc_driver_name, FALLBACK_GCC_EXEC_PREFIX);
++ }
++ }
++#endif
++
+ driver d (true, /* can_finalize */
+ false); /* debug */
+ int result = d.main (argvec->length (),
diff --git a/debian/patches/pr94253.diff b/debian/patches/pr94253.diff
new file mode 100644
index 0000000..6b42326
--- /dev/null
+++ b/debian/patches/pr94253.diff
@@ -0,0 +1,48 @@
+commit 50e1e417b5cc68a6fd280e0a67c5c4eba524b70b
+Author: Richard Sandiford <richard.sandiford@arm.com>
+Date: Sun Mar 22 18:51:48 2020 +0000
+
+ rs6000: Allow FPRs to change between SDmode and DDmode [PR94254]
+
+ g:497498c878d48754318e486428e2aa30854020b9 caused lra to cycle
+ on some SDmode reloads for power6. As explained in more detail
+ in the PR comments, the problem was a conflict between two target
+ hooks: rs6000_secondary_memory_needed_mode required SDmode FPR
+ reloads to use DDmode memory (rightly, since using SDmode memory
+ wouldn't make progress) but rs6000_can_change_mode_class didn't
+ allow FPRs to change from SDmode to DDmode. Previously lra
+ ignored that and changed the mode anyway.
+
+ From what Segher says, it sounds like the "from_size < 8 || to_size < 8"
+ check is mostly there for SF<->64-bit subregs, and that SDmode is stored
+ in the way that target-independent code expects. This patch therefore
+ allows SD<->DD changes.
+
+ I wondered about checking for SD<->64-bit changes instead, but that
+ seemed like an unnecessary generalisation for this stage.
+
+ 2020-03-23 Richard Sandiford <richard.sandiford@arm.com>
+
+ gcc/
+ PR target/94254
+ * config/rs6000/rs6000.c (rs6000_can_change_mode_class): Allow
+ FPRs to change between SDmode and DDmode.
+
+--- a/src/gcc/config/rs6000/rs6000.cc
++++ b/src/gcc/config/rs6000/rs6000.cc
+@@ -13699,6 +13699,15 @@ rs6000_can_change_mode_class (machine_mo
+ || (to == SDmode && from == DDmode))
+ return true;
+
++ /* Allow SD<->DD changes, since SDmode values are stored in
++ the low half of the DDmode, just like target-independent
++ code expects. We need to allow at least SD->DD since
++ rs6000_secondary_memory_needed_mode asks for that change
++ to be made for SD reloads. */
++ if ((to == DDmode && from == SDmode)
++ || (to == SDmode && from == DDmode))
++ return true;
++
+ if (from_size < 8 || to_size < 8)
+ return false;
+
diff --git a/debian/patches/rename-info-files.diff b/debian/patches/rename-info-files.diff
new file mode 100644
index 0000000..4702d5f
--- /dev/null
+++ b/debian/patches/rename-info-files.diff
@@ -0,0 +1,661 @@
+# DP: Allow transformations on info file names. Reference the
+# DP: transformed info file names in the texinfo files.
+
+
+2004-02-17 Matthias Klose <doko@debian.org>
+
+gcc/ChangeLog:
+ * Makefile.in: Allow transformations on info file names.
+ Define MAKEINFODEFS, macros to pass transformated info file
+ names to makeinfo.
+ * doc/cpp.texi: Use macros defined in MAKEINFODEFS for references.
+ * doc/cppinternals.texi: Likewise.
+ * doc/extend.texi: Likewise.
+ * doc/gcc.texi: Likewise.
+ * doc/gccint.texi: Likewise.
+ * doc/invoke.texi: Likewise.
+ * doc/libgcc.texi: Likewise.
+ * doc/makefile.texi: Likewise.
+ * doc/passes.texi: Likewise.
+ * doc/sourcebuild.texi: Likewise.
+ * doc/standards.texi: Likewise.
+ * doc/trouble.texi: Likewise.
+
+gcc/fortran/ChangeLog:
+ * Make-lang.in: Allow transformations on info file names.
+ Pass macros of transformated info file defined in MAKEINFODEFS
+ names to makeinfo.
+ * gfortran.texi: Use macros defined in MAKEINFODEFS for references.
+
+--- a/src/gcc/fortran/gfortran.texi
++++ b/src/gcc/fortran/gfortran.texi
+@@ -101,7 +101,7 @@ Texts being (a) (see below), and with th
+ @ifinfo
+ @dircategory Software development
+ @direntry
+-* gfortran: (gfortran). The GNU Fortran Compiler.
++* @value{fngfortran}: (@value{fngfortran}). The GNU Fortran Compiler.
+ @end direntry
+ This file documents the use and the internals of
+ the GNU Fortran compiler, (@command{gfortran}).
+--- a/src/gcc/fortran/Make-lang.in
++++ b/src/gcc/fortran/Make-lang.in
+@@ -116,7 +116,9 @@ fortran.tags: force
+ cd $(srcdir)/fortran; $(ETAGS) -o TAGS.sub *.c *.h; \
+ $(ETAGS) --include TAGS.sub --include ../TAGS.sub
+
+-fortran.info: doc/gfortran.info doc/gfc-internals.info
++INFO_FORTRAN_NAME = $(shell echo gfortran|sed '$(program_transform_name)')
++INFO_FORTRAN_I_NAME = $(shell echo gfc-internals|sed '$(program_transform_name)')
++fortran.info: doc/$(INFO_FORTRAN_NAME).info doc/$(INFO_FORTRAN_I_NAME).info
+
+ F95_DVIFILES = doc/gfortran.dvi
+
+@@ -199,10 +201,10 @@ GFORTRAN_TEXI = \
+ $(srcdir)/doc/include/gcc-common.texi \
+ gcc-vers.texi
+
+-doc/gfortran.info: $(GFORTRAN_TEXI)
++doc/$(INFO_FORTRAN_NAME).info: $(GFORTRAN_TEXI)
+ if [ x$(BUILD_INFO) = xinfo ]; then \
+ rm -f doc/gfortran.info-*; \
+- $(MAKEINFO) -I $(srcdir)/doc/include -I $(srcdir)/fortran \
++ $(MAKEINFO) $(MAKEINFODEFS) -I $(srcdir)/doc/include -I $(srcdir)/fortran \
+ -o $@ $<; \
+ else true; fi
+
+@@ -230,7 +232,7 @@ GFC_INTERNALS_TEXI = \
+ $(srcdir)/doc/include/gcc-common.texi \
+ gcc-vers.texi
+
+-doc/gfc-internals.info: $(GFC_INTERNALS_TEXI)
++doc/$(INFO_FORTRAN_I_NAME).info: $(GFC_INTERNALS_TEXI)
+ if [ x$(BUILD_INFO) = xinfo ]; then \
+ rm -f doc/gfc-internals.info-*; \
+ $(MAKEINFO) -I $(srcdir)/doc/include -I $(srcdir)/fortran \
+@@ -267,7 +269,7 @@ fortran.install-common: install-finclude
+
+ fortran.install-plugin:
+
+-fortran.install-info: $(DESTDIR)$(infodir)/gfortran.info
++fortran.install-info: $(DESTDIR)$(infodir)/$(INFO_FORTRAN_NAME).info
+
+ fortran.install-man: $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext)
+
+@@ -285,7 +287,7 @@ fortran.uninstall:
+ rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_INSTALL_NAME)$(exeext); \
+ rm -rf $(DESTDIR)$(man1dir)/$(GFORTRAN_INSTALL_NAME)$(man1ext); \
+ rm -rf $(DESTDIR)$(bindir)/$(GFORTRAN_TARGET_INSTALL_NAME)$(exeext); \
+- rm -rf $(DESTDIR)$(infodir)/gfortran.info*
++ rm -rf $(DESTDIR)$(infodir)/$(INFO_FORTRAN_NAME).info*
+
+ #
+ # Clean hooks:
+--- a/src/gcc/Makefile.in
++++ b/src/gcc/Makefile.in
+@@ -3304,8 +3304,31 @@ install-no-fixedincludes:
+
+ doc: $(BUILD_INFO) $(GENERATED_MANPAGES)
+
+-INFOFILES = doc/cpp.info doc/gcc.info doc/gccint.info \
+- doc/gccinstall.info doc/cppinternals.info
++INFO_CPP_NAME = $(shell echo cpp|sed '$(program_transform_name)')
++INFO_GCC_NAME = $(shell echo gcc|sed '$(program_transform_name)')
++INFO_GXX_NAME = $(shell echo g++|sed '$(program_transform_name)')
++INFO_GCCINT_NAME = $(shell echo gccint|sed '$(program_transform_name)')
++INFO_GCCINSTALL_NAME = $(shell echo gccinstall|sed '$(program_transform_name)')
++INFO_CPPINT_NAME = $(shell echo cppinternals|sed '$(program_transform_name)')
++
++INFO_FORTRAN_NAME = $(shell echo gfortran|sed '$(program_transform_name)')
++INFO_GCCGO_NAME = $(shell echo gccgo|sed '$(program_transform_name)')
++
++INFOFILES = doc/$(INFO_CPP_NAME).info doc/$(INFO_GCC_NAME).info \
++ doc/$(INFO_GCCINT_NAME).info \
++ doc/$(INFO_GCCINSTALL_NAME).info doc/$(INFO_CPPINT_NAME).info
++
++MAKEINFODEFS = -D 'fncpp $(INFO_CPP_NAME)' \
++ -D 'fngcc $(INFO_GCC_NAME)' \
++ -D 'fngcov $(INFO_GCC_NAME)' \
++ -D 'fngcovtool $(INFO_GCC_NAME)' \
++ -D 'fngcovdump $(INFO_GCC_NAME)' \
++ -D 'fngxx $(INFO_GXX_NAME)' \
++ -D 'fngccint $(INFO_GCCINT_NAME)' \
++ -D 'fngccinstall $(INFO_GCCINSTALL_NAME)' \
++ -D 'fncppint $(INFO_CPPINT_NAME)' \
++ -D 'fngfortran $(INFO_FORTRAN_NAME)' \
++ -D 'fngccgo $(INFO_GCCGO_NAME)'
+
+ info: $(INFOFILES) lang.info @GENINSRC@ srcinfo lang.srcinfo
+
+@@ -3353,7 +3376,20 @@ gcc-vers.texi: $(BASEVER) $(DEVPHASE)
+ if [ -n "$(PKGVERSION)" ]; then \
+ echo "@set VERSION_PACKAGE $(PKGVERSION)" >> $@T; \
+ fi
+- echo "@set BUGURL $(BUGURL_TEXI)" >> $@T; \
++ echo "@set BUGURL $(BUGURL_TEXI)" >> $@T
++ ( \
++ echo '@set fncpp $(INFO_CPP_NAME)'; \
++ echo '@set fngcc $(INFO_GCC_NAME)'; \
++ echo '@set fngcov $(INFO_GCC_NAME)'; \
++ echo '@set fngcovtool $(INFO_GCC_NAME)'; \
++ echo '@set fngcovdump $(INFO_GCC_NAME)'; \
++ echo '@set fngxx $(INFO_GXX_NAME)'; \
++ echo '@set fngccint $(INFO_GCCINT_NAME)'; \
++ echo '@set fngccinstall $(INFO_GCCINSTALL_NAME)'; \
++ echo '@set fncppint $(INFO_CPPINT_NAME)'; \
++ echo '@set fngfortran $(INFO_FORTRAN_NAME)'; \
++ echo '@set fngccgo $(INFO_GCCGO_NAME)'; \
++ ) >> $@T
+ mv -f $@T $@
+
+
+@@ -3361,21 +3397,41 @@ gcc-vers.texi: $(BASEVER) $(DEVPHASE)
+ # patterns. To use them, put each of the specific targets with its
+ # specific dependencies but no build commands.
+
+-doc/cpp.info: $(TEXI_CPP_FILES)
+-doc/gcc.info: $(TEXI_GCC_FILES)
+-doc/gccint.info: $(TEXI_GCCINT_FILES)
+-doc/cppinternals.info: $(TEXI_CPPINT_FILES)
+-
++# Generic entry to handle info files, which are not renamed (currently Ada)
+ doc/%.info: %.texi
+ if [ x$(BUILD_INFO) = xinfo ]; then \
+ $(MAKEINFO) $(MAKEINFOFLAGS) -I . -I $(gcc_docdir) \
+ -I $(gcc_docdir)/include -o $@ $<; \
+ fi
+
++doc/$(INFO_CPP_NAME).info: $(TEXI_CPP_FILES)
++ if [ x$(BUILD_INFO) = xinfo ]; then \
++ $(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(gcc_docdir) \
++ -I $(gcc_docdir)/include -o $@ $<; \
++ fi
++
++doc/$(INFO_GCC_NAME).info: $(TEXI_GCC_FILES)
++ if [ x$(BUILD_INFO) = xinfo ]; then \
++ $(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(gcc_docdir) \
++ -I $(gcc_docdir)/include -o $@ $<; \
++ fi
++
++doc/$(INFO_GCCINT_NAME).info: $(TEXI_GCCINT_FILES)
++ if [ x$(BUILD_INFO) = xinfo ]; then \
++ $(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(gcc_docdir) \
++ -I $(gcc_docdir)/include -o $@ $<; \
++ fi
++
++doc/$(INFO_CPPINT_NAME).info: $(TEXI_CPPINT_FILES)
++ if [ x$(BUILD_INFO) = xinfo ]; then \
++ $(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(gcc_docdir) \
++ -I $(gcc_docdir)/include -o $@ $<; \
++ fi
++
+ # Duplicate entry to handle renaming of gccinstall.info
+-doc/gccinstall.info: $(TEXI_GCCINSTALL_FILES)
++doc/$(INFO_GCCINSTALL_NAME).info: $(TEXI_GCCINSTALL_FILES)
+ if [ x$(BUILD_INFO) = xinfo ]; then \
+- $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
++ $(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(gcc_docdir) \
+ -I $(gcc_docdir)/include -o $@ $<; \
+ fi
+
+@@ -3785,11 +3841,11 @@ install-driver: installdirs xgcc$(exeext
+ # $(INSTALL_DATA) might be a relative pathname, so we can't cd into srcdir
+ # to do the install.
+ install-info:: doc installdirs \
+- $(DESTDIR)$(infodir)/cpp.info \
+- $(DESTDIR)$(infodir)/gcc.info \
+- $(DESTDIR)$(infodir)/cppinternals.info \
+- $(DESTDIR)$(infodir)/gccinstall.info \
+- $(DESTDIR)$(infodir)/gccint.info \
++ $(DESTDIR)$(infodir)/$(INFO_CPP_NAME).info \
++ $(DESTDIR)$(infodir)/$(INFO_GCC_NAME).info \
++ $(DESTDIR)$(infodir)/$(INFO_CPPINT_NAME).info \
++ $(DESTDIR)$(infodir)/$(INFO_GCCINSTALL_NAME).info \
++ $(DESTDIR)$(infodir)/$(INFO_GCCINT_NAME).info \
+ lang.install-info
+
+ $(DESTDIR)$(infodir)/%.info: doc/%.info installdirs
+@@ -4028,8 +4084,11 @@ uninstall: lang.uninstall
+ -rm -rf $(DESTDIR)$(bindir)/$(GCOV_INSTALL_NAME)$(exeext)
+ -rm -rf $(DESTDIR)$(man1dir)/$(GCC_INSTALL_NAME)$(man1ext)
+ -rm -rf $(DESTDIR)$(man1dir)/cpp$(man1ext)
+- -rm -f $(DESTDIR)$(infodir)/cpp.info* $(DESTDIR)$(infodir)/gcc.info*
+- -rm -f $(DESTDIR)$(infodir)/cppinternals.info* $(DESTDIR)$(infodir)/gccint.info*
++ -rm -f $(DESTDIR)$(infodir)/$(INFO_CPP_NAME).info*
++ -rm -f $(DESTDIR)$(infodir)/$(INFO_GCC_NAME).info*
++ -rm -f $(DESTDIR)$(infodir)/$(INFO_CPPINT_NAME).info*
++ -rm -f $(DESTDIR)$(infodir)/$(INFO_GCCINT_NAME).info*
++ -rm -f $(DESTDIR)$(infodir)/$(INFO_GCCINSTALL_NAME).info*
+ for i in ar nm ranlib ; do \
+ install_name=`echo gcc-$$i|sed '$(program_transform_name)'`$(exeext) ;\
+ target_install_name=$(target_noncanonical)-`echo gcc-$$i|sed '$(program_transform_name)'`$(exeext) ; \
+--- a/src/gcc/ada/gnat-style.texi
++++ b/src/gcc/ada/gnat-style.texi
+@@ -12,7 +12,7 @@
+ @finalout
+ @dircategory GNU Ada Tools
+ @direntry
+-* gnat-style: (gnat-style.info). gnat-style
++* gnat-style: (gnat-style-14). GNAT Coding Style
+ @end direntry
+
+ @definfoenclose strong,`,'
+--- a/src/gcc/ada/gnat_rm.texi
++++ b/src/gcc/ada/gnat_rm.texi
+@@ -12,7 +12,7 @@
+ @finalout
+ @dircategory GNU Ada Tools
+ @direntry
+-* gnat_rm: (gnat_rm.info). gnat_rm
++* GNAT Reference Manual: (gnat_rm-14). Reference Manual for GNU Ada tools.
+ @end direntry
+
+ @definfoenclose strong,`,'
+--- a/src/gcc/doc/invoke.texi
++++ b/src/gcc/doc/invoke.texi
+@@ -16647,7 +16647,7 @@ One of the standard libraries bypassed b
+ @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
+ which GCC uses to overcome shortcomings of particular machines, or special
+ needs for some languages.
+-(@xref{Interface,,Interfacing to GCC Output,gccint,GNU Compiler
++(@xref{Interface,,Interfacing to GCC Output,@value{fngccint},GNU Compiler
+ Collection (GCC) Internals},
+ for more discussion of @file{libgcc.a}.)
+ In most cases, you need @file{libgcc.a} even when you want to avoid
+@@ -16656,7 +16656,7 @@ or @option{-nodefaultlibs} you should us
+ This ensures that you have no unresolved references to internal GCC
+ library subroutines.
+ (An example of such an internal subroutine is @code{__main}, used to ensure C++
+-constructors are called; @pxref{Collect2,,@code{collect2}, gccint,
++constructors are called; @pxref{Collect2,,@code{collect2}, @value{fngccint},
+ GNU Compiler Collection (GCC) Internals}.)
+
+ @item -e @var{entry}
+@@ -34111,7 +34111,7 @@ Note that you can also specify places to
+ @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These
+ take precedence over places specified using environment variables, which
+ in turn take precedence over those specified by the configuration of GCC@.
+-@xref{Driver,, Controlling the Compilation Driver @file{gcc}, gccint,
++@xref{Driver,, Controlling the Compilation Driver @file{gcc}, @value{fngccint},
+ GNU Compiler Collection (GCC) Internals}.
+
+ @table @env
+@@ -34291,7 +34291,7 @@ the headers it contains change.
+
+ A precompiled header file is searched for when @code{#include} is
+ seen in the compilation. As it searches for the included file
+-(@pxref{Search Path,,Search Path,cpp,The C Preprocessor}) the
++(@pxref{Search Path,,Search Path,@value{fncpp},The C Preprocessor}) the
+ compiler looks for a precompiled header in each directory just before it
+ looks for the include file in that directory. The name searched for is
+ the name specified in the @code{#include} with @samp{.gch} appended. If
+--- a/src/gcc/doc/extend.texi
++++ b/src/gcc/doc/extend.texi
+@@ -24503,7 +24503,7 @@ want to write code that checks whether t
+ test for the GNU compiler the same way as for C programs: check for a
+ predefined macro @code{__GNUC__}. You can also use @code{__GNUG__} to
+ test specifically for GNU C++ (@pxref{Common Predefined Macros,,
+-Predefined Macros,cpp,The GNU C Preprocessor}).
++Predefined Macros,@value{fncpp},The GNU C Preprocessor}).
+
+ @menu
+ * C++ Volatiles:: What constitutes an access to a volatile object.
+--- a/src/gcc/doc/standards.texi
++++ b/src/gcc/doc/standards.texi
+@@ -332,5 +332,5 @@ specification, described at @uref{https:
+ GNAT Reference Manual}, for information on standard
+ conformance and compatibility of the Ada compiler.
+
+-@xref{Standards,,Standards, gfortran, The GNU Fortran Compiler}, for details
++@xref{Standards,,Standards, @value{fngfortran}, The GNU Fortran Compiler}, for details
+ of standards supported by GNU Fortran.
+--- a/src/gcc/doc/libgcc.texi
++++ b/src/gcc/doc/libgcc.texi
+@@ -24,7 +24,7 @@ that needs them.
+ GCC will also generate calls to C library routines, such as
+ @code{memcpy} and @code{memset}, in some cases. The set of routines
+ that GCC may possibly use is documented in @ref{Other
+-Builtins,,,gcc, Using the GNU Compiler Collection (GCC)}.
++Builtins,,,@value{fngcc}, Using the GNU Compiler Collection (GCC)}.
+
+ These routines take arguments and return values of a specific machine
+ mode, not a specific C type. @xref{Machine Modes}, for an explanation
+--- a/src/gcc/doc/gccint.texi
++++ b/src/gcc/doc/gccint.texi
+@@ -49,7 +49,7 @@ Texts being (a) (see below), and with th
+ @ifnottex
+ @dircategory Software development
+ @direntry
+-* gccint: (gccint). Internals of the GNU Compiler Collection.
++* @value{fngccint}: (@value{fngccint}). Internals of the GNU Compiler Collection.
+ @end direntry
+ This file documents the internals of the GNU compilers.
+ @sp 1
+@@ -81,7 +81,7 @@ write front ends for new languages. It
+ @value{VERSION_PACKAGE}
+ @end ifset
+ version @value{version-GCC}. The use of the GNU compilers is documented in a
+-separate manual. @xref{Top,, Introduction, gcc, Using the GNU
++separate manual. @xref{Top,, Introduction, @value{fngcc}, Using the GNU
+ Compiler Collection (GCC)}.
+
+ This manual is mainly a reference manual rather than a tutorial. It
+--- a/src/gcc/doc/cpp.texi
++++ b/src/gcc/doc/cpp.texi
+@@ -50,7 +50,7 @@ This manual contains no Invariant Sectio
+ @ifinfo
+ @dircategory Software development
+ @direntry
+-* Cpp: (cpp). The GNU C preprocessor.
++* @value{fncpp}: (@value{fncpp}). The GNU C preprocessor.
+ @end direntry
+ @end ifinfo
+
+--- a/src/gcc/doc/gcc.texi
++++ b/src/gcc/doc/gcc.texi
+@@ -129,7 +129,7 @@ version @value{version-GCC}.
+ The internals of the GNU compilers, including how to port them to new
+ targets and some information about how to write front ends for new
+ languages, are documented in a separate manual. @xref{Top,,
+-Introduction, gccint, GNU Compiler Collection (GCC) Internals}.
++Introduction, @value{fngccint}, GNU Compiler Collection (GCC) Internals}.
+
+ @menu
+ * G++ and GCC:: You can compile C or C++ programs.
+--- a/src/gcc/doc/install.texi
++++ b/src/gcc/doc/install.texi
+@@ -89,7 +89,7 @@ Free Documentation License}''.
+ @end ifinfo
+ @dircategory Software development
+ @direntry
+-* gccinstall: (gccinstall). Installing the GNU Compiler Collection.
++* @value{fngccinstall}: (@value{fngccinstall}). Installing the GNU Compiler Collection.
+ @end direntry
+
+ @c Part 3 Titlepage and Copyright
+--- a/src/gcc/doc/cppinternals.texi
++++ b/src/gcc/doc/cppinternals.texi
+@@ -7,7 +7,7 @@
+ @ifinfo
+ @dircategory Software development
+ @direntry
+-* Cpplib: (cppinternals). Cpplib internals.
++* @value{fncppint}: (@value{fncppint}). Cpplib internals.
+ @end direntry
+ @end ifinfo
+
+--- a/src/libgomp/libgomp.texi
++++ b/src/libgomp/libgomp.texi
+@@ -31,7 +31,7 @@ texts being (a) (see below), and with th
+ @ifinfo
+ @dircategory GNU Libraries
+ @direntry
+-* libgomp: (libgomp). GNU Offloading and Multi Processing Runtime Library.
++* @value{fnlibgomp}: (@value{fnlibgomp}). GNU Offloading and Multi Processing Runtime Library.
+ @end direntry
+
+ This manual documents libgomp, the GNU Offloading and Multi Processing
+--- a/src/libgomp/Makefile.in
++++ b/src/libgomp/Makefile.in
+@@ -610,7 +610,8 @@ info_TEXINFOS = libgomp.texi
+
+ # AM_CONDITIONAL on configure check ACX_CHECK_PROG_VER([MAKEINFO])
+ @BUILD_INFO_TRUE@STAMP_BUILD_INFO = stamp-build-info
+-CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO)
++INFO_LIBGOMP_NAME = $(shell echo libgomp|sed '$(program_transform_name)')
++CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO) $(INFO_LIBGOMP_NAME).info
+ MAINTAINERCLEANFILES = $(srcdir)/libgomp.info
+ MULTISRCTOP =
+ MULTIBUILDTOP =
+@@ -1390,15 +1391,16 @@ env.lo: libgomp_f.h
+ env.o: libgomp_f.h
+
+ all-local: $(STAMP_GENINSRC)
+-
+-stamp-geninsrc: libgomp.info
+- cp -p $(top_builddir)/libgomp.info $(srcdir)/libgomp.info
++stamp-geninsrc: $(INFO_LIBGOMP_NAME).info
++ cp -p $(top_builddir)/$(INFO_LIBGOMP_NAME).info $(srcdir)/libgomp.info
+ @touch $@
+
+-libgomp.info: $(STAMP_BUILD_INFO)
++libgomp.info: $(INFO_LIBGOMP_NAME).info
++ [ "$(INFO_LIBGOMP_NAME).info" = libgomp.info ] || cp $(INFO_LIBGOMP_NAME).info libgomp.info
++$(INFO_LIBGOMP_NAME).info: $(STAMP_BUILD_INFO)
+
+ stamp-build-info: libgomp.texi
+- $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -o libgomp.info $(srcdir)/libgomp.texi
++ $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -D 'fnlibgomp $(INFO_LIBGOMP_NAME)' -I $(srcdir) -o $(INFO_LIBGOMP_NAME).info $(srcdir)/libgomp.texi
+ @touch $@
+
+ # target overrides
+--- a/src/libgomp/Makefile.am
++++ b/src/libgomp/Makefile.am
+@@ -128,14 +128,16 @@ endif
+
+ all-local: $(STAMP_GENINSRC)
+
+-stamp-geninsrc: libgomp.info
+- cp -p $(top_builddir)/libgomp.info $(srcdir)/libgomp.info
++stamp-geninsrc: $(INFO_LIBGOMP_NAME).info
++ cp -p $(top_builddir)/$(INFO_LIBGOMP_NAME).info $(srcdir)/libgomp.info
+ @touch $@
+
+-libgomp.info: $(STAMP_BUILD_INFO)
++libgomp.info: $(INFO_LIBGOMP_NAME).info
++ [ "$(INFO_LIBGOMP_NAME).info = libgomp.info ] || cp $(INFO_LIBGOMP_NAME).info libgomp.info
++$(INFO_LIBGOMP_NAME).info: $(STAMP_BUILD_INFO)
+
+ stamp-build-info: libgomp.texi
+- $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -o libgomp.info $(srcdir)/libgomp.texi
++ $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -D 'fnlibgomp $(INFO_LIBGOMP_NAME)' -I $(srcdir) -o $(INFO_LIBGOMP_NAME).info $(srcdir)/libgomp.texi
+ @touch $@
+
+
+--- a/src/libitm/libitm.texi
++++ b/src/libitm/libitm.texi
+@@ -20,7 +20,7 @@ Free Documentation License''.
+ @ifinfo
+ @dircategory GNU Libraries
+ @direntry
+-* libitm: (libitm). GNU Transactional Memory Library
++* @value{fnlibitm}: (@value{fnlibitm}). GNU Transactional Memory Library
+ @end direntry
+
+ This manual documents the GNU Transactional Memory Library.
+--- a/src/libitm/Makefile.am
++++ b/src/libitm/Makefile.am
+@@ -107,14 +107,17 @@ endif
+
+ all-local: $(STAMP_GENINSRC)
+
+-stamp-geninsrc: libitm.info
+- cp -p $(top_builddir)/libitm.info $(srcdir)/libitm.info
++INFO_LIBITM_NAME = $(shell echo libitm|sed '$(program_transform_name)')
++stamp-geninsrc: $(INFO_LIBITM_NAME).info
++ cp -p $(top_builddir)/$(INFO_LIBITM_NAME).info $(srcdir)/libitm.info
+ @touch $@
+
+-libitm.info: $(STAMP_BUILD_INFO)
++libitm.info: $(INFO_LIBITM_NAME).info
++ [ $(INFO_LIBITM_NAME).info = libitm.info ] || cp $(INFO_LIBITM_NAME).info libitm.info
++$(INFO_LIBITM_NAME).info: $(STAMP_BUILD_INFO)
+
+ stamp-build-info: libitm.texi
+- $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -o libitm.info $(srcdir)/libitm.texi
++ $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -D 'fnlibitm $(INFO_LIBITM_NAME)'-o $(INFO_LIBITM_NAME).info $(srcdir)/libitm.texi
+ @touch $@
+
+
+--- a/src/libitm/Makefile.in
++++ b/src/libitm/Makefile.in
+@@ -1186,14 +1186,17 @@ vpath % $(strip $(search_path))
+
+ all-local: $(STAMP_GENINSRC)
+
+-stamp-geninsrc: libitm.info
+- cp -p $(top_builddir)/libitm.info $(srcdir)/libitm.info
++INFO_LIBITM_NAME = $(shell echo libitm|sed '$(program_transform_name)')
++stamp-geninsrc: $(INFO_LIBITM_NAME).info
++ cp -p $(top_builddir)/$(INFO_LIBITM_NAME).info $(srcdir)/libitm.info
+ @touch $@
+
+-libitm.info: $(STAMP_BUILD_INFO)
++libitm.info: $(INFO_LIBITM_NAME).info
++ [ $(INFO_LIBITM_NAME).info = libitm.info ] || cp $(INFO_LIBITM_NAME).info libitm.info
++$(INFO_LIBITM_NAME).info: $(STAMP_BUILD_INFO)
+
+ stamp-build-info: libitm.texi
+- $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -o libitm.info $(srcdir)/libitm.texi
++ $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -D 'fnlibitm $(INFO_LIBITM_NAME)' -o $(INFO_LIBITM_NAME).info $(srcdir)/libitm.texi
+ @touch $@
+
+ # GNU Make needs to see an explicit $(MAKE) variable in the command it
+--- a/src/gcc/go/Make-lang.in
++++ b/src/gcc/go/Make-lang.in
+@@ -95,10 +95,11 @@ GO_TEXI_FILES = \
+ $(gcc_docdir)/include/gcc-common.texi \
+ gcc-vers.texi
+
+-doc/gccgo.info: $(GO_TEXI_FILES)
++INFO_GCCGO_NAME = $(shell echo gccgo|sed '$(program_transform_name)')
++doc/$(INFO_GCCGO_NAME).info: $(GO_TEXI_FILES)
+ if test "x$(BUILD_INFO)" = xinfo; then \
+- rm -f doc/gccgo.info*; \
+- $(MAKEINFO) $(MAKEINFOFLAGS) -I $(gcc_docdir) \
++ rm -f doc/$(INFO_GCCGO_NAME).info*; \
++ $(MAKEINFO) $(MAKEINFOFLAGS) $(MAKEINFODEFS) -I $(gcc_docdir) \
+ -I $(gcc_docdir)/include -o $@ $<; \
+ else true; fi
+
+@@ -124,7 +125,7 @@ gccgo.pod: go/gccgo.texi
+ go.all.cross: gccgo-cross$(exeext)
+ go.start.encap: gccgo$(exeext)
+ go.rest.encap:
+-go.info: doc/gccgo.info
++go.info: doc/$(INFO_GCCGO_NAME).info
+ go.dvi: doc/gccgo.dvi
+ go.pdf: doc/gccgo.pdf
+ go.html: $(build_htmldir)/go/index.html
+@@ -163,7 +164,7 @@ go.install-common: installdirs
+
+ go.install-plugin:
+
+-go.install-info: $(DESTDIR)$(infodir)/gccgo.info
++go.install-info: $(DESTDIR)$(infodir)/$(INFO_GCCGO_NAME).info
+
+ go.install-pdf: doc/gccgo.pdf
+ @$(NORMAL_INSTALL)
+@@ -203,7 +204,7 @@ go.uninstall:
+ rm -rf $(DESTDIR)$(bindir)/$(GCCGO_INSTALL_NAME)$(exeext)
+ rm -rf $(DESTDIR)$(man1dir)/$(GCCGO_INSTALL_NAME)$(man1ext)
+ rm -rf $(DESTDIR)$(bindir)/$(GCCGO_TARGET_INSTALL_NAME)$(exeext)
+- rm -rf $(DESTDIR)$(infodir)/gccgo.info*
++ rm -rf $(DESTDIR)$(infodir)/$(INFO_GCCGO_NAME).info*
+
+ # Clean hooks.
+
+--- a/src/gcc/go/gccgo.texi
++++ b/src/gcc/go/gccgo.texi
+@@ -50,7 +50,7 @@ man page gfdl(7).
+ @format
+ @dircategory Software development
+ @direntry
+-* Gccgo: (gccgo). A GCC-based compiler for the Go language
++* @value{fngccgo}: (@value{fngccgo}). A GCC-based compiler for the Go language
+ @end direntry
+ @end format
+
+@@ -124,7 +124,7 @@ and the Info entries for @file{gccgo} an
+
+ The @command{gccgo} command is a frontend to @command{gcc} and
+ supports many of the same options. @xref{Option Summary, , Option
+-Summary, gcc, Using the GNU Compiler Collection (GCC)}. This manual
++Summary, @value{fngcc}, Using the GNU Compiler Collection (GCC)}. This manual
+ only documents the options specific to @command{gccgo}.
+
+ The @command{gccgo} command may be used to compile Go source code into
+--- a/src/libquadmath/libquadmath.texi
++++ b/src/libquadmath/libquadmath.texi
+@@ -25,7 +25,7 @@ copy and modify this GNU manual.
+ @ifinfo
+ @dircategory GNU Libraries
+ @direntry
+-* libquadmath: (libquadmath). GCC Quad-Precision Math Library
++* @value{fnlibquadmath}: (@value{fnlibquadmath}). GCC Quad-Precision Math Library
+ @end direntry
+
+ This manual documents the GCC Quad-Precision Math Library API.
+--- a/src/libquadmath/Makefile.am
++++ b/src/libquadmath/Makefile.am
+@@ -134,16 +134,18 @@ STAMP_BUILD_INFO =
+ endif
+
+
+-stamp-geninsrc: libquadmath.info
+- cp -p $(top_builddir)/libquadmath.info $(srcdir)/libquadmath.info
++INFO_LIBQMATH_NAME = $(shell echo libquadmath|sed '$(program_transform_name)')
++
++stamp-geninsrc: $(INFO_LIBQMATH_NAME).info
++ cp -p $(top_builddir)/$(INFO_LIBQMATH_NAME).info $(srcdir)/libquadmath.info
+ @touch $@
+
+ stamp-build-info: libquadmath.texi $(libquadmath_TEXINFOS)
+- $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -o libquadmath.info $(srcdir)/libquadmath.texi
++ $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -o $(INFO_LIBQMATH_NAME).info $(srcdir)/libquadmath.texi
+ @touch $@
+
+-CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO)
+-MAINTAINERCLEANFILES = $(srcdir)/libquadmath.info
++CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO) $(INFO_LIBQMATH_NAME).info
++MAINTAINERCLEANFILES = $(srcdir)/$(INFO_LIBQMATH_NAME).info
+
+ endif BUILD_LIBQUADMATH
+
+--- a/src/libquadmath/Makefile.in
++++ b/src/libquadmath/Makefile.in
+@@ -283,7 +283,8 @@ AM_V_texidevnull = $(am__v_texidevnull_@
+ am__v_texidevnull_ = $(am__v_texidevnull_@AM_DEFAULT_V@)
+ am__v_texidevnull_0 = > /dev/null
+ am__v_texidevnull_1 =
+-INFO_DEPS = libquadmath.info
++INFO_LIBQMATH_NAME = $(shell echo libquadmath|sed '$(program_transform_name)')
++INFO_DEPS = $(INFO_LIBQMATH_NAME).info
+ am__TEXINFO_TEX_DIR = $(srcdir)/../gcc/doc/include
+ DVIS = libquadmath.dvi
+ PDFS = libquadmath.pdf
+@@ -552,8 +553,8 @@ AUTOMAKE_OPTIONS = foreign info-in-build
+
+ # AM_CONDITIONAL on configure check ACX_CHECK_PROG_VER([MAKEINFO])
+ @BUILD_INFO_TRUE@@BUILD_LIBQUADMATH_TRUE@STAMP_BUILD_INFO = stamp-build-info
+-@BUILD_LIBQUADMATH_TRUE@CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO)
+-@BUILD_LIBQUADMATH_TRUE@MAINTAINERCLEANFILES = $(srcdir)/libquadmath.info
++@BUILD_LIBQUADMATH_TRUE@CLEANFILES = $(STAMP_GENINSRC) $(STAMP_BUILD_INFO) $(INFO_LIBQMATH_NAME).info
++@BUILD_LIBQUADMATH_TRUE@MAINTAINERCLEANFILES = $(srcdir)/$(INFO_LIBQMATH_NAME).info
+
+ # Automake Documentation:
+ # If your package has Texinfo files in many directories, you can use the
+@@ -1434,19 +1435,19 @@ uninstall-am: uninstall-dvi-am uninstall
+ @BUILD_LIBQUADMATH_TRUE@@LIBQUAD_USE_SYMVER_SUN_TRUE@@LIBQUAD_USE_SYMVER_TRUE@ sed 's,\([^/ ]*\)\.l\([ao]\),.libs/\1.\2,g'` \
+ @BUILD_LIBQUADMATH_TRUE@@LIBQUAD_USE_SYMVER_SUN_TRUE@@LIBQUAD_USE_SYMVER_TRUE@ > $@ || (rm -f $@ ; exit 1)
+
+-@BUILD_LIBQUADMATH_TRUE@stamp-geninsrc: libquadmath.info
+-@BUILD_LIBQUADMATH_TRUE@ cp -p $(top_builddir)/libquadmath.info $(srcdir)/libquadmath.info
++@BUILD_LIBQUADMATH_TRUE@stamp-geninsrc: $(INFO_LIBQMATH_NAME).info
++@BUILD_LIBQUADMATH_TRUE@ cp -p $(top_builddir)/$(INFO_LIBQMATH_NAME).info $(srcdir)/$(INFO_LIBQMATH_NAME).info
+ @BUILD_LIBQUADMATH_TRUE@ @touch $@
+
+ @BUILD_LIBQUADMATH_TRUE@stamp-build-info: libquadmath.texi $(libquadmath_TEXINFOS)
+-@BUILD_LIBQUADMATH_TRUE@ $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -o libquadmath.info $(srcdir)/libquadmath.texi
++@BUILD_LIBQUADMATH_TRUE@ $(MAKEINFO) $(AM_MAKEINFOFLAGS) $(MAKEINFOFLAGS) -I $(srcdir) -o $(INFO_LIBQMATH_NAME).info $(srcdir)/libquadmath.texi
+ @BUILD_LIBQUADMATH_TRUE@ @touch $@
+
+ all-local: $(ALL_LOCAL_DEPS)
+
+ # Unconditionally override this target, so that automake's definition
+ # does not wrongly interfere.
+-libquadmath.info: $(STAMP_BUILD_INFO)
++$(INFO_LIBQMATH_NAME).info: $(STAMP_BUILD_INFO)
+
+ libquadmath-vers.texi:
+ echo "@set BUGURL $(REPORT_BUGS_TEXI)" > $@
diff --git a/debian/patches/rust-enabled.diff b/debian/patches/rust-enabled.diff
new file mode 100644
index 0000000..d0972fa
--- /dev/null
+++ b/debian/patches/rust-enabled.diff
@@ -0,0 +1,23 @@
+# DP: Explicitely enable rust, too late to be removed from 23.04
+
+--- a/src/configure.ac
++++ b/src/configure.ac
+@@ -2150,18 +2150,6 @@ if test -d ${srcdir}/gcc; then
+ ;;
+ esac
+
+- # Disable Rust for GCC 13 release.
+- case ${add_this_lang}:${language} in
+- yes:rust)
+- # Specifically requested language; tell them.
+- AC_MSG_ERROR([Rust is not supported in GCC 13 release])
+- ;;
+- *:rust)
+- # Silently disable.
+- add_this_lang=unsupported
+- ;;
+- esac
+-
+ # Disable jit if -enable-host-shared not specified
+ # but not if building for Mingw. All code in Windows
+ # is position independent code (PIC).
diff --git a/debian/patches/skip-bootstrap-multilib.diff b/debian/patches/skip-bootstrap-multilib.diff
new file mode 100644
index 0000000..a07b8c1
--- /dev/null
+++ b/debian/patches/skip-bootstrap-multilib.diff
@@ -0,0 +1,22 @@
+# DP: Skip non-default multilib and libstdc++-v3 debug builds in bootstrap builds
+
+--- a/src/config-ml.in
++++ b/src/config-ml.in
+@@ -492,6 +492,17 @@ esac
+ # Tests like `if [ -n "$multidirs" ]' require it.
+ multidirs=`echo "$multidirs" | sed -e 's/^[ ][ ]*//' -e 's/[ ][ ]*$//' -e 's/[ ][ ]*/ /g'`
+
++# stage1 and stage2 builds of the non-default multilib configurations
++# are not needed; skip these to save some build time.
++if [ -f ../../stage_final ] && [ -f ../../stage_current ]; then
++ stage_final=`cat ../../stage_final`
++ stage_current=`cat ../../stage_current`
++ if [ "$stage_current" != "$stage_final" ]; then
++ echo "Skip `basename $ml_realsrcdir` non-default multilibs for bootstrap stage $stage_current"
++ multidirs=
++ fi
++fi
++
+ # Add code to library's top level makefile to handle building the multilib
+ # subdirs.
+
diff --git a/debian/patches/sparc64-biarch-long-double-128.diff b/debian/patches/sparc64-biarch-long-double-128.diff
new file mode 100644
index 0000000..a57da82
--- /dev/null
+++ b/debian/patches/sparc64-biarch-long-double-128.diff
@@ -0,0 +1,33 @@
+# DP: Fix --with-long-double-128 for sparc32 when defaulting to 64-bit.
+
+On sparc, the --with-long-double-128 option doesn't change anything for
+a 64-bit compiler, as it always default to 128-bit long doubles. For
+a 32/64-bit compiler defaulting to 32-bit this correctly control the
+size of long double of the 32-bit compiler, however for a 32/64-bit
+compiler defaulting to 64-bit, the built-in specs force the
+-mlong-double-64 option. This makes the option useless in this case.
+
+The patch below fixes that by removing the -mlong-double-64 from the
+built-in spec, using the default instead.
+
+Changelog gcc/
+
+2013-12-04 Aurelien Jarno <aurelien@aurel32.net>
+
+ * config/sparc/linux64.h (CC1_SPEC): When defaulting to 64-bit,
+ don't force -mlong-double-64 when -m32 or -mv8plus is given.
+
+--- a/src/gcc/config/sparc/linux64.h
++++ b/src/gcc/config/sparc/linux64.h
+@@ -160,9 +160,9 @@ extern const char *host_detect_local_cpu
+ #else
+ #define CC1_SPEC GNU_USER_TARGET_CC1_SPEC ASAN_CC1_SPEC \
+ "%{m32:%{m64:%emay not use both -m32 and -m64}} \
+-%{m32:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
++%{m32:-mptr32 -mno-stack-bias \
+ %{!mcpu*:-mcpu=cypress}} \
+-%{mv8plus:-mptr32 -mno-stack-bias %{!mlong-double-128:-mlong-double-64} \
++%{mv8plus:-mptr32 -mno-stack-bias \
+ %{!mcpu*:-mcpu=v9}} \
+ %{!m32:%{!mcpu*:-mcpu=ultrasparc}} \
+ %{!mno-vis:%{!m32:%{!mcpu=v9:-mvis}}}"
diff --git a/debian/patches/sys-auxv-header.diff b/debian/patches/sys-auxv-header.diff
new file mode 100644
index 0000000..b8f26d7
--- /dev/null
+++ b/debian/patches/sys-auxv-header.diff
@@ -0,0 +1,40 @@
+# DP: Check for the sys/auxv.h header file.
+
+--- a/src/gcc/configure.ac
++++ b/src/gcc/configure.ac
+@@ -1347,6 +1347,7 @@ AC_HEADER_TIOCGWINSZ
+ AC_CHECK_HEADERS(limits.h stddef.h string.h strings.h stdlib.h time.h iconv.h \
+ fcntl.h ftw.h unistd.h sys/auxv.h sys/file.h sys/time.h sys/mman.h \
+ sys/resource.h sys/param.h sys/times.h sys/stat.h sys/locking.h \
++ sys/auxv.h \
+ direct.h malloc.h langinfo.h ldfcn.h locale.h wchar.h)
+
+ # Check for thread headers.
+--- a/src/gcc/config.in
++++ b/src/gcc/config.in
+@@ -2037,6 +2037,12 @@
+ #endif
+
+
++/* Define to 1 if you have the <sys/auxv.h> header file. */
++#ifndef USED_FOR_TARGET
++#undef HAVE_SYS_AUXV_H
++#endif
++
++
+ /* Define to 1 if you have the <sys/file.h> header file. */
+ #ifndef USED_FOR_TARGET
+ #undef HAVE_SYS_FILE_H
+--- a/src/gcc/config/rs6000/driver-rs6000.cc
++++ b/src/gcc/config/rs6000/driver-rs6000.cc
+@@ -35,6 +35,10 @@ along with GCC; see the file COPYING3.
+ # include <link.h>
+ #endif
+
++#ifdef HAVE_SYS_AUXV_H
++# include <sys/auxv.h>
++#endif
++
+ #if defined (__APPLE__) || (__FreeBSD__)
+ # include <sys/types.h>
+ # include <sys/sysctl.h>
diff --git a/debian/patches/t-libunwind-elf-Wl-z-defs.diff b/debian/patches/t-libunwind-elf-Wl-z-defs.diff
new file mode 100644
index 0000000..082d4d5
--- /dev/null
+++ b/debian/patches/t-libunwind-elf-Wl-z-defs.diff
@@ -0,0 +1,13 @@
+# DP: strip -z,defs from linker options for internal libunwind.
+
+--- a/src/libgcc/config/t-libunwind-elf
++++ b/src/libgcc/config/t-libunwind-elf
+@@ -31,7 +31,7 @@ SHLIBUNWIND_SONAME = @shlib_base_name@.s
+
+ SHLIBUNWIND_LINK = $(CC) $(LIBGCC2_CFLAGS) -shared \
+ -nodefaultlibs -Wl,-h,$(SHLIBUNWIND_SONAME) \
+- -Wl,-z,text -Wl,-z,defs -o $(SHLIB_DIR)/$(SHLIBUNWIND_SONAME).tmp \
++ -Wl,-z,text -o $(SHLIB_DIR)/$(SHLIBUNWIND_SONAME).tmp \
+ @multilib_flags@ $(SHLIB_OBJS) -lc && \
+ rm -f $(SHLIB_DIR)/$(SHLIB_SOLINK) && \
+ if [ -f $(SHLIB_DIR)/$(SHLIBUNWIND_SONAME) ]; then \
diff --git a/debian/patches/testsuite-glibc-warnings.diff b/debian/patches/testsuite-glibc-warnings.diff
new file mode 100644
index 0000000..b1353f0
--- /dev/null
+++ b/debian/patches/testsuite-glibc-warnings.diff
@@ -0,0 +1,18 @@
+# DP: fix testcases that triggered -Wunused-result with glibc
+# DP: Author: Steve Beattie <steve.beattie@canonical.com>
+---
+ src/gcc/testsuite/c-c++-common/cilk-plus/AN/comma_exp.c | 2 +-
+ src/gcc/testsuite/c-c++-common/tsan/fd_pipe_race.c | 1 +
+ 2 files changed, 2 insertions(+), 1 deletion(-)
+
+Index: b/src/gcc/testsuite/c-c++-common/tsan/fd_pipe_race.c
+===================================================================
+--- a/src/gcc/testsuite/c-c++-common/tsan/fd_pipe_race.c
++++ b/src/gcc/testsuite/c-c++-common/tsan/fd_pipe_race.c
+@@ -1,5 +1,5 @@
+ /* { dg-shouldfail "tsan" } */
+-/* { dg-additional-options "-ldl" } */
++/* { dg-additional-options "-Wno-unused-result -ldl" } */
+
+ #include <pthread.h>
+ #include <unistd.h>
diff --git a/debian/patches/testsuite-hardening-format.diff b/debian/patches/testsuite-hardening-format.diff
new file mode 100644
index 0000000..b968027
--- /dev/null
+++ b/debian/patches/testsuite-hardening-format.diff
@@ -0,0 +1,304 @@
+#! /bin/sh -e
+
+# All lines beginning with `# DPATCH:' are a description of the patch.
+# DP: Description: use -Wno-format on tests that cannot be adjusted other ways.
+# DP: Author: Kees Cook <kees@ubuntu.com>
+# DP: Ubuntu: https://bugs.launchpad.net/bugs/344502
+
+dir=
+if [ $# -eq 3 -a "$2" = '-d' ]; then
+ pdir="-d $3"
+ dir="$3/"
+elif [ $# -ne 1 ]; then
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+fi
+case "$1" in
+ -patch)
+ patch $pdir -f --no-backup-if-mismatch -p1 < $0
+ #cd ${dir}gcc && autoconf
+ ;;
+ -unpatch)
+ patch $pdir -f --no-backup-if-mismatch -R -p1 < $0
+ #rm ${dir}gcc/configure
+ ;;
+ *)
+ echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
+ exit 1
+esac
+exit 0
+
+---
+ src/gcc/testsuite/c-c++-common/torture/vector-compare-1.c | 1 +
+ src/gcc/testsuite/g++.dg/abi/pragma-pack1.C | 2 ++
+ src/gcc/testsuite/g++.dg/abi/regparm1.C | 1 +
+ src/gcc/testsuite/g++.dg/cpp0x/constexpr-tuple.C | 1 +
+ src/gcc/testsuite/g++.dg/torture/pr51436.C | 1 +
+ src/gcc/testsuite/g++.old-deja/g++.law/weak.C | 2 +-
+ src/gcc/testsuite/g++.old-deja/g++.other/std1.C | 1 +
+ src/gcc/testsuite/gcc.c-torture/execute/vfprintf-chk-1.x | 5 +++++
+ src/gcc/testsuite/gcc.c-torture/execute/vprintf-chk-1.x | 5 +++++
+ src/gcc/testsuite/gcc.dg/charset/builtin2.c | 2 +-
+ src/gcc/testsuite/gcc.dg/format/format.exp | 2 +-
+ src/gcc/testsuite/gcc.dg/ipa/ipa-sra-1.c | 2 +-
+ src/gcc/testsuite/gcc.dg/lto/20090218-2_0.c | 2 ++
+ src/gcc/testsuite/gcc.dg/pr30473.c | 2 +-
+ src/gcc/testsuite/gcc.dg/pr38902.c | 2 +-
+ src/gcc/testsuite/gcc.dg/pr59418.c | 2 +-
+ src/gcc/testsuite/gcc.dg/torture/tls/tls-test.c | 2 +-
+ src/gcc/testsuite/gcc.dg/tree-ssa/builtin-fprintf-1.c | 2 +-
+ src/gcc/testsuite/gcc.dg/tree-ssa/builtin-fprintf-chk-1.c | 2 +-
+ src/gcc/testsuite/gcc.dg/tree-ssa/builtin-printf-1.c | 2 +-
+ src/gcc/testsuite/gcc.dg/tree-ssa/builtin-printf-chk-1.c | 2 +-
+ src/gcc/testsuite/gcc.dg/tree-ssa/builtin-vfprintf-1.c | 2 +-
+ src/gcc/testsuite/gcc.dg/tree-ssa/builtin-vfprintf-chk-1.c | 2 +-
+ src/gcc/testsuite/gcc.dg/tree-ssa/builtin-vprintf-1.c | 2 +-
+ src/gcc/testsuite/gcc.dg/tree-ssa/builtin-vprintf-chk-1.c | 2 +-
+ src/gcc/testsuite/gcc.dg/tree-ssa/isolate-4.c | 2 +-
+ src/gcc/testsuite/objc.dg/torture/strings/const-str-3.m | 2 +-
+ 28 files changed, 40 insertions(+), 18 deletions(-)
+
+--- /dev/null
++++ b/src/gcc/testsuite/gcc.c-torture/execute/vfprintf-chk-1.x
+@@ -0,0 +1,5 @@
++# Implement "/* { dg-options "-U_FORITFY_SOURCE" } */", due to
++# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20567
++
++set additional_flags "-U_FORTIFY_SOURCE"
++return 0
+--- /dev/null
++++ b/src/gcc/testsuite/gcc.c-torture/execute/vprintf-chk-1.x
+@@ -0,0 +1,5 @@
++# Implement "/* { dg-options "-U_FORITFY_SOURCE" } */", due to
++# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20567
++
++set additional_flags "-U_FORTIFY_SOURCE"
++return 0
+--- a/src/gcc/testsuite/gcc.dg/charset/builtin2.c
++++ b/src/gcc/testsuite/gcc.dg/charset/builtin2.c
+@@ -3,7 +3,7 @@
+
+ /* { dg-do compile } */
+ /* { dg-require-iconv "IBM1047" } */
+-/* { dg-options "-O2 -fexec-charset=IBM1047" } */
++/* { dg-options "-O2 -fexec-charset=IBM1047 -Wno-format" } */
+ /* { dg-final { scan-assembler-not "printf" } } */
+ /* { dg-final { scan-assembler-not "fprintf" } } */
+ /* { dg-final { scan-assembler-not "sprintf" } } */
+--- a/src/gcc/testsuite/gcc.dg/format/format.exp
++++ b/src/gcc/testsuite/gcc.dg/format/format.exp
+@@ -26,7 +26,7 @@ load_lib gcc-dg.exp
+ load_lib torture-options.exp
+
+ torture-init
+-set-torture-options [list { } { -DWIDE } ]
++set-torture-options [list { -Wformat=0 } { -DWIDE -Wformat=0 } ]
+
+ dg-init
+ gcc-dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] "" ""
+--- a/src/gcc/testsuite/gcc.dg/pr30473.c
++++ b/src/gcc/testsuite/gcc.dg/pr30473.c
+@@ -1,7 +1,7 @@
+ /* PR middle-end/30473 */
+ /* Make sure this doesn't ICE. */
+ /* { dg-do compile } */
+-/* { dg-options "-O2" } */
++/* { dg-options "-O2 -Wno-format" } */
+
+ extern int sprintf (char *, const char *, ...);
+
+--- a/src/gcc/testsuite/gcc.dg/pr38902.c
++++ b/src/gcc/testsuite/gcc.dg/pr38902.c
+@@ -1,6 +1,6 @@
+ /* PR target/38902 */
+ /* { dg-do run } */
+-/* { dg-options "-O2 -fstack-protector" } */
++/* { dg-options "-O2 -fstack-protector -Wno-format" } */
+ /* { dg-require-effective-target fstack_protector } */
+
+ #ifdef DEBUG
+--- a/src/gcc/testsuite/gcc.dg/pr59418.c
++++ b/src/gcc/testsuite/gcc.dg/pr59418.c
+@@ -2,7 +2,7 @@
+ /* Reported by Ryan Mansfield <rmansfield@qnx.com> */
+
+ /* { dg-do compile } */
+-/* { dg-options "-Os -g" } */
++/* { dg-options "-Os -g -Wno-format-zero-length" } */
+ /* { dg-options "-march=armv7-a+fp -mfloat-abi=hard -Os -g" { target { arm*-*-* && { ! arm_thumb1 } } } } */
+
+ extern int printf (const char *__format, ...);
+--- a/src/gcc/testsuite/gcc.dg/ipa/ipa-sra-1.c
++++ b/src/gcc/testsuite/gcc.dg/ipa/ipa-sra-1.c
+@@ -1,5 +1,5 @@
+ /* { dg-do run } */
+-/* { dg-options "-O2 -fipa-sra -fdump-ipa-sra-details" } */
++/* { dg-options "-O2 -fipa-sra -fdump-ipa-sra-details -Wformat=0" } */
+
+ struct bovid
+ {
+--- a/src/gcc/testsuite/gcc.dg/lto/20090218-2_0.c
++++ b/src/gcc/testsuite/gcc.dg/lto/20090218-2_0.c
+@@ -1,3 +1,5 @@
++/* { dg-lto-options "-Wno-nonnull" } */
++
+ void set_mem_alias_set ();
+ void emit_push_insn () {
+ set_mem_alias_set ();
+--- a/src/gcc/testsuite/c-c++-common/torture/vector-compare-1.c
++++ b/src/gcc/testsuite/c-c++-common/torture/vector-compare-1.c
+@@ -1,4 +1,5 @@
+ /* { dg-do run } */
++/* { dg-options "-Wformat=0" } */
+ #define vector(elcount, type) \
+ __attribute__((vector_size((elcount)*sizeof(type)))) type
+
+--- a/src/gcc/testsuite/gcc.dg/tree-ssa/builtin-vprintf-chk-1.c
++++ b/src/gcc/testsuite/gcc.dg/tree-ssa/builtin-vprintf-chk-1.c
+@@ -1,5 +1,5 @@
+ /* { dg-do compile } */
+-/* { dg-options "-O2 -fdump-tree-fab1" } */
++/* { dg-options "-O2 -fdump-tree-fab1 -Wno-format-zero-length" } */
+
+ #include <stdarg.h>
+
+--- a/src/gcc/testsuite/gcc.dg/tree-ssa/builtin-vprintf-1.c
++++ b/src/gcc/testsuite/gcc.dg/tree-ssa/builtin-vprintf-1.c
+@@ -1,5 +1,5 @@
+ /* { dg-do compile } */
+-/* { dg-options "-O2 -fdump-tree-fab1" } */
++/* { dg-options "-O2 -fdump-tree-fab1 -Wno-format-zero-length" } */
+
+ #include <stdarg.h>
+
+--- a/src/gcc/testsuite/gcc.dg/tree-ssa/builtin-printf-1.c
++++ b/src/gcc/testsuite/gcc.dg/tree-ssa/builtin-printf-1.c
+@@ -1,5 +1,5 @@
+ /* { dg-do compile } */
+-/* { dg-options "-O2 -fdump-tree-fab1" } */
++/* { dg-options "-O2 -fdump-tree-fab1 -Wno-format-zero-length" } */
+
+ extern int printf (const char *, ...);
+ volatile int vi0, vi1, vi2, vi3, vi4, vi5, vi6, vi7, vi8, vi9, via;
+--- a/src/gcc/testsuite/gcc.dg/tree-ssa/builtin-printf-chk-1.c
++++ b/src/gcc/testsuite/gcc.dg/tree-ssa/builtin-printf-chk-1.c
+@@ -1,5 +1,5 @@
+ /* { dg-do compile } */
+-/* { dg-options "-O2 -fdump-tree-fab1" } */
++/* { dg-options "-O2 -fdump-tree-fab1 -Wno-format-zero-length" } */
+
+ extern int __printf_chk (int, const char *, ...);
+ volatile int vi0, vi1, vi2, vi3, vi4, vi5, vi6, vi7, vi8, vi9, via;
+--- a/src/gcc/testsuite/gcc.dg/tree-ssa/builtin-fprintf-1.c
++++ b/src/gcc/testsuite/gcc.dg/tree-ssa/builtin-fprintf-1.c
+@@ -1,5 +1,5 @@
+ /* { dg-do compile } */
+-/* { dg-options "-O2 -fdump-tree-fab1" } */
++/* { dg-options "-O2 -fdump-tree-fab1 -Wno-format-zero-length" } */
+
+ typedef struct { int i; } FILE;
+ FILE *fp;
+--- a/src/gcc/testsuite/gcc.dg/tree-ssa/builtin-fprintf-chk-1.c
++++ b/src/gcc/testsuite/gcc.dg/tree-ssa/builtin-fprintf-chk-1.c
+@@ -1,5 +1,5 @@
+ /* { dg-do compile } */
+-/* { dg-options "-O2 -fdump-tree-fab1" } */
++/* { dg-options "-O2 -fdump-tree-fab1 -Wno-format-zero-length" } */
+
+ typedef struct { int i; } FILE;
+ FILE *fp;
+--- a/src/gcc/testsuite/gcc.dg/torture/tls/tls-test.c
++++ b/src/gcc/testsuite/gcc.dg/torture/tls/tls-test.c
+@@ -1,7 +1,7 @@
+ /* { dg-do run } */
+ /* { dg-require-effective-target tls } */
+ /* { dg-require-effective-target pthread } */
+-/* { dg-options "-pthread" } */
++/* { dg-options "-pthread -Wformat=0" } */
+
+ #include <pthread.h>
+ extern int printf (char *,...);
+--- a/src/gcc/testsuite/objc.dg/torture/strings/const-str-3.m
++++ b/src/gcc/testsuite/objc.dg/torture/strings/const-str-3.m
+@@ -2,7 +2,7 @@
+ /* Developed by Markus Hitter <mah@jump-ing.de>. */
+ /* { dg-do run } */
+ /* { dg-xfail-run-if "Needs OBJC2 ABI" { *-*-darwin* && { lp64 && { ! objc2 } } } { "-fnext-runtime" } { "" } } */
+-/* { dg-options "-fconstant-string-class=Foo" } */
++/* { dg-options "-fconstant-string-class=Foo -Wno-format-security" } */
+ /* { dg-options "-mno-constant-cfstrings -fconstant-string-class=Foo" { target *-*-darwin* } } */
+
+ #include "../../../objc-obj-c++-shared/objc-test-suite-types.h"
+--- a/src/gcc/testsuite/g++.dg/abi/pragma-pack1.C
++++ b/src/gcc/testsuite/g++.dg/abi/pragma-pack1.C
+@@ -1,5 +1,7 @@
+ // PR c++/7046
+
++// { dg-options "-Wformat=0" }
++
+ extern "C" int printf (const char *, ...);
+
+ #pragma pack(4)
+--- a/src/gcc/testsuite/g++.dg/abi/regparm1.C
++++ b/src/gcc/testsuite/g++.dg/abi/regparm1.C
+@@ -1,6 +1,7 @@
+ // PR c++/29911 (9381)
+ // { dg-do run { target i?86-*-* x86_64-*-* } }
+ // { dg-require-effective-target c++11 }
++// { dg-options "-Wformat=0" }
+
+ extern "C" int printf(const char *, ...);
+
+--- a/src/gcc/testsuite/g++.dg/cpp0x/constexpr-tuple.C
++++ b/src/gcc/testsuite/g++.dg/cpp0x/constexpr-tuple.C
+@@ -1,5 +1,6 @@
+ // PR c++/53202
+ // { dg-do run { target c++11 } }
++// { dg-options "-Wformat=0" }
+
+ #include <tuple>
+
+--- a/src/gcc/testsuite/g++.dg/torture/pr51436.C
++++ b/src/gcc/testsuite/g++.dg/torture/pr51436.C
+@@ -1,4 +1,5 @@
+ /* { dg-do compile } */
++/* { dg-options "-Wno-nonnull" } */
+ /* { dg-additional-options "-Wno-return-type" } */
+
+ typedef __SIZE_TYPE__ size_t;
+--- a/src/gcc/testsuite/g++.old-deja/g++.law/weak.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.law/weak.C
+@@ -1,6 +1,6 @@
+ // { dg-do link { target i?86-*-linux* i?86-*-gnu* x86_64-*-linux* } }
+ // { dg-require-effective-target static }
+-// { dg-options "-static" }
++// { dg-options "-static -Wno-nonnull" }
+ // Bug: g++ fails to instantiate operator<<.
+
+ // libc-5.4.xx has __IO_putc in its static C library, which can conflict
+--- a/src/gcc/testsuite/g++.old-deja/g++.other/std1.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.other/std1.C
+@@ -1,4 +1,5 @@
+ // { dg-do assemble }
++// { dg-options "-Wno-nonnull" }
+ // Origin: Mark Mitchell <mark@codesourcery.com>
+
+ extern "C" int memcmp (const void * __s1,
+--- a/src/gcc/testsuite/gcc.dg/tree-ssa/builtin-vfprintf-1.c
++++ b/src/gcc/testsuite/gcc.dg/tree-ssa/builtin-vfprintf-1.c
+@@ -1,5 +1,5 @@
+ /* { dg-do compile } */
+-/* { dg-options "-O2 -fdump-tree-fab1" } */
++/* { dg-options "-O2 -fdump-tree-fab1 -Wno-format-zero-length" } */
+
+ #include <stdarg.h>
+
+--- a/src/gcc/testsuite/gcc.dg/tree-ssa/builtin-vfprintf-chk-1.c
++++ b/src/gcc/testsuite/gcc.dg/tree-ssa/builtin-vfprintf-chk-1.c
+@@ -1,5 +1,5 @@
+ /* { dg-do compile } */
+-/* { dg-options "-O2 -fdump-tree-fab1" } */
++/* { dg-options "-O2 -fdump-tree-fab1 -Wno-format-zero-length" } */
+
+ #include <stdarg.h>
+
diff --git a/debian/patches/testsuite-hardening-printf-types.diff b/debian/patches/testsuite-hardening-printf-types.diff
new file mode 100644
index 0000000..248cb5e
--- /dev/null
+++ b/debian/patches/testsuite-hardening-printf-types.diff
@@ -0,0 +1,667 @@
+# DP: Description: adjust/standardize printf types to avoid -Wformat warnings.
+# DP: Author: Kees Cook <kees@ubuntu.com>
+# DP: Ubuntu: https://bugs.launchpad.net/bugs/344502
+
+Index: b/src/gcc/testsuite/g++.dg/ext/align1.C
+===================================================================
+--- a/src/gcc/testsuite/g++.dg/ext/align1.C
++++ b/src/gcc/testsuite/g++.dg/ext/align1.C
+@@ -16,6 +16,7 @@ float f1 __attribute__ ((aligned));
+ int
+ main (void)
+ {
+- printf ("%d %d\n", __alignof (a1), __alignof (f1));
++ // "%td" is not allowed by ISO C++, so use %p with a void * cast
++ printf ("%p %p\n", (void*)__alignof (a1), (void*)__alignof (f1));
+ return (__alignof (a1) < __alignof (f1));
+ }
+Index: b/src/gcc/testsuite/g++.old-deja/g++.law/operators28.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.law/operators28.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.law/operators28.C
+@@ -14,7 +14,8 @@ void* new_test::operator new(size_t sz,
+ {
+ void *p;
+
+- printf("%d %d %d\n", sz, count, type);
++ // ISO C++ does not support format size modifier "z", so use a cast
++ printf("%u %d %d\n", (unsigned int)sz, count, type);
+
+ p = new char[sz * count];
+ ((new_test *)p)->type = type;
+Index: b/src/gcc/testsuite/gcc.dg/torture/matrix-2.c
+===================================================================
+--- a/src/gcc/testsuite/gcc.dg/torture/matrix-2.c
++++ b/src/gcc/testsuite/gcc.dg/torture/matrix-2.c
+@@ -42,7 +42,7 @@ main (int argc, char **argv)
+ }
+ for (i = 0; i < ARCHnodes; i++)
+ for (j = 0; j < 3; j++)
+- printf ("%x\n",vel[i][j]);
++ printf ("%p\n",vel[i][j]);
+ /*if (i!=1 || j!=1)*/
+ /*if (i==1 && j==1)
+ continue;
+@@ -82,14 +82,14 @@ mem_init (void)
+ for (j = 0; j < 3; j++)
+ {
+ vel[i][j] = (int *) malloc (ARCHnodes1 * sizeof (int));
+- printf ("%x %d %d\n",vel[i][j], ARCHnodes1, sizeof (int));
++ printf ("%p %d %d\n",vel[i][j], ARCHnodes1, (int)sizeof (int));
+ }
+ }
+ for (i = 0; i < ARCHnodes; i++)
+ {
+ for (j = 0; j < 3; j++)
+ {
+- printf ("%x\n",vel[i][j]);
++ printf ("%p\n",vel[i][j]);
+ }
+ }
+
+@@ -98,7 +98,7 @@ mem_init (void)
+ {
+ for (j = 0; j < 3; j++)
+ {
+- printf ("%x\n",vel[i][j]);
++ printf ("%p\n",vel[i][j]);
+ /*for (k = 0; k < ARCHnodes1; k++)
+ {
+ vel[i][j][k] = d;
+Index: b/src/gcc/testsuite/gcc.dg/packed-vla.c
+===================================================================
+--- a/src/gcc/testsuite/gcc.dg/packed-vla.c
++++ b/src/gcc/testsuite/gcc.dg/packed-vla.c
+@@ -18,8 +18,8 @@ int func(int levels)
+ int b[4];
+ } __attribute__ ((__packed__)) foo;
+
+- printf("foo %d\n", sizeof(foo));
+- printf("bar %d\n", sizeof(bar));
++ printf("foo %d\n", (int)sizeof(foo));
++ printf("bar %d\n", (int)sizeof(bar));
+
+ if (sizeof (foo) != sizeof (bar))
+ abort ();
+Index: b/src/gcc/testsuite/g++.dg/opt/alias2.C
+===================================================================
+--- a/src/gcc/testsuite/g++.dg/opt/alias2.C
++++ b/src/gcc/testsuite/g++.dg/opt/alias2.C
+@@ -30,14 +30,14 @@ public:
+
+
+ _Deque_base::~_Deque_base() {
+- printf ("bb %x %x\n", this, *_M_start._M_node);
++ printf ("bb %p %x\n", this, *_M_start._M_node);
+ }
+
+ void
+ _Deque_base::_M_initialize_map()
+ {
+ yy = 0x123;
+- printf ("aa %x %x\n", this, yy);
++ printf ("aa %p %x\n", this, yy);
+
+ _M_start._M_node = &yy;
+ _M_start._M_cur = yy;
+Index: b/src/gcc/testsuite/g++.old-deja/g++.abi/vbase1.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.abi/vbase1.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.abi/vbase1.C
+@@ -33,7 +33,7 @@ struct VBase
+ void Offset () const
+ {
+ printf ("VBase\n");
+- printf (" VBase::member %d\n", &this->VBase::member - (int *)this);
++ printf (" VBase::member %d\n", (int)(&this->VBase::member - (int *)this));
+ }
+ };
+
+@@ -55,8 +55,8 @@ struct VDerived : virtual VBase
+ void Offset () const
+ {
+ printf ("VDerived\n");
+- printf (" VBase::member %d\n", &this->VBase::member - (int *)this);
+- printf (" VDerived::member %d\n", &this->VDerived::member - (int *)this);
++ printf (" VBase::member %d\n", (int)(&this->VBase::member - (int *)this));
++ printf (" VDerived::member %d\n", (int)(&this->VDerived::member - (int *)this));
+ }
+ };
+ struct B : virtual VBase
+@@ -65,8 +65,8 @@ struct B : virtual VBase
+ void Offset () const
+ {
+ printf ("B\n");
+- printf (" VBase::member %d\n", &this->VBase::member - (int *)this);
+- printf (" B::member %d\n", &this->B::member - (int *)this);
++ printf (" VBase::member %d\n", (int)(&this->VBase::member - (int *)this));
++ printf (" B::member %d\n", (int)(&this->B::member - (int *)this));
+ }
+ };
+ struct MostDerived : B, virtual VDerived
+@@ -75,10 +75,10 @@ struct MostDerived : B, virtual VDerived
+ void Offset () const
+ {
+ printf ("MostDerived\n");
+- printf (" VBase::member %d\n", &this->VBase::member - (int *)this);
+- printf (" B::member %d\n", &this->B::member - (int *)this);
+- printf (" VDerived::member %d\n", &this->VDerived::member - (int *)this);
+- printf (" MostDerived::member %d\n", &this->MostDerived::member - (int *)this);
++ printf (" VBase::member %d\n", (int)(&this->VBase::member - (int *)this));
++ printf (" B::member %d\n", (int)(&this->B::member - (int *)this));
++ printf (" VDerived::member %d\n", (int)(&this->VDerived::member - (int *)this));
++ printf (" MostDerived::member %d\n", (int)(&this->MostDerived::member - (int *)this));
+ }
+ };
+
+@@ -95,10 +95,10 @@ int main ()
+ if (ctorVDerived != &dum.VDerived::member)
+ return 24;
+
+- printf (" VBase::member %d\n", &dum.VBase::member - this_);
+- printf (" B::member %d\n", &dum.B::member - this_);
+- printf (" VDerived::member %d\n", &dum.VDerived::member - this_);
+- printf (" MostDerived::member %d\n", &dum.MostDerived::member - this_);
++ printf (" VBase::member %d\n", (int)(&dum.VBase::member - this_));
++ printf (" B::member %d\n", (int)(&dum.B::member - this_));
++ printf (" VDerived::member %d\n", (int)(&dum.VDerived::member - this_));
++ printf (" MostDerived::member %d\n", (int)(&dum.MostDerived::member - this_));
+ dum.MostDerived::Offset ();
+ dum.B::Offset ();
+ dum.VDerived::Offset ();
+Index: b/src/gcc/testsuite/g++.old-deja/g++.brendan/template8.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.brendan/template8.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.brendan/template8.C
+@@ -15,6 +15,6 @@ int main(){
+
+ Double_alignt<20000> heap;
+
+- printf(" &heap.array[0] = %d, &heap.for_alignt = %d\n", &heap.array[0], &heap.for_alignt);
++ printf(" &heap.array[0] = %p, &heap.for_alignt = %p\n", (void*)&heap.array[0], (void*)&heap.for_alignt);
+
+ }
+Index: b/src/gcc/testsuite/g++.old-deja/g++.eh/ptr1.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.eh/ptr1.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.eh/ptr1.C
+@@ -16,7 +16,7 @@ int main()
+ }
+
+ catch (E *&e) {
+- printf ("address of e is 0x%lx\n", (__SIZE_TYPE__)e);
++ printf ("address of e is %p\n", (void *)e);
+ return !((__SIZE_TYPE__)e != 5 && e->x == 5);
+ }
+ return 2;
+Index: b/src/gcc/testsuite/g++.old-deja/g++.jason/access23.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.jason/access23.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.jason/access23.C
+@@ -42,19 +42,19 @@ public:
+ void DoSomething() {
+ PUB_A = 0;
+ Foo::A = 0;
+- printf("%x\n",pX);
++ printf("%p\n",pX);
+ Foo::PUB.A = 0;
+- printf("%x\n",PUB.pX);
++ printf("%p\n",PUB.pX);
+ B = 0;
+- printf("%x\n",Foo::pY);
++ printf("%p\n",Foo::pY);
+ PRT_A = 0;
+ PRT.B = 0;
+- printf("%x\n",Foo::PRT.pY);
++ printf("%p\n",Foo::PRT.pY);
+ PRV_A = 0; // { dg-error "" }
+ Foo::C = 0; // { dg-error "" }
+- printf("%x\n",pZ); // { dg-error "" }
++ printf("%p\n",pZ); // { dg-error "" }
+ Foo::PRV.C = 0; // { dg-error "" }
+- printf("%x\n",PRV.pZ); // { dg-error "" }
++ printf("%p\n",PRV.pZ); // { dg-error "" }
+ }
+ };
+
+@@ -64,17 +64,17 @@ int main()
+
+ a.PUB_A = 0;
+ a.A = 0;
+- printf("%x\n",a.pX);
++ printf("%p\n",a.pX);
+ a.PRT_A = 0; // { dg-error "" }
+ a.B = 0; // { dg-error "" }
+- printf("%x\n",a.pY); // { dg-error "" }
++ printf("%p\n",a.pY); // { dg-error "" }
+ a.PRV_A = 0; // { dg-error "" }
+ a.C = 0; // { dg-error "" }
+- printf("%x\n",a.pZ); // { dg-error "" }
++ printf("%p\n",a.pZ); // { dg-error "" }
+ a.PUB.A = 0;
+- printf("%x\n",a.PUB.pX);
++ printf("%p\n",a.PUB.pX);
+ a.PRT.B = 0; // { dg-error "" }
+- printf("%x\n",a.PRT.pY); // { dg-error "" }
++ printf("%p\n",a.PRT.pY); // { dg-error "" }
+ a.PRV.C = 0; // { dg-error "" }
+- printf("%x\n",a.PRV.pZ); // { dg-error "" }
++ printf("%p\n",a.PRV.pZ); // { dg-error "" }
+ }
+Index: b/src/gcc/testsuite/g++.old-deja/g++.law/cvt8.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.law/cvt8.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.law/cvt8.C
+@@ -20,12 +20,12 @@ struct B {
+ B::operator const A&() const {
+ static A a;
+ a.i = i;
+- printf("convert B to A at %x\n", &a);
++ printf("convert B to A at %p\n", (void*)&a);
+ return a;
+ }
+
+ void f(A &a) { // { dg-message "" } in passing argument
+- printf("A at %x is %d\n", &a, a.i);
++ printf("A at %p is %d\n", (void*)&a, a.i);
+ }
+
+ int main() {
+Index: b/src/gcc/testsuite/g++.old-deja/g++.mike/net35.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.mike/net35.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.mike/net35.C
+@@ -17,10 +17,10 @@ public:
+
+ int main() {
+ C c;
+- printf("&c.x = %x\n", &c.x);
+- printf("&c.B1::x = %x\n", &c.B1::x);
+- printf("&c.B2::x = %x\n", &c.B2::x);
+- printf("&c.A::x = %x\n", &c.A::x);
++ printf("&c.x = %p\n", (void*)&c.x);
++ printf("&c.B1::x = %p\n", (void*)&c.B1::x);
++ printf("&c.B2::x = %p\n", (void*)&c.B2::x);
++ printf("&c.A::x = %p\n", (void*)&c.A::x);
+ if (&c.x != &c.B1::x
+ || &c.x != &c.B2::x
+ || &c.x != &c.A::x)
+Index: b/src/gcc/testsuite/g++.old-deja/g++.mike/offset1.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.mike/offset1.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.mike/offset1.C
+@@ -6,7 +6,7 @@ int fail = 0;
+ class Foo {
+ public:
+ virtual void setName() {
+- printf("Foo at %x\n", this);
++ printf("Foo at %p\n", (void*)this);
+ if (vp != (void*)this)
+ fail = 1;
+ }
+@@ -15,7 +15,7 @@ public:
+ class Bar : public Foo {
+ public:
+ virtual void init(int argc, char **argv) {
+- printf("Bar's Foo at %x\n", (Foo*)this);
++ printf("Bar's Foo at %p\n", (void*)(Foo*)this);
+ vp = (void*)(Foo*)this;
+ setName();
+ }
+Index: b/src/gcc/testsuite/g++.old-deja/g++.mike/p12306.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.mike/p12306.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.mike/p12306.C
+@@ -18,7 +18,7 @@ public:
+ if (ptr2 != &(*this).slist)
+ fail = 6;
+
+- if (0) printf("at %x %x\n", (RWSlistIterator*)this, &(*this).slist);
++ if (0) printf("at %p %p\n", (void*)(RWSlistIterator*)this, (void*)&(*this).slist);
+ }
+ };
+
+@@ -54,14 +54,14 @@ Sim_Event_Manager::Sim_Event_Manager ()
+ void Sim_Event_Manager::post_event () {
+ ptr1 = (RWSlistIterator*)&last_posted_event_position_;
+ ptr2 = &((RWSlistIterator*)&last_posted_event_position_)->slist;
+- if (0) printf("at %x %x\n", (RWSlistIterator*)&last_posted_event_position_,
+- &((RWSlistIterator*)&last_posted_event_position_)->slist);
++ if (0) printf("at %p %p\n", (void*)(RWSlistIterator*)&last_posted_event_position_,
++ (void*)&((RWSlistIterator*)&last_posted_event_position_)->slist);
+ if (ptr1 != (RWSlistIterator*)&last_posted_event_position_)
+ fail = 1;
+ if (ptr2 != &((RWSlistIterator&)last_posted_event_position_).slist)
+ fail = 2;
+- if (0) printf("at %x ?%x\n", (RWSlistIterator*)&last_posted_event_position_,
+- &((RWSlistIterator&)last_posted_event_position_).slist);
++ if (0) printf("at %p ?%p\n", (void*)(RWSlistIterator*)&last_posted_event_position_,
++ (void*)&((RWSlistIterator&)last_posted_event_position_).slist);
+ if (ptr1 != (RWSlistIterator*)&last_posted_event_position_)
+ fail = 3;
+ if (ptr2 != &((RWSlistIterator&)last_posted_event_position_).slist)
+Index: b/src/gcc/testsuite/g++.old-deja/g++.mike/p3579.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.mike/p3579.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.mike/p3579.C
+@@ -7,26 +7,26 @@ int num_x;
+
+ class Y {
+ public:
+- Y () { printf("Y() this: %x\n", this); }
+- ~Y () { printf("~Y() this: %x\n", this); }
++ Y () { printf("Y() this: %p\n", (void*)this); }
++ ~Y () { printf("~Y() this: %p\n", (void*)this); }
+ };
+
+ class X {
+ public:
+ X () {
+ ++num_x;
+- printf("X() this: %x\n", this);
++ printf("X() this: %p\n", (void*)this);
+ Y y;
+ *this = (X) y;
+ }
+
+- X (const Y & yy) { printf("X(const Y&) this: %x\n", this); ++num_x; }
++ X (const Y & yy) { printf("X(const Y&) this: %p\n", (void*)this); ++num_x; }
+ X & operator = (const X & xx) {
+- printf("X.op=(X&) this: %x\n", this);
++ printf("X.op=(X&) this: %p\n", (void*)this);
+ return *this;
+ }
+
+- ~X () { printf("~X() this: %x\n", this); --num_x; }
++ ~X () { printf("~X() this: %p\n", (void*)this); --num_x; }
+ };
+
+ int main (int, char **) {
+Index: b/src/gcc/testsuite/g++.old-deja/g++.mike/p3708a.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.mike/p3708a.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.mike/p3708a.C
+@@ -38,7 +38,7 @@ public:
+ virtual void xx(int doit) {
+ --num;
+ if (ptr != this)
+- printf("FAIL\n%x != %x\n", ptr, this);
++ printf("FAIL\n%p != %p\n", ptr, (void*)this);
+ printf ("C is destructed.\n");
+ B::xx (0);
+ if (doit) A::xx (1);
+Index: b/src/gcc/testsuite/g++.old-deja/g++.mike/p3708b.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.mike/p3708b.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.mike/p3708b.C
+@@ -48,7 +48,7 @@ public:
+ virtual void xx(int doit) {
+ --num;
+ if (ptr != this) {
+- printf("FAIL\n%x != %x\n", ptr, this);
++ printf("FAIL\n%p != %p\n", ptr, (void*)this);
+ exit(1);
+ }
+ printf ("D is destructed.\n");
+Index: b/src/gcc/testsuite/g++.old-deja/g++.mike/p3708.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.mike/p3708.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.mike/p3708.C
+@@ -38,7 +38,7 @@ public:
+ virtual void xx(int doit) {
+ --num;
+ if (ptr != this)
+- printf("FAIL\n%x != %x\n", ptr, this);
++ printf("FAIL\n%p != %p\n", ptr, (void*)this);
+ printf ("C is destructed.\n");
+ B::xx (0);
+ if (doit) A::xx (1);
+Index: b/src/gcc/testsuite/g++.old-deja/g++.mike/p646.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.mike/p646.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.mike/p646.C
+@@ -35,20 +35,20 @@ int foo::si = 0;
+ foo::foo ()
+ {
+ si++;
+- printf ("new foo @ 0x%x; now %d foos\n", this, si);
++ printf ("new foo @ %p; now %d foos\n", (void*)this, si);
+ }
+
+ foo::foo (const foo &other)
+ {
+ si++;
+- printf ("another foo @ 0x%x; now %d foos\n", this, si);
++ printf ("another foo @ %p; now %d foos\n", (void*)this, si);
+ *this = other;
+ }
+
+ foo::~foo ()
+ {
+ si--;
+- printf ("deleted foo @ 0x%x; now %d foos\n", this, si);
++ printf ("deleted foo @ %p; now %d foos\n", (void*)this, si);
+ }
+
+ int
+Index: b/src/gcc/testsuite/g++.old-deja/g++.mike/p710.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.mike/p710.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.mike/p710.C
+@@ -30,7 +30,7 @@ class B
+ virtual ~B() {}
+ void operator delete(void*,size_t s)
+ {
+- printf("B::delete() %d\n",s);
++ printf("B::delete() %u\n",(unsigned int)s);
+ }
+ void operator delete(void*){}
+ };
+Index: b/src/gcc/testsuite/g++.old-deja/g++.mike/p789a.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.mike/p789a.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.mike/p789a.C
+@@ -13,10 +13,10 @@ struct foo
+ int x;
+ foo () {
+ x = count++;
+- printf("this %d = %x\n", x, (void *)this);
++ printf("this %d = %p\n", x, (void *)this);
+ }
+ virtual ~foo () {
+- printf("this %d = %x\n", x, (void *)this);
++ printf("this %d = %p\n", x, (void *)this);
+ --count;
+ }
+ };
+@@ -31,7 +31,7 @@ int main ()
+ {
+ for (int j = 0; j < 3; j++)
+ {
+- printf("&a[%d][%d] = %x\n", i, j, (void *)&array[i][j]);
++ printf("&a[%d][%d] = %p\n", i, j, (void *)&array[i][j]);
+ }
+ }
+ // The count should be nine, if not, fail the test.
+Index: b/src/gcc/testsuite/g++.old-deja/g++.mike/pmf2.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.mike/pmf2.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.mike/pmf2.C
+@@ -42,7 +42,7 @@ B_table b;
+ bar jar;
+
+ int main() {
+- printf("ptr to B_table=%x, ptr to A_table=%x\n",&b,(A_table*)&b);
++ printf("ptr to B_table=%p, ptr to A_table=%p\n",(void*)&b,(void*)(A_table*)&b);
+ B_table::B_ti_fn z = &B_table::func1;
+ int j = 1;
+ jar.call_fn_fn1(j,(void *)&z);
+Index: b/src/gcc/testsuite/g++.old-deja/g++.mike/temp.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.mike/temp.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.mike/temp.C
+@@ -7,11 +7,11 @@ class T {
+ public:
+ T() {
+ i = 1;
+- printf("T() at %x\n", this);
++ printf("T() at %p\n", (void*)this);
+ }
+ T(const T& o) {
+ i = o.i;
+- printf("T(const T&) at %x <-- %x\n", this, &o);
++ printf("T(const T&) at %p <-- %p\n", (void*)this, (void*)&o);
+ }
+ T operator +(const T& o) {
+ T r;
+@@ -21,7 +21,7 @@ public:
+ operator int () {
+ return i;
+ }
+- ~T() { printf("~T() at %x\n", this); }
++ ~T() { printf("~T() at %p\n", (void*)this); }
+ } s, b;
+
+ int foo() { return getenv("TEST") == 0; }
+Index: b/src/gcc/testsuite/g++.old-deja/g++.other/temporary1.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.other/temporary1.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.other/temporary1.C
+@@ -5,16 +5,16 @@ int c, d;
+ class Foo
+ {
+ public:
+- Foo() { printf("Foo() 0x%08lx\n", (__SIZE_TYPE__)this); ++c; }
+- Foo(Foo const &) { printf("Foo(Foo const &) 0x%08lx\n", (__SIZE_TYPE__)this); }
+- ~Foo() { printf("~Foo() 0x%08lx\n", (__SIZE_TYPE__)this); ++d; }
++ Foo() { printf("Foo() %p\n", (void*)this); ++c; }
++ Foo(Foo const &) { printf("Foo(Foo const &) %p\n", (void*)this); }
++ ~Foo() { printf("~Foo() %p\n", (void*)this); ++d; }
+ };
+
+ // Bar creates constructs a temporary Foo() as a default
+ class Bar
+ {
+ public:
+- Bar(Foo const & = Foo()) { printf("Bar(Foo const &) 0x%08lx\n", (__SIZE_TYPE__)this); }
++ Bar(Foo const & = Foo()) { printf("Bar(Foo const &) %p\n", (void*)this); }
+ };
+
+ void fakeRef(Bar *)
+Index: b/src/gcc/testsuite/g++.old-deja/g++.other/virtual8.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.other/virtual8.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.other/virtual8.C
+@@ -4,7 +4,7 @@ extern "C" int printf (const char*, ...)
+ struct A
+ {
+ virtual void f () {
+- printf ("%x\n", this);
++ printf ("%p\n", (void*)this);
+ }
+ };
+
+Index: b/src/gcc/testsuite/g++.old-deja/g++.pt/memtemp23.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.pt/memtemp23.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.pt/memtemp23.C
+@@ -13,7 +13,7 @@ struct S
+
+ template <class U>
+ void f(U u)
+- { printf ("In S::f(U)\nsizeof(U) == %d\n", sizeof(u)); }
++ { printf ("In S::f(U)\nsizeof(U) == %d\n", (int)sizeof(u)); }
+
+ int c[16];
+ };
+Index: b/src/gcc/testsuite/g++.old-deja/g++.pt/memtemp24.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.pt/memtemp24.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.pt/memtemp24.C
+@@ -13,7 +13,7 @@ struct S
+
+ template <class U>
+ void f(U u)
+- { printf ("In S::f(U)\nsizeof(U) == %d\n", sizeof(u)); }
++ { printf ("In S::f(U)\nsizeof(U) == %d\n", (int)sizeof(u)); }
+
+ int c[16];
+ };
+Index: b/src/gcc/testsuite/g++.old-deja/g++.pt/memtemp25.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.pt/memtemp25.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.pt/memtemp25.C
+@@ -6,7 +6,7 @@ template <class X>
+ struct S
+ {
+ template <class U>
+- void f(U u) { printf ("%d\n", sizeof (U)); }
++ void f(U u) { printf ("%d\n", (int)sizeof (U)); }
+
+ int i[4];
+ };
+Index: b/src/gcc/testsuite/g++.old-deja/g++.pt/memtemp26.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.pt/memtemp26.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.pt/memtemp26.C
+@@ -16,7 +16,7 @@ template <class X>
+ template <class U>
+ void S<X>::f(U u)
+ {
+- printf ("%d\n", sizeof (U));
++ printf ("%d\n", (int)sizeof (U));
+ }
+
+
+Index: b/src/gcc/testsuite/g++.old-deja/g++.pt/t39.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.pt/t39.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.pt/t39.C
+@@ -10,9 +10,9 @@ struct frob {
+
+ template <class T>
+ void frob<T>::print () {
+- printf ("this = %08x\n", this);
+- printf (" ptr = %08x\n", ptr);
+- printf (" values = %x %x %x ...\n", ptr[0], ptr[1], ptr[2]);
++ printf ("this = %p\n", (void*)this);
++ printf (" ptr = %p\n", (void*)ptr);
++ printf (" values = %x %x %x ...\n", (int)ptr[0], (int)ptr[1], (int)ptr[2]);
+ }
+
+ static int x[10];
+Index: b/src/gcc/testsuite/g++.old-deja/g++.robertl/eb17.C
+===================================================================
+--- a/src/gcc/testsuite/g++.old-deja/g++.robertl/eb17.C
++++ b/src/gcc/testsuite/g++.old-deja/g++.robertl/eb17.C
+@@ -44,15 +44,15 @@ int main()
+ A * a = new B;
+ B * b = dynamic_cast<B *>(a);
+
+- printf("%p\n",b); // (*2*)
++ printf("%p\n",(void*)b); // (*2*)
+ b->print();
+
+ a = b;
+- printf("%p\n",a);
++ printf("%p\n",(void*)a);
+ a->print();
+
+ a = a->clone();
+- printf("%p\n",a);
++ printf("%p\n",(void*)a);
+ a->print(); // (*1*)
+
+ return 0;
+Index: b/src/gcc/testsuite/gcc.dg/pch/inline-4.c
+===================================================================
+--- a/src/gcc/testsuite/gcc.dg/pch/inline-4.c
++++ b/src/gcc/testsuite/gcc.dg/pch/inline-4.c
+@@ -1,6 +1,6 @@
+ #include "inline-4.h"
+ extern int printf (const char *, ...);
+ int main(void) {
+- printf (getstring());
++ printf ("%s", getstring());
+ return 0;
+ }
diff --git a/debian/patches/testsuite-hardening-updates.diff b/debian/patches/testsuite-hardening-updates.diff
new file mode 100644
index 0000000..112a3b8
--- /dev/null
+++ b/debian/patches/testsuite-hardening-updates.diff
@@ -0,0 +1,84 @@
+# DP: Fix some gcc and g++ testcases to pass with hardening defaults
+
+---
+ src/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c | 2 +-
+ src/gcc/testsuite/g++.dg/asan/asan_test.C | 2 +-
+ src/gcc/testsuite/g++.dg/asan/interception-malloc-test-1.C | 2 +-
+ src/gcc/testsuite/g++.dg/fstack-protector-strong.C | 2 +-
+ src/gcc/testsuite/gcc.c-torture/execute/memset-1.c | 1 -
+ src/gcc/testsuite/gcc.c-torture/execute/memset-1.x | 5 +++++
+ src/gcc/testsuite/gcc.dg/fstack-protector-strong.c | 2 +-
+ src/gcc/testsuite/gcc.dg/stack-usage-1.c | 2 +-
+ src/gcc/testsuite/gcc.dg/superblock.c | 2 +-
+ src/gcc/testsuite/gcc.target/i386/sw-1.c | 2 +-
+ 11 files changed, 14 insertions(+), 10 deletions(-)
+
+--- a/src/gcc/testsuite/g++.dg/asan/asan_test.C
++++ b/src/gcc/testsuite/g++.dg/asan/asan_test.C
+@@ -2,7 +2,7 @@
+ // { dg-skip-if "" { *-*-* } { "*" } { "-O2" } }
+ // { dg-skip-if "" { *-*-* } { "-flto" } { "" } }
+ // { dg-additional-sources "asan_globals_test-wrapper.cc" }
+-// { dg-options "-std=c++11 -fsanitize=address -fno-builtin -Wall -Werror -Wno-alloc-size-larger-than -Wno-array-bounds -Wno-stringop-overflow -Wno-stringop-overread -g -DASAN_UAR=0 -DASAN_HAS_EXCEPTIONS=1 -DASAN_HAS_BLACKLIST=0 -DSANITIZER_USE_DEJAGNU_GTEST=1 -lasan -lpthread" }
++// { dg-options "-std=c++11 -fsanitize=address -fno-builtin -Wall -Werror -Wno-alloc-size-larger-than -Wno-array-bounds -Wno-stringop-overflow -Wno-stringop-overread -Wno-unused-result -g -DASAN_UAR=0 -DASAN_HAS_EXCEPTIONS=1 -DASAN_HAS_BLACKLIST=0 -DSANITIZER_USE_DEJAGNU_GTEST=1 -lasan -lpthread" }
+ // { dg-additional-options "-ldl" { target { ! *-*-freebsd* } } }
+ // { dg-additional-options "-DASAN_NEEDS_SEGV=1" { target { ! arm*-*-* } } }
+ // { dg-additional-options "-DASAN_LOW_MEMORY=1 -DASAN_NEEDS_SEGV=0" { target arm*-*-* } }
+--- a/src/gcc/testsuite/g++.dg/asan/interception-malloc-test-1.C
++++ b/src/gcc/testsuite/g++.dg/asan/interception-malloc-test-1.C
+@@ -1,7 +1,7 @@
+ // ASan interceptor can be accessed with __interceptor_ prefix.
+
+ // { dg-do run { target *-*-linux* *-*-freebsd* } }
+-// { dg-options "-fno-builtin-free" }
++// { dg-options "-fno-builtin-free -Wno-unused-result" }
+ // { dg-additional-options "-D__NO_INLINE__" { target { *-*-linux-gnu *-*-freebsd* } } }
+ // { dg-shouldfail "asan" }
+
+--- a/src/gcc/testsuite/gcc.c-torture/execute/memset-1.c
++++ b/src/gcc/testsuite/gcc.c-torture/execute/memset-1.c
+@@ -1,3 +1,5 @@
++/* { dg-prune-output ".*warning: memset used with constant zero length parameter.*" } */
++
+ /* Copyright (C) 2002 Free Software Foundation.
+
+ Test memset with various combinations of pointer alignments and lengths to
+--- a/src/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c
++++ b/src/gcc/testsuite/c-c++-common/asan/strncpy-overflow-1.c
+@@ -1,5 +1,5 @@
+ /* { dg-do run } */
+-/* { dg-options "-fno-builtin-malloc -fno-builtin-strncpy" } */
++/* { dg-options "-fno-builtin-malloc -fno-builtin-strncpy -U_FORTIFY_SOURCE" } */
+ /* { dg-additional-options "-D_FORTIFY_SOURCE=0 -gdwarf-3" { target *-*-darwin* } } */
+ /* { dg-shouldfail "asan" } */
+
+--- a/src/gcc/testsuite/gcc.dg/fstack-protector-strong.c
++++ b/src/gcc/testsuite/gcc.dg/fstack-protector-strong.c
+@@ -1,7 +1,7 @@
+ /* Test that stack protection is done on chosen functions. */
+
+ /* { dg-do compile { target i?86-*-* x86_64-*-* rs6000-*-* s390x-*-* } } */
+-/* { dg-options "-O2 -fstack-protector-strong" } */
++/* { dg-options "-O2 -fstack-protector-strong -U_FORTIFY_SOURCE" } */
+
+ /* This test checks the presence of __stack_chk_fail function in assembler.
+ * Compiler generates _stack_chk_fail_local (wrapper) calls instead for PIC.
+--- a/src/gcc/testsuite/g++.dg/fstack-protector-strong.C
++++ b/src/gcc/testsuite/g++.dg/fstack-protector-strong.C
+@@ -1,7 +1,7 @@
+ /* Test that stack protection is done on chosen functions. */
+
+ /* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+-/* { dg-options "-O2 -fstack-protector-strong" } */
++/* { dg-options "-O2 -fstack-protector-strong -U_FORTIFY_SOURCE" } */
+
+ /* This test checks the presence of __stack_chk_fail function in assembler.
+ * Compiler generates _stack_chk_fail_local (wrapper) calls instead for PIC.
+--- /dev/null
++++ b/src/gcc/testsuite/gcc.c-torture/execute/memset-1.x
+@@ -0,0 +1,5 @@
++# Implement "/* { dg-options "-U_FORITFY_SOURCE" } */", due to
++# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20567
++
++set additional_flags "-U_FORTIFY_SOURCE"
++return 0