Skip to contentSkip to conversation

package/libcap: backport upstream patch to fix build on Xtensa

PATCH Applied Thomas Petazzoni via buildroot 3 participants 5 messages May 16, 2025 – May 19, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/libcap: backport upstream patch to fix build on Xtensa

Following the bump of libcap to version 2.76 in commit e2eb2ee58b9f70ebb83231537cca19bd28fa48de, the build started failing on Xtensa. The bug was reported upstream at
https://bugzilla.kernel.org/show_bug.cgi?id=219915 and was subsequently fixed by upstream commit:

https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=6cdd8cd72ebcedd6b1b6c989a7e5722d5d87f35c

Which we backport in this commit.

Fixes:

https://autobuild.buildroot.org/results/b9ff9258f407898eeee80dd8cc4dd1d777f44c06

---
 ...-Support-for-__xtensa__-architecture.patch | 65 +++++++++++++++++++
 1 file changed, 65 insertions(+)
 create mode 100644 package/libcap/0002-Support-for-__xtensa__-architecture.patch
package/libcap/0002-Support-for-__xtensa__-architecture.patch new file +65 -0
new file mode 100644
index 0000000000..a81a1952aa
@@ -0,0 +1,65 @@
+From 9421f4ff93c341482d3aa4a0cd57aba1978bdd62 Mon Sep 17 00:00:00 2001
+From: "Andrew G. Morgan" <[email protected]>
+Date: Sat, 19 Apr 2025 08:00:23 -0700
+Subject: [PATCH] Support for __xtensa__ architecture.
+
+It looks like __xtensa__ defines SA_RESTORER, but my read of the
+kernel code suggests that signal handling does not require it be
+set. Specifically, if the SA_RESTORER flag is not set, the kernel
+inserts a sys_rt_sigreturn call into the stack frame.
+
+Signed-off-by: Andrew G. Morgan <[email protected]>
+Upstream: 6cdd8cd72ebcedd6b1b6c989a7e5722d5d87f35c
+Signed-off-by: Thomas Petazzoni <[email protected]>
+---
+ psx/psx_calls.c | 13 +++++++------
+ 1 file changed, 7 insertions(+), 6 deletions(-)
+
+diff --git a/psx/psx_calls.c b/psx/psx_calls.c
+index 8195964..aff105f 100644
+--- a/psx/psx_calls.c
++++ b/psx/psx_calls.c
+@@ -49,7 +49,8 @@
+     || defined(__powerpc__) || defined(__s390__) || defined(__riscv) \
+     || defined(__alpha__) || defined(__hppa__) || defined(__sh__) \
+     || defined(__m68k__) || defined(__sparc__) || defined(__arc__) \
+-    || defined(__microblaze__) || defined(__or1k__)
++    || defined(__microblaze__) || defined(__or1k__) \
++    || defined(__xtensa__)
+ 
+ #undef _NSIG
+ #undef _NSIG_BPW
+@@ -69,8 +70,7 @@
+ #define _NSIG_WORDS  (_NSIG / _NSIG_BPW)
+ 
+ #if defined(__x86_64__) || defined(__i386__) \
+-    || defined(__arm__) \
+-    || defined(__powerpc__) \
++    || defined(__arm__) || defined(__powerpc__) \
+     || defined(__arc__)
+ /* field used */
+ #define SA_RESTORER  0x04000000
+@@ -78,8 +78,9 @@
+ 
+ #if defined(SA_RESTORER) \
+     || defined(__aarch64__) \
+-    || defined(__m68k__) || defined(__sh__) || defined(__sparc__) \
+-    || defined(__s390__) || defined(__sparc__)
++    || defined(__m68k__) || defined(__sh__) \
++    || defined(__s390__) || defined(__sparc__) \
++    || defined(__xtensa__)
+ /* field defined */
+ #define _HAS_SA_RESTORER   void *sa_restorer;
+ #else
+@@ -93,7 +94,7 @@ typedef struct {
+ #define sigset_t psx_sigset_t
+ 
+ struct psx_sigaction {
+-#if defined(__m68k__) || defined(__alpha__)
++#if defined(__m68k__) || defined(__alpha__) || defined(__xtensa__)
+     void *sa_handler;
+     sigset_t sa_mask;
+     unsigned long sa_flags;
+-- 
+2.49.0
+
Signature · 6 lines
2.49.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 9 lines · Thomas Petazzoni via buildroot

Following the bump of libcap to version 2.76 in commit e2eb2ee58b9f70ebb83231537cca19bd28fa48de, the build started failing on Xtensa. The bug was reported upstream at
https://bugzilla.kernel.org/show_bug.cgi?id=219915 and was subsequently fixed by upstream commit:

https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=6cdd8cd72ebcedd6b1b6c989a7e5722d5d87f35c

Quoted 8 lines

Which we backport in this commit.

Fixes:

https://autobuild.buildroot.org/results/b9ff9258f407898eeee80dd8cc4dd1d777f44c06

Applied to master, thanks.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw
In reply to Thomas Petazzoni via buildroot
Quoted 8 lines · Thomas Petazzoni via buildroot

Following the bump of libcap to version 2.76 in commit e2eb2ee58b9f70ebb83231537cca19bd28fa48de, the build started failing on Xtensa. The bug was reported upstream at
https://bugzilla.kernel.org/show_bug.cgi?id=219915 and was subsequently fixed by upstream commit:

   https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=6cdd8cd72ebcedd6b1b6c989a7e5722d5d87f35c
Quoted 7 lines

Which we backport in this commit.

Fixes:

   https://autobuild.buildroot.org/results/b9ff9258f407898eeee80dd8cc4dd1d777f44c06

Applied to 2025.02.x, thanks.

Regards,
Arnout

Quoted 66 lines
---
  ...-Support-for-__xtensa__-architecture.patch | 65 +++++++++++++++++++
  1 file changed, 65 insertions(+)

create mode 100644 package/libcap/0002-Support-for-__xtensa__-architecture.patch

package/libcap/0002-Support-for-__xtensa__-architecture.patch new file +55 -0
new file mode 100644
index 0000000000..a81a1952aa
@@ -0,0 +1,65 @@
+From 9421f4ff93c341482d3aa4a0cd57aba1978bdd62 Mon Sep 17 00:00:00 2001
+From: "Andrew G. Morgan" <[email protected]>
+Date: Sat, 19 Apr 2025 08:00:23 -0700
+Subject: [PATCH] Support for __xtensa__ architecture.
+
+It looks like __xtensa__ defines SA_RESTORER, but my read of the
+kernel code suggests that signal handling does not require it be
+set. Specifically, if the SA_RESTORER flag is not set, the kernel
+inserts a sys_rt_sigreturn call into the stack frame.
+
+Signed-off-by: Andrew G. Morgan <[email protected]>
+Upstream: 6cdd8cd72ebcedd6b1b6c989a7e5722d5d87f35c
+Signed-off-by: Thomas Petazzoni <[email protected]>
+---
+ psx/psx_calls.c | 13 +++++++------
+ 1 file changed, 7 insertions(+), 6 deletions(-)
+
+diff --git a/psx/psx_calls.c b/psx/psx_calls.c
+index 8195964..aff105f 100644
+--- a/psx/psx_calls.c
++++ b/psx/psx_calls.c
+@@ -49,7 +49,8 @@
+     || defined(__powerpc__) || defined(__s390__) || defined(__riscv) \
+     || defined(__alpha__) || defined(__hppa__) || defined(__sh__) \
+     || defined(__m68k__) || defined(__sparc__) || defined(__arc__) \
+-    || defined(__microblaze__) || defined(__or1k__)
++    || defined(__microblaze__) || defined(__or1k__) \
++    || defined(__xtensa__)
+
+ #undef _NSIG
+ #undef _NSIG_BPW
+@@ -69,8 +70,7 @@
+ #define _NSIG_WORDS  (_NSIG / _NSIG_BPW)
+
+ #if defined(__x86_64__) || defined(__i386__) \
+-    || defined(__arm__) \
+-    || defined(__powerpc__) \
++    || defined(__arm__) || defined(__powerpc__) \
+     || defined(__arc__)
+ /* field used */
+ #define SA_RESTORER  0x04000000
+@@ -78,8 +78,9 @@
+
+ #if defined(SA_RESTORER) \
+     || defined(__aarch64__) \
+-    || defined(__m68k__) || defined(__sh__) || defined(__sparc__) \
+-    || defined(__s390__) || defined(__sparc__)
++    || defined(__m68k__) || defined(__sh__) \
++    || defined(__s390__) || defined(__sparc__) \
++    || defined(__xtensa__)
+ /* field defined */
+ #define _HAS_SA_RESTORER   void *sa_restorer;
+ #else
+@@ -93,7 +94,7 @@ typedef struct {
+ #define sigset_t psx_sigset_t

package/libcap/0002-Support-for-__xtensa__-architecture.patch line 65

Quoted 10 lines
package/libcap/0002-Support-for-__xtensa__-architecture.patch new file +10 -0
+
+ struct psx_sigaction {
+-#if defined(__m68k__) || defined(__alpha__)
++#if defined(__m68k__) || defined(__alpha__) || defined(__xtensa__)
+     void *sa_handler;
+     sigset_t sa_mask;
+     unsigned long sa_flags;
+--
+2.49.0
+

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw
Quoted 16 lines · Arnout Vandecappelle via buildroot
Quoted 10 lines · Thomas Petazzoni via buildroot

Following the bump of libcap to version 2.76 in commit e2eb2ee58b9f70ebb83231537cca19bd28fa48de, the build started failing on Xtensa. The bug was reported upstream at
https://bugzilla.kernel.org/show_bug.cgi?id=219915 and was subsequently fixed by upstream commit:
https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=6cdd8cd72ebcedd6b1b6c989a7e5722d5d87f35c
Which we backport in this commit.
Fixes:
https://autobuild.buildroot.org/results/b9ff9258f407898eeee80dd8cc4dd1d777f44c06

Quoted 4 lines

Applied to 2025.02.x, thanks.

Regards,
Arnout

2025.02.x still has libcap 2.73. I don't think this patch should have been applied to the stable branch; libcap no longer builds successfully for me in 2025.02.2.

iliana
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#4 lore raw
Quoted 16 lines · iliana etaoin
Quoted 16 lines · Arnout Vandecappelle via buildroot
Quoted 10 lines · Thomas Petazzoni via buildroot

Following the bump of libcap to version 2.76 in commit e2eb2ee58b9f70ebb83231537cca19bd28fa48de, the build started failing on Xtensa. The bug was reported upstream at
https://bugzilla.kernel.org/show_bug.cgi?id=219915 and was subsequently fixed by upstream commit:

   https://git.kernel.org/pub/scm/libs/libcap/libcap.git/commit/?id=6cdd8cd72ebcedd6b1b6c989a7e5722d5d87f35c
Which we backport in this commit.
Fixes:
   https://autobuild.buildroot.org/results/b9ff9258f407898eeee80dd8cc4dd1d777f44c06
Quoted 6 lines
Quoted 4 lines

Applied to 2025.02.x, thanks.

Regards,
Arnout

2025.02.x still has libcap 2.73. I don't think this patch should have been applied to the stable branch; libcap no longer builds successfully for me in 2025.02.2.

Indeed, I'm releasing 2025.02.3 now with a revert of that patch.

Thanks, and sorry for the trouble,
Arnout

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot