Skip to content

_LARGEFILE64_SOURCE redefined in single file library on 32-bit Linux #2443

@indygreg

Description

@indygreg

If I attempt to compile the file file library on 32-bit Linux, I get the following error:

gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Ic-ext -Izstd -I/opt/_internal/cpython-3.9.1/include/python3.9 -c zstd.c -o build/temp.linux-i686-3.9/zstd.o -DZSTD_SINGLE_FILE -DZSTDLIB_VISIBILITY= -DZDICTLIB_VISIBILITY= -DZSTDERRORLIB_VISIBILITY= -fvisibility=hidden -Werror
  In file included from c-ext/python-zstandard.h:21,
                   from zstd.c:19:
  zstd/zstdlib.c:79852: error: "_LARGEFILE64_SOURCE" redefined [-Werror]
  79852 | #  define _LARGEFILE64_SOURCE
        |
  In file included from /usr/include/limits.h:26,
                   from /opt/rh/devtoolset-9/root/usr/lib/gcc/i686-redhat-linux/9/include/limits.h:194,
                   from /opt/rh/devtoolset-9/root/usr/lib/gcc/i686-redhat-linux/9/include/syslimits.h:7,
                   from /opt/rh/devtoolset-9/root/usr/lib/gcc/i686-redhat-linux/9/include/limits.h:34,
                   from /opt/_internal/cpython-3.9.1/include/python3.9/Python.h:11,
                   from c-ext/python-zstandard.h:13,
                   from zstd.c:19:
  /usr/include/features.h:174: note: this is the location of the previous definition
    174 | # define _LARGEFILE64_SOURCE 1
        |
  cc1: all warnings being treated as errors

The faulty code in question appears to be in zdict.c:

/**** start inlining dictBuilder/zdict.c ****/

<snip>

/*-**************************************
*  Compiler Options
****************************************/
/* Unix Large Files support (>4GB) */
#define _FILE_OFFSET_BITS 64
#if (defined(__sun__) && (!defined(__LP64__)))   /* Sun Solaris 32-bits requires specific definitions */
#  define _LARGEFILE_SOURCE
#elif ! defined(__LP64__)                        /* No point defining Large file for 64 bit */
#  define _LARGEFILE64_SOURCE
#endif

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions