Skip to contentSkip to conversation

package/atop: fix musl build

PATCH Applied Yegor Yefremov via buildroot 1 participant 4 messages Sep 30 – Oct 16

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/atop: fix musl build

From: Yegor Yefremov <[email protected]>

Since the bump to version 2.13.0, atop fails to build with musl:

drawbar.c:2336:33: error: implicit declaration of function 'waddwstr'; did you mean 'waddstr'? [-Wimplicit-function-declaration]

(Before 2.13.0, the same configurations already failed earlier on uClibc because _POSIX_C_SOURCE was defined without a value. Upstream fixed that in 2.13.0 by giving it an explicit value, but the same pattern remains for _XOPEN_SOURCE.)

ncurses only declares its wide-character API, including waddwstr(), when NCURSES_WIDECHAR is set. If the application does not set it, curses.h derives it from the feature test macros:

  #if defined(_XOPEN_SOURCE_EXTENDED) || \
      (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500))

drawbar.c defines _XOPEN_SOURCE with an empty value, which makes the check evaluate as 0 >= 500 and fail.

This only breaks with musl because of the C library's <features.h>, which curses.h pulls in through <stdio.h> before doing the check. glibc and uClibc both redefine _XOPEN_SOURCE to 700 and define _XOPEN_SOURCE_EXTENDED whenever _GNU_SOURCE is set, which drawbar.c does, so the empty definition gets fixed up. musl never modifies the application's feature test macros, so the empty value reaches curses.h and the wide-character prototypes are left out.

Add a patch that defines _XOPEN_SOURCE as 700, matching the _POSIX_C_SOURCE value of 200809L that is already used.

Fixes:
- https://autobuild.buildroot.org/results/914c1d8fa0fc8bbef64e4a64d58e5941d0077a3e
- https://autobuild.buildroot.org/results/b91/b91ea0722202de0d1fdeeaeea167fd1b21b6d5d6

Assisted-by Claude:claude-opus-5-5
---
 ...xplicit-value-for-_XOPEN_SOURCE-macr.patch | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 package/atop/0001-drawbar-define-explicit-value-for-_XOPEN_SOURCE-macr.patch
package/atop/0001-drawbar-define-explicit-value-for-_XOPEN_SOURCE-macr.patch new file +48 -0
new file mode 100644
index 0000000000..d526d58433
@@ -0,0 +1,48 @@
+From 54799216beac63a195cd6d34b22476fc15a80295 Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <[email protected]>
+Date: Wed, 30 Sep 2026 10:59:49 +0200
+Subject: [PATCH] drawbar: define explicit value for _XOPEN_SOURCE macro
+
+drawbar.c uses the wide-character curses function waddwstr(). ncurses
+only declares its wide-character API when NCURSES_WIDECHAR is set,
+which curses.h derives from the feature test macros:
+
+  #if defined(_XOPEN_SOURCE_EXTENDED) || \
+      (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500))
+
+drawbar.c defines _XOPEN_SOURCE without a value, so _XOPEN_SOURCE - 0
+evaluates to 0 and the check fails.
+
+With glibc and uClibc this goes unnoticed, because their <features.h>
+redefines _XOPEN_SOURCE to 700 (and defines _XOPEN_SOURCE_EXTENDED)
+whenever _GNU_SOURCE is set. musl does not touch the application's
+feature test macros, so the empty definition reaches curses.h
+unchanged and the build fails:
+
+drawbar.c:2336:33: error: implicit declaration of function 'waddwstr'; did you mean 'waddstr'? [-Wimplicit-function-declaration]
+
+Define _XOPEN_SOURCE as 700, which matches the already explicit
+_POSIX_C_SOURCE value of 200809L (both refer to POSIX.1-2008).
+
+Signed-off-by: Yegor Yefremov <[email protected]>
+Upstream: https://github.com/Atoptool/atop/pull/415
+---
+ drawbar.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drawbar.c b/drawbar.c
+index 651a81e..e4db0d6 100644
+--- a/drawbar.c
++++ b/drawbar.c
+@@ -104,7 +104,7 @@
+ // the other.
+ /////////////////////////////////////////////////////////////////////////////
+ #define _POSIX_C_SOURCE	200809L
+-#define _XOPEN_SOURCE
++#define _XOPEN_SOURCE	700
+ #define _GNU_SOURCE
+ #define _DEFAULT_SOURCE
+ 
+-- 
+2.34.1
+
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
author Tested-by Thomas Perale on v1 1/1
#1 lore raw

Hi,

Tested by modifying support/testing/tests/package/test_atop.py to use musl library.

I would just add the reference to the buildroot commit that made the bump: 2110131cab2a613567c99491ba540bb33440e46c

In reply of:

Quoted 103 lines

Since the bump to version 2.13.0, atop fails to build with musl:

drawbar.c:2336:33: error: implicit declaration of function 'waddwstr'; did you mean 'waddstr'? [-Wimplicit-function-declaration]

(Before 2.13.0, the same configurations already failed earlier on uClibc because _POSIX_C_SOURCE was defined without a value. Upstream fixed that in 2.13.0 by giving it an explicit value, but the same pattern remains for _XOPEN_SOURCE.)

ncurses only declares its wide-character API, including waddwstr(), when NCURSES_WIDECHAR is set. If the application does not set it, curses.h derives it from the feature test macros:

  #if defined(_XOPEN_SOURCE_EXTENDED) || \
      (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500))

drawbar.c defines _XOPEN_SOURCE with an empty value, which makes the check evaluate as 0 >= 500 and fail.

This only breaks with musl because of the C library's <features.h>, which curses.h pulls in through <stdio.h> before doing the check. glibc and uClibc both redefine _XOPEN_SOURCE to 700 and define _XOPEN_SOURCE_EXTENDED whenever _GNU_SOURCE is set, which drawbar.c does, so the empty definition gets fixed up. musl never modifies the application's feature test macros, so the empty value reaches curses.h and the wide-character prototypes are left out.

Add a patch that defines _XOPEN_SOURCE as 700, matching the _POSIX_C_SOURCE value of 200809L that is already used.

Fixes:
- https://autobuild.buildroot.org/results/914c1d8fa0fc8bbef64e4a64d58e5941d0077a3e
- https://autobuild.buildroot.org/results/b91/b91ea0722202de0d1fdeeaeea167fd1b21b6d5d6

Assisted-by Claude:claude-opus-5-5
---
 ...xplicit-value-for-_XOPEN_SOURCE-macr.patch | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 package/atop/0001-drawbar-define-explicit-value-for-_XOPEN_SOURCE-macr.patch
package/atop/0001-drawbar-define-explicit-value-for-_XOPEN_SOURCE-macr.patch new file +48 -0
new file mode 100644
index 0000000000..d526d58433
@@ -0,0 +1,48 @@
+From 54799216beac63a195cd6d34b22476fc15a80295 Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <[email protected]>
+Date: Wed, 30 Sep 2026 10:59:49 +0200
+Subject: [PATCH] drawbar: define explicit value for _XOPEN_SOURCE macro
+
+drawbar.c uses the wide-character curses function waddwstr(). ncurses
+only declares its wide-character API when NCURSES_WIDECHAR is set,
+which curses.h derives from the feature test macros:
+
+  #if defined(_XOPEN_SOURCE_EXTENDED) || \
+      (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500))
+
+drawbar.c defines _XOPEN_SOURCE without a value, so _XOPEN_SOURCE - 0
+evaluates to 0 and the check fails.
+
+With glibc and uClibc this goes unnoticed, because their <features.h>
+redefines _XOPEN_SOURCE to 700 (and defines _XOPEN_SOURCE_EXTENDED)
+whenever _GNU_SOURCE is set. musl does not touch the application's
+feature test macros, so the empty definition reaches curses.h
+unchanged and the build fails:
+
+drawbar.c:2336:33: error: implicit declaration of function 'waddwstr'; did you mean 'waddstr'? [-Wimplicit-function-declaration]
+
+Define _XOPEN_SOURCE as 700, which matches the already explicit
+_POSIX_C_SOURCE value of 200809L (both refer to POSIX.1-2008).
+
+Signed-off-by: Yegor Yefremov <[email protected]>
+Upstream: https://github.com/Atoptool/atop/pull/415
+---
+ drawbar.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drawbar.c b/drawbar.c
+index 651a81e..e4db0d6 100644
+--- a/drawbar.c
++++ b/drawbar.c
+@@ -104,7 +104,7 @@
+ // the other.
+ /////////////////////////////////////////////////////////////////////////////
+ #define _POSIX_C_SOURCE	200809L
+-#define _XOPEN_SOURCE
++#define _XOPEN_SOURCE	700
+ #define _GNU_SOURCE
+ #define _DEFAULT_SOURCE
+ 
+-- 
+2.34.1
+
Signature · 6 lines
2.34.1

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

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

#2 lore raw

Hi,

Quoted 6 lines · Thomas Perale via buildroot

Hi,

Tested by modifying support/testing/tests/package/test_atop.py to use musl library.

I would just add the reference to the buildroot commit that made the bump: 2110131cab2a613567c99491ba540bb33440e46c

I applied this patch after adding the reference to the commit, as suggested.

Quoted 102 lines

In reply of:

Quoted 99 lines

Since the bump to version 2.13.0, atop fails to build with musl:

drawbar.c:2336:33: error: implicit declaration of function 'waddwstr'; did you mean 'waddstr'? [-Wimplicit-function-declaration]

(Before 2.13.0, the same configurations already failed earlier on uClibc because _POSIX_C_SOURCE was defined without a value. Upstream fixed that in 2.13.0 by giving it an explicit value, but the same pattern remains for _XOPEN_SOURCE.)

ncurses only declares its wide-character API, including waddwstr(), when NCURSES_WIDECHAR is set. If the application does not set it, curses.h derives it from the feature test macros:

  #if defined(_XOPEN_SOURCE_EXTENDED) || \
      (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500))

drawbar.c defines _XOPEN_SOURCE with an empty value, which makes the check evaluate as 0 >= 500 and fail.

This only breaks with musl because of the C library's <features.h>, which curses.h pulls in through <stdio.h> before doing the check. glibc and uClibc both redefine _XOPEN_SOURCE to 700 and define _XOPEN_SOURCE_EXTENDED whenever _GNU_SOURCE is set, which drawbar.c does, so the empty definition gets fixed up. musl never modifies the application's feature test macros, so the empty value reaches curses.h and the wide-character prototypes are left out.

Add a patch that defines _XOPEN_SOURCE as 700, matching the _POSIX_C_SOURCE value of 200809L that is already used.

Fixes:
-
https://autobuild.buildroot.org/results/914c1d8fa0fc8bbef64e4a64d58e5941d0077a3e
-
https://autobuild.buildroot.org/results/b91/b91ea0722202de0d1fdeeaeea167fd1b21b6d5d6

Assisted-by Claude:claude-opus-5-5
---
 ...xplicit-value-for-_XOPEN_SOURCE-macr.patch | 48 
+++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 

package/atop/0001-drawbar-define-explicit-value-for-_XOPEN_SOURCE-macr.patch

(quoted diff) +0 -0
new file mode 100644
index 0000000000..d526d58433

b/package/atop/0001-drawbar-define-explicit-value-for-_XOPEN_SOURCE-macr.patch

(quoted diff) +1 -0
@@ -0,0 +1,48 @@
+From 54799216beac63a195cd6d34b22476fc15a80295 Mon Sep 17 00:00:00 

2001

package/atop/0001-drawbar-define-explicit-value-for-_XOPEN_SOURCE-macr.patch new file +3 -0
+From: Yegor Yefremov <[email protected]>
+Date: Wed, 30 Sep 2026 10:59:49 +0200
+Subject: [PATCH] drawbar: define explicit value for _XOPEN_SOURCE 

macro

package/atop/0001-drawbar-define-explicit-value-for-_XOPEN_SOURCE-macr.patch new file +18 -0
+
+drawbar.c uses the wide-character curses function waddwstr(). ncurses
+only declares its wide-character API when NCURSES_WIDECHAR is set,
+which curses.h derives from the feature test macros:
+
+  #if defined(_XOPEN_SOURCE_EXTENDED) || \
+      (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500))
+
+drawbar.c defines _XOPEN_SOURCE without a value, so _XOPEN_SOURCE - 0
+evaluates to 0 and the check fails.
+
+With glibc and uClibc this goes unnoticed, because their <features.h>
+redefines _XOPEN_SOURCE to 700 (and defines _XOPEN_SOURCE_EXTENDED)
+whenever _GNU_SOURCE is set. musl does not touch the application's
+feature test macros, so the empty definition reaches curses.h
+unchanged and the build fails:
+
+drawbar.c:2336:33: error: implicit declaration of function 

'waddwstr'; did you mean 'waddstr'? [-Wimplicit-function-declaration]

package/atop/0001-drawbar-define-explicit-value-for-_XOPEN_SOURCE-macr.patch new file +17 -0
+
+Define _XOPEN_SOURCE as 700, which matches the already explicit
+_POSIX_C_SOURCE value of 200809L (both refer to POSIX.1-2008).
+
+Signed-off-by: Yegor Yefremov <[email protected]>
+Upstream: https://github.com/Atoptool/atop/pull/415
+---
+ drawbar.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drawbar.c b/drawbar.c
+index 651a81e..e4db0d6 100644
+--- a/drawbar.c
++++ b/drawbar.c
+@@ -104,7 +104,7 @@
+ // the other.
+ 

/////////////////////////////////////////////////////////////////////////////
+ #define _POSIX_C_SOURCE 200809L
+-#define _XOPEN_SOURCE
++#define _XOPEN_SOURCE 700

Quoted 8 lines
Quoted 8 lines

+ #define _GNU_SOURCE
+ #define _DEFAULT_SOURCE

package/atop/0001-drawbar-define-explicit-value-for-_XOPEN_SOURCE-macr.patch new file +4 -1
+
+--
+2.34.1
+
--

2.34.1

Best regards,

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

#3 lore raw
In reply to Yegor Yefremov via buildroot

In reply of:

Quoted 30 lines

Since the bump to version 2.13.0, atop fails to build with musl:

drawbar.c:2336:33: error: implicit declaration of function 'waddwstr'; did you mean 'waddstr'? [-Wimplicit-function-declaration]

(Before 2.13.0, the same configurations already failed earlier on uClibc because _POSIX_C_SOURCE was defined without a value. Upstream fixed that in 2.13.0 by giving it an explicit value, but the same pattern remains for _XOPEN_SOURCE.)

ncurses only declares its wide-character API, including waddwstr(), when NCURSES_WIDECHAR is set. If the application does not set it, curses.h derives it from the feature test macros:

  #if defined(_XOPEN_SOURCE_EXTENDED) || \
      (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500))

drawbar.c defines _XOPEN_SOURCE with an empty value, which makes the check evaluate as 0 >= 500 and fail.

This only breaks with musl because of the C library's <features.h>, which curses.h pulls in through <stdio.h> before doing the check. glibc and uClibc both redefine _XOPEN_SOURCE to 700 and define _XOPEN_SOURCE_EXTENDED whenever _GNU_SOURCE is set, which drawbar.c does, so the empty definition gets fixed up. musl never modifies the application's feature test macros, so the empty value reaches curses.h and the wide-character prototypes are left out.

Add a patch that defines _XOPEN_SOURCE as 700, matching the _POSIX_C_SOURCE value of 200809L that is already used.

Quoted 7 lines

Fixes:
- https://autobuild.buildroot.org/results/914c1d8fa0fc8bbef64e4a64d58e5941d0077a3e
- https://autobuild.buildroot.org/results/b91/b91ea0722202de0d1fdeeaeea167fd1b21b6d5d6

Assisted-by Claude:claude-opus-5-5

Applied to 2026.08.x. Thanks

Quoted 49 lines
---
 ...xplicit-value-for-_XOPEN_SOURCE-macr.patch | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 package/atop/0001-drawbar-define-explicit-value-for-_XOPEN_SOURCE-macr.patch
package/atop/0001-drawbar-define-explicit-value-for-_XOPEN_SOURCE-macr.patch new file +38 -0
new file mode 100644
index 0000000000..d526d58433
@@ -0,0 +1,48 @@
+From 54799216beac63a195cd6d34b22476fc15a80295 Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <[email protected]>
+Date: Wed, 30 Sep 2026 10:59:49 +0200
+Subject: [PATCH] drawbar: define explicit value for _XOPEN_SOURCE macro
+
+drawbar.c uses the wide-character curses function waddwstr(). ncurses
+only declares its wide-character API when NCURSES_WIDECHAR is set,
+which curses.h derives from the feature test macros:
+
+  #if defined(_XOPEN_SOURCE_EXTENDED) || \
+      (defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE - 0 >= 500))
+
+drawbar.c defines _XOPEN_SOURCE without a value, so _XOPEN_SOURCE - 0
+evaluates to 0 and the check fails.
+
+With glibc and uClibc this goes unnoticed, because their <features.h>
+redefines _XOPEN_SOURCE to 700 (and defines _XOPEN_SOURCE_EXTENDED)
+whenever _GNU_SOURCE is set. musl does not touch the application's
+feature test macros, so the empty definition reaches curses.h
+unchanged and the build fails:
+
+drawbar.c:2336:33: error: implicit declaration of function 'waddwstr'; did you mean 'waddstr'? [-Wimplicit-function-declaration]
+
+Define _XOPEN_SOURCE as 700, which matches the already explicit
+_POSIX_C_SOURCE value of 200809L (both refer to POSIX.1-2008).
+
+Signed-off-by: Yegor Yefremov <[email protected]>
+Upstream: https://github.com/Atoptool/atop/pull/415
+---
+ drawbar.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/drawbar.c b/drawbar.c
+index 651a81e..e4db0d6 100644
+--- a/drawbar.c
++++ b/drawbar.c
+@@ -104,7 +104,7 @@
+ // the other.

package/atop/0001-drawbar-define-explicit-value-for-_XOPEN_SOURCE-macr.patch line 48

Quoted 10 lines
package/atop/0001-drawbar-define-explicit-value-for-_XOPEN_SOURCE-macr.patch new file +10 -0
+ /////////////////////////////////////////////////////////////////////////////
+ #define _POSIX_C_SOURCE	200809L
+-#define _XOPEN_SOURCE
++#define _XOPEN_SOURCE	700
+ #define _GNU_SOURCE
+ #define _DEFAULT_SOURCE
+ 
+-- 
+2.34.1
+

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