[LTP] [PATCH v3 1/4] include: tst_clone.h: Fix possible MUSL build failures

Cyril Hrubis chrubis@suse.cz
Tue Aug 27 14:02:34 CEST 2024


The problem is that on musl sched.h exposes clone() when _GNU_SOURCE is
defined and at the same time sched.h does not get pulled before
tst_clone.h gets included, which means that the macro from tst_clone.h
that rewrites clone() functions actually rewrites the function
declaration in the system header.

We remove the tst_clone.h from the old library because the newly
included sched.h causes conflicts in the cpuset/cpuset_lib/ directory
and the tst_clone.h header is used only in a single old library test
i.e. clone02.c.

This commit is needed in order to avoid build failures in the next
commits that add support for the shell test library.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 include/old/test.h                        | 1 -
 include/tst_clone.h                       | 2 ++
 testcases/kernel/syscalls/clone/clone02.c | 1 +
 3 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/include/old/test.h b/include/old/test.h
index 0e210e4ef..306868fb5 100644
--- a/include/old/test.h
+++ b/include/old/test.h
@@ -31,7 +31,6 @@
 #include "tst_pid.h"
 #include "tst_cmd.h"
 #include "tst_cpu.h"
-#include "tst_clone.h"
 #include "old_device.h"
 #include "old_tmpdir.h"
 #include "tst_minmax.h"
diff --git a/include/tst_clone.h b/include/tst_clone.h
index 56f23142d..a57d761ca 100644
--- a/include/tst_clone.h
+++ b/include/tst_clone.h
@@ -5,6 +5,8 @@
 #ifndef TST_CLONE_H__
 #define TST_CLONE_H__
 
+#include <sched.h>
+
 #ifdef TST_TEST_H__
 
 /* The parts of clone3's clone_args we support */
diff --git a/testcases/kernel/syscalls/clone/clone02.c b/testcases/kernel/syscalls/clone/clone02.c
index 821adc2d9..fd3ee1aed 100644
--- a/testcases/kernel/syscalls/clone/clone02.c
+++ b/testcases/kernel/syscalls/clone/clone02.c
@@ -59,6 +59,7 @@
 #include <sched.h>
 #include "test.h"
 #include "safe_macros.h"
+#include "tst_clone.h"
 
 #define FLAG_ALL (CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|SIGCHLD)
 #define FLAG_NONE SIGCHLD
-- 
2.44.2



More information about the ltp mailing list