NetBSD Problem Report #48215

From ryo_on@yk.rim.or.jp  Mon Sep 16 03:57:28 2013
Return-Path: <ryo_on@yk.rim.or.jp>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id D76F371189
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 16 Sep 2013 03:57:27 +0000 (UTC)
Message-Id: <20130916035725.7D57A20270031@mail.SiriusCloud.jp>
Date: Mon, 16 Sep 2013 12:57:25 +0900 (JST)
From: ryoon@NetBSD.org
Reply-To: ryoon@NetBSD.org
To: gnats-bugs@gnats.NetBSD.org
Subject: pkg_add fails on recent NetBSD/evbearmv6hf-el current
X-Send-Pr-Version: 3.95

>Number:         48215
>Notify-List:    bsiegert@NetBSD.org
>Category:       port-arm
>Synopsis:       pkg_add fails on recent NetBSD/evbearmv6hf-el current
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    port-arm-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Sep 16 04:00:00 +0000 2013
>Last-Modified:  Mon Oct 07 04:25:01 +0000 2013
>Originator:     Ryo ONODERA
>Release:        NetBSD 6.99.23
>Organization:

>Environment:


System: NetBSD tellurium.elements.tetera.org 6.99.23 NetBSD 6.99.23 (DTRACE) #4: Tue Sep 3 09:25:35 JST 2013 ryo_on@tellurium.elements.tetera.org:/usr/obj/amd64/sys/arch/amd64/compile/DTRACE amd64
Architecture: x86_64
Machine: amd64
>Description:
After http://mail-index.netbsd.org/source-changes/2013/09/14/msg047577.html ,
pkg_add fails with the following error.

$ pkg_add /usr/pkgbin/All/digest-20121220.tgz
pkg_add: Warning: package `digest-20121220' was built for a platform:
pkg_add: NetBSD/earmv6hf 6.99.23 (pkg) vs. NetBSD/earm 6.99.23 (this host)
pkg_add: 1 package addition failed

$ make -V MACHINE_ARCH
earmv6hf

$ uname -p
earmv6hf

I cannot find origin of "earm", sadly.

>How-To-Repeat:
Do "make install" in any package directory, for example,
pkgsrc/pkgtools/digest.
Or make package and pkg_add.

>Fix:

I have no idea.

>Release-Note:

>Audit-Trail:
From: Matt Thomas <matt@3am-software.com>
To: gnats-bugs@NetBSD.org,
 ryoon@NetBSD.org
Cc: port-arm-maintainer@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el current
Date: Sun, 15 Sep 2013 22:45:41 -0700

 On Sep 15, 2013, at 9:00 PM, ryoon@NetBSD.org wrote:

 >> Number:         48215
 >> Category:       port-arm
 >> Synopsis:       pkg_add fails on recent NetBSD/evbearmv6hf-el current
 >> Confidential:   no
 >> Severity:       serious
 >> Priority:       medium
 >> Responsible:    port-arm-maintainer
 >> State:          open
 >> Class:          sw-bug
 >> Submitter-Id:   net
 >> Arrival-Date:   Mon Sep 16 04:00:00 +0000 2013
 >> Originator:     Ryo ONODERA
 >> Release:        NetBSD 6.99.23
 >> Organization:
 > =09
 >> Environment:
 > =09
 > =09
 > System: NetBSD tellurium.elements.tetera.org 6.99.23 NetBSD 6.99.23 =
 (DTRACE) #4: Tue Sep 3 09:25:35 JST 2013 =
 ryo_on@tellurium.elements.tetera.org:/usr/obj/amd64/sys/arch/amd64/compile=
 /DTRACE amd64
 > Architecture: x86_64
 > Machine: amd64
 >> Description:
 > After =
 http://mail-index.netbsd.org/source-changes/2013/09/14/msg047577.html ,
 > pkg_add fails with the following error.
 >=20
 > $ pkg_add /usr/pkgbin/All/digest-20121220.tgz
 > pkg_add: Warning: package `digest-20121220' was built for a platform:
 > pkg_add: NetBSD/earmv6hf 6.99.23 (pkg) vs. NetBSD/earm 6.99.23 (this =
 host)
 > pkg_add: 1 package addition failed
 >=20
 > $ make -V MACHINE_ARCH
 > earmv6hf
 >=20
 > $ uname -p
 > earmv6hf
 >=20
 > I cannot find origin of "earm", sadly.
 > =09
 >> How-To-Repeat:
 > Do "make install" in any package directory, for example,
 > pkgsrc/pkgtools/digest.
 > Or make package and pkg_add.
 > =09
 >> Fix:
 > =09
 > I have no idea.
 >=20
 >> Unformatted:

 That seems to be a pkg tools program, not an arm problem.=

From: Ryo ONODERA <ryo_on@yk.rim.or.jp>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el
 current
Date: Mon, 16 Sep 2013 14:53:43 +0900 (JST)

 Hi,

 From: Matt Thomas <matt@3am-software.com>, Date: Sun, 15 Sep 2013 22:45:41 -0700

 > That seems to be a pkg tools program, not an arm problem.

 Thank you.
 I will investigate pkg_install deeper.

 --
 Ryo ONODERA // ryo_on@yk.rim.or.jp
 PGP fingerprint = 82A2 DC91 76E0 A10A 8ABB  FD1B F404 27FA C7D1 15F3

From: Nick Hudson <skrll@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: Ryo ONODERA <ryo_on@yk.rim.or.jp>, port-arm-maintainer@netbsd.org, 
 gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, ryoon@NetBSD.org
Subject: Re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el
 current
Date: Mon, 16 Sep 2013 09:09:23 +0100

 This is a multi-part message in MIME format.
 --------------040706010803020104010603
 Content-Type: text/plain; charset=ISO-8859-1; format=flowed
 Content-Transfer-Encoding: 7bit

 On 09/16/13 06:55, Ryo ONODERA wrote:
 > The following reply was made to PR port-arm/48215; it has been noted by GNATS.
 >
 > From: Ryo ONODERA <ryo_on@yk.rim.or.jp>
 > To: gnats-bugs@netbsd.org
 > Cc:
 > Subject: Re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el
 >   current
 > Date: Mon, 16 Sep 2013 14:53:43 +0900 (JST)
 >
 >   Hi,
 >   
 >   From: Matt Thomas <matt@3am-software.com>, Date: Sun, 15 Sep 2013 22:45:41 -0700
 >   
 >   > That seems to be a pkg tools program, not an arm problem.
 >   
 >   Thank you.
 >   I will investigate pkg_install deeper.

 Something like the attached diff should fix this. I didn't even compile 
 test it, though.

 Nick

 --------------040706010803020104010603
 Content-Type: text/plain; charset=us-ascii;
  name="diff"
 Content-Transfer-Encoding: 7bit
 Content-Disposition: attachment;
  filename="diff"

 Index: pkgtools/pkg_install/files/add/perform.c
 ===================================================================
 RCS file: /cvsroot/pkgsrc/pkgtools/pkg_install/files/add/perform.c,v
 retrieving revision 1.105
 diff -u -p -u -r1.105 perform.c
 --- pkgtools/pkg_install/files/add/perform.c	2 Sep 2013 10:28:44 -0000	1.105
 +++ pkgtools/pkg_install/files/add/perform.c	16 Sep 2013 08:05:25 -0000
 @@ -908,8 +908,17 @@ check_platform(struct pkg_task *pkg)

  	if (OverrideMachine != NULL)
  		effective_arch = OverrideMachine;
 -	else
 -		effective_arch = MACHINE_ARCH;
 +	else {
 +		static char machine_arch_buf[sizeof(utsname.machine)];
 +		const int mib[2] = { CTL_HW, HW_MACHINE_ARCH };
 +		size_t len = sizeof(machine_arch_buf);
 +
 +		if (sysctl(mib, __arraycount(mib), machine_arch_buf,
 +		    &len, NULL, 0) == 0)
 +			effective_arch = machine_arch_buf;
 +		else
 +			effective_arch = MACHINE_ARCH;
 +	}

  	/* If either the OS or arch are different, bomb */
  	if (strcmp(OPSYS_NAME, pkg->buildinfo[BI_OPSYS]) ||

 --------------040706010803020104010603--

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el
 current
Date: Mon, 16 Sep 2013 14:55:39 +0000

 On Mon, Sep 16, 2013 at 08:10:01AM +0000, Nick Hudson wrote:
  >  Something like the attached diff should fix this. I didn't even compile 
  >  test it, though.

 It's probably better to try to arrange the build so MACHINE_ARCH
 contains the right string.

 calling sysctl directly will probably make for compile-time fun on
 Solaris and other legacy platforms.

 -- 
 David A. Holland
 dholland@netbsd.org

From: Matt Thomas <matt@3am-software.com>
To: gnats-bugs@NetBSD.org,
 David Holland <dholland-bugs@netbsd.org>
Cc: port-arm-maintainer@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el current
Date: Mon, 16 Sep 2013 08:10:17 -0700

 On Sep 16, 2013, at 8:00 AM, David Holland <dholland-bugs@netbsd.org> =
 wrote:

 > The following reply was made to PR port-arm/48215; it has been noted =
 by GNATS.
 >=20
 > From: David Holland <dholland-bugs@netbsd.org>
 > To: gnats-bugs@NetBSD.org
 > Cc:=20
 > Subject: Re: port-arm/48215: pkg_add fails on recent =
 NetBSD/evbearmv6hf-el
 > current
 > Date: Mon, 16 Sep 2013 14:55:39 +0000
 >=20
 > On Mon, Sep 16, 2013 at 08:10:01AM +0000, Nick Hudson wrote:
 >> Something like the attached diff should fix this. I didn't even =
 compile=20
 >> test it, though.
 >=20
 > It's probably better to try to arrange the build so MACHINE_ARCH
 > contains the right string.
 >=20
 > calling sysctl directly will probably make for compile-time fun on
 > Solaris and other legacy platforms.

 So conditionalize it with #ifdef NETBSD_SOURCE / #endif=

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el
 current
Date: Tue, 17 Sep 2013 01:43:35 +0000

 On Mon, Sep 16, 2013 at 03:15:00PM +0000, Matt Thomas wrote:
  >  > It's probably better to try to arrange the build so MACHINE_ARCH
  >  > contains the right string.
  >  >
  >  > calling sysctl directly will probably make for compile-time fun on
  >  > Solaris and other legacy platforms.
  >  
  >  So conditionalize it with #ifdef NETBSD_SOURCE / #endif=

 Or maybe fix it right?

 The build inherits MACHINE_ARCH from the environment, which gets it
 from the nbmake wrapper. If it's wrong there, that seems like a bug.

 -- 
 David A. Holland
 dholland@netbsd.org

From: matthew green <mrg@eterna.com.au>
To: gnats-bugs@NetBSD.org
Cc: port-arm-maintainer@netbsd.org, gnats-admin@netbsd.org,
    netbsd-bugs@netbsd.org, ryoon@NetBSD.org
Subject: re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el current
Date: Tue, 17 Sep 2013 13:19:45 +1000

 >  On Mon, Sep 16, 2013 at 03:15:00PM +0000, Matt Thomas wrote:
 >   >  > It's probably better to try to arrange the build so MACHINE_ARCH
 >   >  > contains the right string.
 >   >  >
 >   >  > calling sysctl directly will probably make for compile-time fun on
 >   >  > Solaris and other legacy platforms.
 >   >  
 >   >  So conditionalize it with #ifdef NETBSD_SOURCE / #endif=
 >  
 >  Or maybe fix it right?
 >  
 >  The build inherits MACHINE_ARCH from the environment, which gets it
 >  from the nbmake wrapper. If it's wrong there, that seems like a bug.

 this has to do with the value exportd by <sys/param.h>, not
 the value set by the build.

 since these binaries are always going to report the same value,
 i suspect that fixing arm/param.h to report the right value
 depending on the compiler options would fix the problem without
 having to patch every program that uses them to use sysctl on
 netbsd...


 .mrg.

From: Matt Thomas <matt@3am-software.com>
To: matthew green <mrg@eterna.com.au>
Cc: gnats-bugs@NetBSD.org,
 port-arm-maintainer@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el current
Date: Mon, 16 Sep 2013 22:44:00 -0700

 On Sep 16, 2013, at 8:19 PM, matthew green <mrg@eterna.com.au> wrote:

 > 
 >> On Mon, Sep 16, 2013 at 03:15:00PM +0000, Matt Thomas wrote:
 >>>> It's probably better to try to arrange the build so MACHINE_ARCH
 >>>> contains the right string.
 >>>> 
 >>>> calling sysctl directly will probably make for compile-time fun on
 >>>> Solaris and other legacy platforms.
 >>> 
 >>> So conditionalize it with #ifdef NETBSD_SOURCE / #endif=
 >> 
 >> Or maybe fix it right?
 >> 
 >> The build inherits MACHINE_ARCH from the environment, which gets it
 >> from the nbmake wrapper. If it's wrong there, that seems like a bug.
 > 
 > this has to do with the value exportd by <sys/param.h>, not
 > the value set by the build.
 > 
 > since these binaries are always going to report the same value,
 > i suspect that fixing arm/param.h to report the right value
 > depending on the compiler options would fix the problem without
 > having to patch every program that uses them to use sysctl on
 > netbsd...

 As I said on tech-userlevel, it can't be done at the compiler level.
 The alternative is to add CPPFLAGS+= -DMACHINE_ARCH=\"${MACHINE_ARCH}\"
 to the lib Makefile.
 And not have arm params.h #undef it.

From: christos@zoulas.com (Christos Zoulas)
To: matthew green <mrg@eterna.com.au>, gnats-bugs@NetBSD.org
Cc: port-arm-maintainer@netbsd.org, gnats-admin@netbsd.org, 
	netbsd-bugs@netbsd.org, ryoon@NetBSD.org
Subject: re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el current
Date: Tue, 17 Sep 2013 07:48:51 -0400

 On Sep 17,  1:19pm, mrg@eterna.com.au (matthew green) wrote:
 -- Subject: re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el

 | since these binaries are always going to report the same value,
 | i suspect that fixing arm/param.h to report the right value
 | depending on the compiler options would fix the problem without
 | having to patch every program that uses them to use sysctl on
 | netbsd...

 The problem is that some archs with different machine_archs use the
 same toolchain and can't be told apart.

 christos

From: matthew green <mrg@eterna.com.au>
To: christos@zoulas.com (Christos Zoulas)
Cc: port-arm-maintainer@netbsd.org, gnats-admin@netbsd.org,
    netbsd-bugs@netbsd.org, ryoon@NetBSD.org, gnats-bugs@NetBSD.org
Subject: re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el current
Date: Wed, 18 Sep 2013 03:30:37 +1000

 > | since these binaries are always going to report the same value,
 > | i suspect that fixing arm/param.h to report the right value
 > | depending on the compiler options would fix the problem without
 > | having to patch every program that uses them to use sysctl on
 > | netbsd...
 > 
 > The problem is that some archs with different machine_archs use the
 > same toolchain and can't be told apart.

 how so?  can't the header file define MACHINE/MACHINE_ARCH based
 upon the compiler defines?  eg, from sparc64/param.h:

 #ifdef __arch64__
 #define _MACHINE        sparc64
 #define MACHINE         "sparc64"
 #define _MACHINE_ARCH   sparc64
 #define MACHINE_ARCH    "sparc64"
 #define MID_MACHINE     MID_SPARC64
 #else
 #define _MACHINE        sparc
 #define MACHINE         "sparc"
 #define _MACHINE_ARCH   sparc
 #define MACHINE_ARCH    "sparc"
 #define MID_MACHINE     MID_SPARC
 #endif


 .mrg.

From: Matt Thomas <matt@3am-software.com>
To: gnats-bugs@NetBSD.org
Cc: port-arm-maintainer@netbsd.org,
 gnats-admin@netbsd.org,
 netbsd-bugs@netbsd.org
Subject: Re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el current
Date: Tue, 17 Sep 2013 10:36:32 -0700

 On Sep 17, 2013, at 10:35 AM, matthew green <mrg@eterna.com.au> wrote:

 > The following reply was made to PR port-arm/48215; it has been noted =
 by GNATS.
 >=20
 > From: matthew green <mrg@eterna.com.au>
 > To: christos@zoulas.com (Christos Zoulas)
 > Cc: port-arm-maintainer@netbsd.org, gnats-admin@netbsd.org,
 >    netbsd-bugs@netbsd.org, ryoon@NetBSD.org, gnats-bugs@NetBSD.org
 > Subject: re: port-arm/48215: pkg_add fails on recent =
 NetBSD/evbearmv6hf-el current
 > Date: Wed, 18 Sep 2013 03:30:37 +1000
 >=20
 >> | since these binaries are always going to report the same value,
 >> | i suspect that fixing arm/param.h to report the right value
 >> | depending on the compiler options would fix the problem without
 >> | having to patch every program that uses them to use sysctl on
 >> | netbsd...
 >>=20
 >> The problem is that some archs with different machine_archs use the
 >> same toolchain and can't be told apart.
 >=20
 > how so?  can't the header file define MACHINE/MACHINE_ARCH based
 > upon the compiler defines?  eg, from sparc64/param.h:
 >=20
 > #ifdef __arch64__
 > #define _MACHINE        sparc64
 > #define MACHINE         "sparc64"
 > #define _MACHINE_ARCH   sparc64
 > #define MACHINE_ARCH    "sparc64"
 > #define MID_MACHINE     MID_SPARC64
 > #else
 > #define _MACHINE        sparc
 > #define MACHINE         "sparc"
 > #define _MACHINE_ARCH   sparc
 > #define MACHINE_ARCH    "sparc"
 > #define MID_MACHINE     MID_SPARC
 > #endif

 For evbearm & evbearmv5, there is nothing to distinguish them.
 Ditto for evbearmhf & evbearmv5hf.=

From: matthew green <mrg@eterna.com.au>
To: Matt Thomas <matt@3am-software.com>
Cc: port-arm-maintainer@netbsd.org, gnats-admin@netbsd.org,
    netbsd-bugs@netbsd.org, gnats-bugs@NetBSD.org
Subject: re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el current
Date: Wed, 18 Sep 2013 04:04:14 +1000

 > For evbearm & evbearmv5, there is nothing to distinguish them.
 > Ditto for evbearmhf & evbearmv5hf.

 so there's no way to application code to know what sort of
 compilation environment is available?

 that seems like a bug to me.


 .mrg.

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el
 current
Date: Sat, 28 Sep 2013 19:30:11 +0000

 On Tue, Sep 17, 2013 at 03:20:01AM +0000, matthew green wrote:
  >  >  The build inherits MACHINE_ARCH from the environment, which gets it
  >  >  from the nbmake wrapper. If it's wrong there, that seems like a bug.
  >  
  >  this has to do with the value exportd by <sys/param.h>, not
  >  the value set by the build.

 external/bsd/pkg_install/sbin/pkg_add/Makefile has

    CPPFLAGS+=      -DMACHINE_ARCH=\"${MACHINE_ARCH}\"

 and it seems to me that overriding this is a bug.

 -- 
 David A. Holland
 dholland@netbsd.org

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el
 current
Date: Mon, 7 Oct 2013 04:21:48 +0000

 not sent to gnats (all PR traffic should be sent to gnats-bugs; it
 remails)

    ------

 From: Moritz Wilhelmy <mw+netbsd@barfooze.de>
 To: port-arm-maintainer@netbsd.org, gnats-admin@netbsd.org,
 	netbsd-bugs@netbsd.org, ryoon@NetBSD.org
 Subject: Re: port-arm/48215: pkg_add fails on recent NetBSD/evbearmv6hf-el
 	current
 Date: Fri, 4 Oct 2013 21:40:15 +0200

 Alright, after a long time of debugging it seems the situation is as
 follows:

 * The pkg_install Makefile adds -DMACHINE_ARCH=\"${MACHINE_ARCH}\" to the
   CC flags, where MACHINE_ARCH is the right value of earmhf.

 * the pkg_add code pulls in param.h which undefs MACHINE_ARCH and
   replaces it by "earm".

 Also I don't understand why MACHINE_ARCH is set to several different
 values depending on _KERNEL. Can someone please explain this to me?

 Also port-arm/48267 is a duplicate of port-arm/48215, so please close
 it. Sorry about that.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.