• Nathan Chancellor's avatar
    ARM: 8833/1: Ensure that NEON code always compiles with Clang · c716b08e
    Nathan Chancellor authored
    [ Upstream commit de9c0d49 ]
    
    While building arm32 allyesconfig, I ran into the following errors:
    
      arch/arm/lib/xor-neon.c:17:2: error: You should compile this file with
      '-mfloat-abi=softfp -mfpu=neon'
    
      In file included from lib/raid6/neon1.c:27:
      /home/nathan/cbl/prebuilt/lib/clang/8.0.0/include/arm_neon.h:28:2:
      error: "NEON support not enabled"
    
    Building V=1 showed NEON_FLAGS getting passed along to Clang but
    __ARM_NEON__ was not getting defined. Ultimately, it boils down to Clang
    only defining __ARM_NEON__ when targeting armv7, rather than armv6k,
    which is the '-march' value for allyesconfig.
    
    >From lib/Basic/Targets/ARM.cpp in the Clang source:
    
      // This only gets set when Neon instructions are actually available, unlike
      // the VFP define, hence the soft float and arch check. This is subtly
      // different from gcc, we follow the intent which was that it should be set
      // when Neon instructions are actually available.
      if ((FPU & NeonFPU) && !SoftFloat && ArchVersion >= 7) {
        Builder.defineMacro("__ARM_NEON", "1");
        Builder.defineMacro("__ARM_NEON__");
        // current AArch32 NEON implementations do not support double-precision
        // floating-point even when it is present in VFP.
        Builder.defineMacro("__ARM_NEON_FP",
                            "0x" + Twine::utohexstr(HW_FP & ~HW_FP_DP));
      }
    
    Ard Biesheuvel recommended explicitly adding '-march=armv7-a' at the
    beginning of the NEON_FLAGS definitions so that __ARM_NEON__ always gets
    definined by Clang. This doesn't functionally change anything because
    that code will only run where NEON is supported, which is implicitly
    armv7.
    
    Link: https://github.com/ClangBuiltLinux/linux/issues/287Suggested-by: 's avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
    Signed-off-by: Nathan Chancellor's avatarNathan Chancellor <natechancellor@gmail.com>
    Acked-by: 's avatarNicolas Pitre <nico@linaro.org>
    Reviewed-by: 's avatarNick Desaulniers <ndesaulniers@google.com>
    Reviewed-by: Stefan Agner's avatarStefan Agner <stefan@agner.ch>
    Signed-off-by: 's avatarRussell King <rmk+kernel@armlinux.org.uk>
    Signed-off-by: 's avatarSasha Levin <sashal@kernel.org>
    c716b08e
Name
Last commit
Last update
..
Marvell Loading commit data...
Microchip Loading commit data...
OMAP Loading commit data...
SA1100 Loading commit data...
SH-Mobile Loading commit data...
SPEAr Loading commit data...
Samsung Loading commit data...
Samsung-S3C24XX Loading commit data...
VFP Loading commit data...
keystone Loading commit data...
nwfpe Loading commit data...
pxa Loading commit data...
sti Loading commit data...
stm32 Loading commit data...
sunxi Loading commit data...
Booting Loading commit data...
IXP4xx Loading commit data...
Interrupts Loading commit data...
Netwinder Loading commit data...
Porting Loading commit data...
README Loading commit data...
Setup Loading commit data...
cluster-pm-race-avoidance.txt Loading commit data...
firmware.txt Loading commit data...
kernel_mode_neon.txt Loading commit data...
kernel_user_helpers.txt Loading commit data...
mem_alignment Loading commit data...
memory.txt Loading commit data...
swp_emulation Loading commit data...
tcm.txt Loading commit data...
uefi.txt Loading commit data...
vlocks.txt Loading commit data...