-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Allow building with latest Clang HEAD #1847
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
Open
arichardson
wants to merge
26
commits into
freebsd:main
Choose a base branch
from
arichardson:clang-head-warning-fixes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+121
−82
Conversation
This file contains hidden or 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
3b547bf
to
a9ada86
Compare
Summary: This ensures this header can be included without an explicit or implicit sys/types.h include first. This causes issues building SPEC2017 which includes sys/rtprio.h and then we get an error due to missing u_char definition. Reviewers: emaste, imp Differential Revision: https://reviews.freebsd.org/D52041
Summary: glibc defines two versions of strerror_r, the char* returning one is used when _GNU_SOURCE is defined. This triggers a -Wint-conversion error in the krb5 strerror_r wrapper, but until clang 19 this was just a normal warning, now it defaults to being an error. /home/runner/work/freebsd-src/freebsd-src/crypto/krb5/src/util/support/strerror_r.c: In function ‘k5_strerror_r’: /home/runner/work/freebsd-src/freebsd-src/crypto/krb5/src/util/support/strerror_r.c:94:12: warning: returning ‘char *’ from a function with return type ‘int’ makes integer from pointer without a cast [-Wint-conversion] 94 | return strerror_r(errnum, buf, buflen); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This was not caught by the GitHub CI since it still builds with clang 18 on the Linux runners. Add -Werror=int-conversion to the build flags to catch errors like this in the future. MFC after: 3 days Reviewers: jrtc27, emaste Subscribers: imp MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D52526
Summary: The init function does not need to aquire a lock for TAILQ_INIT, so just add __no_lock_analysis. We could also acquire the lock to silence the analysis but that is unnecessary. Reviewers: imp MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D52533
Summary: This attribute can be used to annotate char arrays that are not supposed to be terminated with a NUL char and is needed to silence clang's new -Wunterminated-string-initialization warning. The name matches linuxkpi. Reviewers: emaste, imp, jhb, jrtc27 Differential Revision: https://reviews.freebsd.org/D52565
Summary: Use the new __nostring attribute since the signature is not NUL-terminated. Reviewers: imp, emaste, jhb Subscribers: bdragon MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D52535
Reviewers: jhb, emaste Subscribers: imp MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D52528
Fixes build failure with latest clang HEAD: error: initializer-string for character array is too long, array size is 2 but initializer has size 3 (including the null terminating character) MFC after: 3 days
Found by the latest clang HEAD analysis. This is not a false positive. MFC after: 3 days
Found building with latest clang MFC after: 3 days
Fix `passing 'printf' format string where 'freebsd_kprintf' format string is expected [-Werror,-Wformat]` by using __printf__ which is remapped to __freebsd_kprintf__. MFC after: 3 days
This is only used in memcmp() calls, so the missing NUL is safe. MFC after: 3 days
These are not used as strings, don't warn about missing NUL terminator. MFC after: 3 days
This is not used as a string, don't warn about missing NUL terminator. MFC after: 3 days
This is not used as a string, don't warn about missing NUL terminator. MFC after: 3 days
This is not used as a string, don't warn about missing NUL terminator. MFC after: 3 days
Summary: This defaults to an error in clang HEAD, use a char-by-char initializer instead. Reviewers: emaste, jhb, jrtc27 Subscribers: imp MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D52532
This is not used as a string, don't warn about missing NUL terminator. MFC after: 3 days
Use a normal string and strlen() instead of a fixed-size char[]. MFC after: 3 days
This was fixed in upstream ncurses (https://ncurses.scripts.mit.edu/?p=ncurses.git;a=commitdiff;h=64afa9627b292b87c8473928854f3dd8c463d833), but for now only pull in the minimal fix that avoids reading beyond the end of the buffer during strlen(). MFC after: 3 days
Summary: This is not used as a string, don't warn about missing NUL terminator. Silence -Wunterminated-string-initialization warning by adding 1 to size. We can't use __nonstring unconditionally in bmake since the bmake bootstrap headers don't define it. MFC after: 1 week Test Plan: compiles with clang HEAD Reviewers: sjg Subscribers: imp Differential Revision: https://reviews.freebsd.org/D52563
This is triggered by every file that uses gtest-printers.h. See google/googletest#4762. MFC after: 3 days
The __printflike macro sets the format to freebsd_kprintf which recent clang understands and warns about. Fixes the following error: `passing 'printf' format string where 'freebsd_kprintf' format string is expected [-Werror,-Wformat]` MFC after: 1 week
The __printflike macro sets the format to freebsd_kprintf which recent clang understands and warns about. Fixes the following error: `passing 'printf' format string where 'freebsd_kprintf' format string is expected [-Werror,-Wformat]` MFC after: 1 week
The native_to_linux_itimerspec() call should have used l_oval as the output parameter here.
Summary: The netmap_ring struct starts with various const members and rencent clang warns about leaving them uninitialized. Having them const in the first place is highly suspicious since they are updated with various macros but using hand-coded __DECONST(). But fixing that is a more invasive change that I am unable to test. ``` .../freebsd/sys/dev/netmap/netmap_kloop.c:320:21: error: default initialization of an object of type 'struct netmap_ring' with const member leaves the object uninitialized [-Werror,-Wdefault-const-init-field-unsafe] 320 | struct netmap_ring shadow_ring; /* shadow copy of the netmap_ring */ | ^ .../freebsd/sys/net/netmap.h:290:16: note: member 'buf_ofs' declared 'const' here 290 | const int64_t buf_ofs; | ^ ``` Test Plan: Compiles Reviewers: vmaffione, jhb Subscribers: imp Differential Revision: https://reviews.freebsd.org/D52568
a9ada86
to
71ae6c7
Compare
This should be ready now, I've built it locally targeting amd64 and risc64 |
Use the latest Clang packages available for macos and Ubuntu 24.04 to ensure we also test newer versions in addition to the oldest supported version.
d17474f
to
70633bc
Compare
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.
I uploaded many of these to phabricator, but for a lot of these small ones it seems like a lot of overhead, so I'm just pushing the full set of required changes here.