2024-04-04 17:00:00

by Muhammad Usama Anjum

[permalink] [raw]
Subject: [Bug Report] selftests: Clang: kselftests build errors in KernelCI

Hi,

We have caught bugs in kselftest suites on linux-next and on stable-RCs etc
when using clang. There are two types of bugs (logs with clang-17 are
attached.):
As usually people use GCC, there are GCC-specific flags added to the
Makefiles that clang doesn't recognize. For example:
* clang: error: argument unused during compilation: '-pie'
[-Werror,-Wunused-command-line-argument]
* clang: error: unknown argument '-static-libasan'; did you mean
'-static-libsan'?
* clang: error: cannot specify -o when generating multiple output files

Clang has best static analysis tools. It is reporting static errors. For
example:
* test_execve.c:121:13: warning: variable 'have_outer_privilege' is used
uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
* test_execve.c:121:9: note: remove the 'if' if its condition is always true
* test_memcontrol.c:727:6: warning: variable 'fd' is used uninitialized
whenever 'if' condition is true [-Wsometimes-uninitialized]

We have found these issues through our new KernelCI system when enabling
kselftest and clang there. The new system dashboard is a WIP, so It is not
the web dashboard you are used-to with in KernelCI. We can show you ways of
pulling the data if you are interest into.

Unless the above is some sort of false-positive or misconfiguration, it
would be great to support clang for kselftests. What we can do from our
side is that clang kselftests builds should be enabled on KernelCI to find
and fix the errors. What is your stance about this?

Thanks,
Usama


Attachments:
stable-rc.log (100.54 kB)
kselftest.next-20240404.log (528.71 kB)
Download all attachments