Thread (6 messages) 6 messages, 2 authors, 2021-09-10

Re: linux-next: build failure while building Linus' tree

From: Nick Desaulniers <ndesaulniers@google.com>
Date: 2021-09-10 22:02:33
Also in: lkml, llvm

On Thu, Sep 9, 2021 at 3:50 PM Nick Desaulniers [off-list ref] wrote:
+ Rasmus

This was introduced in
commit f0907827a8a91 ("compiler.h: enable builtin overflow checkers and add
fallback code")
which added division using the `/` operator, which is problematic when checking
for overflows of 64b operands on 32b targets.

We'll probably need helpers from linux/math64.h and some combination of
__builtin_choose_expr/__builtin_types_compatible_p.

That will help us fix another compiler bug for older clang releases, too.
https://github.com/ClangBuiltLinux/linux/issues/1438.
Ok, I have something hacked up that I think will work:
https://gist.github.com/nickdesaulniers/2479818f4983bbf2d688cebbab435863
This incomplete diff is a little hacked up to reproduce the issue with
a known-bad revision of clang that demonstrates a similar issue to GCC
4.9.  You can ignore the movement of check_mul_overflow and friends in
include/linux/overflow.h.

I think I'm going to break that up into 2 or 3 patches:
1. move is_signed_type from include/linux/overflow.h to perhaps
include/linux/typecheck.h.
2. add div64_x64, div_x64, and div_64 to include/linux/math64.h, use
them in include/linux/overflow.h to fix GCC 4.9
3. move multiply fallbacks out of
COMPILER_HAS_GENERIC_BUILTIN_OVERFLOW for clang < 14.
-- 
Thanks,
~Nick Desaulniers
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help