public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* mainline build failure for x86_64 and arm64 with clang
@ 2022-09-26  8:55 Sudip Mukherjee (Codethink)
  2022-09-26 15:39 ` Nathan Chancellor
  0 siblings, 1 reply; 3+ messages in thread
From: Sudip Mukherjee (Codethink) @ 2022-09-26  8:55 UTC (permalink / raw)
  To: nathan, ndesaulniers; +Cc: torvalds, linux-kernel, llvm

Hi All,

Yesterday I updated my clang to:
clang version 16.0.0 (https://github.com/llvm/llvm-project.git bcb1397bda667e75200ae0be9a65fd17dd0763d4)

And with that I see new build failures of mainline.

I am not copying all the errors but others look similar to these.
From x86_64 almodconfig:

In file included from scripts/mod/devicetable-offsets.c:3:
In file included from ./include/linux/mod_devicetable.h:13:
In file included from ./include/linux/uuid.h:12:
In file included from ./include/linux/string.h:253:
./include/linux/fortify-string.h:159:10: error: ISO C does not allow indirection on operand of type 'void *' [-Werror,-Wvoid-ptr-dereference]
        q_len = strlen(q);
                ^~~~~~~~~

From x86_64 defconfig:

In file included from arch/x86/kernel/asm-offsets.c:9:
In file included from ./include/linux/crypto.h:20:
In file included from ./include/linux/slab.h:15:
In file included from ./include/linux/gfp.h:7:
In file included from ./include/linux/mmzone.h:8:
In file included from ./include/linux/spinlock.h:55:
In file included from ./include/linux/preempt.h:78:
In file included from ./arch/x86/include/asm/preempt.h:7:
In file included from ./include/linux/thread_info.h:60:
In file included from ./arch/x86/include/asm/thread_info.h:53:
In file included from ./arch/x86/include/asm/cpufeature.h:5:
In file included from ./arch/x86/include/asm/processor.h:22:
In file included from ./arch/x86/include/asm/msr.h:11:
In file included from ./arch/x86/include/asm/cpumask.h:5:
In file included from ./include/linux/cpumask.h:12:
In file included from ./include/linux/bitmap.h:9:
./include/linux/find.h:119:31: error: ISO C does not allow indirection on operand of type 'void *' [-Werror,-Wvoid-ptr-dereference]
                unsigned long val = *addr & GENMASK(size - 1, 0);
                                            ^~~~~~~~~~~~~~~~~~~~
./include/linux/bits.h:38:3: note: expanded from macro 'GENMASK'
        (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
         ^~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/bits.h:25:3: note: expanded from macro 'GENMASK_INPUT_CHECK'
                __is_constexpr((l) > (h)), (l) > (h), 0)))
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/const.h:12:25: note: expanded from macro '__is_constexpr'
        (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
                               ^
./include/linux/build_bug.h:16:62: note: expanded from macro 'BUILD_BUG_ON_ZERO'
#define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))


From arm64 allmodconfig:

In file included from scripts/mod/devicetable-offsets.c:3:
In file included from ./include/linux/mod_devicetable.h:13:
In file included from ./include/linux/uuid.h:12:
In file included from ./include/linux/string.h:253:
./include/linux/fortify-string.h:159:10: error: ISO C does not allow indirection on operand of type 'void *' [-Werror,-Wvoid-ptr-dereference]
        q_len = strlen(q);
                ^~~~~~~~~
./include/linux/fortify-string.h:131:24: note: expanded from macro 'strlen'
        __builtin_choose_expr(__is_constexpr(__builtin_strlen(p)),      \
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/linux/const.h:12:25: note: expanded from macro '__is_constexpr'
        (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I dont know if its some regression introduced in clang, or really a kernel issue.

I will go back to my previous clang version (329b972d416a) for now untill I know more.

-- 
Regards
Sudip

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: mainline build failure for x86_64 and arm64 with clang
  2022-09-26  8:55 mainline build failure for x86_64 and arm64 with clang Sudip Mukherjee (Codethink)
@ 2022-09-26 15:39 ` Nathan Chancellor
  2022-09-26 16:50   ` Nick Desaulniers
  0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2022-09-26 15:39 UTC (permalink / raw)
  To: Sudip Mukherjee (Codethink); +Cc: ndesaulniers, torvalds, linux-kernel, llvm

Hi Sudip,

On Mon, Sep 26, 2022 at 09:55:27AM +0100, Sudip Mukherjee (Codethink) wrote:
> Hi All,
> 
> Yesterday I updated my clang to:
> clang version 16.0.0 (https://github.com/llvm/llvm-project.git bcb1397bda667e75200ae0be9a65fd17dd0763d4)
> 
> And with that I see new build failures of mainline.
> 
> I am not copying all the errors but others look similar to these.
> From x86_64 almodconfig:
> 
> In file included from scripts/mod/devicetable-offsets.c:3:
> In file included from ./include/linux/mod_devicetable.h:13:
> In file included from ./include/linux/uuid.h:12:
> In file included from ./include/linux/string.h:253:
> ./include/linux/fortify-string.h:159:10: error: ISO C does not allow indirection on operand of type 'void *' [-Werror,-Wvoid-ptr-dereference]
>         q_len = strlen(q);
>                 ^~~~~~~~~
> 
> From x86_64 defconfig:
> 
> In file included from arch/x86/kernel/asm-offsets.c:9:
> In file included from ./include/linux/crypto.h:20:
> In file included from ./include/linux/slab.h:15:
> In file included from ./include/linux/gfp.h:7:
> In file included from ./include/linux/mmzone.h:8:
> In file included from ./include/linux/spinlock.h:55:
> In file included from ./include/linux/preempt.h:78:
> In file included from ./arch/x86/include/asm/preempt.h:7:
> In file included from ./include/linux/thread_info.h:60:
> In file included from ./arch/x86/include/asm/thread_info.h:53:
> In file included from ./arch/x86/include/asm/cpufeature.h:5:
> In file included from ./arch/x86/include/asm/processor.h:22:
> In file included from ./arch/x86/include/asm/msr.h:11:
> In file included from ./arch/x86/include/asm/cpumask.h:5:
> In file included from ./include/linux/cpumask.h:12:
> In file included from ./include/linux/bitmap.h:9:
> ./include/linux/find.h:119:31: error: ISO C does not allow indirection on operand of type 'void *' [-Werror,-Wvoid-ptr-dereference]
>                 unsigned long val = *addr & GENMASK(size - 1, 0);
>                                             ^~~~~~~~~~~~~~~~~~~~
> ./include/linux/bits.h:38:3: note: expanded from macro 'GENMASK'
>         (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
>          ^~~~~~~~~~~~~~~~~~~~~~~~~
> ./include/linux/bits.h:25:3: note: expanded from macro 'GENMASK_INPUT_CHECK'
>                 __is_constexpr((l) > (h)), (l) > (h), 0)))
>                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ./include/linux/const.h:12:25: note: expanded from macro '__is_constexpr'
>         (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
>                                ^
> ./include/linux/build_bug.h:16:62: note: expanded from macro 'BUILD_BUG_ON_ZERO'
> #define BUILD_BUG_ON_ZERO(e) ((int)(sizeof(struct { int:(-!!(e)); })))
> 
> 
> From arm64 allmodconfig:
> 
> In file included from scripts/mod/devicetable-offsets.c:3:
> In file included from ./include/linux/mod_devicetable.h:13:
> In file included from ./include/linux/uuid.h:12:
> In file included from ./include/linux/string.h:253:
> ./include/linux/fortify-string.h:159:10: error: ISO C does not allow indirection on operand of type 'void *' [-Werror,-Wvoid-ptr-dereference]
>         q_len = strlen(q);
>                 ^~~~~~~~~
> ./include/linux/fortify-string.h:131:24: note: expanded from macro 'strlen'
>         __builtin_choose_expr(__is_constexpr(__builtin_strlen(p)),      \
>                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ./include/linux/const.h:12:25: note: expanded from macro '__is_constexpr'
>         (sizeof(int) == sizeof(*(8 ? ((void *)((long)(x) * 0l)) : (int *)8)))
>                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> I dont know if its some regression introduced in clang, or really a kernel issue.
> 
> I will go back to my previous clang version (329b972d416a) for now untill I know more.

Thanks for testing and the report! I noticed this over the weekend, it
comes from a new warning in clang:

https://github.com/llvm/llvm-project/commit/e07ead85a368173a56e96a21d6841aa497ad80f8

It was brought up on GitHub as well:

https://github.com/ClangBuiltLinux/linux/issues/1720

I have reported this to the clang developers upstream to see if there is
any way that the diagnostic could be improved:

https://reviews.llvm.org/D134461#3815298

Otherwise, we will just have to disable it, which I will send a patch
for later if the warning is not going to be adjusted in any way.

If you wanted to continue testing with upstream LLVM, you can either
just revert that commit or explicitly disable -Wvoid-ptr-dereference in
the main Makefile like so, which is ultimately what I will send if I
need to.

Cheers,
Nathan

diff --git a/Makefile b/Makefile
index 647a42a1f800..0bf60134f13c 100644
--- a/Makefile
+++ b/Makefile
@@ -967,6 +967,9 @@ KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
 # Another good warning that we'll want to enable eventually
 KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
 
+# New warning from clang that is quite noisy due to '__is_constexpr'
+KBUILD_CFLAGS += $(call cc-disable-warning, void-ptr-dereference)
+
 # Enabled with W=2, disabled by default as noisy
 ifdef CONFIG_CC_IS_GCC
 KBUILD_CFLAGS += -Wno-maybe-uninitialized

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: mainline build failure for x86_64 and arm64 with clang
  2022-09-26 15:39 ` Nathan Chancellor
@ 2022-09-26 16:50   ` Nick Desaulniers
  0 siblings, 0 replies; 3+ messages in thread
From: Nick Desaulniers @ 2022-09-26 16:50 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Sudip Mukherjee (Codethink), torvalds, linux-kernel, llvm

On Mon, Sep 26, 2022 at 8:40 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Thanks for testing and the report! I noticed this over the weekend, it
> comes from a new warning in clang:
>
> https://github.com/llvm/llvm-project/commit/e07ead85a368173a56e96a21d6841aa497ad80f8
>
> It was brought up on GitHub as well:
>
> https://github.com/ClangBuiltLinux/linux/issues/1720
>
> I have reported this to the clang developers upstream to see if there is
> any way that the diagnostic could be improved:
>
> https://reviews.llvm.org/D134461#3815298
>
> Otherwise, we will just have to disable it, which I will send a patch
> for later if the warning is not going to be adjusted in any way.
>
> If you wanted to continue testing with upstream LLVM, you can either
> just revert that commit or explicitly disable -Wvoid-ptr-dereference in
> the main Makefile like so, which is ultimately what I will send if I
> need to.
>
> Cheers,
> Nathan

Thanks for the reports.  It sounds like the Clang developers will pare
back the warning for unevaluated contexts (sizeof, typeof).  If it
takes longer than a few days for that to land, let's send your below
patch to help keep CI systems green.

Consider putting the below into
scripts/Makefile.extrawarn

>
> diff --git a/Makefile b/Makefile
> index 647a42a1f800..0bf60134f13c 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -967,6 +967,9 @@ KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow)
>  # Another good warning that we'll want to enable eventually
>  KBUILD_CFLAGS += $(call cc-disable-warning, restrict)
>
> +# New warning from clang that is quite noisy due to '__is_constexpr'
> +KBUILD_CFLAGS += $(call cc-disable-warning, void-ptr-dereference)
> +
>  # Enabled with W=2, disabled by default as noisy
>  ifdef CONFIG_CC_IS_GCC
>  KBUILD_CFLAGS += -Wno-maybe-uninitialized



-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-09-26 16:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-09-26  8:55 mainline build failure for x86_64 and arm64 with clang Sudip Mukherjee (Codethink)
2022-09-26 15:39 ` Nathan Chancellor
2022-09-26 16:50   ` Nick Desaulniers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox