NetBSD Problem Report #54100

From tsutsui@ceres.dti.ne.jp  Fri Apr  5 11:07:40 2019
Return-Path: <tsutsui@ceres.dti.ne.jp>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id B8C2F7A167
	for <gnats-bugs@gnats.NetBSD.org>; Fri,  5 Apr 2019 11:07:40 +0000 (UTC)
Message-Id: <201904051107.x35B7ZVS003027@ceres.dti.ne.jp>
Date: Fri, 5 Apr 2019 20:07:35 +0900 (JST)
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: _HOST_ARCH on NetBSD/amd64 returns 'uname -m' not 'uname -p'
X-Send-Pr-Version: 3.95

>Number:         54100
>Category:       toolchain
>Synopsis:       _HOST_ARCH on NetBSD/amd64 returns 'uname -m' not 'uname -p'
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 05 11:10:00 +0000 2019
>Originator:     Izumi Tsutsui
>Release:        NetBSD 8.0
>Organization:
>Environment:
System: NetBSD optiplex 8.0 NetBSD 8.0 (GENERIC) #0: Tue Jul 17 14:59:51 UTC 2018  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
Architecture: x86_64
Machine: amd64
>Description:
In <bsd.host.mk> ${_HOST_ARCH} for ${TOOLDIR} is
defined as the following:

---

.if !defined(HOST_OSTYPE)
_HOST_OSNAME!=	uname -s
_HOST_OSREL!=	uname -r
# For _HOST_ARCH, if uname -p fails, or prints "unknown", or prints
# something that does not look like an identifier, then use uname -m.
_HOST_ARCH!=	uname -p 2>/dev/null
_HOST_ARCH:=	${HOST_ARCH:tW:C/.*[^-_A-Za-z0-9].*//:S/unknown//}
.if empty(_HOST_ARCH)
_HOST_ARCH!=	uname -m
.endif
HOST_OSTYPE:=	${_HOST_OSNAME}-${_HOST_OSREL:C/\([^\)]*\)//g:[*]:C/ /_/g}-${_HOST_ARCH:C/\([^\)]*\)//g:[*]:C/ /_/g}
.MAKEOVERRIDES+= HOST_OSTYPE
.endif # !defined(HOST_OSTYPE)

---

So ${_HOST_ARCH} on NetBSD/amd64 should be "x86_64" as uname -p returns.
However on the NetBSD/amd64 host it returns "amd64".

>How-To-Repeat:

% uname -a
NetBSD optiplex 8.0 NetBSD 8.0 (GENERIC) #0: Tue Jul 17 14:59:51 UTC 2018  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
% uname -p
x86_64
% uname -m
amd64
% cat Makefile 
.include <bsd.own.mk>

all:
        @echo _HOST_ARCH is ${_HOST_ARCH}
        @echo TOOLDIR is ${TOOLDIR}

% env USETOOLS=yes make all
_HOST_ARCH is amd64
TOOLDIR is /tooldir.NetBSD-8.0-amd64
% 


>Fix:

Something wrong (triggered by underscore?) in the following definition?
> _HOST_ARCH:=    ${HOST_ARCH:tW:C/.*[^-_A-Za-z0-9].*//:S/unknown//}

---
Izumi Tsutsui

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.