public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Building a allyesconfig kernel fails because macros are being redefined
@ 2025-10-12 23:47 Jesper Juhl
  2025-10-13  1:24 ` Nathan Chancellor
  2025-11-09  7:13 ` [PATCH 0/2] fix AT_RENAME_* redefinitions with glibc < 2.43 Masaharu Noguchi
  0 siblings, 2 replies; 7+ messages in thread
From: Jesper Juhl @ 2025-10-12 23:47 UTC (permalink / raw)
  To: linux-kernel

My current git HEAD is at  3a8660878839faadb4f1a6dd72c3179c1df56787

If I do :
    make mrproper
    make allyesconfig
    make -j 33
it 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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Building a allyesconfig kernel fails because macros are being redefined
  2025-10-12 23:47 Building a allyesconfig kernel fails because macros are being redefined Jesper Juhl
@ 2025-10-13  1:24 ` Nathan Chancellor
  2025-11-09  7:13 ` [PATCH 0/2] fix AT_RENAME_* redefinitions with glibc < 2.43 Masaharu Noguchi
  1 sibling, 0 replies; 7+ messages in thread
From: Nathan Chancellor @ 2025-10-13  1:24 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-kernel

On Mon, Oct 13, 2025 at 01:47:54AM +0200, Jesper Juhl wrote:
> My current git HEAD is at  3a8660878839faadb4f1a6dd72c3179c1df56787
> 
> If I do :
>     make mrproper
>     make allyesconfig
>     make -j 33
> it 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
>      |          ^~~~~~~~~~~~~~~~~~

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 0/2] fix AT_RENAME_* redefinitions with glibc < 2.43
  2025-10-12 23:47 Building a allyesconfig kernel fails because macros are being redefined Jesper Juhl
  2025-10-13  1:24 ` Nathan Chancellor
@ 2025-11-09  7:13 ` Masaharu Noguchi
  2025-11-09  7:13   ` [PATCH 1/2] uapi: fcntl: guard AT_RENAME_* aliases Masaharu Noguchi
  2025-11-09  7:13   ` [PATCH 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions Masaharu Noguchi
  1 sibling, 2 replies; 7+ messages in thread
From: Masaharu Noguchi @ 2025-11-09  7:13 UTC (permalink / raw)
  To: jesperjuhl76, Jeff Layton, Chuck Lever
  Cc: Alexander Aring, linux-fsdevel, linux-kernel, Masaharu Noguchi

LKML 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.

Link: https://lore.kernel.org/all/CAHaCkme7C8LDpWVX8TnDQQ+feWeQy_SA3HYfpyyPNFee_+Z2EA@mail.gmail.com/ # LKML report
Link: https://lore.kernel.org/all/20251013012423.GA331@ax162/ # follow-up
Link: https://sourceware.org/git/?p=glibc.git;a=commit;h=1166170d95863e5a6f8121a5ca9d97713f524f49 # glibc fix

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(+)

-- 
2.51.1

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/2] uapi: fcntl: guard AT_RENAME_* aliases
  2025-11-09  7:13 ` [PATCH 0/2] fix AT_RENAME_* redefinitions with glibc < 2.43 Masaharu Noguchi
@ 2025-11-09  7:13   ` Masaharu Noguchi
  2025-11-09 16:13     ` David Laight
  2025-11-09  7:13   ` [PATCH 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions Masaharu Noguchi
  1 sibling, 1 reply; 7+ messages in thread
From: Masaharu Noguchi @ 2025-11-09  7:13 UTC (permalink / raw)
  To: jesperjuhl76, Jeff Layton, Chuck Lever
  Cc: Alexander Aring, linux-fsdevel, linux-kernel, Masaharu Noguchi

Signed-off-by: Masaharu Noguchi <nogunix@gmail.com>
---
 include/uapi/linux/fcntl.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h
index 3741ea1b73d8..e3026381fbe7 100644
--- a/include/uapi/linux/fcntl.h
+++ b/include/uapi/linux/fcntl.h
@@ -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
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions
  2025-11-09  7:13 ` [PATCH 0/2] fix AT_RENAME_* redefinitions with glibc < 2.43 Masaharu Noguchi
  2025-11-09  7:13   ` [PATCH 1/2] uapi: fcntl: guard AT_RENAME_* aliases Masaharu Noguchi
@ 2025-11-09  7:13   ` Masaharu Noguchi
  2025-11-09 16:04     ` David Laight
  1 sibling, 1 reply; 7+ messages in thread
From: Masaharu Noguchi @ 2025-11-09  7:13 UTC (permalink / raw)
  To: jesperjuhl76, Jeff Layton, Chuck Lever
  Cc: Alexander Aring, linux-fsdevel, linux-kernel, Masaharu Noguchi

Signed-off-by: Masaharu Noguchi <nogunix@gmail.com>
---
 samples/vfs/test-statx.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/samples/vfs/test-statx.c b/samples/vfs/test-statx.c
index 49c7a46cee07..eabea80e9db8 100644
--- a/samples/vfs/test-statx.c
+++ b/samples/vfs/test-statx.c
@@ -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
-- 
2.51.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions
  2025-11-09  7:13   ` [PATCH 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions Masaharu Noguchi
@ 2025-11-09 16:04     ` David Laight
  0 siblings, 0 replies; 7+ messages in thread
From: David Laight @ 2025-11-09 16:04 UTC (permalink / raw)
  To: Masaharu Noguchi
  Cc: jesperjuhl76, Jeff Layton, Chuck Lever, Alexander Aring,
	linux-fsdevel, linux-kernel

On Sun,  9 Nov 2025 16:13:04 +0900
Masaharu Noguchi <nogunix@gmail.com> wrote:

> Signed-off-by: Masaharu Noguchi <nogunix@gmail.com>
> ---
>  samples/vfs/test-statx.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/samples/vfs/test-statx.c b/samples/vfs/test-statx.c
> index 49c7a46cee07..eabea80e9db8 100644
> --- a/samples/vfs/test-statx.c
> +++ b/samples/vfs/test-statx.c
> @@ -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

There is no need for the #if, just #undef the symbols.
It is probably worthy of a short comment.

	David

>  #include <linux/fcntl.h>
>  #define statx foo
>  #define statx_timestamp foo_timestamp


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/2] uapi: fcntl: guard AT_RENAME_* aliases
  2025-11-09  7:13   ` [PATCH 1/2] uapi: fcntl: guard AT_RENAME_* aliases Masaharu Noguchi
@ 2025-11-09 16:13     ` David Laight
  0 siblings, 0 replies; 7+ messages in thread
From: David Laight @ 2025-11-09 16:13 UTC (permalink / raw)
  To: Masaharu Noguchi
  Cc: jesperjuhl76, Jeff Layton, Chuck Lever, Alexander Aring,
	linux-fsdevel, linux-kernel

On Sun,  9 Nov 2025 16:13:03 +0900
Masaharu Noguchi <nogunix@gmail.com> wrote:

> Signed-off-by: Masaharu Noguchi <nogunix@gmail.com>
> ---
>  include/uapi/linux/fcntl.h | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h
> index 3741ea1b73d8..e3026381fbe7 100644
> --- a/include/uapi/linux/fcntl.h
> +++ b/include/uapi/linux/fcntl.h
> @@ -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

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


>  
>  /* Flag for faccessat(2). */
>  #define AT_EACCESS		0x200	/* Test access permitted for


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-11-09 16:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-12 23:47 Building a allyesconfig kernel fails because macros are being redefined Jesper Juhl
2025-10-13  1:24 ` Nathan Chancellor
2025-11-09  7:13 ` [PATCH 0/2] fix AT_RENAME_* redefinitions with glibc < 2.43 Masaharu Noguchi
2025-11-09  7:13   ` [PATCH 1/2] uapi: fcntl: guard AT_RENAME_* aliases Masaharu Noguchi
2025-11-09 16:13     ` David Laight
2025-11-09  7:13   ` [PATCH 2/2] samples: vfs: avoid libc AT_RENAME_* redefinitions Masaharu Noguchi
2025-11-09 16:04     ` David Laight

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox