NetBSD Problem Report #41963

From kre@munnari.OZ.AU  Tue Sep  1 01:57:00 2009
Return-Path: <kre@munnari.OZ.AU>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 4AE0F63BAC2
	for <gnats-bugs@gnats.NetBSD.org>; Tue,  1 Sep 2009 01:57:00 +0000 (UTC)
Message-Id: <200909010156.n811upas003240@jade.coe.psu.ac.th>
Date: Tue, 1 Sep 2009 08:56:51 +0700 (ICT)
From: kre@munnari.OZ.AU
To: gnats-bugs@gnats.NetBSD.org
Subject: archivers/xz compilation errors (NetBSD 4.0 / i386)
X-Send-Pr-Version: 3.95

>Number:         41963
>Category:       pkg
>Synopsis:       archivers/xz compilation errors (NetBSD 4.0 / i386)
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    pkg-manager
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 01 02:00:01 +0000 2009
>Closed-Date:    Fri Sep 04 16:57:27 +0000 2009
>Last-Modified:  Fri Sep 04 17:00:04 +0000 2009
>Originator:     Robert Elz
>Release:        NetBSD 4.0   pkgsrc -current
>Organization:
	Prince of Songkla University
>Environment:
System: NetBSD jade.coe.psu.ac.th 4.0_STABLE NetBSD 4.0_STABLE (JADE-1.696-20080517) #9: Fri May 23 18:55:13 ICT 2008 kre@jade.coe.psu.ac.th:/usr/obj/4/kernels/JADE i386
Architecture: i386
Machine: i386
>Description:
	archivers/xz (xz-4.999.9beta) fails to compile on NetBSD 4.0 (i386).
	Problems relate to sysctl.

>How-To-Repeat:
	I use pkg_comp with NetBSD 4.0 sets installed, and libkver, to
	obtain a fairly pure 4.0 release environment.   No x* sets,
	this setup uses pkgsrc modular xorg instead (I doubt that is
	relevant).

	Build produces ...

cc -std=gnu99 -DHAVE_CONFIG_H -I. -I../..  -DLOCALEDIR=\"/usr/pkg/share/locale\"  -I../../src/common  -I../../src/liblzma/api  -I../../lib  -DLZMA_API_STATIC -I/usr/include -pthread  -fvisibility=hidden -Wall -Wextra -Wformat=2 -Winit-self -Wmissing-include-dirs -Wstrict-aliasing -Wfloat-equal -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wmissing-noreturn -Wredundant-decls -O2 -I/usr/include -MT xz-hardware.o -MD -MP -MF .deps/xz-hardware.Tpo -c -o xz-hardware.o `test -f 'hardware.c' || echo './'`hardware.c
In file included from hardware.c:14:
../../src/common/physmem.h: In function 'physmem':
../../src/common/physmem.h:107: warning: passing argument 6 of 'sysctl' makes integer from pointer without a cast
In file included from hardware.c:15:
../../src/common/cpucores.h: In function 'cpucores':
../../src/common/cpucores.h:43: warning: passing argument 2 of 'sysctl' makes integer from pointer without a cast
../../src/common/cpucores.h:43: error: too few arguments to function 'sysctl'
*** Error code 1

Stop.
make: stopped in /pkg_comp/obj/pkgsrc/archivers/xz/4x/xz-4.999.9beta/src/xz
*** Error code 1

Stop.

>Fix:

>Release-Note:

>Audit-Trail:
From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/41963: archivers/xz compilation errors (NetBSD 4.0 / i386) 
Date: Thu, 03 Sep 2009 23:58:01 +0700

   | 	archivers/xz (xz-4.999.9beta) fails to compile on NetBSD 4.0 (i386).
   | 	Problems relate to sysctl.

 When I submitted that PR, I marked it non-critical/medium, as to me,
 at the time, it was "just another package that didn't compile on
 an old NetBSD".

 But, it turns out that xz is needed in order to build lots of
 other packages (at least the fonts/tex-*-doc packages) so the
 status of this PR should really have been critical/high ...
 (Is there some way to get that altered, other than by e-mailing
 to gnats-admin and begging?)

 But since no-one seems to have wanted to claim responsibility for
 this (and yes, I know it is only  2 and a half days old...) I thought
 I could take a look and see if I can fix the problem.

 After looking at it, I cannot imagine that this thing (version 4.999.9beta)
 has ever compiled on any BSD version (or anything that uses sysctl rather
 than sysinfo to extract system data).   The fault (the one thing that is
 a real compilation error) was a missing arg to systcl() - and what's more,
 two different calls had it correct in one, and incorrect in the other, so
 it is not just that sysctl() has varied its arg list over time, or anything
 like that - it is a simple typo in one place.

 The patch below corrects the compilation error, also removes a comple of
 compilation warnings (also seen in the PR)  which were caused by passing
 NULL where 0 was expected (probably harmless on systems where sizeof(int)
 is the same as sizeof(void *) and most probably harmless where the latter
 is bigger, as this was the final arg, but still trivial to fix.

 The patch also corrects the way the result from sysctl was being
 tested, the core

 	if (!sysctl(...

 is just weird - as I read its doc, sysctl can never return 0, it returns
 -1 if there is an error (normal) and the number of bytes copied out if
 it all works, unless sysctl() was somehow able to both succeed, and return
 no data, I can't imagine how a 0 result is possible (the buffer size for
 the result is > 0).

 Never mind.

 Apply the following patch in the archivers/xz directory, commit the
 results (which includes creating a new patches directory, with two
 patches in it), and after that, xz builds just fine.

 There's no need for a revbump, on any stsem where this compiled before,
 nothing will change, on any system where the new patches make a difference
 it could not possibly have compiled.

 kre

 diff -rN -u ../xz/distinfo ./distinfo
 --- ../xz/distinfo	2009-08-31 22:33:12.000000000 +0700
 +++ ./distinfo	2009-09-03 23:41:37.000000000 +0700
 @@ -3,3 +3,5 @@
  SHA1 (xz-4.999.9beta.tar.gz) = 9627de3997ddcdb02f8d327e84b2cf1941ecd230
  RMD160 (xz-4.999.9beta.tar.gz) = 1253ce01746c748c8549effa5041224044919c4e
  Size (xz-4.999.9beta.tar.gz) = 1037541 bytes
 +SHA1 (patch-aa) = 131a15878478612e282929b2af42fa47f3220ce3
 +SHA1 (patch-ab) = fd417519922aa963035482bf324c69f622b5131c
 diff -rN -u ../xz/patches/patch-aa ./patches/patch-aa
 --- ../xz/patches/patch-aa	1970-01-01 07:00:00.000000000 +0700
 +++ ./patches/patch-aa	2009-09-03 23:41:22.000000000 +0700
 @@ -0,0 +1,13 @@
 +$NetBSD$
 +
 +--- src/common/cpucores.h-BAD	2009-08-27 15:37:12.000000000 +0000
 ++++ src/common/cpucores.h
 +@@ -40,7 +40,7 @@ cpucores(void)
 + 	int name[2] = { CTL_HW, HW_NCPU };
 + 	int cpus;
 + 	size_t cpus_size = sizeof(cpus);
 +-	if (!sysctl(name, &cpus, &cpus_size, NULL, NULL)
 ++	if (sysctl(name, 2, &cpus, &cpus_size, NULL, 0) > 0
 + 			&& cpus_size == sizeof(cpus) && cpus > 0)
 + 		ret = (uint32_t)(cpus);
 + #endif
 diff -rN -u ../xz/patches/patch-ab ./patches/patch-ab
 --- ../xz/patches/patch-ab	1970-01-01 07:00:00.000000000 +0700
 +++ ./patches/patch-ab	2009-09-03 23:41:22.000000000 +0700
 @@ -0,0 +1,13 @@
 +$NetBSD$
 +
 +--- src/common/physmem.h-BAD	2009-08-27 15:37:12.000000000 +0000
 ++++ src/common/physmem.h
 +@@ -104,7 +104,7 @@ physmem(void)
 + 		uint64_t u64;
 + 	} mem;
 + 	size_t mem_ptr_size = sizeof(mem.u64);
 +-	if (!sysctl(name, 2, &mem.u64, &mem_ptr_size, NULL, NULL)) {
 ++	if (sysctl(name, 2, &mem.u64, &mem_ptr_size, NULL, 0) > 0) {
 + 		// IIRC, 64-bit "return value" is possible on some 64-bit
 + 		// BSD systems even with HW_PHYSMEM (instead of HW_PHYSMEM64),
 + 		// so support both.


From: Bernd Ernesti <netbsd@lists.veego.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/41963: archivers/xz compilation errors (NetBSD 4.0 / i386)
Date: Thu, 3 Sep 2009 19:18:21 +0200

 On Thu, Sep 03, 2009 at 05:00:12PM +0000, Robert Elz wrote:
 [..]
 >  But, it turns out that xz is needed in order to build lots of
 >  other packages (at least the fonts/tex-*-doc packages) so the
 >  status of this PR should really have been critical/high ...
 >  (Is there some way to get that altered, other than by e-mailing
 >  to gnats-admin and begging?)

 It just needs someone to do it, which means it is now changed :)

 Bernd

From: Robert Elz <kre@munnari.OZ.AU>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/41963: archivers/xz compilation errors (NetBSD 4.0 / i386) 
Date: Fri, 04 Sep 2009 01:19:39 +0700

     Date:        Thu,  3 Sep 2009 17:20:03 +0000 (UTC)
     From:        Bernd Ernesti <netbsd@lists.veego.de>
     Message-ID:  <20090903172003.A064A63B842@www.NetBSD.org>

   |  It just needs someone to do it, which means it is now changed :)

 Thanks!

 kre

State-Changed-From-To: open->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Fri, 04 Sep 2009 16:57:27 +0000
State-Changed-Why:
Committed, thanks.


From: Thomas Klausner <wiz@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/41963 CVS commit: pkgsrc/archivers/xz
Date: Fri, 4 Sep 2009 16:57:14 +0000

 Module Name:	pkgsrc
 Committed By:	wiz
 Date:		Fri Sep  4 16:57:14 UTC 2009

 Modified Files:
 	pkgsrc/archivers/xz: distinfo
 Added Files:
 	pkgsrc/archivers/xz/patches: patch-aa patch-ab

 Log Message:
 Fix build on NetBSD-4.0/i386. Patches from Robert Elz in PR 41963.
 (Also sent upstream.)


 To generate a diff of this commit:
 cvs rdiff -u -r1.2 -r1.3 pkgsrc/archivers/xz/distinfo
 cvs rdiff -u -r0 -r1.1 pkgsrc/archivers/xz/patches/patch-aa \
     pkgsrc/archivers/xz/patches/patch-ab

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

>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.