[Reproducible-commits] [dpkg] 21/54: Dpkg::Arch: Make the host gnu type retrieval more compiler agnostic

Mattia Rizzolo mattia at debian.org
Fri Jan 15 18:54:00 UTC 2016


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

mattia pushed a commit to branch pu/reproducible_builds
in repository dpkg.

commit db5de206928c9eb6d686b83e64d31fd1cfc40915
Author: Guillem Jover <guillem at debian.org>
Date:   Mon Nov 2 04:44:05 2015 +0100

    Dpkg::Arch: Make the host gnu type retrieval more compiler agnostic
    
    Rename get_gcc_host_gnu_type() to get_host_gnu_type(), and use a hash to
    store the values per compiler name, so that we can keep track of different
    output depending on the compiler selected.
    
    Update the warning messages to not assume that CC is pointing to gcc.
---
 debian/changelog             |  2 ++
 scripts/Dpkg/Arch.pm         | 39 +++++++++++++++++++++------------------
 scripts/dpkg-architecture.pl | 10 +++++-----
 3 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 2533089..c41348c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -13,6 +13,8 @@ dpkg (1.18.4) UNRELEASED; urgency=low
     block, to unify the code an allow a future switch into a shared library.
   * Perform any necessary cleanups on normal exit from dpkg-divert --add and
     --remove commands.
+  * Make dpkg-architecture warning on non-matching GNU system type compiler
+    agnostic.
   * Build system:
     - Set PERL5LIB globally for the test suite to the local modules directory,
       to avoid using the system modules. Regression introduced in dpkg 1.17.8.
diff --git a/scripts/Dpkg/Arch.pm b/scripts/Dpkg/Arch.pm
index 1c0d468..373d0b1 100644
--- a/scripts/Dpkg/Arch.pm
+++ b/scripts/Dpkg/Arch.pm
@@ -38,7 +38,7 @@ our @EXPORT_OK = qw(
     get_raw_host_arch
     get_build_arch
     get_host_arch
-    get_gcc_host_gnu_type
+    get_host_gnu_type
     get_valid_arches
     debarch_eq
     debarch_is
@@ -115,27 +115,30 @@ sub get_build_arch()
 }
 
 {
-    my $gcc_host_gnu_type;
+    my %cc_host_gnu_type;
 
-    sub get_gcc_host_gnu_type()
+    sub get_host_gnu_type()
     {
-	return $gcc_host_gnu_type if defined $gcc_host_gnu_type;
+        my $CC = $ENV{CC} || 'gcc';
 
-	$gcc_host_gnu_type = qx(\${CC:-gcc} -dumpmachine);
+        return $cc_host_gnu_type{$CC} if defined $cc_host_gnu_type{$CC};
+
+        $cc_host_gnu_type{$CC} = qx($CC -dumpmachine);
 	if ($? >> 8) {
-	    $gcc_host_gnu_type = '';
+            $cc_host_gnu_type{$CC} = '';
 	} else {
-	    chomp $gcc_host_gnu_type;
+            chomp $cc_host_gnu_type{$CC};
 	}
 
-	return $gcc_host_gnu_type;
+        return $cc_host_gnu_type{$CC};
     }
 
     sub set_host_gnu_type
     {
         my ($host_gnu_type) = @_;
+        my $CC = $ENV{CC} || 'gcc';
 
-        $gcc_host_gnu_type = $host_gnu_type;
+        $cc_host_gnu_type{$CC} = $host_gnu_type;
     }
 }
 
@@ -152,23 +155,23 @@ sub get_raw_host_arch()
 
     return $host_arch if defined $host_arch;
 
-    $gcc_host_gnu_type = get_gcc_host_gnu_type();
+    my $host_gnu_type = get_host_gnu_type();
 
-    if ($gcc_host_gnu_type eq '') {
-        warning(g_("couldn't determine gcc system type, falling back to " .
+    if ($host_gnu_type eq '') {
+        warning(g_('cannot determine CC system type, falling back to ' .
                    'default (native compilation)'));
     } else {
-        my (@host_archtriplet) = gnutriplet_to_debtriplet($gcc_host_gnu_type);
+        my (@host_archtriplet) = gnutriplet_to_debtriplet($host_gnu_type);
         $host_arch = debtriplet_to_debarch(@host_archtriplet);
 
         if (defined $host_arch) {
-            $gcc_host_gnu_type = debtriplet_to_gnutriplet(@host_archtriplet);
+            $host_gnu_type = debtriplet_to_gnutriplet(@host_archtriplet);
         } else {
-            warning(g_('unknown gcc system type %s, falling back to ' .
-                       'default (native compilation)'), $gcc_host_gnu_type);
-            $gcc_host_gnu_type = '';
+            warning(g_('unknown CC system type %s, falling back to ' .
+                       'default (native compilation)'), $host_gnu_type);
+            $host_gnu_type = '';
         }
-        set_host_gnu_type($gcc_host_gnu_type);
+        set_host_gnu_type($host_gnu_type);
     }
 
     if (!defined($host_arch)) {
diff --git a/scripts/dpkg-architecture.pl b/scripts/dpkg-architecture.pl
index 1c00c37..64188ea 100755
--- a/scripts/dpkg-architecture.pl
+++ b/scripts/dpkg-architecture.pl
@@ -26,7 +26,7 @@ use Dpkg ();
 use Dpkg::Gettext;
 use Dpkg::Getopt;
 use Dpkg::ErrorHandling;
-use Dpkg::Arch qw(get_raw_build_arch get_raw_host_arch get_gcc_host_gnu_type
+use Dpkg::Arch qw(get_raw_build_arch get_raw_host_arch get_host_gnu_type
                   debarch_to_cpuattrs
                   get_valid_arches debarch_eq debarch_is debarch_to_debtriplet
                   debarch_to_gnutriplet gnutriplet_to_debarch
@@ -280,12 +280,12 @@ if (action_needs(DEB_HOST | DEB_GNU_INFO)) {
     }
     ($v{DEB_HOST_GNU_CPU}, $v{DEB_HOST_GNU_SYSTEM}) = split(/-/, $v{DEB_HOST_GNU_TYPE}, 2);
 
-    my $gcc = get_gcc_host_gnu_type();
+    my $host_gnu_type = get_host_gnu_type();
 
-    warning(g_('specified GNU system type %s does not match gcc system ' .
+    warning(g_('specified GNU system type %s does not match CC system ' .
                'type %s, try setting a correct CC environment variable'),
-            $v{DEB_HOST_GNU_TYPE}, $gcc)
-        if ($gcc ne '') && ($gcc ne $v{DEB_HOST_GNU_TYPE});
+            $v{DEB_HOST_GNU_TYPE}, $host_gnu_type)
+        if ($host_gnu_type ne '') && ($host_gnu_type ne $v{DEB_HOST_GNU_TYPE});
 }
 
 #

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



More information about the Reproducible-commits mailing list