Bug 27042 - [alpha] anonymous union in struct stat confuses detection logic
Summary: [alpha] anonymous union in struct stat confuses detection logic
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: 2.33
Assignee: Not yet assigned to anyone
URL: https://sourceware.org/pipermail/libc...
Keywords:
Depends on:
Blocks:
 
Reported: 2020-12-09 16:18 UTC by Matt Turner
Modified: 2020-12-21 12:20 UTC (History)
2 users (show)

See Also:
Host: alpha*-*-linux*
Target:
Build:
Last reconfirmed:


Attachments
dev-libs/glib-2.66.3 build failure (823 bytes, application/x-perl)
2020-12-09 16:18 UTC, Matt Turner
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Turner 2020-12-09 16:18:07 UTC
Created attachment 13030 [details]
dev-libs/glib-2.66.3 build failure

glibc's bits/stat.h header tricks the configure feature detection in at least dev-libs/glib and app-arch/zstd (see bug 735818).

The issue is

#  define __ST_TIME(X)                         \
       __extension__ union {                   \
           struct timespec st_##X##tim;        \
           struct {                            \
               __time_t st_##X##time;          \
               unsigned long st_##X##timensec; \
           };                                  \
       }

... a neat trick using an anonymous union to provide st_mtimensec, et al.

glib's configuration results look like this on amd64:

Checking if "statx() test" compiles: YES 
Header <locale.h> has symbol "LC_MESSAGES" : YES 
Checking whether type "struct stat" has member "st_mtimensec" : NO 
Checking whether type "struct stat" has member "st_mtim.tv_nsec" : YES 
Checking whether type "struct stat" has member "st_atimensec" : NO 
Checking whether type "struct stat" has member "st_atim.tv_nsec" : YES 
Checking whether type "struct stat" has member "st_ctimensec" : NO 
Checking whether type "struct stat" has member "st_ctim.tv_nsec" : YES 

but like this on alpha:

Checking if "statx() test" compiles: YES 
Header <locale.h> has symbol "LC_MESSAGES" : YES 
Checking whether type "struct stat" has member "st_mtimensec" : YES 
Checking whether type "struct stat" has member "st_mtim.tv_nsec" : YES 
Checking whether type "struct stat" has member "st_atimensec" : YES 
Checking whether type "struct stat" has member "st_atim.tv_nsec" : YES 
Checking whether type "struct stat" has member "st_ctimensec" : YES 
Checking whether type "struct stat" has member "st_ctim.tv_nsec" : YES 

which ultimately causes the build to compile a path that doesn't work. (Attached is the build failure snippet)


See downstream bug reports
https://bugs.gentoo.org/759001
https://bugs.gentoo.org/735818
Comment 1 Andreas Schwab 2020-12-09 16:52:21 UTC
The existence of the st_?time macros is an implementation detail.
Comment 2 Matt Turner 2020-12-09 17:53:59 UTC
Please don't do that.
Comment 3 Adhemerval Zanella 2020-12-21 12:20:40 UTC
Fixed on 2.33.