-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clang inspired fixes, add clang CI permutation #172
Conversation
Whelp seems like sanitizers and clang don't play well together... I'm assuming gcc uses static sanitizer libs while clang shared ones, or vice versa. Flipping to draft, feel free to review and comment though. |
Required for puts(), reported by clang-tidy. Fixes: b644b8d ("tools: add kmod_version() helper") Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
Required for size_t, reported by clang-tidy. Fixes: 38943b2 ("shared: use size_t for strbuf") Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
Initialize the variable, otherwise we'll get (random) stack value if the user hasn't provided --syslog. Reported by scan-build. Fixes: ca8f04e ("tools/insmod: add syslog and verbose options") Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
Initialize the variable, otherwise we'll get (random) stack value if the user hasn't provided --syslog. Reported by scan-build. Fixes: 24fe68d ("tools/rmmod: make opt variables non-global") Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
Initialize the variable, otherwise we'll get (random) stack value if the user hasn't provided --syslog. Reported by scan-build. Fixes: 6313d40 ("tools/lsmod: add basic opts like rmmod") Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
Older versions of clang (14.0.0 as seen in Ubuntu 22.04) will flag a warning that we're using unsigned int, with a unsigned char modifier. Newer versions like 16.0.6 (Debian unstable), 17.0.6 (Alpine), etc do not flag this as an issue. In practise the number fits in the latter range, so just add a cast to silence the warning. Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
Clang will detect that the enum cannot be zero, thus triggering a warning. Since this is an external (public API) function, the end-user can provide any input so we want to keep the check. Note: include the pragmas in a if defined(__clang__) guard, otherwise we'll trigger -Wunknown_pragma which will become an error in CI and developer builds. Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
There was some recent snafu which meant the container wasn't available. With that resolved, we can drop our hack and use the correct container directly. Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
I'm about to add some more and the current (almost sorted) state breaks my brain :-x Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
Applied most of the patches, leaving some comments in others. Thanks |
7617ce7
to
e8d1628
Compare
Updated the PR dropping the already merged changes. In addition we have:
CI now passes all permutations apart from Fedora 40 and Ubuntu 22.04:
As you can see I didn't succeed in excluding them - web linter complains Any tips would be appreciated. In the meanwhile feel free to grab whatever makes sense. |
e8d1628
to
0e3493f
Compare
Is this still a draft? |
Since it's getting really hairy, I've split out the prep patches into separate PRs. As those land, I will respin the final patches and undraft. |
31ad907
to
497a04a
Compare
The newly enabled clang build already flagged another few issues (alongside the ELFDBG) 🎉 In addition we have:
Last two are from #172 ... With the final outstanding piece (add test toggle --disable-sanitizer) which doesn't seem doable ATM. |
The recently added "always build ELFDBG" patch is already paying dividends... Clang is flagging a "fmt" is not literal warning. That's clearly wrong, although without _printf_format_ clang was struggling to figure things out. With the attribute, it helpfully flagged that handful of the modifiers are wrong. Signed-off-by: Emil Velikov <[email protected]>
Convert the existing wrapper script, into one that we source to set the environment aka LD_PRELOAD. Thus a developer can, use/test/debug the tests without using meson. Namely: - source scripts/sanitizer-env.sh - build/testsuite/test-depmod Signed-off-by: Emil Velikov <[email protected]>
With the sanitizers supported in both gcc + clang and all the issues resolved, let's enable them via build-dev.ini. This means, developers will see any issues OOTB without having to run through the CI. As a nice bonus, let's re-enable them for ubuntu:22.04 - it should be working fine now. Signed-off-by: Emil Velikov <[email protected]>
497a04a
to
c89d457
Compare
Masking Fedora + clang, nuked clang all together 🤯 Converted to keep Fedora gcc/clang yet disable the sanitizers. Plus some last second commit reshuffle, for extra fun 😂 |
By default clang uses static sanitizer libraries, which causes build and test-time failures. Swap for the shared libasan which resolves both. Note: meson tries to be helpful here, throwing a warning that we should use -D b_lundef=false which is incorrect in our case. Signed-off-by: Emil Velikov <[email protected]>
With the clang issues resolved, let's add it to the CI matrix so fewer issues get it. Note: Fedora 40 doesn't ship the shared sanitizer library, while older Fedora versions did. Fedora 41 will be coming with LLVM 19, which will have the binary (seemingly with different name 🤦). Let's leave the Fedora/clang infra in and just mask it out sanitizers for the next month or so, until the new version comes out. Then we can re-evaluate. Signed-off-by: Emil Velikov <[email protected]>
Signed-off-by: Emil Velikov <[email protected]>
Mention that running outside of `meson test", one needs to set the env. aka "source scripts/sanitizer-env.sh". Also gently discourage using sanitizers alongside gdb and strace. While thing might work it's not the setup we want to support, I think. Signed-off-by: Emil Velikov <[email protected]>
c89d457
to
86f2f91
Compare
We have added meson recently, with the goal to remove the make/autotools one in a release or two. Update the reference to the meson equivalent. Signed-off-by: Emil Velikov <[email protected]>
86f2f91
to
154fe19
Compare
The recently added "always build ELFDBG" patch is already paying dividends... Clang is flagging a "fmt" is not literal warning. That's clearly wrong, although without _printf_format_ clang was struggling to figure things out. With the attribute, it helpfully flagged that handful of the modifiers are wrong. Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
Convert the existing wrapper script, into one that we source to set the environment aka LD_PRELOAD. Thus a developer can, use/test/debug the tests without using meson. Namely: - source scripts/sanitizer-env.sh - build/testsuite/test-depmod Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
With the sanitizers supported in both gcc + clang and all the issues resolved, let's enable them via build-dev.ini. This means, developers will see any issues OOTB without having to run through the CI. As a nice bonus, let's re-enable them for ubuntu:22.04 - it should be working fine now. Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
By default clang uses static sanitizer libraries, which causes build and test-time failures. Swap for the shared libasan which resolves both. Note: meson tries to be helpful here, throwing a warning that we should use -D b_lundef=false which is incorrect in our case. Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
With the clang issues resolved, let's add it to the CI matrix so fewer issues get it. Note: Fedora 40 doesn't ship the shared sanitizer library, while older Fedora versions did. Fedora 41 will be coming with LLVM 19, which will have the binary (seemingly with different name 🤦). Let's leave the Fedora/clang infra in and just mask it out sanitizers for the next month or so, until the new version comes out. Then we can re-evaluate. Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
Mention that running outside of `meson test", one needs to set the env. aka "source scripts/sanitizer-env.sh". Also gently discourage using sanitizers alongside gdb and strace. While thing might work it's not the setup we want to support, I think. Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
We have added meson recently, with the goal to remove the make/autotools one in a release or two. Update the reference to the meson equivalent. Signed-off-by: Emil Velikov <[email protected]> Link: #172 Signed-off-by: Lucas De Marchi <[email protected]>
I did a small fixup in testsuite/README and applied. Thanks! |
This series fixes all the issues spotted by clang (+ be that clang itself, scan-build or cland-tidy) and adds it to CI.
At a glance - from the 5 distros we have 4 major clang versions and as indicated in the patches, there's some value in having them.
Understandably, the CI matrix is becoming a bit of a zoo... Although half of it will be gone with the drop of autotools, soon (tm) 😅
Plus since they're all parallel jobs, I think we can bare with it.