arm64: alternatives: Use vdso/bits.h instead of linux/bits.h
PATCH 1/1 arm64: alternatives: Use vdso/bits.h instead of linux/bits.h
When building with CONFIG_LTO after commit ba00c2a04fa5 ("arm64: fix the build with binutils 2.27"), the following build error occurs:
In file included from arch/arm64/kernel/module-plts.c:6:
In file included from include/linux/elf.h:6:
In file included from arch/arm64/include/asm/elf.h:8:
In file included from arch/arm64/include/asm/hwcap.h:9:
In file included from arch/arm64/include/asm/cpufeature.h:9:
In file included from arch/arm64/include/asm/alternative-macros.h:5:
In file included from include/linux/bits.h:22:
In file included from include/linux/build_bug.h:5:
In file included from include/linux/compiler.h:248:
In file included from arch/arm64/include/asm/rwonce.h:71:
include/asm-generic/rwonce.h:67:9: error: expected string literal in 'asm'
return __READ_ONCE(*(unsigned long *)addr);
^
arch/arm64/include/asm/rwonce.h:43:16: note: expanded from macro '__READ_ONCE'
asm volatile(__LOAD_RCPC(b, %w0, %1) \
^
arch/arm64/include/asm/rwonce.h:17:2: note: expanded from macro '__LOAD_RCPC'
ALTERNATIVE( \
^Similar to the issue resolved by commit 0072dc1b53c3 ("arm64: avoid BUILD_BUG_ON() in alternative-macros"), there is a circular include dependency through <linux/bits.h> when CONFIG_LTO is enabled due to <asm/rwonce.h> appearing in the include chain before the contents of <asm/alternative-macros.h>, which results in ALTERNATIVE() not getting expanded properly because it has not been defined yet.
Avoid this issue by including <vdso/bits.h>, which includes the definition of the BIT() macro, instead of <linux/bits.h>, as BIT() is the only macro from bits.h that is relevant to this header.
--- arch/arm64/include/asm/alternative-macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/alternative-macros.h +1 -1
@@ -2,8 +2,8 @@#ifndef __ASM_ALTERNATIVE_MACROS_H#define __ASM_ALTERNATIVE_MACROS_H -#include <linux/bits.h> #include <linux/const.h> +#include <vdso/bits.h> #include <asm/cpucaps.h> #include <asm/insn-def.h>
base-commit: ba00c2a04fa5431d204a4183062b30372c062aa7
Signature · 1 line
2.37.3
Quoted 56 lines · Nathan Chancellor
When building with
CONFIG_LTOafter commitba00c2a04fa5("arm64: fix the build with binutils 2.27"), the following build error occurs:In file included from
arch/arm64/kernel/module-plts.c:6:
In file included frominclude/linux/elf.h:6:
In file included fromarch/arm64/include/asm/elf.h:8:
In file included fromarch/arm64/include/asm/hwcap.h:9:
In file included fromarch/arm64/include/asm/cpufeature.h:9:
In file included fromarch/arm64/include/asm/alternative-macros.h:5:
In file included frominclude/linux/bits.h:22:
In file included frominclude/linux/build_bug.h:5:
In file included frominclude/linux/compiler.h:248:
In file included fromarch/arm64/include/asm/rwonce.h:71:
include/asm-generic/rwonce.h:67:9: error: expected string literal in 'asm'return __READ_ONCE(*(unsigned long *)addr); ^ arch/arm64/include/asm/rwonce.h:43:16: note: expanded from macro '__READ_ONCE' asm volatile(__LOAD_RCPC(b, %w0, %1) \ ^ arch/arm64/include/asm/rwonce.h:17:2: note: expanded from macro '__LOAD_RCPC' ALTERNATIVE( \ ^Similar to the issue resolved by commit
0072dc1b53c3("arm64: avoidBUILD_BUG_ON()in alternative-macros"), there is a circular include dependency through <linux/bits.h> whenCONFIG_LTOis enabled due to <asm/rwonce.h> appearing in the include chain before the contents of <asm/alternative-macros.h>, which results inALTERNATIVE()not getting expanded properly because it has not been defined yet.Avoid this issue by including <
vdso/bits.h>, which includes the definition of theBIT()macro, instead of <linux/bits.h>, asBIT()is the only macro frombits.hthat is relevant to this header.Fixes ba00c2a04fa5 ("arm64: fix the build with binutils 2.27")Signed-off-by Nathan Chancellor <[email protected]>--- arch/arm64/include/asm/alternative-macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/arm64/include/asm/alternative-macros.h +1
-1@@ -2,8 +2,8 @@#ifndef __ASM_ALTERNATIVE_MACROS_H#define __ASM_ALTERNATIVE_MACROS_H -#include <linux/bits.h> #include <linux/const.h> +#include <vdso/bits.h> #include <asm/cpucaps.h> #include <asm/insn-def.h>
Quoted 1 line
base-commit:
ba00c2a04fa5431d204a4183062b30372c062aa7
The 'vdso' namespace is a bit of a misnomer, but that's not your fault and I can confirm that this fixes the build on for-next/core with defconfig + thin LTO, so:
Thanks!
Will
Quoted 23 lines · Nathan Chancellor
When building with
CONFIG_LTOafter commitba00c2a04fa5("arm64: fix the build with binutils 2.27"), the following build error occurs:In file included from
arch/arm64/kernel/module-plts.c:6:
In file included frominclude/linux/elf.h:6:
In file included fromarch/arm64/include/asm/elf.h:8:
In file included fromarch/arm64/include/asm/hwcap.h:9:
In file included fromarch/arm64/include/asm/cpufeature.h:9:
In file included fromarch/arm64/include/asm/alternative-macros.h:5:
In file included frominclude/linux/bits.h:22:
In file included frominclude/linux/build_bug.h:5:
In file included frominclude/linux/compiler.h:248:
In file included fromarch/arm64/include/asm/rwonce.h:71:
include/asm-generic/rwonce.h:67:9: error: expected string literal in 'asm'return __READ_ONCE(*(unsigned long *)addr); ^ arch/arm64/include/asm/rwonce.h:43:16: note: expanded from macro '__READ_ONCE' asm volatile(__LOAD_RCPC(b, %w0, %1) \ ^ arch/arm64/include/asm/rwonce.h:17:2: note: expanded from macro '__LOAD_RCPC' ALTERNATIVE( \ ^
Quoted 1 line
[...]
Applied to arm64 (for-next/core), thanks!
[1/1] arm64: alternatives: Use vdso/bits.h instead of linux/bits.h
https://git.kernel.org/arm64/c/d2995249a2f7
Signature · 1 line
Catalin