pkgsrc-Bugs archive

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

Re: pkg/41963: archivers/xz compilation errors (NetBSD 4.0 / i386)



The following reply was made to PR pkg/41963; it has been noted by GNATS.

From: Robert Elz <kre%munnari.OZ.AU@localhost>
To: gnats-bugs%NetBSD.org@localhost
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.
 
 


Home | Main Index | Thread Index | Old Index