Subject: Re: bug#57337: [PATCH 0/2] Add docxbox

From: Ludovic Courtès <[email-masked]>
Date: Thu, 08 Sep 2022 14:46:02 +0200

Wiktor Żelazny <[email-masked]> skribis:

> From: Wiktor Żelazny <[email-masked]>
>
> * gnu/packages/cpp.scm (miniz-cpp): New variable.

[...]

> +++ b/gnu/packages/patches/miniz-cpp-fixed-duplicated-symbols.patch
> @@ -0,0 +1,2734 @@
> +commit 64f974213ac16f78c008bd148c8a2a07e902f148
> +Author: Kay Stenschke <[email-masked]>
> +Date:   Mon Apr 27 12:13:34 2020 +0200
> +
> +    Fixed duplicated symbols
> +    
> +    Using miniz-cpp from multiple translation units caused linker error.
> +    Done: marked declarations as static for correct linking from multiple translation units.
> +
> +diff --git a/zip_file.hpp b/zip_file.hpp
> +index c324f70..3aff33c 100644
> +--- a/zip_file.hpp
> ++++ b/zip_file.hpp
> +@@ -226,12 +226,12 @@
> + //#define MINIZ_NO_MALLOC
> + 
> + #if defined(__TINYC__) && (defined(__linux) || defined(__linux__))
> +-  // TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux
> ++// TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux
> +   #define MINIZ_NO_TIME
> + #endif
> + 
> + #if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS)
> +-  #include <time.h>
> ++#include <time.h>
> + #endif
> + 
> + #if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__)
> +@@ -272,15 +272,15 @@ extern "C" {
> + typedef unsigned long mz_ulong;
> + 
> + // mz_free() internally uses the MZ_FREE() macro (which by default calls free() unless you've modified the MZ_MALLOC macro) to release a block allocated from the heap.
> +-void mz_free(void *p);
> ++static void mz_free(void *p);
> + 
> + #define MZ_ADLER32_INIT (1)
> + // mz_adler32() returns the initial adler-32 value to use when called with ptr==NULL.
> +-mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len);
> ++static mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len);
> + 
> + #define MZ_CRC32_INIT (0)
> + // mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL.
> +-mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
> ++static mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
> + 
> + // Compression strategies.
> + enum { MZ_DEFAULT_STRATEGY = 0, MZ_FILTERED = 1, MZ_HUFFMAN_ONLY = 2, MZ_RLE = 3, MZ_FIXED = 4 };
> +@@ -343,7 +343,7 @@ typedef struct mz_stream_s
> + typedef mz_stream *mz_streamp;
> + 
> + // Returns the version string of miniz.c.
> +-const char *mz_version(void);
> ++static const char *mz_version(void);
> + 
> + // mz_deflateInit() initializes a compressor with default options:
> + // Parameters:

[...]

> ++#define Z_NO_FLUSH            MZ_NO_FLUSH
> ++#define Z_PARTIAL_FLUSH       MZ_PARTIAL_FLUSH
> ++#define Z_SYNC_FLUSH          MZ_SYNC_FLUSH
> ++#define Z_FULL_FLUSH          MZ_FULL_FLUSH
> ++#define Z_FINISH              MZ_FINISH
> ++#define Z_BLOCK               MZ_BLOCK
> ++#define Z_OK                  MZ_OK
> ++#define Z_STREAM_END          MZ_STREAM_END
> ++#define Z_NEED_DICT           MZ_NEED_DICT
> ++#define Z_ERRNO               MZ_ERRNO
> ++#define Z_STREAM_ERROR        MZ_STREAM_ERROR
> ++#define Z_DATA_ERROR          MZ_DATA_ERROR
> ++#define Z_MEM_ERROR           MZ_MEM_ERROR
> ++#define Z_BUF_ERROR           MZ_BUF_ERROR
> ++#define Z_VERSION_ERROR       MZ_VERSION_ERROR
> ++#define Z_PARAM_ERROR         MZ_PARAM_ERROR
> ++#define Z_NO_COMPRESSION      MZ_NO_COMPRESSION
> ++#define Z_BEST_SPEED          MZ_BEST_SPEED
> ++#define Z_BEST_COMPRESSION    MZ_BEST_COMPRESSION
> ++#define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION
> ++#define Z_DEFAULT_STRATEGY    MZ_DEFAULT_STRATEGY
> ++#define Z_FILTERED            MZ_FILTERED
> ++#define Z_HUFFMAN_ONLY        MZ_HUFFMAN_ONLY
> ++#define Z_RLE                 MZ_RLE
> ++#define Z_FIXED               MZ_FIXED
> ++#define Z_DEFLATED            MZ_DEFLATED
> ++#define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS
> ++#define alloc_func            mz_alloc_func
> ++#define free_func             mz_free_func
> ++#define internal_state        mz_internal_state
> ++#define z_stream              mz_stream
> ++#define deflateInit           mz_deflateInit
> ++#define deflateInit2          mz_deflateInit2
> ++#define deflateReset          mz_deflateReset
> ++#define deflate               mz_deflate
> ++#define deflateEnd            mz_deflateEnd
> ++#define deflateBound          mz_deflateBound
> ++#define compress              mz_compress
> ++#define compress2             mz_compress2
> ++#define compressBound         mz_compressBound
> ++#define inflateInit           mz_inflateInit
> ++#define inflateInit2          mz_inflateInit2
> ++#define inflate               mz_inflate
> ++#define inflateEnd            mz_inflateEnd
> ++#define uncompress            mz_uncompress
> ++#define crc32                 mz_crc32
> ++#define adler32               mz_adler32

It would seem that the code uses a bundled copy of zlib, which is why it
needs to rename things.  Do I get it right?

If so, it would be best to remove the bundled zlib and instead add zlib
as an input.

Thanks,
Ludo’.