On 5/15/19 2:30 AM, Osipov, Michael wrote: > > I don't know how to solve this differently for now, but to disable > include_next in configure.ac if the compiler is aCC.
Better yet, let's stop using the -include option as it's not portable. The -include option was used only to attempt to keep b2sum.c identical with upstream, but we've already given up on that for other reasons, so I installed the attached patches to fix this (the first patch drops -include, the second patch lessens changes from upstream).
>From 05412088900635a5965c0b5d2dde875387d63f0b Mon Sep 17 00:00:00 2001 From: Paul Eggert <egg...@cs.ucla.edu> Date: Wed, 15 May 2019 12:42:23 -0700 Subject: [PATCH 1/2] b2sum: port to HP-UX aCC MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Its support for the -include option is flaky. Problem reported by Michael Osipov (Bug#35650). Plus, we could run into other compilers that donât support any option like -include. Change the code so that -include is not needed. Although this causes us to depart from the upstream version, weâre already doing that for other reasons. * configure.ac (USE_XLC_INCLUDE): Remove, as thereâs no guarantee a compiler will support something like -include. * src/blake2/b2sum.c [HAVE_CONFIG_H]: Include <config.h>. * src/local.mk (src_b2sum_CPPFLAGS): Add -DHAVE_CONFIG_H. Do not use -include or a substitute. --- configure.ac | 12 ------------ src/blake2/b2sum.c | 4 ++++ src/local.mk | 9 +-------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/configure.ac b/configure.ac index f97ff862e..781a305e2 100644 --- a/configure.ac +++ b/configure.ac @@ -508,18 +508,6 @@ CFLAGS=$ac_save_CFLAGS LDFLAGS=$ac_save_LDFLAGS ac_c_werror_flag=$cu_save_c_werror_flag -# Detect when using xlc to determine whether to use -qinclude= -AC_CACHE_CHECK([whether the system supports xlc include], [utils_cv_xlc], - [AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([[ - #ifndef __xlc__ - #error "not xlc" - #endif - ]])], - [utils_cv_xlc=yes], - [utils_cv_xlc=no])]) -AM_CONDITIONAL([USE_XLC_INCLUDE], [test "$utils_cv_xlc" = yes]) - ############################################################################ dnl Autogenerated by the 'gen-lists-of-programs.sh' auxiliary script. diff --git a/src/blake2/b2sum.c b/src/blake2/b2sum.c index 5df2046f8..5cb25b86a 100644 --- a/src/blake2/b2sum.c +++ b/src/blake2/b2sum.c @@ -13,6 +13,10 @@ https://blake2.net. */ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/src/local.mk b/src/local.mk index a69d40521..763c8a01c 100644 --- a/src/local.mk +++ b/src/local.mk @@ -399,14 +399,7 @@ src_sha384sum_SOURCES = src/md5sum.c src_sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS) src_sha512sum_SOURCES = src/md5sum.c src_sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS) -# Include the file on the command line to avoid modifying -# the blake2 upstream source -if USE_XLC_INCLUDE -src_b2sum_CPPFLAGS = -qinclude=config.h -else -src_b2sum_CPPFLAGS = -include config.h -endif -src_b2sum_CPPFLAGS += -DHASH_ALGO_BLAKE2=1 $(AM_CPPFLAGS) +src_b2sum_CPPFLAGS = -DHASH_ALGO_BLAKE2=1 -DHAVE_CONFIG_H $(AM_CPPFLAGS) src_b2sum_SOURCES = src/md5sum.c \ src/blake2/blake2.h src/blake2/blake2-impl.h \ src/blake2/blake2b-ref.c \ -- 2.21.0
>From 4a67a8f633c7f1b7eb12279be90326ca6062389f Mon Sep 17 00:00:00 2001 From: Paul Eggert <egg...@cs.ucla.edu> Date: Wed, 15 May 2019 12:57:53 -0700 Subject: [PATCH 2/2] b2sum: sync better with upstream * src/blake2/b2sum.c: Reorder source code to minimize diffs from: https://github.com/BLAKE2/BLAKE2/blob/master/b2sum/b2sum.c --- src/blake2/b2sum.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/blake2/b2sum.c b/src/blake2/b2sum.c index 5cb25b86a..9f1108137 100644 --- a/src/blake2/b2sum.c +++ b/src/blake2/b2sum.c @@ -30,18 +30,19 @@ #include "blake2.h" +#if 0 /* This will help compatibility with coreutils */ -int blake2b_stream( FILE *stream, void *resstream, size_t outbytes ) +int blake2s_stream( FILE *stream, void *resstream, size_t outbytes ) { int ret = -1; size_t sum, n; - blake2b_state S[1]; + blake2s_state S[1]; static const size_t buffer_length = 32768; uint8_t *buffer = ( uint8_t * )malloc( buffer_length ); if( !buffer ) return -1; - blake2b_init( S, outbytes ); + blake2s_init( S, outbytes ); while( 1 ) { @@ -67,32 +68,32 @@ int blake2b_stream( FILE *stream, void *resstream, size_t outbytes ) goto final_process; } - blake2b_update( S, buffer, buffer_length ); + blake2s_update( S, buffer, buffer_length ); } final_process:; - if( sum > 0 ) blake2b_update( S, buffer, sum ); + if( sum > 0 ) blake2s_update( S, buffer, sum ); - blake2b_final( S, resstream, outbytes ); + blake2s_final( S, resstream, outbytes ); ret = 0; cleanup_buffer: free( buffer ); return ret; } +#endif -#if 0 -int blake2s_stream( FILE *stream, void *resstream, size_t outbytes ) +int blake2b_stream( FILE *stream, void *resstream, size_t outbytes ) { int ret = -1; size_t sum, n; - blake2s_state S[1]; + blake2b_state S[1]; static const size_t buffer_length = 32768; uint8_t *buffer = ( uint8_t * )malloc( buffer_length ); if( !buffer ) return -1; - blake2s_init( S, outbytes ); + blake2b_init( S, outbytes ); while( 1 ) { @@ -118,20 +119,21 @@ int blake2s_stream( FILE *stream, void *resstream, size_t outbytes ) goto final_process; } - blake2s_update( S, buffer, buffer_length ); + blake2b_update( S, buffer, buffer_length ); } final_process:; - if( sum > 0 ) blake2s_update( S, buffer, sum ); + if( sum > 0 ) blake2b_update( S, buffer, sum ); - blake2s_final( S, resstream, outbytes ); + blake2b_final( S, resstream, outbytes ); ret = 0; cleanup_buffer: free( buffer ); return ret; } +#if 0 int blake2sp_stream( FILE *stream, void *resstream, size_t outbytes ) { @@ -253,6 +255,7 @@ static void usage( char **argv, int errcode ) exit( errcode ); } + int main( int argc, char **argv ) { blake2fn blake2_stream = blake2b_stream; -- 2.21.0