linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] xfsprogs: Fix compiling against musl libc
@ 2025-08-09 17:13 Johannes Nixdorf
  2025-08-09 17:13 ` [PATCH 1/2] configure: Base NEED_INTERNAL_STATX on libc headers first Johannes Nixdorf
  2025-08-09 17:13 ` [PATCH 2/2] libfrog: Define STATX__RESERVED if not provided by the system Johannes Nixdorf
  0 siblings, 2 replies; 7+ messages in thread
From: Johannes Nixdorf @ 2025-08-09 17:13 UTC (permalink / raw)
  To: XFS Development Team; +Cc: Johannes Nixdorf

The musl libc statx interface is provided independently from the
kernel headers, so not all defines from the kernel header (here:
STATX__RESERVED) are exported, and checking linux/stat.h as in the
current configure test checking for newest additions to struct statx
will not provide a result that is consistent with the actual code
using the libc interface.

On Alpine Linux this is already fixed by providing the defines
OVERRIDE_SYSTEM_STATX and STATX__RESERVED manually instead of fixing
up the autodetection (OVERRIDE_SYSTEM_STATX) and providing a fallback
(STATX__RESERVED) [1].

[1]: https://gitlab.alpinelinux.org/alpine/aports/-/blob/8ff6aa1e459a75b66375f56269fce43ca2c2f9bf/main/xfsprogs/APKBUILD#L27

Signed-off-by: Johannes Nixdorf <johannes@nixdorf.dev>
---
Johannes Nixdorf (2):
      configure: Base NEED_INTERNAL_STATX on libc headers first
      libfrog: Define STATX__RESERVED if not provided by the system

 libfrog/statx.h       |  5 ++++-
 m4/package_libcdev.m4 | 10 +++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)
---
base-commit: 854665693e6770c0730c1354871f08d01be6a333
change-id: 20250809-musl-fixes-99160afadcdf

Best regards,
-- 
Johannes Nixdorf <johannes@nixdorf.dev>


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

* [PATCH 1/2] configure: Base NEED_INTERNAL_STATX on libc headers first
  2025-08-09 17:13 [PATCH 0/2] xfsprogs: Fix compiling against musl libc Johannes Nixdorf
@ 2025-08-09 17:13 ` Johannes Nixdorf
  2025-08-11 10:42   ` Christoph Hellwig
  2025-08-28  9:11   ` Petr Vaněk
  2025-08-09 17:13 ` [PATCH 2/2] libfrog: Define STATX__RESERVED if not provided by the system Johannes Nixdorf
  1 sibling, 2 replies; 7+ messages in thread
From: Johannes Nixdorf @ 2025-08-09 17:13 UTC (permalink / raw)
  To: XFS Development Team; +Cc: Johannes Nixdorf

At compile time the libc headers are preferred, and linux/stat.h is
only included if the libc headers don't provide a definition for statx
and its types (tested on STATX_TYPE). The configure test should be
based on the same logic.

This fixes one cause for failing to compile against musl libc.

Signed-off-by: Johannes Nixdorf <johannes@nixdorf.dev>
---
 m4/package_libcdev.m4 | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/m4/package_libcdev.m4 b/m4/package_libcdev.m4
index b77ac1a7580a8089b8980cae4dcdbe69540c3482..650b8b7be389dd3ead7fe15de69806ddeb294509 100644
--- a/m4/package_libcdev.m4
+++ b/m4/package_libcdev.m4
@@ -129,7 +129,15 @@ AC_DEFUN([AC_NEED_INTERNAL_STATX],
         AC_CHECK_MEMBER(struct statx.stx_atomic_write_unit_max_opt,
           ,
           need_internal_statx=yes,
-          [#include <linux/stat.h>]
+          [[
+#define _GNU_SOURCE
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#ifndef STATX_TYPE
+#include <linux/stat.h>
+#endif
+]]
         )
       ],need_internal_statx=yes,
       [#include <linux/stat.h>]

-- 
2.50.1


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

* [PATCH 2/2] libfrog: Define STATX__RESERVED if not provided by the system
  2025-08-09 17:13 [PATCH 0/2] xfsprogs: Fix compiling against musl libc Johannes Nixdorf
  2025-08-09 17:13 ` [PATCH 1/2] configure: Base NEED_INTERNAL_STATX on libc headers first Johannes Nixdorf
@ 2025-08-09 17:13 ` Johannes Nixdorf
  2025-08-11 10:43   ` Christoph Hellwig
  2025-08-28  9:12   ` Petr Vaněk
  1 sibling, 2 replies; 7+ messages in thread
From: Johannes Nixdorf @ 2025-08-09 17:13 UTC (permalink / raw)
  To: XFS Development Team; +Cc: Johannes Nixdorf

This define is not provided by musl libc. Use the fallback that is
already provided if statx and its types (tested on STATX_TYPE) are
not defined in the general case.

This fixes one cause for failing to compile against musl libc.

Signed-off-by: Johannes Nixdorf <johannes@nixdorf.dev>
---
 libfrog/statx.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/libfrog/statx.h b/libfrog/statx.h
index e11e2d8f49fa5fabf546fcdce8f4f9e2047300f2..9fb15adcfc1f765f7a242b9bfbc53d281e8dcaed 100644
--- a/libfrog/statx.h
+++ b/libfrog/statx.h
@@ -191,7 +191,6 @@ statx(
 #define STATX_BLOCKS		0x00000400U	/* Want/got stx_blocks */
 #define STATX_BASIC_STATS	0x000007ffU	/* The stuff in the normal stat struct */
 #define STATX_BTIME		0x00000800U	/* Want/got stx_btime */
-#define STATX__RESERVED		0x80000000U	/* Reserved for future struct statx expansion */
 
 /*
  * This is deprecated, and shall remain the same value in the future.  To avoid
@@ -221,6 +220,10 @@ statx(
 
 #endif /* STATX_TYPE */
 
+#ifndef STATX__RESERVED
+#define STATX__RESERVED		0x80000000U	/* Reserved for future struct statx expansion */
+#endif
+
 #ifndef STATX_MNT_ID
 #define STATX_MNT_ID		0x00001000U	/* Got stx_mnt_id */
 #endif

-- 
2.50.1


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

* Re: [PATCH 1/2] configure: Base NEED_INTERNAL_STATX on libc headers first
  2025-08-09 17:13 ` [PATCH 1/2] configure: Base NEED_INTERNAL_STATX on libc headers first Johannes Nixdorf
@ 2025-08-11 10:42   ` Christoph Hellwig
  2025-08-28  9:11   ` Petr Vaněk
  1 sibling, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2025-08-11 10:42 UTC (permalink / raw)
  To: Johannes Nixdorf; +Cc: XFS Development Team

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


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

* Re: [PATCH 2/2] libfrog: Define STATX__RESERVED if not provided by the system
  2025-08-09 17:13 ` [PATCH 2/2] libfrog: Define STATX__RESERVED if not provided by the system Johannes Nixdorf
@ 2025-08-11 10:43   ` Christoph Hellwig
  2025-08-28  9:12   ` Petr Vaněk
  1 sibling, 0 replies; 7+ messages in thread
From: Christoph Hellwig @ 2025-08-11 10:43 UTC (permalink / raw)
  To: Johannes Nixdorf; +Cc: XFS Development Team

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>


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

* Re: [PATCH 1/2] configure: Base NEED_INTERNAL_STATX on libc headers first
  2025-08-09 17:13 ` [PATCH 1/2] configure: Base NEED_INTERNAL_STATX on libc headers first Johannes Nixdorf
  2025-08-11 10:42   ` Christoph Hellwig
@ 2025-08-28  9:11   ` Petr Vaněk
  1 sibling, 0 replies; 7+ messages in thread
From: Petr Vaněk @ 2025-08-28  9:11 UTC (permalink / raw)
  To: Johannes Nixdorf; +Cc: XFS Development Team

On Sat, Aug 09, 2025 at 07:13:07PM +0200, Johannes Nixdorf wrote:
> At compile time the libc headers are preferred, and linux/stat.h is
> only included if the libc headers don't provide a definition for statx
> and its types (tested on STATX_TYPE). The configure test should be
> based on the same logic.
> 
> This fixes one cause for failing to compile against musl libc.
> 
> Signed-off-by: Johannes Nixdorf <johannes@nixdorf.dev>

Looks good, it solves the issue for us.

Reviewed-by: Petr Vaněk <arkamar@gentoo.org>

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

* Re: [PATCH 2/2] libfrog: Define STATX__RESERVED if not provided by the system
  2025-08-09 17:13 ` [PATCH 2/2] libfrog: Define STATX__RESERVED if not provided by the system Johannes Nixdorf
  2025-08-11 10:43   ` Christoph Hellwig
@ 2025-08-28  9:12   ` Petr Vaněk
  1 sibling, 0 replies; 7+ messages in thread
From: Petr Vaněk @ 2025-08-28  9:12 UTC (permalink / raw)
  To: Johannes Nixdorf; +Cc: XFS Development Team

On Sat, Aug 09, 2025 at 07:13:08PM +0200, Johannes Nixdorf wrote:
> This define is not provided by musl libc. Use the fallback that is
> already provided if statx and its types (tested on STATX_TYPE) are
> not defined in the general case.
> 
> This fixes one cause for failing to compile against musl libc.
> 
> Signed-off-by: Johannes Nixdorf <johannes@nixdorf.dev>

Looks good, it solves the issue for us.

Reviewed-by: Petr Vaněk <arkamar@gentoo.org>

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

end of thread, other threads:[~2025-08-28  9:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-09 17:13 [PATCH 0/2] xfsprogs: Fix compiling against musl libc Johannes Nixdorf
2025-08-09 17:13 ` [PATCH 1/2] configure: Base NEED_INTERNAL_STATX on libc headers first Johannes Nixdorf
2025-08-11 10:42   ` Christoph Hellwig
2025-08-28  9:11   ` Petr Vaněk
2025-08-09 17:13 ` [PATCH 2/2] libfrog: Define STATX__RESERVED if not provided by the system Johannes Nixdorf
2025-08-11 10:43   ` Christoph Hellwig
2025-08-28  9:12   ` Petr Vaněk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).