include/linux/compiler_types.h:617:38: error: call to '__compiletime_assert_304' declared with attribute error: BUILD_BUG_ON failed: IS_ERR(PTR)
kernel test robot
build botHi Tamir,
FYI, the error/warning still remains.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 5619b098e2fbf3a23bf13d91897056a1fe238c6d commit: 9bfa52dac27a20b43bcb73e56dc45aba6b9aaff1 printf: convert test_hashed into macro date: 9 weeks ago config: xtensa-randconfig-002-20260403 (https://download.01.org/0day-ci/archive/20260403/[email protected]/config) compiler: xtensa-linux-gcc (GCC) 8.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260403/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Fixes: 9bfa52dac27a ("printf: convert test_hashed into macro")
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
In file included from <command-line>:
lib/tests/printf_kunit.c: In function 'errptr.part.2':
>> include/linux/compiler_types.h:617:38: error: call to '__compiletime_assert_304' declared with attribute error: BUILD_BUG_ON failed: IS_ERR(PTR)
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:598:4: note: in definition of macro '__compiletime_assert'
prefix ## suffix(); \
^~~~~~
include/linux/compiler_types.h:617:2: note: in expansion of macro '_compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:50:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
^~~~~~~~~~~~~~~~
lib/tests/printf_kunit.c:758:2: note: in expansion of macro 'BUILD_BUG_ON'
BUILD_BUG_ON(IS_ERR(PTR));
^~~~~~~~~~~~vim +/__compiletime_assert_304 +617 include/linux/compiler_types.h
eb5c2d4b45e3d2d Will Deacon 2020-07-21 603 eb5c2d4b45e3d2d Will Deacon 2020-07-21 604 #define _compiletime_assert(condition, msg, prefix, suffix) \ eb5c2d4b45e3d2d Will Deacon 2020-07-21 605 __compiletime_assert(condition, msg, prefix, suffix) eb5c2d4b45e3d2d Will Deacon 2020-07-21 606 eb5c2d4b45e3d2d Will Deacon 2020-07-21 607 /** eb5c2d4b45e3d2d Will Deacon 2020-07-21 608 * compiletime_assert - break build and emit msg if condition is false eb5c2d4b45e3d2d Will Deacon 2020-07-21 609 * @condition: a compile-time constant condition to check eb5c2d4b45e3d2d Will Deacon 2020-07-21 610 * @msg: a message to emit if condition is false eb5c2d4b45e3d2d Will Deacon 2020-07-21 611 * eb5c2d4b45e3d2d Will Deacon 2020-07-21 612 * In tradition of POSIX assert, this macro will break the build if the eb5c2d4b45e3d2d Will Deacon 2020-07-21 613 * supplied condition is *false*, emitting the supplied error message if the eb5c2d4b45e3d2d Will Deacon 2020-07-21 614 * compiler has support to do so. eb5c2d4b45e3d2d Will Deacon 2020-07-21 615 */ eb5c2d4b45e3d2d Will Deacon 2020-07-21 616 #define compiletime_assert(condition, msg) \
eb5c2d4b45e3d2d Will Deacon 2020-07-21 @617 _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)eb5c2d4b45e3d2d Will Deacon 2020-07-21 618
:::::: The code at line 617 was first introduced by commit
:::::: eb5c2d4b45e3d2d5d052ea6b8f1463976b1020d5 compiler.h: Move compiletime_assert() macros into compiler_types.h
:::::: TO: Will Deacon <[email protected]>
:::::: CC: Will Deacon <[email protected]>
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 65 lines · kernel test robot
Hi Tamir,
FYI, the error/warning still remains.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 5619b098e2fbf3a23bf13d91897056a1fe238c6d commit: 9bfa52dac27a20b43bcb73e56dc45aba6b9aaff1 printf: convert test_hashed into macro date: 9 weeks ago config: xtensa-randconfig-002-20260403 (https://download.01.org/0day-ci/archive/20260403/[email protected]/config) compiler: xtensa-linux-gcc (GCC) 8.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260403/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Fixes: 9bfa52dac27a ("printf: convert test_hashed into macro") | Reported-by: kernel test robot <[email protected]> | Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
In file included from <command-line>:
lib/tests/printf_kunit.c: In function 'errptr.part.2':Quoted 1 line
Quoted 1 line
include/linux/compiler_types.h:617:38: error: call to '__compiletime_assert_304' declared with attribute error:BUILD_BUG_ONfailed:IS_ERR(PTR)
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^
include/linux/compiler_types.h:598:4: note: in definition of macro '__compiletime_assert'prefix ## suffix(); \ ^~~~~~ include/linux/compiler_types.h:617:2: note: in expansion of macro '_compiletime_assert' _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__) ^~~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert' #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg) ^~~~~~~~~~~~~~~~~~ include/linux/build_bug.h:50:2: note: in expansion of macro 'BUILD_BUG_ON_MSG' BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition) ^~~~~~~~~~~~~~~~ lib/tests/printf_kunit.c:758:2: note: in expansion of macro 'BUILD_BUG_ON' BUILD_BUG_ON(IS_ERR(PTR)); ^~~~~~~~~~~~vim +/__compiletime_assert_304 +617
include/linux/compiler_types.heb5c2d4b45e3d2d Will Deacon 2020-07-21 603 eb5c2d4b45e3d2d Will Deacon 2020-07-21 604 #define _compiletime_assert(condition, msg, prefix, suffix) \ eb5c2d4b45e3d2d Will Deacon 2020-07-21 605 __compiletime_assert(condition, msg, prefix, suffix) eb5c2d4b45e3d2d Will Deacon 2020-07-21 606 eb5c2d4b45e3d2d Will Deacon 2020-07-21 607 /** eb5c2d4b45e3d2d Will Deacon 2020-07-21 608 * compiletime_assert - break build and emit msg if condition is false eb5c2d4b45e3d2d Will Deacon 2020-07-21 609 * @condition: a compile-time constant condition to check eb5c2d4b45e3d2d Will Deacon 2020-07-21 610 * @msg: a message to emit if condition is false eb5c2d4b45e3d2d Will Deacon 2020-07-21 611 * eb5c2d4b45e3d2d Will Deacon 2020-07-21 612 * In tradition of POSIX assert, this macro will break the build if the eb5c2d4b45e3d2d Will Deacon 2020-07-21 613 * supplied condition is *false*, emitting the supplied error message if the eb5c2d4b45e3d2d Will Deacon 2020-07-21 614 * compiler has support to do so. eb5c2d4b45e3d2d Will Deacon 2020-07-21 615 */ eb5c2d4b45e3d2d Will Deacon 2020-07-21 616 #define compiletime_assert(condition, msg) \
eb5c2d4b45e3d2dWill Deacon 2020-07-21 @617_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)eb5c2d4b45e3d2dWill Deacon 2020-07-21 618:::::: The code at line 617 was first introduced by commit
::::::eb5c2d4b45e3d2d5d052ea6b8f1463976b1020d5compiler.h: Movecompiletime_assert()macros intocompiler_types.h
Quoted 6 lines
:::::: TO: Will Deacon <[email protected]>
:::::: CC: Will Deacon <[email protected]>--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
I used an LLM to investigate this, including bisecting GCC. Here's what we found:
Quoted 25 lines
I think this is a pre-existing GCC bug, and commit
9bfa52dac27a("printf: converttest_hashedinto macro") is only the trigger.What changed in that commit is that
test_hashed()became a macro, soerrptr()now contains the local char buf[64] and theplain_hash_to_buffer()/test()logic directly instead of calling an out-of-line helper. With the reported xtensa randconfig, that changes GCC's IPA inlining/splitting decisions enough to expose a compiler bug.The actual failure mode is:
BUILD_BUG_ON(IS_ERR(PTR));
in
lib/tests/printf_kunit.c. PTR is not anERR_PTRon xtensa 32-bit, so the assertion is logically false. But withCONFIG_TRACE_BRANCH_PROFILING=yandCONFIG_PROFILE_ALL_BRANCHES=y, IS_ERR()'sunlikely()and theBUILD_BUG_ON()condition expand into branch-profiling counter updates. GCC 8.5 then IPA-splitserrptr(), outlines the cold assert arm into errptr.part.*, and leaves that clone with an unconditional call to_compiletime_assert(), so the build fails even though the path is unreachable.I confirmed that -fno-partial-inlining or -DDISABLE_BRANCH_PROFILING makes the failure go away.
Quoted 7 lines
I also bisected GCC with a reproducer that forces --param=max-inline-insns-auto=30 so the bug is not hidden by unrelated inlining heuristic changes. GCC 11.5.0 still reproduces, GCC 12.1.0 does not, and the first real fix appears to be:
76fe494230477a69f8fa8c8ca2d493acaf343eb1
Fix tree-optimization/101941: IPA splitting out function with error attribute
Human note: That change was motivated by exactly this kind of compilation failure in the kernel [0].
[0] https://github.com/gcc-mirror/gcc/commit/76fe494230477a69f8fa8c8ca2d493acaf343eb1
Quoted 24 lines
That commit teaches ipa-split not to split basic blocks containing calls to functions with attribute((error)) or attribute((warning)), which is exactly what goes wrong here.
So I see two possible mitigations:
1. Work around this in the test by avoiding
IS_ERR()in thatBUILD_BUG_ON(), e.g. use the rawMAX_ERRNOrange check instead:BUILD_BUG_ON((unsigned long)PTR >= (unsigned long)-MAX_ERRNO);That keeps the same build-time check but avoids routing a constant expression through
unlikely()under branch profiling, so GCC 8.5 no longer trips over it.
2. Stop running xtensa randconfig with GCC versions older than the ipa-split fix above, i.e. use GCC >= 12.1 for xtensa in LKP.I had a quick look at lkp-tests, but I don't see an xtensa-specific compiler selection policy there; make.cross appears to consume an already-chosen COMPILER value. So if the preferred mitigation is toolchain-side, that policy likely lives in the 0day/LKP scheduler or job-generation layer outside lkp-tests.
Quoted 5 lines
One caveat on the reporting side: if other architectures are already using newer GCC, or if 0day suppresses duplicate reports after the first failing instance, that would explain why this only showed up as an xtensa GCC 8.5 report even though the underlying compiler bug is not xtensa-specific in principle.
Human again.
Petr, Andy: Would you like me to send a patch with the workaround?
LKP folks: Is GCC 8.5 only used for xtensa, or are old compiler versions also exercised by other architectures, and was this just the first one to hit this condition? If the former, is it possible to bump xtensa to GCC 12.1 or later?
Cheers.
Tamir
Quoted 5 lines · Tamir Duberstein
Quoted 4 lines · kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 5619b098e2fbf3a23bf13d91897056a1fe238c6d commit: 9bfa52dac27a20b43bcb73e56dc45aba6b9aaff1 printf: convert test_hashed into macro date: 9 weeks ago
...
Quoted 2 lines
I used an LLM to investigate this, including bisecting GCC. Here's what we found:
Have you talked to Max Filippov who is arch maintainer in kernel?
...
Quoted 10 lines
Quoted 10 lines
So I see two possible mitigations:
1. Work around this in the test by avoiding
IS_ERR()in thatBUILD_BUG_ON(), e.g. use the rawMAX_ERRNOrange check instead:BUILD_BUG_ON((unsigned long)PTR >= (unsigned long)-MAX_ERRNO);That keeps the same build-time check but avoids routing a constant expression through
unlikely()under branch profiling, so GCC 8.5 no longer trips over it.
I believe it's close to "not an option" as it's a non-scalable change. If in the future IS_ERR() becomes something else (but still covers the same check) this will be in unsync and might trigger in a wrong circumstances (while I don't believe it will happen IRL).
Quoted 2 lines
Quoted 2 lines
2. Stop running xtensa randconfig with GCC versions older than the ipa-split fix above, i.e. use GCC >= 12.1 for xtensa in LKP.
This is also close to that "not an option" as we have Linux kernel wide minimum GCC requirement.
Yes, theoretically any of the above is possible, but I dunno from where the pushback may come.
Quoted 20 lines
Quoted 11 lines
I had a quick look at lkp-tests, but I don't see an xtensa-specific compiler selection policy there; make.cross appears to consume an already-chosen COMPILER value. So if the preferred mitigation is toolchain-side, that policy likely lives in the 0day/LKP scheduler or job-generation layer outside lkp-tests.
One caveat on the reporting side: if other architectures are already using newer GCC, or if 0day suppresses duplicate reports after the first failing instance, that would explain why this only showed up as an xtensa GCC 8.5 report even though the underlying compiler bug is not xtensa-specific in principle.
Human again.
Petr, Andy: Would you like me to send a patch with the workaround?
LKP folks: Is GCC 8.5 only used for xtensa, or are old compiler versions also exercised by other architectures, and was this just the first one to hit this condition? If the former, is it possible to bump xtensa to GCC 12.1 or later?
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 58 lines · Andy Shevchenko
Quoted 5 lines · Tamir Duberstein
Quoted 4 lines · kernel test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 5619b098e2fbf3a23bf13d91897056a1fe238c6d commit: 9bfa52dac27a20b43bcb73e56dc45aba6b9aaff1 printf: convert test_hashed into macro date: 9 weeks ago...
Quoted 2 lines
I used an LLM to investigate this, including bisecting GCC. Here's what we found:
Have you talked to Max Filippov who is arch maintainer in kernel?
...
Quoted 10 lines
Quoted 10 lines
So I see two possible mitigations:
1. Work around this in the test by avoiding
IS_ERR()in thatBUILD_BUG_ON(), e.g. use the rawMAX_ERRNOrange check instead:BUILD_BUG_ON((unsigned long)PTR >= (unsigned long)-MAX_ERRNO);That keeps the same build-time check but avoids routing a constant expression through
unlikely()under branch profiling, so GCC 8.5 no longer trips over it.I believe it's close to "not an option" as it's a non-scalable change. If in the future
IS_ERR()becomes something else (but still covers the same check) this will be in unsync and might trigger in a wrong circumstances (while I don't believe it will happen IRL).Quoted 2 lines
Quoted 2 lines
2. Stop running xtensa randconfig with GCC versions older than the ipa-split fix above, i.e. use GCC >= 12.1 for xtensa in LKP.
This is also close to that "not an option" as we have Linux kernel wide minimum GCC requirement.
Yes, theoretically any of the above is possible, but I dunno from where the pushback may come.
Quoted 16 lines
Quoted 11 lines
I had a quick look at lkp-tests, but I don't see an xtensa-specific compiler selection policy there; make.cross appears to consume an already-chosen COMPILER value. So if the preferred mitigation is toolchain-side, that policy likely lives in the 0day/LKP scheduler or job-generation layer outside lkp-tests.
One caveat on the reporting side: if other architectures are already using newer GCC, or if 0day suppresses duplicate reports after the first failing instance, that would explain why this only showed up as an xtensa GCC 8.5 report even though the underlying compiler bug is not xtensa-specific in principle.
Human again.
Petr, Andy: Would you like me to send a patch with the workaround?
Quoted 10 lines
Quoted 4 lines
LKP folks: Is GCC 8.5 only used for xtensa, or are old compiler versions also exercised by other architectures, and was this just the first one to hit this condition? If the former, is it possible to bump xtensa to GCC 12.1 or later?
--
With Best Regards,
Andy Shevchenko
I sent https://lore.kernel.org/all/[email protected]/
with what I think is a reasonable workaround.