Building a allyesconfig kernel fails because macros are being redefined
Subsystems (2)
My current git HEAD is at 3a8660878839faadb4f1a6dd72c3179c1df56787
If I do :
make mrproper
make allyesconfig
make -j 33it eventually fails with :
...
INSTALL libsubcmd_headers
CALL scripts/checksyscalls.sh CC [U] samples/vfs/test-statx CC [U] samples/watch_queue/watch_test
In file included from samples/vfs/test-statx.c:23:usr/include/linux/fcntl.h:160:9: error: ‘AT_RENAME_NOREPLACE’ redefined [-Werror]
160 | #define AT_RENAME_NOREPLACE 0x0001
| ^~~~~~~~~~~~~~~~~~~
In file included from samples/vfs/test-statx.c:13:/usr/include/stdio.h:171:10: note: this is the location of the previous definition
171 | # define AT_RENAME_NOREPLACE RENAME_NOREPLACE
| ^~~~~~~~~~~~~~~~~~~
usr/include/linux/fcntl.h:161:9: error: ‘AT_RENAME_EXCHANGE’ redefined [-Werror]
161 | #define AT_RENAME_EXCHANGE 0x0002
| ^~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:173:10: note: this is the location of the
previous definition
173 | # define AT_RENAME_EXCHANGE RENAME_EXCHANGE
| ^~~~~~~~~~~~~~~~~~
usr/include/linux/fcntl.h:162:9: error: ‘AT_RENAME_WHITEOUT’ redefined [-Werror]
162 | #define AT_RENAME_WHITEOUT 0x0004
| ^~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:175:10: note: this is the location of the
previous definition
175 | # define AT_RENAME_WHITEOUT RENAME_WHITEOUT
| ^~~~~~~~~~~~~~~~~~In file included from usr/include/linux/watch_queue.h:6,
from samples/watch_queue/watch_test.c:19:usr/include/linux/fcntl.h:160:9: error: ‘AT_RENAME_NOREPLACE’ redefined [-Werror]
160 | #define AT_RENAME_NOREPLACE 0x0001
| ^~~~~~~~~~~~~~~~~~~
In file included from samples/watch_queue/watch_test.c:11:/usr/include/stdio.h:171:10: note: this is the location of the previous definition
171 | # define AT_RENAME_NOREPLACE RENAME_NOREPLACE
| ^~~~~~~~~~~~~~~~~~~
usr/include/linux/fcntl.h:161:9: error: ‘AT_RENAME_EXCHANGE’ redefined [-Werror]
161 | #define AT_RENAME_EXCHANGE 0x0002
| ^~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:173:10: note: this is the location of the
previous definition
173 | # define AT_RENAME_EXCHANGE RENAME_EXCHANGE
| ^~~~~~~~~~~~~~~~~~
usr/include/linux/fcntl.h:162:9: error: ‘AT_RENAME_WHITEOUT’ redefined [-Werror]
162 | #define AT_RENAME_WHITEOUT 0x0004
| ^~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:175:10: note: this is the location of the
previous definition
175 | # define AT_RENAME_WHITEOUT RENAME_WHITEOUT
| ^~~~~~~~~~~~~~~~~~cc1: all warnings being treated as errors
make[4]: *** [scripts/Makefile.userprogs:29:samples/watch_queue/watch_test] Error 1
make[3]: *** [scripts/Makefile.build:556: samples/watch_queue] Error 2 make[3]: *** Waiting for unfinished jobs....
cc1: all warnings being treated as errors
make[4]: *** [scripts/Makefile.userprogs:29: samples/vfs/test-statx] Error 1 make[3]: *** [scripts/Makefile.build:556: samples/vfs] Error 2 make[2]: *** [scripts/Makefile.build:556: samples] Error 2 make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/home/jj/src/linux/Makefile:2010: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
I haven't looked into fixing it (yet), just wanted to let you all know :-)
Kind regards
Jesper Juhl
Quoted 22 lines · Jesper Juhl
My current git HEAD is at
3a8660878839faadb4f1a6dd72c3179c1df56787If I do :
make mrproper make allyesconfig make -j 33it eventually fails with :
...
INSTALLlibsubcmd_headersCALL scripts/checksyscalls.sh CC [U] samples/vfs/test-statx CC [U] samples/watch_queue/watch_testIn file included from
samples/vfs/test-statx.c:23:usr/include/linux/fcntl.h:160:9: error: ‘AT_RENAME_NOREPLACE’ redefined [-Werror]
160 | #defineAT_RENAME_NOREPLACE0x0001| ^~~~~~~~~~~~~~~~~~~In file included from
samples/vfs/test-statx.c:13:/usr/include/stdio.h:171:10: note: this is the location of the previous definition
171 | # defineAT_RENAME_NOREPLACERENAME_NOREPLACE
Quoted 15 lines
| ^~~~~~~~~~~~~~~~~~~
usr/include/linux/fcntl.h:161:9: error: ‘AT_RENAME_EXCHANGE’ redefined [-Werror]
161 | #define AT_RENAME_EXCHANGE 0x0002
| ^~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:173:10: note: this is the location of the
previous definition
173 | # define AT_RENAME_EXCHANGE RENAME_EXCHANGE
| ^~~~~~~~~~~~~~~~~~
usr/include/linux/fcntl.h:162:9: error: ‘AT_RENAME_WHITEOUT’ redefined [-Werror]
162 | #define AT_RENAME_WHITEOUT 0x0004
| ^~~~~~~~~~~~~~~~~~
/usr/include/stdio.h:175:10: note: this is the location of the
previous definition
175 | # define AT_RENAME_WHITEOUT RENAME_WHITEOUT
| ^~~~~~~~~~~~~~~~~~This is a bug in glibc:
https://inbox.sourceware.org/libc-alpha/20250823052706.GA4056405@ax162/
https://sourceware.org/git?p=glibc.git;a=commit;h=1166170d95863e5a6f8121a5ca9d97713f524f49
Cheers,
Nathan
cover fix AT_RENAME_* redefinitions with glibc < 2.43
In reply to Jesper JuhlLKML reports show that allyesconfig currently fails with glibc 2.42 because both <stdio.h> and <linux/fcntl.h> define the AT_RENAME_* macros. A follow-up pointed to glibc commit `1166170d9586 ("libio:
Define AT_RENAME_* with the same tokens as Linux"), which will first appear in glibc 2.43. Until that release lands in common distributions, upstream kernels still build against glibc versions that redeclare the macros and fail under -Werror`.
This series is a small, revertable workaround so developers on Fedora 43 (glibc 2.42) and other distributions with glibc < 2.43 can keep building the samples. The
first patch only emits the AT_RENAME_* aliases when libc does not do so already, and the second patch undefines any libc-provided macros before including <linux/fcntl.h> in the VFS sample. Once glibc 2.43+ is ubiquitous (or if we decide to remove the aliases entirely), these changes can be dropped.
Masaharu Noguchi (2):
uapi: fcntl: guard AT_RENAME_* aliases
samples: vfs: avoid libc AT_RENAME_* redefinitions
include/uapi/linux/fcntl.h | 6 ++++++ samples/vfs/test-statx.c | 9 +++++++++ 2 files changed, 15 insertions(+)
Signature · 1 line
2.51.1
PATCH 1/2 uapi: fcntl: guard AT_RENAME_* aliases
--- include/uapi/linux/fcntl.h | 6 ++++++ 1 file changed, 6 insertions(+)
include/uapi/linux/fcntl.h +6 -0
@@ -157,9 +157,15 @@*/ /* Flags for renameat2(2) (must match legacy RENAME_* flags). */ +#ifndef AT_RENAME_NOREPLACE #define AT_RENAME_NOREPLACE 0x0001 +#endif +#ifndef AT_RENAME_EXCHANGE #define AT_RENAME_EXCHANGE 0x0002 +#endif +#ifndef AT_RENAME_WHITEOUT #define AT_RENAME_WHITEOUT 0x0004 +#endif /* Flag for faccessat(2). */ #define AT_EACCESS 0x200/* Test access permitted for
Signature · 1 line
2.51.1
Re: [PATCH 1/2] uapi: fcntl: guard AT_RENAME_* aliases
Quoted 12 lines · On Sun, 9 Nov 2025 16:13:03 +0900 Masaharu Noguchi <[email protected]> wrote:
Signed-off-by Masaharu Noguchi <[email protected]>--- include/uapi/linux/fcntl.h | 6 ++++++ 1 file changed, 6 insertions(+)include/uapi/linux/fcntl.h +0
-0@@ -157,9 +157,15 @@*/
include/uapi/linux/fcntl.h line 168
Quoted 10 lines
include/uapi/linux/fcntl.h +6
-0/* Flags for renameat2(2) (must match legacy RENAME_* flags). */ +#ifndef AT_RENAME_NOREPLACE #define AT_RENAME_NOREPLACE 0x0001 +#endif +#ifndef AT_RENAME_EXCHANGE #define AT_RENAME_EXCHANGE 0x0002 +#endif +#ifndef AT_RENAME_WHITEOUT #define AT_RENAME_WHITEOUT 0x0004 +#endif
That looks like the start of an 'accident waiting to happen'. Either #undef the constants so that code is guaranteed to get the 'uapi' values, or do explicit checks, eg:
/* stdio.h may have defined AT_RENAME_NOREPLACE */
#if !defined(AT_RENAME_NOREPLACE) || AT_RENAME_NOREPLACE != 0x0001 #define AT_RENAME_NOREPLACE 0x0001
#endif
David
Quoted 3 lines
include/uapi/linux/fcntl.h +0
-0/* Flag for faccessat(2). */ #define AT_EACCESS 0x200/* Test access permitted for
PATCH 2/2 samples: vfs: avoid libc AT_RENAME_* redefinitions
In reply to Masaharu Noguchi--- samples/vfs/test-statx.c | 9 +++++++++ 1 file changed, 9 insertions(+)
samples/vfs/test-statx.c +9 -0
@@ -20,6 +20,15 @@#include <sys/syscall.h> #include <sys/types.h> #include <linux/stat.h> +#ifdef AT_RENAME_NOREPLACE +#undef AT_RENAME_NOREPLACE +#endif +#ifdef AT_RENAME_EXCHANGE +#undef AT_RENAME_EXCHANGE +#endif +#ifdef AT_RENAME_WHITEOUT +#undef AT_RENAME_WHITEOUT +#endif #include <linux/fcntl.h> #define statx foo#define statx_timestamp foo_timestamp
Signature · 1 line
2.51.1
Re: [PATCH 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions
Quoted 12 lines · On Sun, 9 Nov 2025 16:13:04 +0900 Masaharu Noguchi <[email protected]> wrote:
Signed-off-by Masaharu Noguchi <[email protected]>--- samples/vfs/test-statx.c | 9 +++++++++ 1 file changed, 9 insertions(+)samples/vfs/test-statx.c +0
-0@@ -20,6 +20,15 @@#include <sys/syscall.h> #include <sys/types.h>
samples/vfs/test-statx.c line 31
Quoted 10 lines
samples/vfs/test-statx.c +9
-0#include <linux/stat.h> +#ifdef AT_RENAME_NOREPLACE +#undef AT_RENAME_NOREPLACE +#endif +#ifdef AT_RENAME_EXCHANGE +#undef AT_RENAME_EXCHANGE +#endif +#ifdef AT_RENAME_WHITEOUT +#undef AT_RENAME_WHITEOUT +#endif
There is no need for the #if, just #undef the symbols. It is probably worthy of a short comment.
David
Quoted 3 lines
samples/vfs/test-statx.c +0
-0#include <linux/fcntl.h> #define statx foo#define statx_timestamp foo_timestamp