While compiling Busybox 1.7.2 using the default config (make defconfig) with a specific ARM toolchain, I encountered two specific compilation errors. One was related to the route applet, and the other was in taskset.c.
I resolved the taskset.c issue by disabling it temporarily, but later found a proper fix. The root cause lies in a mismatch between uClibc (which Busybox is primarily designed for) and glibc. Specifically, the number of arguments for sched_getaffinity and sched_setaffinity differs between the two.
Error Log:
CC miscutils/taskset.o
miscutils/taskset.c: In function `taskset_main':
miscutils/taskset.c:78: warning: passing arg 2 of `sched_getaffinity'
makes pointer from integer without a cast
miscutils/taskset.c:78: error: too many arguments to function
`sched_getaffinity'
...
Solution:
We can use a preprocessor check for __GLIBC__ to handle the parameter difference. Here is the patch applied to taskset.c:
--- miscutils/taskset.c
+++ miscutils/taskset.c
@@ -75,7 +75,13 @@
if (opt & OPT_p) {
print_aff:
+ /* Glilbc has 2 params for this func */
+#ifdef __GLIBC__
+ if (sched_getaffinity(pid, &mask) < 0)
+#else
if (sched_getaffinity(pid, sizeof(mask), &mask) < 0)
+#endif
bb_perror_msg_and_die("failed to get pid %d's affinity", pid);
By applying this change, the compilation completes successfully. This is a classic example of the subtle porting challenges when working with different C libraries in embedded Linux development.
Comments & Feedback