NetBSD Problem Report #57074

From www@netbsd.org  Tue Oct 25 16:22:28 2022
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_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 CDA7F1A921F
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 25 Oct 2022 16:22:28 +0000 (UTC)
Message-Id: <20221025162227.352261A9239@mollari.NetBSD.org>
Date: Tue, 25 Oct 2022 16:22:27 +0000 (UTC)
From: dns@strangeloop.cc
Reply-To: dns@strangeloop.cc
To: gnats-bugs@NetBSD.org
Subject: sysutils/pv fails to build on modern MacOS, tries to use stat64
X-Send-Pr-Version: www-1.0

>Number:         57074
>Category:       pkg
>Synopsis:       sysutils/pv fails to build on modern MacOS, tries to use stat64
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Oct 25 16:25:00 +0000 2022
>Closed-Date:    Tue May 09 21:32:13 +0000 2023
>Last-Modified:  Tue May 09 21:32:13 +0000 2023
>Originator:     Dennis Lindroos
>Release:        
>Organization:
Strangeloop.CC
>Environment:
Darwin StrangeloopM1.local 21.6.0 Darwin Kernel Version 21.6.0: Mon Aug 22 20:20:05 PDT 2022; root:xnu-8020.140.49~2/RELEASE_ARM64_T8101 arm64
>Description:
PV fails to build on my Apple M1 (aarch64) /MacOS Monterey because there is no "struct stat64":

Xcode version is 14.0.1 Build version 14A400

clang -O2 -I/usr/local/pkg/include -I/usr/local/pkg/include -I./src/include -Isrc/include -DHAVE_CONFIG_H -DLOCALEDIR=\"/usr/local/pkg/share/locale\" -c -o src/pv/cursor.o src/pv/cursor.c
In file included from src/pv/cursor.c:14:
./src/include/pv-internal.h:219:16: error: field has incomplete type 'struct stat64'
        struct stat64 sb_fd;             /* stat of fd symlink */
                      ^
./src/include/pv-internal.h:219:9: note: forward declaration of 'struct stat64'
        struct stat64 sb_fd;             /* stat of fd symlink */
               ^
./src/include/pv-internal.h:220:16: error: field has incomplete type 'struct stat64'
        struct stat64 sb_fd_link;        /* lstat of fd symlink */
                      ^
./src/include/pv-internal.h:219:9: note: forward declaration of 'struct stat64'
        struct stat64 sb_fd;             /* stat of fd symlink */
               ^
2 errors generated.

>How-To-Repeat:
$ cd /home/pkgsrc/sysutils/pv
$ (b)make

>Fix:
GNU Configure seems to find stat64 and think it is ok, so to counteract I added these to Makefile:

.include "../../mk/bsd.prefs.mk"

.if ${OPSYS} == "Darwin" && ${MACHINE_ARCH} == "aarch64"
CONFIGURE_ENV+=         ac_cv_func_stat64=no
.endif

Will this break build on other Darwin's or older Mac's? Maybe checking OPSYS_VERSION > 120000 is a better deal? Unfortunately I don't know much about Mac's and my system is currently 120600.

I want to use this opportunity to thank everyone involved with the PKGsrc. Big thanks guys!
Dennis

>Release-Note:

>Audit-Trail:
From: David Holland <dholland-pbugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/57074: sysutils/pv fails to build on modern MacOS, tries to
 use stat64
Date: Wed, 26 Oct 2022 22:13:16 +0000

 On Tue, Oct 25, 2022 at 04:25:00PM +0000, dns@strangeloop.cc wrote:
  > .if ${OPSYS} == "Darwin" && ${MACHINE_ARCH} == "aarch64"
  > CONFIGURE_ENV+=         ac_cv_func_stat64=no
  > .endif
  > 
  > Will this break build on other Darwin's or older Mac's? Maybe
  > checking OPSYS_VERSION > 120000 is a better deal? Unfortunately I
  > don't know much about Mac's and my system is currently 120600.

 It might. The whole sorry history of this stat64 nonsense has a lot of
 tentacles. But probably not since aarch64 MacOS doesn't go back very
 far.

 I guess the other question is: why does the configure test come up
 with the wrong answer? If we can figure out what's up with that, it's
 a more robust way to fix things. config.log may provide some insight.

  > I want to use this opportunity to thank everyone involved with the
  > PKGsrc. Big thanks guys!

 :-)

 -- 
 David A. Holland
 dholland@netbsd.org

From: dns@strangeloop.cc
To: gnats-bugs@netbsd.org
Cc: pkg-manager@netbsd.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org
Subject: Re: pkg/57074: sysutils/pv fails to build on modern MacOS, tries to
 use stat64
Date: Fri, 28 Oct 2022 00:27:21 +0300

 On 2022-10-27 01:15, David Holland wrote:
 > The following reply was made to PR pkg/57074; it has been noted by 
 > GNATS.
 > 
 > From: David Holland <dholland-pbugs@netbsd.org>
 > To: gnats-bugs@netbsd.org
 > Cc:
 > Subject: Re: pkg/57074: sysutils/pv fails to build on modern MacOS, 
 > tries to
 >  use stat64
 > Date: Wed, 26 Oct 2022 22:13:16 +0000
 > 
 >  On Tue, Oct 25, 2022 at 04:25:00PM +0000, dns@strangeloop.cc wrote:
 >   > .if ${OPSYS} == "Darwin" && ${MACHINE_ARCH} == "aarch64"
 >   > CONFIGURE_ENV+=         ac_cv_func_stat64=no
 >   > .endif
 >   >
 >   > Will this break build on other Darwin's or older Mac's? Maybe
 >   > checking OPSYS_VERSION > 120000 is a better deal? Unfortunately I
 >   > don't know much about Mac's and my system is currently 120600.
 > 
 >  It might. The whole sorry history of this stat64 nonsense has a lot of
 >  tentacles. But probably not since aarch64 MacOS doesn't go back very
 >  far.
 > 
 >  I guess the other question is: why does the configure test come up
 >  with the wrong answer? If we can figure out what's up with that, it's
 >  a more robust way to fix things. config.log may provide some insight.
 > 
 >  --
 >  David A. Holland
 >  dholland@netbsd.org

 I tried my best and I did eventually came up with this diff, which 
 should explain things. I included a few more lines to show how the 
 macros work:

 --- autoconf/header.in.orig     2021-09-04 22:59:47.000000000 +0300
 +++ autoconf/header.in  2022-10-28 00:02:23.000000000 +0300
 @@ -58,21 +58,21 @@
   #ifdef ENABLE_LARGEFILE
   # define __USE_LARGEFILE64 1
   # define _LARGEFILE64_SOURCE 1
   #else
   /*
    * Some Macs have stat64 despite not having open64 while others don't 
 have
    * either, so here even if we don't have open64 or LFS is disabled, we 
 have
    * to check whether stat64 exists and only redefine it if it doesn't
    * otherwise some Macs fail to compile.
    */
 -# ifdef __APPLE__
 +# if defined(__APPLE__) && !defined(_DARWIN_FEATURE_64_BIT_INODE)
   #  ifndef HAVE_STAT64
   #   define stat64 stat
   #   define fstat64 fstat
   #   define lstat64 lstat
   #  endif
   # else
   #  define stat64 stat
   #  define fstat64 fstat
   #  define lstat64 lstat
   # endif


 I could not easily get around the detection of HAVE_STAT64 (autoconf 
 defines this from successful compilation of function stat64(2)) but by 
 using this "64_BIT_NODE" macro, defined on modern (Mac OSX 10.5 or 
 higher) systems, this will ignore HAVE_STAT64 and fallback to the 
 default behaviour of other OS's, which is to "define stat64 stat" and 
 hence fix the code.

 So, until Apple removes stat64(2) altogether this should work.. :)

 Cheers,
 Dennis

From: David Holland <dholland-pbugs@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: pkg-manager@netbsd.org, gnats-admin@netbsd.org, pkgsrc-bugs@netbsd.org,
	dns@strangeloop.cc
Subject: Re: pkg/57074: sysutils/pv fails to build on modern MacOS, tries to
 use stat64
Date: Tue, 9 May 2023 21:22:24 +0000

 On Thu, Oct 27, 2022 at 11:05:01PM +0000, dns@strangeloop.cc wrote:
  >  I could not easily get around the detection of HAVE_STAT64 (autoconf 
  >  defines this from successful compilation of function stat64(2)) but by 
  >  using this "64_BIT_NODE" macro, defined on modern (Mac OSX 10.5 or 
  >  higher) systems, this will ignore HAVE_STAT64 and fallback to the 
  >  default behaviour of other OS's, which is to "define stat64 stat" and 
  >  hence fix the code.

 I think if we can't get the configure test to generate the right
 answer we're better off suppressing it directly rather than using a
 different and only semi-related predefined symbol (which might change
 in the future) to avoid using the results.

 So I think I'll go with the original makefile change we can reexamine
 later if necessary.


 (sorry it took six months to respond)

 -- 
 David A. Holland
 dholland@netbsd.org

From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57074 CVS commit: pkgsrc/sysutils/pv
Date: Tue, 9 May 2023 21:26:18 +0000

 Module Name:	pkgsrc
 Committed By:	dholland
 Date:		Tue May  9 21:26:18 UTC 2023

 Modified Files:
 	pkgsrc/sysutils/pv: Makefile

 Log Message:
 PR 57074 Dennis Lindroos: fix build on aarch64 macos

 Disable configure test for stat64 since apparently it produces the
 wrong answer.


 To generate a diff of this commit:
 cvs rdiff -u -r1.28 -r1.29 pkgsrc/sysutils/pv/Makefile

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: open->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Tue, 09 May 2023 21:32:13 +0000
State-Changed-Why:
Committed, thanks!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.