Bug#1055711: Bug#1057469: gcc-13: Please build gcc with -mbranch-protection=standard to fix PAC/BTI support on arm64

2024-07-04 Thread Emanuele Rocca
On 2024-07-01 03:12, Emanuele Rocca wrote:
> I haven't tested it on cross-builds of the native compiler as that
> currently fails due to unsatisfied dependencies in sid. That case
> should work fine too though.

Double-checked today, cross-builds of the native compiler work as well
both with and without the flag.

Without -mbranch-protection=standard:

  DEB_BUILD_MAINT_OPTIONS=hardening=-branch DEB_BUILD_OPTIONS=nolang=m2 sbuild 
--host=arm64

With -mbranch-protection=standard:

  DEB_BUILD_OPTIONS=nolang=m2 sbuild --host=arm64

Note that sbuild whitelists a set of variables that are passed into the
schroot and all others are dropped, so you'll need the following in
~/.sbuildrc for DEB_BUILD_MAINT_OPTIONS to go through:

 $environment_filter = [Dpkg::BuildInfo::get_build_env_allowed(), 
'DEB_BUILD_MAINT_OPTIONS'];

Alternatively, one can also just take the easy route and pass
hardening=-branch in DEB_BUILD_OPTIONS, which is whitelisted by default:

 DEB_BUILD_OPTIONS='nolang=m2 hardening=-branch' sbuild --host=arm64



Bug#1072071: gcc-13: Please add libatomic for 32-bit SPARC for Ada

2024-07-04 Thread Nicolas Boulenguez
Source: gcc-13
Followup-For: Bug #1072071

Hello.

The attached suggestions are just ideas, not real commits. They are
hand-written and not tested at all, so probably contain typos.
Morever, they were written in a gcc-14 source tree.

For the context, commit e08cd8a2 disables Ada on sparc (bug #1072328).

If Adrian can check that 0001, 0002 and 0003 fix #1072071,
then I suggest to merge them into a single commit,
else
  if Matthias confirms that := was not deliberate
  then I suggest to apply 0001.
From: Nicolas Boulenguez 
Subject: [PATCH 1/3] probably fix a typo in e08cd8a2

--- a/debian/control
+++ b/debian/control
@@ -15,11 +15,11 @@ Build-Depends: debhelper (>= 11), dpkg-dev (>= 1.17.14), g++-multilib [amd64 i38
   gperf, bison, flex,
   gettext, nvptx-tools [amd64 arm64 ppc64el], amdgcn-tools-18 [amd64],
   texinfo, locales-all, sharutils,
-  procps, gnat-13:native [!sparc !loong64], g++-13:native [!loong64], gnat-14:native [loong64], g++-14:native [loong64], netbase, gdc-13:native [!arc !ia64 !m68k !sh4 !s390 !sparc64 !alpha !hurd-alpha !hurd-amd64 !hurd-i386], python3:any, cargo [!hppa !ia64 !m68k !sh4 !alpha !hurd-alpha],
+  procps, gnat-13:native [!arc !ia64 !sh3 !sh3eb !sh4eb !sparc !loong64], g++-13:native [!loong64], gnat-14:native [loong64], g++-14:native [loong64], netbase, gdc-13:native [!arc !ia64 !m68k !sh4 !s390 !sparc64 !alpha !hurd-alpha !hurd-amd64 !hurd-i386], python3:any, cargo [!hppa !ia64 !m68k !sh4 !alpha !hurd-alpha],
   libisl-dev (>= 0.20), libmpc-dev (>= 1.0), libmpfr-dev (>= 3.0.0-9~), libgmp-dev (>= 2:5.0.1~), lib32z1-dev [amd64], lib64z1-dev [i386], unzip ,
   dejagnu , coreutils, chrpath, lsb-release, quilt, time,
   pkg-config, libgc-dev,
-  g++-14-for-host , gobjc-14-for-host [!avr] , gfortran-14-for-host , gdc-14-for-host [!arc !ia64 !m68k !sh4 !s390 !sparc64 !alpha !hurd-alpha !hurd-amd64 !hurd-i386] , gccgo-14-for-host [!arc !avr !hppa !loong64 !m68k !sh4] , gnat-14-for-host [!sparc] , gm2-14-for-host [!powerpc !ppc64 !sh4] ,
+  g++-14-for-host , gobjc-14-for-host [!avr] , gfortran-14-for-host , gdc-14-for-host [!arc !ia64 !m68k !sh4 !s390 !sparc64 !alpha !hurd-alpha !hurd-amd64 !hurd-i386] , gccgo-14-for-host [!arc !avr !hppa !loong64 !m68k !sh4] , gnat-14-for-host [!arc !ia64 !sh3 !sh3eb !sh4eb !sparc] , gm2-14-for-host [!powerpc !ppc64 !sh4] ,
 Build-Depends-Indep: doxygen , graphviz , ghostscript , texlive-latex-base , xsltproc , libxml2-utils , docbook-xsl-ns ,
 Homepage: http://gcc.gnu.org/
 Vcs-Browser: https://salsa.debian.org/toolchain-team/gcc
--- a/debian/rules.defs
+++ b/debian/rules.defs
@@ -872,7 +872,7 @@ ifeq (,$(filter $(DEB_STAGE),stage1 stage2))
 # Ada 
 ada_no_cpus	:= arc ia64 sh3 sh3eb sh4eb
 #ada_no_cpus	+= armel # See Debian #1061370
-ada_no_cpus	:= sparc # See Debian #1072328
+ada_no_cpus	+= sparc # See Debian #1072328
 ada_no_systems	:= 
 ada_no_cross	:= no
 ada_no_snap	:= no
From: Nicolas Boulenguez 
Subject: [PATCH 2/3] untested fix for #1072071

--- a/debian/patches/ada-armel-libatomic.diff
+++ b/debian/patches/ada-armel-libatomic.diff
@@ -1,11 +1,14 @@
-Description: link libgnarl with libatomic on armel
+Description: link libgnarl with libatomic on armel and sparc
  On other architectures, the library is ignored thanks to --as-needed.
  .
- Seen with 14-20240429-1:
+ Seen with 14-20240429-1 on armel:
  cd rts; [bla]/./gcc/xgcc [bla] -shared [bla] -o libgnarl-14.so [bla]
  /usr/bin/arm-linux-gnueabi-ld: libgnat-14.so: undefined reference to `__atomic_compare_exchange_8'
  /usr/bin/arm-linux-gnueabi-ld: libgnat-14.so: undefined reference to `__atomic_load_8'
  .
+ Seen with 13.2.0-25 on sparc:
+ checking fp.h usability... /usr/sparc-linux-gnu/bin/ld: libgnat-13.so: undefined reference to `__atomic_compare_exchange_8'
+ .
  Libatomic becomes an artificial dependency for Ada in Makefile.def,
  so a better solution is welcome.
  .
@@ -22,6 +25,7 @@ Description: link libgnarl with libatomic on armel
  (ada-gnattools-cross.diff adds checking options to LDFLAGS,
   then adds LDFLAGS to the command line).
 Bug-Debian: https://bugs.debian.org/861734
+Bug-Debian: https://bugs.debian.org/1072071
 Author: Matthias Klose 
 Author: Nicolas Boulenguez 
 
@@ -35,6 +39,14 @@ Author: Nicolas Boulenguez 
LIBGNAT_TARGET_PAIRS = \
a-intnam.adsFrom: Nicolas Boulenguez 
Subject: [PATCH 3/3] revert e08cd8a2

--- a/debian/control
+++ b/debian/control
@@ -15,11 +15,11 @@ Build-Depends: debhelper (>= 11), dpkg-dev (>= 1.17.14), g++-multilib [amd64 i38
   gperf, bison, flex,
   gettext, nvptx-tools [amd64 arm64 ppc64el], amdgcn-tools-18 [amd64],
   texinfo, locales-all, sharutils,
-  procps, gnat-13:native [!arc !ia64 !sh3 !sh3eb !sh4eb !sparc !loong64], g++-13:native [!loong64], gnat-14:native [loong64], g++-14:native [loong64], netbase, gdc-13:native [!arc !ia64 !m68k !sh4 !s390 !sparc64 !alpha !hurd-alpha !hurd-amd64 !hurd-i386], python3:any, cargo [!hppa !ia64 !m68k !sh4 !alpha !hurd-alpha],
+  procps, gnat-13:native [!arc !ia64 !sh3 !

Bug#1074577: gnat ftbfs with glibc from experimental

2024-07-04 Thread Nicolas Boulenguez
Source: gcc-13
Followup-For: Bug #1074577

Matthias Klose:
> Simon Chopin came up with a conditional to work with both variants
[before and after glibc introduces __USE_TIME64_REDIRECTS]
> #if defined(__USE_TIME64_REDIRECTS) || (__TIMESIZE == 32 && __USE_TIME_BITS64)

I have forwarded this upstream as version 11.

This changes the libgnat-13 sources (System.OS_Constants).

Most Ada packages will require a bin-NMU after you upload gcc-13,
ideally before people start filling FTBS bug reports.

I take the opportunity to apply some postponed changes.
I do not commit them because I have tested no build,
but the only changes since the (tested) version 10 are
 * the line above, tested by Simon Chopin in Ubuntu
 * unapplying small style changes reviewed by upstream
From: Nicolas Boulenguez 
Subject: [PATCH] Ada: update patches for PR114065 (time_64) to v11

The fix 2bacf86d for #1074577 by Simon Chopin at
https://bugs.launchpad.net/ubuntu/+source/gcc-13/+bug/2071605 requires
a rebuild of all Ada libraries, so we might as well
* update all patches to version 11
* apply the parts fixing bugs, but not the style suggestions
---
 ...ersions-with-C-struct-timeval-from-GN.diff | 143 -
 ...ersions-with-C-struct-timespec-from-A.diff | 167 -
 ...ersions-with-C-time_t-from-System.OS_.diff |  79 ---
 ...imeval-and-timespec-definitions-and-c.diff | 604 ++
 ...-unneeded-x32-variant-of-System.Linux.diff | 146 -
 ...ed-posix2008-variant-of-System.Parame.diff | 229 ---
 ...ed-darwin-solaris-x32-variants-of-Sys.diff | 472 --
 ...sleep-from-System.OS_Primitives.Timed.diff |  74 ---
 ...its-time-functions-from-GNU-libc-when.diff |  74 ++-
 debian/rules.patch|   7 -
 10 files changed, 520 insertions(+), 1475 deletions(-)
 delete mode 100644 debian/patches/0001-Ada-remove-conversions-with-C-struct-timeval-from-GN.diff
 delete mode 100644 debian/patches/0002-Ada-remove-conversions-with-C-struct-timespec-from-A.diff
 delete mode 100644 debian/patches/0003-Ada-remove-conversions-with-C-time_t-from-System.OS_.diff
 delete mode 100644 debian/patches/0005-Ada-drop-unneeded-x32-variant-of-System.Linux.diff
 delete mode 100644 debian/patches/0006-Ada-drop-unneeded-posix2008-variant-of-System.Parame.diff
 delete mode 100644 debian/patches/0007-Ada-drop-unneeded-darwin-solaris-x32-variants-of-Sys.diff
 delete mode 100644 debian/patches/0008-Ada-import-nanosleep-from-System.OS_Primitives.Timed.diff

diff --git a/debian/patches/0001-Ada-remove-conversions-with-C-struct-timeval-from-GN.diff b/debian/patches/0001-Ada-remove-conversions-with-C-struct-timeval-from-GN.diff
deleted file mode 100644
index d57d7ec7..
--- a/debian/patches/0001-Ada-remove-conversions-with-C-struct-timeval-from-GN.diff
+++ /dev/null
@@ -1,143 +0,0 @@
-From bedb7553c420da59938eacb115fd9384e54ceae0 Mon Sep 17 00:00:00 2001
-From: Nicolas Boulenguez 
-Date: Fri, 5 Apr 2024 16:51:54 +0200
-Subject: [PATCH 1/9] Ada: remove conversions with C struct timeval from
- GNAT.Calendar
-

- gcc/ada/doc/gnat_rm/the_gnat_library.rst |  2 -
- gcc/ada/libgnat/g-calend.adb | 58 
- gcc/ada/libgnat/g-calend.ads | 18 
- 3 files changed, 78 deletions(-)
-
-diff --git a/src/gcc/ada/doc/gnat_rm/the_gnat_library.rst b/src/gcc/ada/doc/gnat_rm/the_gnat_library.rst
-index 3aae70a..bcec49f 100644
 a/src/gcc/ada/doc/gnat_rm/the_gnat_library.rst
-+++ b/src/gcc/ada/doc/gnat_rm/the_gnat_library.rst
-@@ -674,8 +674,6 @@ Machine-specific implementations are available in some cases.
- 
- Extends the facilities provided by ``Ada.Calendar`` to include handling
- of days of the week, an extended ``Split`` and ``Time_Of`` capability.
--Also provides conversion of ``Ada.Calendar.Time`` values to and from the
--C ``timeval`` format.
- 
- .. _`GNAT.Calendar.Time_IO_(g-catiio.ads)`:
- 
-diff --git a/src/gcc/ada/libgnat/g-calend.adb b/src/gcc/ada/libgnat/g-calend.adb
-index 0a98eb2..e0d34f5 100644
 a/src/gcc/ada/libgnat/g-calend.adb
-+++ b/src/gcc/ada/libgnat/g-calend.adb
-@@ -29,11 +29,8 @@
- --  --
- --
- 
--with Interfaces.C.Extensions;
--
- package body GNAT.Calendar is
-use Ada.Calendar;
--   use Interfaces;
- 
--
--- Day_In_Year --
-@@ -328,61 +325,6 @@ package body GNAT.Calendar is
-Time_Zone=> 0);
-end Time_Of_At_Locale;
- 
--   -
--   -- To_Duration --
--   -
--
--   function To_Duration (T : not null access timeval) return Duration is
--
--  procedure timeval_to_duration
--(T: not null access timeval;
-- sec  : not null access C.Extensions.long_long;
-- usec : not null access C.long);
--  pragma Import (C, timeval_to_duration, "__gnat_timeval_to_duration");
--
--  Micro : constant := 10**6;
--  sec