-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Linux: Fix build warnings from LLVM/Clang 15.0.7 #14738
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ryao
commented
Apr 11, 2023
Building with Clang on Linux generates a warning that err could be uninitialized if mnt_ns is a NULL pointer. However, mnt_ns should never be NULL, so there is no need to put this behind an if statement. Taking it outside of the if statement means that the possibility of err being uninitialized goes from being always zero in a way that the compiler could not realize to a way that is always zero in a way that the compiler can realize. Sponsored-By: Wasabi Technology, Inc. Signed-off-by: Richard Yao <richard.yao@klarasystems.com>
Clang points out that there is a comparison against -1, but we cannot fix it because that is from the kernel headers, which we must support. We can workaround this by using a pragma. Sponsored-By: Wasabi Technology, Inc. Signed-off-by: Richard Yao <richard.yao@klarasystems.com>
For reference, this is the output from
Linux's tracepoint headers do a compile time check to see if a type is signed or unsigned, and this trips the compiler diagnostic. |
behlendorf
approved these changes
Apr 20, 2023
behlendorf
pushed a commit
that referenced
this pull request
Apr 20, 2023
Clang points out that there is a comparison against -1, but we cannot fix it because that is from the kernel headers, which we must support. We can workaround this by using a pragma. Sponsored-By: Wasabi Technology, Inc. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Youzhong Yang <yyang@mathworks.com> Signed-off-by: Richard Yao <richard.yao@klarasystems.com> Closes #14738
andrewc12
pushed a commit
to andrewc12/openzfs
that referenced
this pull request
May 1, 2023
Building with Clang on Linux generates a warning that err could be uninitialized if mnt_ns is a NULL pointer. However, mnt_ns should never be NULL, so there is no need to put this behind an if statement. Taking it outside of the if statement means that the possibility of err being uninitialized goes from being always zero in a way that the compiler could not realize to a way that is always zero in a way that the compiler can realize. Sponsored-By: Wasabi Technology, Inc. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Youzhong Yang <yyang@mathworks.com> Signed-off-by: Richard Yao <richard.yao@klarasystems.com> Closes openzfs#14738
andrewc12
pushed a commit
to andrewc12/openzfs
that referenced
this pull request
May 1, 2023
Clang points out that there is a comparison against -1, but we cannot fix it because that is from the kernel headers, which we must support. We can workaround this by using a pragma. Sponsored-By: Wasabi Technology, Inc. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Youzhong Yang <yyang@mathworks.com> Signed-off-by: Richard Yao <richard.yao@klarasystems.com> Closes openzfs#14738
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
I recently needed to build a recent kernel on a Ubuntu 18.04 system with sanitizers that required a much more recent compiler than those included with Ubuntu 18.04. The first modern compiler that I got working on it was LLVM/Clang 15.0.7, so I built both the kernel and ZFS with it, only to discover that -Werror causes build failures because of issues that go uncaught because almost nobody builds the Linux kernel modules with LLVM/Clang.
This was done by Klara Systems and sponsored by Wasabi Technology, Inc.
Description
The individual patches have descriptions.
How Has This Been Tested?
Here are some rough instructions describing how I tested this.
I first installed pkgsrc:
I then built Linux roughly this way:
For ZFS, I had a local branch that I rebased on master, but the commands to do the same with master are roughly this:
The make command will fail without these patches.
I needed to install new firmware for the newer kernel's NIC driver:
There is a debian bug for that:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1006500
There is a weird bug in the kernel's block device driver for the controller that has the drive with the rootfs where it requires the partitions to be reprobed when kexec booting (it affects older kernels, although I have yet to confirm it also affects the latest), so I installed dracut and modified it to reprobe all devices:
Then I kexec booted into the new kernel after building an initramfs archive:
After reconnecting to the machine over SSH, I was able to load the kernel modules:
Then I simply imported the pool and ran a workload on it. Everything worked.
Types of changes
Checklist:
Signed-off-by
.