Hi!

On Sun, 2021-01-24 at 23:36:52 +0300, Alexey Brodkin wrote:
> Package: dpkg
> Version: 1.19.7ubuntu3-1~202101232134~ubuntu20.04.1
> Severity: wishlist
> Tags: patch

> ARC architecture seem to match requirements for being added to the dpkg
> (https://wiki.debian.org/Teams/Dpkg/FAQ#Q._Can_we_add_support_for_new_dpkg_architectures.3F):
> 
>  * GNU triplet is there since 2013,
>    see: 
> https://git.savannah.gnu.org/cgit/config.git/commit/?id=986360de6e412cbed27dbe2dbfb64ddbd18e7370
>  * Binutils, GCC & uClibc support ARC for many years now,
>    glibc 2.32 finally gained ARC support, see 
> https://lists.gnu.org/archive/html/info-gnu/2020-08/msg00002.html 

Sorry, didn't reply up to now due to the freeze, this not looking
ready yet (as glibc is not even in Debian), but mostly because it
slipped my mind, but that kind of blocks progress on your side.
So let's see. :)

Or, were you looking to get this included for bullseye? (I think this
would not qualify, but, I think we might have done exceptions in such
cases in the past.)

Is the ABI fully stabilized now?

> >From 96523e18473b56743bf2f7d308c2d786f337e52e Mon Sep 17 00:00:00 2001
> From: Alexey Brodkin <abrod...@synopsys.com>
> Date: Sun, 24 Jan 2021 00:34:52 +0300
> Subject: [PATCH] Add ARC architecture

> diff --git a/data/cputable b/data/cputable
> index 9f2a8e0e4..114a66ecb 100644
> --- a/data/cputable
> +++ b/data/cputable
> @@ -20,6 +20,8 @@ i386                i686            (i[34567]86|pentium)    
> 32      little
>  ia64         ia64            ia64                    64      little
>  alpha                alpha           alpha.*                 64      little
>  amd64                x86_64          (amd64|x86_64)          64      little
> +arc          arc             arc.*                   32      little
> +arceb                arc             arceb.*                 32      big
>  armeb                armeb           arm.*b                  32      big
>  arm          arm             arm.*                   32      little
>  arm64                aarch64         aarch64                 64      little

This looked incorrect, as it ends up not being a bijective relation,
so the lines need to be swapped. The problem is that the comments do
not explain this nor the test suite checks. So I improved both with the
attached patches, which I'll commit into master once I open it up for
1.21.x.

Also just to make sure, the GNU triplets are:

  arc-linux-gnu
  arceb-linux-gnu

No ABI modifiers (stuff like “eabi”) for the libc part (“gnu“) right?

Thanks,
Guillem
From f5cae4f8fc4ef67ec5e26dffeb3b3c540949f554 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guil...@debian.org>
Date: Mon, 25 Jan 2021 05:37:06 +0100
Subject: [PATCH] test: Add unit tests for architecture bijective mapping
 property

The architectures need to have the bijective property when converting
back and forth from the Debian arch name to the GNU triplet. Enforce
this in the test suite to make it easier to guarantee this when adding
new architectures to the tables.
---
 scripts/t/Dpkg_Arch.t | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/scripts/t/Dpkg_Arch.t b/scripts/t/Dpkg_Arch.t
index a3a9e6fee..4f26778aa 100644
--- a/scripts/t/Dpkg_Arch.t
+++ b/scripts/t/Dpkg_Arch.t
@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 16836;
+use Test::More tests => 17914;
 
 use_ok('Dpkg::Arch', qw(debarch_to_debtuple debarch_to_multiarch
                         debarch_eq debarch_is debarch_is_wildcard
@@ -24,9 +24,12 @@ use_ok('Dpkg::Arch', qw(debarch_to_debtuple debarch_to_multiarch
                         debarch_to_abiattrs debarch_to_cpubits
                         debarch_list_parse
                         debtuple_to_debarch gnutriplet_to_debarch
+                        debtuple_to_gnutriplet gnutriplet_to_debtuple
                         get_host_gnu_type
                         get_valid_arches));
 
+my @valid_arches = get_valid_arches();
+
 sub get_valid_wildcards
 {
     my %wildcards;
@@ -37,7 +40,7 @@ sub get_valid_wildcards
         any-any-any-any
     );
 
-    foreach my $archname (get_valid_arches()) {
+    foreach my $archname (@valid_arches) {
         my @tuple = debarch_to_debtuple($archname);
 
         my @wildcards_arch = (
@@ -174,7 +177,17 @@ is(gnutriplet_to_debarch(undef), undef, 'undef gnutriplet');
 is(gnutriplet_to_debarch('unknown-unknown-unknown'), undef, 'unknown gnutriplet');
 is(gnutriplet_to_debarch('x86_64-linux-gnu'), 'amd64', 'known gnutriplet');
 
-is(scalar get_valid_arches(), 539, 'expected amount of known architectures');
+foreach my $arch (@valid_arches) {
+    my @tuple = debarch_to_debtuple($arch);
+    is(debtuple_to_debarch(@tuple), $arch,
+       "bijective arch $arch to tuple @tuple");
+
+    my $triplet = debtuple_to_gnutriplet(@tuple);
+    is_deeply([ gnutriplet_to_debtuple($triplet) ], \@tuple,
+              "bijective triplet $triplet to tuple @tuple");
+}
+
+is(scalar @valid_arches, 539, 'expected amount of known architectures');
 
 {
     local $ENV{CC} = 'false';
-- 
2.30.1

From 06cf2888850c63c59bf75820d2b69159684e6ba3 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guil...@debian.org>
Date: Mon, 25 Jan 2021 05:41:00 +0100
Subject: [PATCH] arch: Clarify that the regex columns need to be ordered to
 match first

The entries are used in a first match order, so the regexes need to
be listed from most specific to less specific.
---
 data/cputable | 3 ++-
 data/ostable  | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/data/cputable b/data/cputable
index 9f2a8e0e4..505641659 100644
--- a/data/cputable
+++ b/data/cputable
@@ -11,7 +11,8 @@
 # - Column 2 is the GNU name for the CPU, used to output build, host and
 #   target variables in ‘dpkg-architecture’.
 # - Column 3 is an extended regular expression used to match against the
-#   CPU part of the output of the GNU config.guess script.
+#   CPU part of the output of the GNU config.guess script. The order of
+#   this column is important as it is used in a first match basis.
 # - Column 4 is the size (in bits) of pointers.
 # - Column 5 is the endianness (byte ordering in numbers).
 #
diff --git a/data/ostable b/data/ostable
index 99c1f889d..055363bb9 100644
--- a/data/ostable
+++ b/data/ostable
@@ -11,7 +11,8 @@
 # - Column 2 is the GNU name for the system, used to output build, host and
 #   target variables in ‘dpkg-architecture’.
 # - Column 3 is an extended regular expression used to match against the
-#   system part of the output of the GNU config.guess script.
+#   system part of the output of the GNU config.guess script. The order of
+#   this column is important as it is used in a first match basis.
 #
 # <Debian name>		<GNU name>		<config.guess regex>
 eabi-uclibc-linux	linux-uclibceabi	linux[^-]*-uclibceabi
-- 
2.30.1

Reply via email to