public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH 0/3] tools/sched_ext: fix compilation issues
@ 2026-03-03  7:23 Zhao Mengmeng
  2026-03-03  7:23 ` [PATCH 1/3] tools/sched_ext: Add -fms-extensions to bpf build flags Zhao Mengmeng
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Zhao Mengmeng @ 2026-03-03  7:23 UTC (permalink / raw)
  To: tj, void, arighi, changwoo, shuah, nathan, nick.desaulniers+lkml,
	morbo, justinstitt
  Cc: sched-ext, linux-kernel, linux-kselftest, bpf, llvm, zhaomengmeng

From: Zhao Mengmeng <zhaomengmeng@kylinos.cn>

This series addresses compilation issues in the sched_ext (scx)
tooling and selftests when using Clang 17.

1. Add -fms-extensions flags to scheduler and selftests to avoid build
warning like "declaration does not declare anything"
2. Use signed div for peek_dsq.bpf.c to avoid clang 17 crash.

Zhao Mengmeng (3):
  tools/sched_ext: Add -fms-extensions to bpf build flags
  selftests/sched_ext: Add -fms-extensions to bpf build flags
  selftests/sched_ext: Fix peek_dsq.bpf.c compile error for clang 17

 tools/sched_ext/Makefile                         | 2 ++
 tools/testing/selftests/sched_ext/Makefile       | 2 ++
 tools/testing/selftests/sched_ext/peek_dsq.bpf.c | 4 ++--
 3 files changed, 6 insertions(+), 2 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] tools/sched_ext: Add -fms-extensions to bpf build flags
  2026-03-03  7:23 [PATCH 0/3] tools/sched_ext: fix compilation issues Zhao Mengmeng
@ 2026-03-03  7:23 ` Zhao Mengmeng
  2026-03-03  7:23 ` [PATCH 2/3] selftests/sched_ext: " Zhao Mengmeng
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Zhao Mengmeng @ 2026-03-03  7:23 UTC (permalink / raw)
  To: tj, void, arighi, changwoo, shuah, nathan, nick.desaulniers+lkml,
	morbo, justinstitt
  Cc: sched-ext, linux-kernel, linux-kselftest, bpf, llvm, zhaomengmeng

From: Zhao Mengmeng <zhaomengmeng@kylinos.cn>

Similar to commit 835a50753579 ("selftests/bpf: Add -fms-extensions to
bpf build flags") and commit 639f58a0f480 ("bpftool: Fix build warnings
due to MS extensions")

The kernel is now built with -fms-extensions, therefore
generated vmlinux.h contains types like:
struct aes_key {
        struct aes_enckey;
        union aes_invkey_arch inv_k;
};

struct ns_common {
	...
        union {
                struct ns_tree;
                struct callback_head ns_rcu;
        };
};

Which raise warning like below when building scx scheduler:

tools/sched_ext/build/include/vmlinux.h:50533:3: warning:
declaration does not declare anything [-Wmissing-declarations]
 50533 |                 struct ns_tree;
       |                 ^
Fix it by using -fms-extensions and -Wno-microsoft-anon-tag flags
to build bpf programs that #include "vmlinux.h"

Signed-off-by: Zhao Mengmeng <zhaomengmeng@kylinos.cn>
---
 tools/sched_ext/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/sched_ext/Makefile b/tools/sched_ext/Makefile
index 47ad7444677e..21554f089692 100644
--- a/tools/sched_ext/Makefile
+++ b/tools/sched_ext/Makefile
@@ -122,6 +122,8 @@ BPF_CFLAGS = -g -D__TARGET_ARCH_$(SRCARCH)					\
 	     -I../../include							\
 	     $(call get_sys_includes,$(CLANG))					\
 	     -Wall -Wno-compare-distinct-pointer-types				\
+	     -Wno-microsoft-anon-tag						\
+	     -fms-extensions							\
 	     -O2 -mcpu=v3
 
 # sort removes libbpf duplicates when not cross-building
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] selftests/sched_ext: Add -fms-extensions to bpf build flags
  2026-03-03  7:23 [PATCH 0/3] tools/sched_ext: fix compilation issues Zhao Mengmeng
  2026-03-03  7:23 ` [PATCH 1/3] tools/sched_ext: Add -fms-extensions to bpf build flags Zhao Mengmeng
@ 2026-03-03  7:23 ` Zhao Mengmeng
  2026-03-03  7:23 ` [PATCH 3/3] selftests/sched_ext: Fix peek_dsq.bpf.c compile error for clang 17 Zhao Mengmeng
  2026-03-03  7:50 ` [PATCH 0/3] tools/sched_ext: fix compilation issues Andrea Righi
  3 siblings, 0 replies; 5+ messages in thread
From: Zhao Mengmeng @ 2026-03-03  7:23 UTC (permalink / raw)
  To: tj, void, arighi, changwoo, shuah, nathan, nick.desaulniers+lkml,
	morbo, justinstitt
  Cc: sched-ext, linux-kernel, linux-kselftest, bpf, llvm, zhaomengmeng

From: Zhao Mengmeng <zhaomengmeng@kylinos.cn>

Similar to commit 835a50753579 ("selftests/bpf: Add -fms-extensions to
bpf build flags") and commit 639f58a0f480 ("bpftool: Fix build warnings
due to MS extensions")

Fix "declaration does not declare anything" warning by using
-fms-extensions and -Wno-microsoft-anon-tag flags to build bpf programs
that #include "vmlinux.h"

Signed-off-by: Zhao Mengmeng <zhaomengmeng@kylinos.cn>
---
 tools/testing/selftests/sched_ext/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/sched_ext/Makefile b/tools/testing/selftests/sched_ext/Makefile
index 2815a875bde2..a3bbe2c7911b 100644
--- a/tools/testing/selftests/sched_ext/Makefile
+++ b/tools/testing/selftests/sched_ext/Makefile
@@ -93,6 +93,8 @@ BPF_CFLAGS = -g -D__TARGET_ARCH_$(SRCARCH)					\
 	     $(CLANG_SYS_INCLUDES) 						\
 	     -Wall -Wno-compare-distinct-pointer-types				\
 	     -Wno-incompatible-function-pointer-types				\
+	     -Wno-microsoft-anon-tag						\
+	     -fms-extensions							\
 	     -O2 -mcpu=v3
 
 # sort removes libbpf duplicates when not cross-building
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] selftests/sched_ext: Fix peek_dsq.bpf.c compile error for clang 17
  2026-03-03  7:23 [PATCH 0/3] tools/sched_ext: fix compilation issues Zhao Mengmeng
  2026-03-03  7:23 ` [PATCH 1/3] tools/sched_ext: Add -fms-extensions to bpf build flags Zhao Mengmeng
  2026-03-03  7:23 ` [PATCH 2/3] selftests/sched_ext: " Zhao Mengmeng
@ 2026-03-03  7:23 ` Zhao Mengmeng
  2026-03-03  7:50 ` [PATCH 0/3] tools/sched_ext: fix compilation issues Andrea Righi
  3 siblings, 0 replies; 5+ messages in thread
From: Zhao Mengmeng @ 2026-03-03  7:23 UTC (permalink / raw)
  To: tj, void, arighi, changwoo, shuah, nathan, nick.desaulniers+lkml,
	morbo, justinstitt
  Cc: sched-ext, linux-kernel, linux-kselftest, bpf, llvm, zhaomengmeng

From: Zhao Mengmeng <zhaomengmeng@kylinos.cn>

When compiling sched_ext selftests using clang 17.0.6, it raised
compiler crash and build error:

Error at line 68: Unsupport signed division for DAG: 0x55b2f9a60240:
i64 = sdiv 0x55b2f9a609b0, Constant:i64<100>, peek_dsq.bpf.c:68:25 @[
peek_dsq.bpf.c:95:4 @[ peek_dsq.bpf.c:169:8 @[ peek
_dsq.bpf.c:140:6 ] ] ]Please convert to unsigned div/mod

After digging, it's not a compiler error, clang supported Signed division
only when using -mcpu=v4, while we use -mcpu=v3 currently, the better way
is to use unsigned div, see [1] for details.

[1] https://github.com/llvm/llvm-project/issues/70433

Signed-off-by: Zhao Mengmeng <zhaomengmeng@kylinos.cn>
---
 tools/testing/selftests/sched_ext/peek_dsq.bpf.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/sched_ext/peek_dsq.bpf.c b/tools/testing/selftests/sched_ext/peek_dsq.bpf.c
index a3faf5bb49d6..784f2f6c1af9 100644
--- a/tools/testing/selftests/sched_ext/peek_dsq.bpf.c
+++ b/tools/testing/selftests/sched_ext/peek_dsq.bpf.c
@@ -58,14 +58,14 @@ static void record_peek_result(long pid)
 {
 	u32 slot_key;
 	long *slot_pid_ptr;
-	int ix;
+	u32 ix;
 
 	if (pid <= 0)
 		return;
 
 	/* Find an empty slot or one with the same PID */
 	bpf_for(ix, 0, 10) {
-		slot_key = (pid + ix) % MAX_SAMPLES;
+		slot_key = ((u64)pid + ix) % MAX_SAMPLES;
 		slot_pid_ptr = bpf_map_lookup_elem(&peek_results, &slot_key);
 		if (!slot_pid_ptr)
 			continue;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] tools/sched_ext: fix compilation issues
  2026-03-03  7:23 [PATCH 0/3] tools/sched_ext: fix compilation issues Zhao Mengmeng
                   ` (2 preceding siblings ...)
  2026-03-03  7:23 ` [PATCH 3/3] selftests/sched_ext: Fix peek_dsq.bpf.c compile error for clang 17 Zhao Mengmeng
@ 2026-03-03  7:50 ` Andrea Righi
  3 siblings, 0 replies; 5+ messages in thread
From: Andrea Righi @ 2026-03-03  7:50 UTC (permalink / raw)
  To: Zhao Mengmeng
  Cc: tj, void, changwoo, shuah, nathan, nick.desaulniers+lkml, morbo,
	justinstitt, sched-ext, linux-kernel, linux-kselftest, bpf, llvm,
	zhaomengmeng

On Tue, Mar 03, 2026 at 03:23:14PM +0800, Zhao Mengmeng wrote:
> From: Zhao Mengmeng <zhaomengmeng@kylinos.cn>
> 
> This series addresses compilation issues in the sched_ext (scx)
> tooling and selftests when using Clang 17.
> 
> 1. Add -fms-extensions flags to scheduler and selftests to avoid build
> warning like "declaration does not declare anything"
> 2. Use signed div for peek_dsq.bpf.c to avoid clang 17 crash.

I confirm this removes the annoying warnings and these options are used in
other BPF selftests as well, so looks good to me.

Reviewed-by: Andrea Righi <arighi@nvidia.com>

Thanks!
-Andrea

> 
> Zhao Mengmeng (3):
>   tools/sched_ext: Add -fms-extensions to bpf build flags
>   selftests/sched_ext: Add -fms-extensions to bpf build flags
>   selftests/sched_ext: Fix peek_dsq.bpf.c compile error for clang 17
> 
>  tools/sched_ext/Makefile                         | 2 ++
>  tools/testing/selftests/sched_ext/Makefile       | 2 ++
>  tools/testing/selftests/sched_ext/peek_dsq.bpf.c | 4 ++--
>  3 files changed, 6 insertions(+), 2 deletions(-)
> 
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-03  7:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-03  7:23 [PATCH 0/3] tools/sched_ext: fix compilation issues Zhao Mengmeng
2026-03-03  7:23 ` [PATCH 1/3] tools/sched_ext: Add -fms-extensions to bpf build flags Zhao Mengmeng
2026-03-03  7:23 ` [PATCH 2/3] selftests/sched_ext: " Zhao Mengmeng
2026-03-03  7:23 ` [PATCH 3/3] selftests/sched_ext: Fix peek_dsq.bpf.c compile error for clang 17 Zhao Mengmeng
2026-03-03  7:50 ` [PATCH 0/3] tools/sched_ext: fix compilation issues Andrea Righi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox