On Tue, Jan 26, 2021 at 12:36:47AM +0100, Klemens Nanni wrote:
> - Add --alias/-A option to set .zip name for stdin input
> - Add --comment/-C option to add comment in .gz or .zip
> - Fix a bug that misidentified a multi-entry .zip
> - Fix a bug that did not emit double syncs for -i -p 1
> - Fix a bug in yarn that could try to access freed data
> - Do not delete multi-entry .zip files when extracting
> - Do not reject .zip entries with bit 11 set
> - Avoid a possible threads lock-order inversion
> - Ignore trailing junk after a gzip stream by default
> 
> Besides the routine update, I had to amend CFLAGS to fix the following
> warning:
> 
>       cc -O2 -pipe   -Wall -Wextra  -c pigz.c
>       pigz.c:4543:9: warning: implicit declaration of function 'pledge' is 
> invalid in C99 [-Wimplicit-function-declaration]
>           if (pledge("stdio rpath wpath cpath fattr chown", NULL) == -1) {
>               ^
> 
> That's because of this change in 2.5:
> 
> --- pig.c     Mon Jan 25 23:26:18 2021
> +++ pig.c     Mon Jan 25 23:42:30 2021
> @@ -321,8 +330,10 @@
>     buffers to about the same number.
>   */
>  
> -// Use large file functions if available.
> -#define _FILE_OFFSET_BITS 64
> +// Portability defines.
> +#define _FILE_OFFSET_BITS 64            // Use large file functions
> +#define _LARGE_FILES                    // Same thing for AIX
> +#define _POSIX_C_SOURCE 200809L         // For MinGW
>  
>  // Included headers and what is expected from each.
>  #include <stdio.h>      // fflush(), fprintf(), fputs(), getchar(), putc(),
> 
> 
> _POSIX_C_SOURCE makes <sys/cdefs.h> define __POSIX_VISIBLE and, because
> _BSD_SOURCE is not defined, therefore also define __BSD_VISIBLE 0.
> 
> <unistd.h> only protoypes pledge(2) under __BSD_VISIBLE, so fix the
> warning by defining _BSD_SOURCE such that <sys/cdefs.h> defines
> __BSD_VISIBLE 1.

daniel@ suggested putting `+#define _POSIX_C_SOURCE 200809L' under
`ifndef __OpenBSD__' which does seem a bit more straight forward.

> @@ -22,6 +21,10 @@ MASTER_SITES =     https://zlib.net/pigz/
>  
>  MAKE_FLAGS = CC="${CC}" \
>               CFLAGS="${CFLAGS} -Wall -Wextra"
> +
> +# pigz.c 2.5 defines _POSIX_C_SOURCE which prevents <unistd.h> from
> +# prototyping pledge(2), override the define
> +CFLAGS +=    -D_BSD_SOURCE
>  
>  ALL_TARGET = pigz

We could also add the following below the include and try to upstream
the overall patch for pledge(2) support:

        #ifdef __OpenBSD__
        # define _BSD_SOURCE    /* prototype pledge(2) */
        #endif

For now, here's what I think is the least intrusive version, i.e.
practically reverting the define for everything but MinGW such that this
hunk in itself could be upstreamed regardless of OpenBSD/pledge(2).

Feedback? OK?


Index: Makefile
===================================================================
RCS file: /cvs/ports/archivers/pigz/Makefile,v
retrieving revision 1.8
diff -u -p -r1.8 Makefile
--- Makefile    12 Jul 2019 20:43:29 -0000      1.8
+++ Makefile    31 Jan 2021 00:02:24 -0000
@@ -5,8 +5,7 @@ NOT_FOR_ARCHS=  ${GCC3_ARCHS}
 
 COMMENT =      parallel implementation of gzip utilizing multiple cores
 
-DISTNAME =     pigz-2.4
-REVISION =     0
+DISTNAME =     pigz-2.5
 CATEGORIES =   archivers
 HOMEPAGE =     https://zlib.net/pigz/
 
Index: distinfo
===================================================================
RCS file: /cvs/ports/archivers/pigz/distinfo,v
retrieving revision 1.4
diff -u -p -r1.4 distinfo
--- distinfo    25 Jan 2018 10:34:49 -0000      1.4
+++ distinfo    25 Jan 2021 22:26:27 -0000
@@ -1,2 +1,2 @@
-SHA256 (pigz-2.4.tar.gz) = pPgWIip7Qmm9IyaAWQtXnMxyWR8bta2vzXIIynfhT3M=
-SIZE (pigz-2.4.tar.gz) = 98234
+SHA256 (pigz-2.5.tar.gz) = oAZkVwLKrsrOYzqJ61w3FIK0SkjQTzTgBY4rhdddTDY=
+SIZE (pigz-2.5.tar.gz) = 106438
Index: patches/patch-pigz_c
===================================================================
RCS file: /cvs/ports/archivers/pigz/patches/patch-pigz_c,v
retrieving revision 1.1
diff -u -p -r1.1 patch-pigz_c
--- patches/patch-pigz_c        10 Jul 2018 13:32:44 -0000      1.1
+++ patches/patch-pigz_c        31 Jan 2021 00:15:20 -0000
@@ -1,9 +1,26 @@
 $OpenBSD: patch-pigz_c,v 1.1 2018/07/10 13:32:44 kn Exp $
 
+Revert an unconditional define of _POSIX_C_SOURCE introduced in pigz 2.5
+which causes <sys/cdefs.h> to define __POSIX_VISIBLE and therefore
+(because _BSD_SOURCE is not defined) also define __BSD_VISIBLE 0
+which prevents <unistd.h> from prototyping pledge(2).
+
+Use pledge.
+
 Index: pigz.c
 --- pigz.c.orig
 +++ pigz.c
-@@ -4307,6 +4307,11 @@ int main(int argc, char **argv) {
+@@ -333,7 +333,9 @@
+ // Portability defines.
+ #define _FILE_OFFSET_BITS 64            // Use large file functions
+ #define _LARGE_FILES                    // Same thing for AIX
++#ifdef __MINGW32__
+ #define _POSIX_C_SOURCE 200809L         // For MinGW
++#endif
+ 
+ // Included headers and what is expected from each.
+ #include <stdio.h>      // fflush(), fprintf(), fputs(), getchar(), putc(),
+@@ -4540,6 +4542,11 @@ int main(int argc, char **argv) {
      char *opts, *p;                 // environment default options, marker
      ball_t err;                     // error information from throw()
  
@@ -15,7 +32,7 @@ Index: pigz.c
      g.ret = 0;
      try {
          // initialize globals
-@@ -4408,6 +4413,12 @@ int main(int argc, char **argv) {
+@@ -4646,6 +4653,12 @@ int main(int argc, char **argv) {
              else if (option(argv[n]))   // process argument
                  argv[n] = NULL;         // remove if option
          option(NULL);                   // check for missing parameter

Reply via email to