Hi,
I'm having some troubles compiling zstd and the issue appears to revolve around the lack of "__USE_MISC" being declared.
In glibc they declare __USE_MISC if there is defined __DEFAULT_SOURCE, see features.h:369 (ish):
#if defined _DEFAULT_SOURCE # define __USE_MISC 1 #endif
However, we don't declare this in uclibc_ng and seem to have some quite different handling around __DEFAULT_SOURCE
I have zero idea what is supposed to be happening with these macros, so I don't feel qualified to suggest a solution, but it appears to cause problems for at least openrc and zstd now. Could someone please review these macros and if appropriate for uclibc_ng, please also define __USE_MISC for the case of __DEFAULT_SOURCE in features.h
Thanks
Ed W
Cancel the previous... I must have been staring at the wrong thing. Cause is TOTALLY different
OK, to recap:
Compiling zstd-1.4.5 using uclibc-ng, will trigger an error in programs/util.c which basically indicates that the section "struct stat" in bits/stat.h relating to the definitions of "st_mtim" are hidden behind "#define __USE_MISC"
I have prepared a patch that I'm about to send upstream to zstd which will add a declare for __USE_MISC and this allows compilation...
BUT...
The underlying reason appears to be that in glibc, the relevant section of <bits/stat.h> reads as follows
#ifdef __USE_XOPEN2K8 /* Nanosecond resolution timestamps are stored in a format equivalent to 'struct timespec'. This is the type used whenever possible but the Unix namespace rules do not allow the identifier 'timespec' to appear in the <sys/stat.h> header. Therefore we have to handle the use of this header in strictly standard-compliant sources special. */ struct timespec st_atim; /* Time of last access. */ struct timespec st_mtim; /* Time of last modification. */ struct timespec st_ctim; /* Time of last status change. */ # define st_atime st_atim.tv_sec /* Backward compatibility. */ # define st_mtime st_mtim.tv_sec # define st_ctime st_ctim.tv_sec #else
So it's hidden behind "#ifdef __USE_XOPEN2K8", whereas in uclibc_ng we have:
#ifdef __USE_MISC /* Nanosecond resolution timestamps are stored in a format equivalent to 'struct timespec'. This is the type used whenever possible but the Unix namespace rules do not allow the identifier 'timespec' to appear in the <sys/stat.h> header. Therefore we have to handle the use of this header in strictly standard-compliant sources special. */ struct timespec st_atim; /* Time of last access. */ struct timespec st_mtim; /* Time of last modification. */ struct timespec st_ctim; /* Time of last status change. */ # define st_atime st_atim.tv_sec /* Backward compatibility. */ # define st_mtime st_mtim.tv_sec # define st_ctime st_ctim.tv_sec #else
Now, I have no idea what is supposed to happen, but in glibc, this is all turned on by:
#if defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE - 0) >= 200809L # define __USE_XOPEN2K8 1
We have the same stanzas in uclibc_ng, but they don't have the same effects, nor do they define __USE_MISC
I believe that the solution is the following patch? Could someone more knowledgeable than me check this and make an appropriate change please?
--- a/bits/stat.h 2020-06-16 14:10:25.789364391 +0000 +++ b/bits/stat.h 2020-07-06 15:34:49.221988579 +0000 @@ -61,7 +61,7 @@ #else __blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */ #endif -#ifdef __USE_MISC +#ifdef __USE_XOPEN2K8 /* Nanosecond resolution timestamps are stored in a format equivalent to 'struct timespec'. This is the type used whenever possible but the Unix namespace rules do not allow the @@ -107,7 +107,7 @@ __blksize_t st_blksize; /* Optimal block size for I/O. */
__blkcnt64_t st_blocks; /* Number 512-byte blocks allocated. */ -#ifdef __USE_MISC +#ifdef __USE_XOPEN2K8 /* Nanosecond resolution timestamps are stored in a format equivalent to 'struct timespec'. This is the type used whenever possible but the Unix namespace rules do not allow the
On 06/07/2020 15:40, Ed W wrote:
Hi,
I'm having some troubles compiling zstd and the issue appears to revolve around the lack of "__USE_MISC" being declared.
In glibc they declare __USE_MISC if there is defined __DEFAULT_SOURCE, see features.h:369 (ish):
#if defined _DEFAULT_SOURCE # define __USE_MISC 1 #endif
However, we don't declare this in uclibc_ng and seem to have some quite different handling around __DEFAULT_SOURCE
I have zero idea what is supposed to be happening with these macros, so I don't feel qualified to suggest a solution, but it appears to cause problems for at least openrc and zstd now. Could someone please review these macros and if appropriate for uclibc_ng, please also define __USE_MISC for the case of __DEFAULT_SOURCE in features.h
Thanks
Ed W
On 06/07/2020 16:37, Ed W wrote:
Cancel the previous... I must have been staring at the wrong thing. Cause is TOTALLY different
OK, to recap:
Compiling zstd-1.4.5 using uclibc-ng, will trigger an error in programs/util.c which basically indicates that the section "struct stat" in bits/stat.h relating to the definitions of "st_mtim" are hidden behind "#define __USE_MISC"
I have prepared a patch that I'm about to send upstream to zstd which will add a declare for __USE_MISC and this allows compilation...
Link to upstream problem report relating to this:
https://github.com/facebook/zstd/issues/1872
Regards
Ed W