Re: lib/test_bitmap.c:920:2: error: call to '__compiletime_assert_239' declared with 'error' attribute: BUILD_BUG_ON failed: !__builtin_constant_p(res)

From: Alexander Lobakin
Date: Fri Jun 16 2023 - 10:05:35 EST


From: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
Date: Thu, 15 Jun 2023 16:48:22 -0400

> On Thu, Jun 15, 2023 at 3:52 PM Nick Desaulniers
> <ndesaulniers@xxxxxxxxxx> wrote:
>>
>> On Thu, Jun 15, 2023 at 7:22 AM Andy Shevchenko
>> <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:

[...]

>>>> 896 bitmap_clear(bitmap, 0, BITS_PER_LONG);
>>>> 897 #if defined(__s390__) && defined(__clang__)
>>>> 898 if (!const_test_bit(7, bitmap))
>>>> 899 #else
>>>> 900 if (!test_bit(7, bitmap))
>>>> 901 #endif
>>>
>>> Hmm... Reveals the bug in clang/arm64?
>>
>> Seems related to the config. ARCH=arm64 defconfig +
>> CONFIG_TEST_BITMAP=y doesn't trigger this for me, but the randconfig
>> does. We'll bisect the config, and update the thread tracking this:
>> https://github.com/ClangBuiltLinux/linux/issues/1874
>
> KASAN and GCOV together seem to be tickling this.

Thanks for root-causing this!
Should I prepare a patch which would work around KASAN + GCOV here or
you're digging the Clang sources for potential issues?

>
>>
>>>
>>>> 919 res = !test_bit(18, &bitopvar);
>>>> > 920 BUILD_BUG_ON(!__builtin_constant_p(res));
>>>> 921 BUILD_BUG_ON(!res);
>>>
>>>
>>> --
>>> With Best Regards,
>>> Andy Shevchenko
>>>
>>>
>>>
>>
>>
>> --
>> Thanks,
>> ~Nick Desaulniers
>
>
>

Thanks,
Olek