libc: decide xstatconv by the headers, not by a kconfig flag
nds32 on the mainline asm-generic ABI, built against linux-3.4 headers,
does not link:
undefined reference to `__xstat32_conv'
The stat wrappers choose their syscall path from the headers (#ifdef
__NR_fstat / __NR_statx / ...), but xstatconv.c -- which holds the
kernel-stat to user-stat conversion those wrappers call on the old
__NR_fstat path -- was compiled only where the kconfig flag
ARCH_HAS_DEPRECATED_SYSCALLS was set. nds32 does not set it, while
linux-3.4 still has __NR_fstat, so the wrapper took the conversion path
and the converter was never built.
Compile the file unconditionally and let its contents decide, in the same
terms the wrappers use:
#if defined(__ARCH_HAS_DEPRECATED_SYSCALLS__) \
|| (defined(__NR_fstat) \
&& !(__WORDSIZE == 64 && defined(__NR_newfstatat)))
The first term keeps the classic arches exactly as they were, the second
covers the case above. The exclusion is needed because 64-bit
asm-generic does define __NR_fstat, but riscv64, aarch64, kvx and tile
take the direct newfstatat path, never call the converters, and have no
kernel_stat in their bits/kernel_stat.h -- compiling the body there
fails. The prototypes in xstatconv.h carry the same guard.
What is left is an empty translation unit wherever the converters are
unreachable, and the linker drops it: the same set as before, plus the
nds32-on-3.4 case that needs it.
Most of the directory already works this way: compiled unconditionally,
gating itself on __NR_*, so the answer follows the same headers the
wrappers were built against. xstatconv.c was the odd one out, selected
by a kconfig flag instead, and a flag is what can disagree with them.
Signed-off-by: Ramin Moussavi <lordrasmus@gmail.com>