commit:     c8c82bae8e84eed2f7692a228e6306febec0e7c5
Author:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 27 09:52:17 2022 +0000
Commit:     Alfredo Tupone <tupone <AT> gentoo <DOT> org>
CommitDate: Sun Feb 27 09:52:17 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c8c82bae

dev-ada/gprbuild: adding compatibility with gnat_2020

Package-Manager: Portage-3.0.30, Repoman-3.0.3
Signed-off-by: Alfredo Tupone <tupone <AT> gentoo.org>

 dev-ada/gprbuild/files/gprbuild-22.0.0-2020.patch | 47 +++++++++++++++++++++++
 dev-ada/gprbuild/gprbuild-22.0.0-r1.ebuild        | 16 +++++++-
 2 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/dev-ada/gprbuild/files/gprbuild-22.0.0-2020.patch 
b/dev-ada/gprbuild/files/gprbuild-22.0.0-2020.patch
new file mode 100644
index 000000000000..ba5c2f858de7
--- /dev/null
+++ b/dev-ada/gprbuild/files/gprbuild-22.0.0-2020.patch
@@ -0,0 +1,47 @@
+--- a/gpr/src/gpr_imports.c    2022-02-27 10:10:34.053638209 +0100
++++ b/gpr/src/gpr_imports.c    2022-02-27 10:12:03.898276758 +0100
+@@ -114,6 +114,44 @@
+ const char *__gnat_default_libgcc_subdir = "lib";
+ #endif
+ 
++#include <sys/types.h>
++#include <sys/stat.h>
++#include <limits.h>
++#include <unistd.h>
++
++  extern long long __gnat_file_time(char* name)
++  {
++    long long result;
++
++    if (name == NULL) {
++      return LLONG_MIN;
++    }
++    /* Number of seconds between <Jan 1st 1970> and <Jan 1st 2150>. */
++    static const long long ada_epoch_offset = (136 * 365 + 44 * 366) * 
86400LL;
++    struct stat sb;
++    if (stat(name, &sb) != 0) {
++      return LLONG_MIN;
++    }
++
++    //  return (sb.st_mtim.tv_sec - ada_epoch_offset) * 1E9
++    //  + sb.st_mtim.tv_nsec;
++    // with check overflow below
++
++    if (__builtin_ssubll_overflow(sb.st_mtim.tv_sec, ada_epoch_offset, 
&result)) {
++      return LLONG_MIN;
++    }
++
++    if (__builtin_smulll_overflow(result, 1E9, &result)) {
++      return LLONG_MIN;
++    }
++
++    if (__builtin_saddll_overflow(result, sb.st_mtim.tv_nsec, &result)) {
++      return LLONG_MIN;
++    }
++
++    return result;
++  }
++
+ #ifdef __cplusplus
+ }
+ #endif

diff --git a/dev-ada/gprbuild/gprbuild-22.0.0-r1.ebuild 
b/dev-ada/gprbuild/gprbuild-22.0.0-r1.ebuild
index 06eb16e01235..97506af95abf 100644
--- a/dev-ada/gprbuild/gprbuild-22.0.0-r1.ebuild
+++ b/dev-ada/gprbuild/gprbuild-22.0.0-r1.ebuild
@@ -1,9 +1,9 @@
-# Copyright 1999-2021 Gentoo Authors
+# Copyright 1999-2022 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=7
 
-ADA_COMPAT=( gnat_2021 )
+ADA_COMPAT=( gnat_202{0,1} )
 
 inherit ada multiprocessing
 
@@ -53,6 +53,18 @@ src_prepare() {
                -e "s:@GNATBIND@:${GNATBIND}:g" \
                src/gprlib.adb \
                || die
+       if use ada_target_gnat_2020; then
+               sed -i \
+                       -e "s:Append_Vector:Append:g" \
+                       -e "s:Insert_Vector:Insert:g" \
+                       src/gprbuild-link.adb \
+                       src/gprinstall-install.adb \
+                       src/gprlib.adb \
+                       src/gprlib-build_shared_lib.adb \
+                       src/gprbind.adb \
+                       || die
+               eapply "${FILESDIR}"/${P}-2020.patch
+       fi
 }
 
 bin_progs="gprbuild gprconfig gprclean gprinstall gprname gprls"

Reply via email to