[PATCH] arm64: avoid BUILD_BUG_ON() in alternative-macros

Marc Zyngier maz at kernel.org
Tue Sep 20 08:48:20 PDT 2022


On Tue, 20 Sep 2022 15:00:44 +0100,
Mark Rutland <mark.rutland at arm.com> wrote:
> 
> Nathan reports that the build fails when using clang and LTO:
> 
> |  In file included from kernel/bounds.c:10:
> |  In file included from ./include/linux/page-flags.h:10:
> |  In file included from ./include/linux/bug.h:5:
> |  In file included from ./arch/arm64/include/asm/bug.h:26:
> |  In file included from ./include/asm-generic/bug.h:5:
> |  In file included from ./include/linux/compiler.h:248:
> |  In file included from ./arch/arm64/include/asm/rwonce.h:11:
> |  ./arch/arm64/include/asm/alternative-macros.h:224:2: error: call to undeclared function 'BUILD_BUG_ON'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
> |          BUILD_BUG_ON(feature >= ARM64_NCAPS);
> |          ^
> |  ./arch/arm64/include/asm/alternative-macros.h:241:2: error: call to undeclared function 'BUILD_BUG_ON'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
> |          BUILD_BUG_ON(feature >= ARM64_NCAPS);
> |          ^
> |  2 errors generated.
> 
> ... the problem being that when LTO is enabled, <asm/rwonce.h> includes
> <asm/alternative-macros.h>, and causes a circular include dependency
> through <linux/bug.h>. This manifests as BUILD_BUG_ON() not being
> defined when used within <asm/alternative-macros.h>.
> 
> This patch avoids the problem and simplifies the include dependencies by
> using compiletime_assert() instead of BUILD_BUG_ON().
> 
> Signed-off-by: Mark Rutland <mark.rutland at arm.com>
> Fixes: 21fb26bfb01ffe0d ("arm64: alternatives: add alternative_has_feature_*()")
> Reported-by: Nathan Chancellor <nathan at kernel.org>
> Tested-by: Nathan Chancellor <nathan at kernel.org>
> Link: http://lore.kernel.org/r/YyigTrxhE3IRPzjs@dev-arch.thelio-3990X
> Cc: Ard Biesheuvel <ardb at kernel.org>
> Cc: Catalin Marinas <catalin.marinas at arm.com>
> Cc: James Morse <james.morse at arm.com>
> Cc: Joey Gouly <joey.gouly at arm.com>
> Cc: Marc Zyngier <maz at kernel.org>
> Cc: Will Deacon <will at kernel.org>
> ---
>  arch/arm64/include/asm/alternative-macros.h | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Acked-by: Marc Zyngier <maz at kernel.org>

	M.

-- 
Without deviation from the norm, progress is not possible.



More information about the linux-arm-kernel mailing list