Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
indygreg opened this issue Dec 26, 2020 · 0 comments · Fixed by #2444
Closed

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

indygreg opened this issue Dec 26, 2020 · 0 comments · Fixed by #2444

Comments

@indygreg
Copy link
Contributor

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
indygreg added a commit to indygreg/zstd that referenced this issue Dec 26, 2020
This ensures the symbols aren't redefined, which would result in a compiler
error.

I was getting redefined symbols for _LARGEFILE64_SOURCE when building for
32-bit x86 Linux on an older CentOS release in a CI environment. With this
change, I'm able to compile the single file library in this environment.

Closes facebook#2443.
indygreg added a commit to indygreg/python-zstandard that referenced this issue Dec 26, 2020
This works around a redefinition error on 32-bit Linux. See
facebook/zstd#2443.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant