NetBSD Problem Report #50830

From  Thu Feb 18 19:08:36 2016
Return-Path: <>
Received: from ( [])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "", Issuer "Postmaster" (verified OK))
	by (Postfix) with ESMTPS id 91AC67ACAB
	for <>; Thu, 18 Feb 2016 19:08:36 +0000 (UTC)
Message-Id: <>
Date: Thu, 18 Feb 2016 19:08:35 +0000 (UTC)
Subject: Building pkgsrc packages broken on Darwin/OS X
X-Send-Pr-Version: www-1.0

>Number:         50830
>Category:       pkg
>Synopsis:       Building pkgsrc packages broken on Darwin/OS X
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    jperkin
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 18 19:10:00 +0000 2016
>Last-Modified:  Tue Mar 08 19:06:20 +0000 2016
>Originator:     Markus Mayer
>Release:        pkgsrc HEAD
Darwin triton.home.lan 15.3.0 Darwin Kernel Version 15.3.0: Thu Dec 10 18:40:58 PST 2015; root:xnu-3248.30.4~1/RELEASE_X86_64 x86_64

Changes made during the commit below break pkgsrc on Darwin in 64 bit mode. Packages will build properly (as 64 bit binaries), but they won't install, because they have been mis-labeled as being for "i386" (i.e. 32 bit platforms) while the host machine will be seen as "x86_64" (i.e. 64 bit platform). pkgsrc reports an architecture mismatch and refuses to install the package.

Author: jperkin <jperkin>
Date:   Sun Jan 24 16:14:44 2016 +0000

    Attempt to bring sanity to how ABI and MACHINE_ARCH are set.

    Previously there were at least 5 different ways MACHINE_ARCH could be set,
    some statically and some at run time, and in many cases these settings
    differed, leading to issues at pkg_add time where there was conflict
    between the setting encoded into the package and that used by pkg_install.

    Instead, move to a single source of truth where the correct value based on
    the host and the chosen (or default) ABI is determined in the bootstrap
    script.  The value can still be overridden in mk.conf if necessary, e.g.
    for cross-compiling.

    ABI is now set by default and if unset a default is calculated based on
    MACHINE_ARCH.  This fixes some OS, e.g. Linux, where the wrong default was
    previously chosen.

    As a result of the refactoring there is no need for LOWER_ARCH, with
    references to it replaced by MACHINE_ARCH.  SPARC_TARGET_ARCH is also

The problem is this change in mk/

 .elif ${OPSYS} == "Darwin"
 LOWER_OPSYS?=          darwin
-.if empty(OS_VERSION:M[1-9].*.*)
-# Automatically select the ABI under Mac OS X Snow Leopard. We don't
-# use this at the moment because too many third party programs don't
-# work with it.
-# _SYSCTL_HW_OPTIONAL_X86_64!= /usr/sbin/sysctl -n hw.optional.x86_64
-# .  if ${_SYSCTL_HW_OPTIONAL_X86_64} == "1"
-# ABI=                 64
-# .else
-# ABI=                 32
-#.  endif
-ABI=                   32
-LOWER_ARCH.32=         i386
-LOWER_ARCH.64=         x86_64
-LOWER_ARCH=            ${LOWER_ARCH.${ABI}}
-LOWER_ARCH!=           ${UNAME} -p
 LOWER_VENDOR?=         apple

Specifically, it is the removal of "MACHINE_ARCH=${LOWER_ARCH}" that is causing the problems. I don't know pkgsrc internals well enough, but I am assuming that MACHINE_ARCH gets set to the output of "uname -p" by default, which is "i386" on Darwin, even on 64 bit machines. So, MACHINE_ARCH needs to be overridden for Darwin, otherwise it won't work.

Attempt to build and install any package on OS X using a recent pkgsrc checkout and observe the (wrongfully reported) i386 vs. x86_64 architecture mismatch.
Probably not the best fix, but this worked for me in a pinch.

diff --git a/mk/ b/mk/
index 9f7ab87..b2966d7 100644
--- a/mk/
+++ b/mk/
@@ -153,6 +153,16 @@ OS_VERSION=                ${_OS_VERSION:C/\(.*\)//}
 OS_VARIANT!=           ${UNAME} -s

 .elif ${OPSYS} == "Darwin"
+.if empty(OS_VERSION:M[1-9].*.*)
+ABI=                   32
+LOWER_ARCH.32=         i386
+LOWER_ARCH.64=         x86_64
+LOWER_ARCH=            ${LOWER_ARCH.${ABI}}
+LOWER_ARCH!=           ${UNAME} -p
 LOWER_OPSYS?=          darwin
 LOWER_VENDOR?=         apple



Responsible-Changed-From-To: pkg-manager->jperkin
Responsible-Changed-When: Tue, 08 Mar 2016 19:06:20 +0000
Jonathan, could you take a look please?
You were the one that committed this change.


NetBSD Home
NetBSD PR Database Search

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