mainline build failure for loongarch allmodconfig with gcc-12
Hi All,
I have been trying to build loongarch as part of my nightly builds, and I can build loongson3_defconfig without any error. But allmodconfig fails with the error:
In function '__cmpxchg',
inlined from 'ssh_seq_next' at drivers/platform/surface/aggregator/controller.c:61:9,
inlined from 'ssam_request_write_data' at drivers/platform/surface/aggregator/controller.c:1483:8, inlined from 'ssam_request_sync_with_buffer' at drivers/platform/surface/aggregator/controller.c:1761:8:././include/linux/compiler_types.h:354:45: error: call to '__compiletime_assert_9' declared with attribute error: BUILD_BUG failed
354 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^././include/linux/compiler_types.h:335:25: note: in definition of macro '__compiletime_assert'
335 | prefix ## suffix(); \
| ^~~~~~
././include/linux/compiler_types.h:354:9: note: in expansion of macro '_compiletime_assert'
354 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
./include/linux/build_bug.h:59:21: note: in expansion of macro 'BUILD_BUG_ON_MSG'
59 | #define BUILD_BUG() BUILD_BUG_ON_MSG(1, "BUILD_BUG failed")
| ^~~~~~~~~~~~~~~~
./arch/loongarch/include/asm/cmpxchg.h:83:17: note: in expansion of macro 'BUILD_BUG'
83 | BUILD_BUG();
| ^~~~~~~~~I will be happy to test any patch or provide any extra log if needed.
Signature · 2 lines
Regards Sudip
Quoted 7 lines · Sudip Mukherjee (Codethink)
I have been trying to build loongarch as part of my nightly builds, and I can build
loongson3_defconfigwithout any error. But allmodconfig fails with the error:In function '
__cmpxchg',
inlined from 'ssh_seq_next' atdrivers/platform/surface/aggregator/controller.c:61:9,
Looks like ssh_seq_next() wants to do an atomic cmpxchg() on a single byte value, and the Loongarch implementation only does 4- and 8-byte versions.
It looks like loongarch - from its MIPS heritage - inherited the "we can't do atomics on byte variables", so that it needs the same strange "do bytes as word accesses with mask-and-shifts".
For MIPS, the code is in __xchg_small() in arch/mips/kernel/cmpxchg.c.
Alpha has something similar, except it's all done in inline asm in arch/alpha/include/asm/xchg.h (look for "____cmpxchg(_u8," in there.
Of course, we could just add a Kconfig variable like "ARCH_LACKS_BYTE_ATOMICS" and make that driver depend on it not being true, and just have Loongarch set it.
But I think loongarch should just implement the byte masking stuff. Particularly since I suspect it can just copy the MIPS code as-is.
Linus
Huacai Chen
maintainerHi, Linus,
Quoted 24 lines · Linus Torvalds
Quoted 7 lines · Sudip Mukherjee (Codethink)
I have been trying to build loongarch as part of my nightly builds, and I can build
loongson3_defconfigwithout any error. But allmodconfig fails with the error:In function '
__cmpxchg',
inlined from 'ssh_seq_next' atdrivers/platform/surface/aggregator/controller.c:61:9,Looks like
ssh_seq_next()wants to do an atomiccmpxchg()on a single byte value, and the Loongarch implementation only does 4- and 8-byte versions.It looks like loongarch - from its MIPS heritage - inherited the "we can't do atomics on byte variables", so that it needs the same strange "do bytes as word accesses with mask-and-shifts".
For MIPS, the code is in
__xchg_small()inarch/mips/kernel/cmpxchg.c.Alpha has something similar, except it's all done in inline asm in
arch/alpha/include/asm/xchg.h(look for "____cmpxchg(_u8," in there.
Quoted 6 lines
Of course, we could just add a
Kconfigvariable like "ARCH_LACKS_BYTE_ATOMICS" and make that driver depend on it not being true, and just have Loongarch set it.But I think loongarch should just implement the byte masking stuff. Particularly since I suspect it can just copy the MIPS code as-is.
Yes, I agree. There is already a proposed patch to do this [1]. It was discussed for a long time about the "forward progress", but I think that problem is solved because LoongArch has "exclusive access (with timeout) of ll" and "random delay of sc" in hardware. So I hope this patch can be accepted now.
Huacai
Quoted 2 lines
Linus