pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/50830: Building pkgsrc packages broken on Darwin/OS X



>Number:         50830
>Category:       pkg
>Synopsis:       Building pkgsrc packages broken on Darwin/OS X
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 18 19:10:00 +0000 2016
>Originator:     Markus Mayer
>Release:        pkgsrc HEAD
>Organization:
>Environment:
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

>Description:
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
    removed.

The problem is this change in mk/bsd.prefs.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}}
-.else
-LOWER_ARCH!=           ${UNAME} -p
-.endif
-MACHINE_ARCH=          ${LOWER_ARCH}
-MAKEFLAGS+=            LOWER_ARCH=${LOWER_ARCH:Q}
 LOWER_OPSYS_VERSUFFIX= ${LOWER_OS_VERSION:C/([0-9]*).*/\1/}
 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.

>How-To-Repeat:
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.
>Fix:
Probably not the best fix, but this worked for me in a pinch.

diff --git a/mk/bsd.prefs.mk b/mk/bsd.prefs.mk
index 9f7ab87..b2966d7 100644
--- a/mk/bsd.prefs.mk
+++ b/mk/bsd.prefs.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}}
+.else
+LOWER_ARCH!=           ${UNAME} -p
+.endif
+MACHINE_ARCH=          ${LOWER_ARCH}
+MAKEFLAGS+=            LOWER_ARCH=${LOWER_ARCH:Q}
 LOWER_OPSYS?=          darwin
 LOWER_OPSYS_VERSUFFIX= ${LOWER_OS_VERSION:C/([0-9]*).*/\1/}
 LOWER_VENDOR?=         apple


Home | Main Index | Thread Index | Old Index