package/libnfs: fix build on strict alignment archs
PATCH 1/2 package/libnfs: fix build on strict alignment archs
Building libnfs fails on targets that have alignment requirements via -Wcast-align even though the underlying buffers are sufficiently aligned. Import the upstream fix that silences those warnings.
--- ...void-cast-to-allow-compile-for-arm32.patch | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 package/libnfs/0003-socket-use-void-cast-to-allow-compile-for-arm32.patch
package/libnfs/0003-socket-use-void-cast-to-allow-compile-for-arm32.patch new file +68 -0
@@ -0,0 +1,68 @@ +From c66dc9a65723e610fd02da38471d68b8289eb074 Mon Sep 17 00:00:00 2001 +From: Rudi Heitbaum <[email protected]> +Date: Tue, 14 Jan 2025 14:09:36 +0000 +Subject: [PATCH] socket: use void cast to allow compile for arm32 + +When compiling for arm32 the error: cast increases required alignment +of target type occurs. + +/lib/socket.c: In function 'rpc_read_from_socket': +lib/socket.c:586:49: error: cast increases required alignment of target type [-Werror=cast-align] + 586 | rpc->rm_xid[1] = ntohl(*(uint32_t *)&buf[0]); + | ^ +lib/socket.c:587:61: error: cast increases required alignment of target type [-Werror=cast-align] + 587 | rpc->pdu = rpc_find_pdu(rpc, ntohl(*(uint32_t *)&buf[0])); + | ^ +lib/socket.c:799:35: error: cast increases required alignment of target type [-Werror=cast-align] + 799 | *((uint32_t *)rpc->inbuf) = htonl(rpc->rm_xid[1]); + | ^ +lib/socket.c:861:71: error: cast increases required alignment of target type [-Werror=cast-align] + 861 | const READ3res *res = (READ3res *) rpc->pdu->zdr_decode_buf; + | ^ + +cast via (void *) to allow the compile to suceed, as all of the source buffers should be 32bit aligned. + +Signed-off-by: Rudi Heitbaum <[email protected]> + +Upstream: https://github.com/sahlberg/libnfs/commit/a01d42a0d9682d3e506d3c78680db8c7d158fe88 +Signed-off-by: Florian Larysch <[email protected]> +--- + lib/socket.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/lib/socket.c b/lib/socket.c +index f51ca4d..5b9fce5 100644 +--- a/lib/socket.c ++++ b/lib/socket.c +@@ -583,8 +583,8 @@ rpc_read_from_socket(struct rpc_context *rpc) + } + if (!rpc->is_server_context) { + rpc->rm_xid[0] = count; +- rpc->rm_xid[1] = ntohl(*(uint32_t *)&buf[0]); +- rpc->pdu = rpc_find_pdu(rpc, ntohl(*(uint32_t *)&buf[0])); ++ rpc->rm_xid[1] = ntohl(*(uint32_t *)(void *)&buf[0]); ++ rpc->pdu = rpc_find_pdu(rpc, ntohl(*(uint32_t *)(void *)&buf[0])); + if (rpc->pdu == NULL) { + rpc_set_error(rpc, "Failed to match incoming PDU/XID." + " Ignoring PDU"); +@@ -796,7 +796,7 @@ rpc_read_from_socket(struct rpc_context *rpc) + } + + /* Copy the next 4 bytes into inbuf */ +- *((uint32_t *)rpc->inbuf) = htonl(rpc->rm_xid[1]); ++ *((uint32_t *)(void *)rpc->inbuf) = htonl(rpc->rm_xid[1]); + + /* but set inpos to 0, we will update it above + * that we have already read these 4 bytes in +@@ -858,7 +858,7 @@ rpc_read_from_socket(struct rpc_context *rpc) + * If the READ failed, bail out here as there is no + * data. + */ +- const READ3res *res = (READ3res *) rpc->pdu->zdr_decode_buf; ++ const READ3res *res = (READ3res *)(void *) rpc->pdu->zdr_decode_buf; + if (res->status != NFS3_OK) { + goto payload_finished; + } +-- +2.53.0 +
Signature · 6 lines
2.53.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH 2/2 package/libnfs: link with -latomic if needed
Building on SPARC fails with undefined references to __atomic_fetch_sub_4 and friends.
Link with libatomic to get the required intrinsics.
--- package/libnfs/libnfs.mk | 4 ++++ 1 file changed, 4 insertions(+)
package/libnfs/libnfs.mk +4 -0
@@ -12,6 +12,10 @@ LIBNFS_LICENSE = LGPL-2.1+ (library), BSD-2-Clause (protocol, .x files), GPL-3.0 LIBNFS_LICENSE_FILES = COPYING LICENCE-BSD.txt LICENCE-LGPL-2.1.txt LICENCE-GPL-3.txt LIBNFS_DEPENDENCIES = host-pkgconf +ifeq ($(BR2_TOOLCHAIN_HAS_LIBATOMIC),y) +LIBNFS_CONF_ENV += LIBS=-latomic +endif + ifeq ($(BR2_PACKAGE_GNUTLS),y) LIBNFS_DEPENDENCIES += gnutls endif
Signature · 6 lines
2.53.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Romain Naour via buildroot
AppliedHello Florian,
Le 17/04/2026 à 00:51, Florian Larysch a écrit :
Quoted 7 lines
Building libnfs fails on targets that have alignment requirements via -Wcast-align even though the underlying buffers are sufficiently aligned. Import the upstream fix that silences those warnings.
Signed-off-by Florian Larysch <[email protected]>
I applied only the first patch of this series to master since it fixes autobuilder failures by applying an upstream patch.
Best regards,
Romain
Quoted 69 lines
--- ...void-cast-to-allow-compile-for-arm32.patch | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 package/libnfs/0003-socket-use-void-cast-to-allow-compile-for-arm32.patchpackage/libnfs/0003-socket-use-void-cast-to-allow-compile-for-arm32.patch new file +58
-0@@ -0,0 +1,68 @@ +From c66dc9a65723e610fd02da38471d68b8289eb074 Mon Sep 17 00:00:00 2001 +From: Rudi Heitbaum <[email protected]> +Date: Tue, 14 Jan 2025 14:09:36 +0000 +Subject: [PATCH] socket: use void cast to allow compile for arm32 + +When compiling for arm32 the error: cast increases required alignment +of target type occurs. + +/lib/socket.c: In function 'rpc_read_from_socket': +lib/socket.c:586:49: error: cast increases required alignment of target type [-Werror=cast-align] + 586 | rpc->rm_xid[1] = ntohl(*(uint32_t *)&buf[0]); + | ^ +lib/socket.c:587:61: error: cast increases required alignment of target type [-Werror=cast-align] + 587 | rpc->pdu = rpc_find_pdu(rpc, ntohl(*(uint32_t *)&buf[0])); + | ^ +lib/socket.c:799:35: error: cast increases required alignment of target type [-Werror=cast-align] + 799 | *((uint32_t *)rpc->inbuf) = htonl(rpc->rm_xid[1]); + | ^ +lib/socket.c:861:71: error: cast increases required alignment of target type [-Werror=cast-align] + 861 | const READ3res *res = (READ3res *) rpc->pdu->zdr_decode_buf; + | ^ + +cast via (void *) to allow the compile to suceed, as all of the source buffers should be 32bit aligned. + +Signed-off-by: Rudi Heitbaum <[email protected]> + +Upstream: https://github.com/sahlberg/libnfs/commit/a01d42a0d9682d3e506d3c78680db8c7d158fe88 +Signed-off-by: Florian Larysch <[email protected]> +--- + lib/socket.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/lib/socket.c b/lib/socket.c +index f51ca4d..5b9fce5 100644 +--- a/lib/socket.c ++++ b/lib/socket.c +@@ -583,8 +583,8 @@ rpc_read_from_socket(struct rpc_context *rpc) + } + if (!rpc->is_server_context) { + rpc->rm_xid[0] = count; +- rpc->rm_xid[1] = ntohl(*(uint32_t *)&buf[0]); +- rpc->pdu = rpc_find_pdu(rpc, ntohl(*(uint32_t *)&buf[0])); ++ rpc->rm_xid[1] = ntohl(*(uint32_t *)(void *)&buf[0]); ++ rpc->pdu = rpc_find_pdu(rpc, ntohl(*(uint32_t *)(void *)&buf[0])); + if (rpc->pdu == NULL) { + rpc_set_error(rpc, "Failed to match incoming PDU/XID." + " Ignoring PDU"); +@@ -796,7 +796,7 @@ rpc_read_from_socket(struct rpc_context *rpc) + } + + /* Copy the next 4 bytes into inbuf */ +- *((uint32_t *)rpc->inbuf) = htonl(rpc->rm_xid[1]); ++ *((uint32_t *)(void *)rpc->inbuf) = htonl(rpc->rm_xid[1]); + + /* but set inpos to 0, we will update it above + * that we have already read these 4 bytes in +@@ -858,7 +858,7 @@ rpc_read_from_socket(struct rpc_context *rpc) + * If the READ failed, bail out here as there is no
package/libnfs/0003-socket-use-void-cast-to-allow-compile-for-arm32.patch line 68
Quoted 10 lines
package/libnfs/0003-socket-use-void-cast-to-allow-compile-for-arm32.patch new file +10
-0+ * data. + */ +- const READ3res *res = (READ3res *) rpc->pdu->zdr_decode_buf; ++ const READ3res *res = (READ3res *)(void *) rpc->pdu->zdr_decode_buf; + if (res->status != NFS3_OK) { + goto payload_finished; + } +-- +2.53.0 +
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Hello Romain,
thanks for picking up the patch!
The second patch in this series is present because after fixing the first issue, my tests builds started getting far enough to run into the one fixed by the second patch. I expect the same will happen with the autobuilders.
Florian
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot