2024-04-04 16:36:05

by Nick Desaulniers

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

Thanks for the report. We've been tracking getting this working for a
while: https://github.com/ClangBuiltLinux/linux/issues/1698. Other
fires have continued to take priority.

On Thu, Apr 4, 2024 at 9:30 AM Muhammad Usama Anjum
<[email protected]> wrote:
>
> 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?

As with anything kernel related; help send patches for obvious fixes.
Or provide steps to reproduce in
https://github.com/ClangBuiltLinux/linux/issues/1698.

--
Thanks,
~Nick Desaulniers


2024-04-04 17:08:14

by Shuah Khan

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

On 4/4/24 10:34, Nick Desaulniers wrote:
> Thanks for the report. We've been tracking getting this working for a
> while: https://github.com/ClangBuiltLinux/linux/issues/1698. Other
> fires have continued to take priority.
>
> On Thu, Apr 4, 2024 at 9:30 AM Muhammad Usama Anjum
> <[email protected]> wrote:
>>
>> 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?
>
> As with anything kernel related; help send patches for obvious fixes.
> Or provide steps to reproduce in
> https://github.com/ClangBuiltLinux/linux/issues/1698.
>

+1 on this. Please send patches to fixes as you find them. We have
been taking fixes found by clang and -Wformat-security, -Werror
checks.

thanks,
-- Shuah