Open smileaf419 opened 1 year ago
Can you share more on your building environment ? Thanks :)
I run a self-built LFS-referenced variant. (Sort of experimental toy: https://github.com/smileaf419/spkg) The error was originally found building ares. No cflags are set (an output of ENV can also be found within the bug report there)
Ok, let me try to reproduce and come back to you. Obviously sounds like fseeko/ftello are not detected for some reason.
To provide more context, ares currently builds all C source files, including those from libchdr, with -std=c11. This causes __STRICT_ANSI__
to be defined, and as a result glibc does not define certain POSIX APIs that it will otherwise define if you specify no standard or one of the GNU variants (e.g. -std=gnu11). fseeko/ftello are POSIX APIs, not standard C.
There are many macros supported by glibc that can influence these definitions:
References: https://man7.org/linux/man-pages/man7/feature_test_macros.7.html https://github.com/bminor/glibc/blob/master/include/features.h
For ares, we can work around this by tweaking the flags passed to the compiler, but there's an opportunity to make the following code more robust across varying compilation environments.
There are a couple of issues with this code as it stands:
There are a lot of options for which macros to define, of course. One or more of _POSIX_C_SOURCE
/_XOPEN_SOURCE
/_GNU_SOURCE
/_LARGEFILE_SOURCE
combined with _FILE_OFFSET_BITS
should cover the bases, though. For what it's worth, the GNU libc manual recommends _GNU_SOURCE
, though it is by far the most expansive.
As an aside, none of this seems to be an issue with BSD libc. It defines fseeko/ftello even with -std=c11 and the offsets are always 64-bit. I have not examined other C standard library implementations.
Using: cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release -DWITH_SYSTEM_ZLIB=1 -DCMAKE_C_COMPILER=clang -D CMAKE_C_STANDARD=11 -D CMAKE_C_EXTENSIONS=0
-- The C compiler identification is Clang 16.0.2 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: /usr/bin/clang - skipped -- Detecting C compile features -- Detecting C compile features - done -- Found ZLIB: /lib/libz.so (found version "1.2.13")
-- Configuring done (0.2s) -- Generating done (0.0s) -- Build files have been written to: /var/tmp/spkg/libchdr-master/build [ 4%] Building C object deps/lzma-22.01/CMakeFiles/lzma.dir/src/Alloc.c.o [ 8%] Building C object deps/lzma-22.01/CMakeFiles/lzma.dir/src/Bra86.c.o [ 12%] Building C object deps/lzma-22.01/CMakeFiles/lzma.dir/src/BraIA64.c.o [ 16%] Building C object deps/lzma-22.01/CMakeFiles/lzma.dir/src/CpuArch.c.o [ 20%] Building C object deps/lzma-22.01/CMakeFiles/lzma.dir/src/Delta.c.o [ 24%] Building C object deps/lzma-22.01/CMakeFiles/lzma.dir/src/LzFind.c.o [ 28%] Building C object deps/lzma-22.01/CMakeFiles/lzma.dir/src/Lzma86Dec.c.o [ 32%] Building C object deps/lzma-22.01/CMakeFiles/lzma.dir/src/LzmaDec.c.o [ 36%] Building C object deps/lzma-22.01/CMakeFiles/lzma.dir/src/LzmaEnc.c.o [ 40%] Building C object deps/lzma-22.01/CMakeFiles/lzma.dir/src/Sort.c.o [ 44%] Linking C static library liblzma.a [ 44%] Built target lzma [ 48%] Building C object CMakeFiles/chdr-static.dir/src/libchdr_bitstream.c.o [ 52%] Building C object CMakeFiles/chdr-static.dir/src/libchdr_cdrom.c.o [ 56%] Building C object CMakeFiles/chdr-static.dir/src/libchdr_chd.c.o /var/tmp/spkg/libchdr-master/src/libchdr_chd.c:814:10: warning: implicit conversion from enumeration type 'enum huffman_error' to different enumeration type 'chd_error' (aka 'enum _chd_error') [-Wenum-conversion] return err;