linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* next: arm64: gcc-8-defconfig: ufshcd.c:10629:2: /builds/linux/include/linux/compiler_types.h:397:38: error: call to '__compiletime_assert_553' declared with attribute error: BUILD_BUG_ON failed:
@ 2023-08-01 12:16 Naresh Kamboju
  2023-08-01 13:23 ` Bart Van Assche
  0 siblings, 1 reply; 7+ messages in thread
From: Naresh Kamboju @ 2023-08-01 12:16 UTC (permalink / raw)
  To: open list, linux-scsi, Linux-Next Mailing List
  Cc: Bart Van Assche, Avri Altman, Martin K. Petersen, Arnd Bergmann,
	Anders Roxell

Following build error noticed while building Linux next-20230801 tag
arm64 defconfig with gcc-8 toolchain.

Regressions found on arm64:

  - build/gcc-8-defconfig
  - build/gcc-8-defconfig-40bc7ee5


Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>

log:
-----
In function 'ufshcd_check_header_layout',
    inlined from 'ufshcd_core_init' at
/builds/linux/drivers/ufs/core/ufshcd.c:10629:2:
/builds/linux/include/linux/compiler_types.h:397:38: error: call to
'__compiletime_assert_553' declared with attribute error: BUILD_BUG_ON
failed: ((u8 *)&(struct request_desc_header){ .enable_crypto = 1})[2]
!= 0x80
  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
                                      ^


Links:
 - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230801/testrun/18754886/suite/build/test/gcc-8-defconfig/log
 - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230801/testrun/18754886/suite/build/test/gcc-8-defconfig/details/
 - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230801/testrun/18754886/suite/build/test/gcc-8-defconfig/history/


--
Linaro LKFT
https://lkft.linaro.org

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

* Re: next: arm64: gcc-8-defconfig: ufshcd.c:10629:2: /builds/linux/include/linux/compiler_types.h:397:38: error: call to '__compiletime_assert_553' declared with attribute error: BUILD_BUG_ON failed:
  2023-08-01 12:16 next: arm64: gcc-8-defconfig: ufshcd.c:10629:2: /builds/linux/include/linux/compiler_types.h:397:38: error: call to '__compiletime_assert_553' declared with attribute error: BUILD_BUG_ON failed: Naresh Kamboju
@ 2023-08-01 13:23 ` Bart Van Assche
  2023-08-01 14:23   ` Naresh Kamboju
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Van Assche @ 2023-08-01 13:23 UTC (permalink / raw)
  To: Naresh Kamboju, open list, linux-scsi, Linux-Next Mailing List
  Cc: Avri Altman, Martin K. Petersen, Arnd Bergmann, Anders Roxell

On 8/1/23 05:16, Naresh Kamboju wrote:
> Following build error noticed while building Linux next-20230801 tag
> arm64 defconfig with gcc-8 toolchain.
> 
> Regressions found on arm64:
> 
>    - build/gcc-8-defconfig
>    - build/gcc-8-defconfig-40bc7ee5
> 
> 
> Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
> 
> log:
> -----
> In function 'ufshcd_check_header_layout',
>      inlined from 'ufshcd_core_init' at
> /builds/linux/drivers/ufs/core/ufshcd.c:10629:2:
> /builds/linux/include/linux/compiler_types.h:397:38: error: call to
> '__compiletime_assert_553' declared with attribute error: BUILD_BUG_ON
> failed: ((u8 *)&(struct request_desc_header){ .enable_crypto = 1})[2]
> != 0x80
>    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
>                                        ^
> 
> 
> Links:
>   - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230801/testrun/18754886/suite/build/test/gcc-8-defconfig/log
>   - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230801/testrun/18754886/suite/build/test/gcc-8-defconfig/details/
>   - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230801/testrun/18754886/suite/build/test/gcc-8-defconfig/history/

I can't reproduce this build error with a gcc-12 arm64 cross-compiler. How
important is gcc-8 for the ARM community?

Thanks,

Bart.


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

* Re: next: arm64: gcc-8-defconfig: ufshcd.c:10629:2: /builds/linux/include/linux/compiler_types.h:397:38: error: call to '__compiletime_assert_553' declared with attribute error: BUILD_BUG_ON failed:
  2023-08-01 13:23 ` Bart Van Assche
@ 2023-08-01 14:23   ` Naresh Kamboju
  2023-08-01 14:56     ` Arnd Bergmann
  0 siblings, 1 reply; 7+ messages in thread
From: Naresh Kamboju @ 2023-08-01 14:23 UTC (permalink / raw)
  To: Bart Van Assche
  Cc: open list, linux-scsi, Linux-Next Mailing List, Avri Altman,
	Martin K. Petersen, Arnd Bergmann, Anders Roxell

On Tue, 1 Aug 2023 at 18:53, Bart Van Assche <bvanassche@acm.org> wrote:
>
> On 8/1/23 05:16, Naresh Kamboju wrote:
> > Following build error noticed while building Linux next-20230801 tag
> > arm64 defconfig with gcc-8 toolchain.
> >
> > Regressions found on arm64:
> >
> >    - build/gcc-8-defconfig
> >    - build/gcc-8-defconfig-40bc7ee5
> >
> >
> > Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
> >
> > log:
> > -----
> > In function 'ufshcd_check_header_layout',
> >      inlined from 'ufshcd_core_init' at
> > /builds/linux/drivers/ufs/core/ufshcd.c:10629:2:
> > /builds/linux/include/linux/compiler_types.h:397:38: error: call to
> > '__compiletime_assert_553' declared with attribute error: BUILD_BUG_ON
> > failed: ((u8 *)&(struct request_desc_header){ .enable_crypto = 1})[2]
> > != 0x80
> >    _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
> >                                        ^
> >
> >
> > Links:
> >   - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230801/testrun/18754886/suite/build/test/gcc-8-defconfig/log
> >   - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230801/testrun/18754886/suite/build/test/gcc-8-defconfig/details/
> >   - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230801/testrun/18754886/suite/build/test/gcc-8-defconfig/history/
>
> I can't reproduce this build error with a gcc-12 arm64 cross-compiler. How
> important is gcc-8 for the ARM community?

You are right,
gcc-12 build pass.
gcc-8 build failed.


If you want to reproduce with gcc-8 you may follow these steps.

# To install tuxmake to your home directory at ~/.local/bin:
# pip3 install -U --user tuxmake
#
# Or install a deb/rpm depending on the running distribution
# See https://tuxmake.org/install-deb/ or
# https://tuxmake.org/install-rpm/
#
# See https://docs.tuxmake.org/ for complete documentation.
# Original tuxmake command with fragments listed below.
# tuxmake --runtime podman --target-arch arm64 --toolchain gcc-8
--kconfig defconfig


tuxmake --runtime podman --target-arch arm64 --toolchain gcc-8
--kconfig https://storage.tuxsuite.com/public/linaro/lkft/builds/2TN3A8EaWQJAcOYnbXZnkb7D3H7/config

>
> Thanks,
>
> Bart.

- Naresh

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

* Re: next: arm64: gcc-8-defconfig: ufshcd.c:10629:2: /builds/linux/include/linux/compiler_types.h:397:38: error: call to '__compiletime_assert_553' declared with attribute error: BUILD_BUG_ON failed:
  2023-08-01 14:23   ` Naresh Kamboju
@ 2023-08-01 14:56     ` Arnd Bergmann
  2023-08-01 17:51       ` Bart Van Assche
  0 siblings, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2023-08-01 14:56 UTC (permalink / raw)
  To: Naresh Kamboju, Bart Van Assche
  Cc: open list, linux-scsi, linux-next, Avri Altman,
	Martin K. Petersen, Anders Roxell

On Tue, Aug 1, 2023, at 16:23, Naresh Kamboju wrote:
> On Tue, 1 Aug 2023 at 18:53, Bart Van Assche <bvanassche@acm.org> wrote:

>> >   - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230801/testrun/18754886/suite/build/test/gcc-8-defconfig/log
>> >   - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230801/testrun/18754886/suite/build/test/gcc-8-defconfig/details/
>> >   - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230801/testrun/18754886/suite/build/test/gcc-8-defconfig/history/
>>
>> I can't reproduce this build error with a gcc-12 arm64 cross-compiler. How
>> important is gcc-8 for the ARM community?
>
> You are right,
> gcc-12 build pass.
> gcc-8 build failed.

I can also reproduce this with gcc-9.5.0 from
https://mirrors.edge.kernel.org/pub/tools/crosstool/ but
not with 10.5.0 or clang.

I get the same results for x86 with gcc-9.5.0.

See https://godbolt.org/z/GjGrW9znc for a partially reduced testcase.

      Arnd

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

* Re: next: arm64: gcc-8-defconfig: ufshcd.c:10629:2: /builds/linux/include/linux/compiler_types.h:397:38: error: call to '__compiletime_assert_553' declared with attribute error: BUILD_BUG_ON failed:
  2023-08-01 14:56     ` Arnd Bergmann
@ 2023-08-01 17:51       ` Bart Van Assche
  2023-08-01 19:54         ` Arnd Bergmann
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Van Assche @ 2023-08-01 17:51 UTC (permalink / raw)
  To: Arnd Bergmann, Naresh Kamboju
  Cc: open list, linux-scsi, linux-next, Avri Altman,
	Martin K. Petersen, Anders Roxell

On 8/1/23 07:56, Arnd Bergmann wrote:
> On Tue, Aug 1, 2023, at 16:23, Naresh Kamboju wrote:
>> On Tue, 1 Aug 2023 at 18:53, Bart Van Assche <bvanassche@acm.org> wrote:
> 
>>>>    - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230801/testrun/18754886/suite/build/test/gcc-8-defconfig/log
>>>>    - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230801/testrun/18754886/suite/build/test/gcc-8-defconfig/details/
>>>>    - https://qa-reports.linaro.org/lkft/linux-next-master/build/next-20230801/testrun/18754886/suite/build/test/gcc-8-defconfig/history/
>>>
>>> I can't reproduce this build error with a gcc-12 arm64 cross-compiler. How
>>> important is gcc-8 for the ARM community?
>>
>> You are right,
>> gcc-12 build pass.
>> gcc-8 build failed.
> 
> I can also reproduce this with gcc-9.5.0 from
> https://mirrors.edge.kernel.org/pub/tools/crosstool/ but
> not with 10.5.0 or clang.
> 
> I get the same results for x86 with gcc-9.5.0.
> 
> See https://godbolt.org/z/GjGrW9znc for a partially reduced testcase.
Thanks Arnd, this is very helpful. The first error message reported for that
test case is as follows:

<source>:34:286: error: call to '__compiletime_assert_655' declared with attribute error: BUILD_BUG_ON failed: ((u8 *)&(struct request_desc_header){ .enable_crypto = 1})[2] != 0x80
    34 |  do { __attribute__((__noreturn__)) extern void __compiletime_assert_655(void) __attribute__((__error__("BUILD_BUG_ON failed: " "((u8 *)&(struct request_desc_header){ .enable_crypto = 1})[2] != 0x80")));
  if (!(!(((u8 *)&(struct request_desc_header){ .enable_crypto = 1})[2] != 0x80))) __compiletime_assert_655(); } while (0);
       |

If I change the return type of ufshcd_check_header_layout() from void
into unsigned int and insert the following at the start of that function:

return ((u8 *)&(struct request_desc_header){ .enable_crypto = 1})[2] != 0x80;

then the compiler shows the following in the output window:

xorl    %eax, %eax

In other words, the expression next to the return statement evaluates to zero
but the same expression does not evaluate to zero in the BUILD_BUG_ON()
statement. Does this perhaps indicate a compiler bug? And if so, what is the
appropriate way to fix the build error? Insert an #ifdef/#endif pair inside
ufshcd_check_header_layout() such that the compile-time checks do not happen
for gcc version 9 or older?

Thanks,

Bart.

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

* Re: next: arm64: gcc-8-defconfig: ufshcd.c:10629:2: /builds/linux/include/linux/compiler_types.h:397:38: error: call to '__compiletime_assert_553' declared with attribute error: BUILD_BUG_ON failed:
  2023-08-01 17:51       ` Bart Van Assche
@ 2023-08-01 19:54         ` Arnd Bergmann
  2023-08-01 20:15           ` Bart Van Assche
  0 siblings, 1 reply; 7+ messages in thread
From: Arnd Bergmann @ 2023-08-01 19:54 UTC (permalink / raw)
  To: Bart Van Assche, Naresh Kamboju
  Cc: open list, linux-scsi, linux-next, Avri Altman,
	Martin K. Petersen, Anders Roxell

On Tue, Aug 1, 2023, at 19:51, Bart Van Assche wrote:
> On 8/1/23 07:56, Arnd Bergmann wrote:
>> On Tue, Aug 1, 2023, at 16:23, Naresh Kamboju wrote:
>
> If I change the return type of ufshcd_check_header_layout() from void
> into unsigned int and insert the following at the start of that function:
>
> return ((u8 *)&(struct request_desc_header){ .enable_crypto = 1})[2] != 0x80;
>
> then the compiler shows the following in the output window:
>
> xorl    %eax, %eax
>
> In other words, the expression next to the return statement evaluates to zero
> but the same expression does not evaluate to zero in the BUILD_BUG_ON()
> statement. Does this perhaps indicate a compiler bug? And if so, what is the
> appropriate way to fix the build error? Insert an #ifdef/#endif pair inside
> ufshcd_check_header_layout() such that the compile-time checks do not happen
> for gcc version 9 or older?

I played around it some more, and this apparently comes
down to constant-folding in sub-byte bitfields, so in the
older compilers neither the ==0x80 nor the !=0x80 case
can be ruled out because of a missing optimization.
Instead the generated code would try to initialize the
variable at runtime and then do a conditional branch to
the assert, but that of course fails the build.

I'd suggest something like

    if (defined(GCC_VERSION) && GCC_VERSION < 100000)
            return;

before the assertion, in that case it doesn't evaluate it.

     Arnd

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

* Re: next: arm64: gcc-8-defconfig: ufshcd.c:10629:2: /builds/linux/include/linux/compiler_types.h:397:38: error: call to '__compiletime_assert_553' declared with attribute error: BUILD_BUG_ON failed:
  2023-08-01 19:54         ` Arnd Bergmann
@ 2023-08-01 20:15           ` Bart Van Assche
  0 siblings, 0 replies; 7+ messages in thread
From: Bart Van Assche @ 2023-08-01 20:15 UTC (permalink / raw)
  To: Arnd Bergmann, Naresh Kamboju
  Cc: open list, linux-scsi, linux-next, Avri Altman,
	Martin K. Petersen, Anders Roxell

On 8/1/23 12:54, Arnd Bergmann wrote:
> On Tue, Aug 1, 2023, at 19:51, Bart Van Assche wrote:
>> On 8/1/23 07:56, Arnd Bergmann wrote:
>>> On Tue, Aug 1, 2023, at 16:23, Naresh Kamboju wrote:
>>
>> If I change the return type of ufshcd_check_header_layout() from void
>> into unsigned int and insert the following at the start of that function:
>>
>> return ((u8 *)&(struct request_desc_header){ .enable_crypto = 1})[2] != 0x80;
>>
>> then the compiler shows the following in the output window:
>>
>> xorl    %eax, %eax
>>
>> In other words, the expression next to the return statement evaluates to zero
>> but the same expression does not evaluate to zero in the BUILD_BUG_ON()
>> statement. Does this perhaps indicate a compiler bug? And if so, what is the
>> appropriate way to fix the build error? Insert an #ifdef/#endif pair inside
>> ufshcd_check_header_layout() such that the compile-time checks do not happen
>> for gcc version 9 or older?
> 
> I played around it some more, and this apparently comes
> down to constant-folding in sub-byte bitfields, so in the
> older compilers neither the ==0x80 nor the !=0x80 case
> can be ruled out because of a missing optimization.
> Instead the generated code would try to initialize the
> variable at runtime and then do a conditional branch to
> the assert, but that of course fails the build.
> 
> I'd suggest something like
> 
>      if (defined(GCC_VERSION) && GCC_VERSION < 100000)
>              return;
> 
> before the assertion, in that case it doesn't evaluate it.

An untested patch has been posted on the linux-scsi mailing list. It would
be really appreciated if someone could help with testing that patch since
none of the Linux distro's that I use regularly provides binaries for gcc-9
nor for gcc-8.

Thanks,

Bart.


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

end of thread, other threads:[~2023-08-01 20:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-01 12:16 next: arm64: gcc-8-defconfig: ufshcd.c:10629:2: /builds/linux/include/linux/compiler_types.h:397:38: error: call to '__compiletime_assert_553' declared with attribute error: BUILD_BUG_ON failed: Naresh Kamboju
2023-08-01 13:23 ` Bart Van Assche
2023-08-01 14:23   ` Naresh Kamboju
2023-08-01 14:56     ` Arnd Bergmann
2023-08-01 17:51       ` Bart Van Assche
2023-08-01 19:54         ` Arnd Bergmann
2023-08-01 20:15           ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).