• Nathan Chancellor's avatar
    mips: Fix unroll macro when building with Clang · df3da048
    Nathan Chancellor authored
    Building with Clang errors after commit 6baaeada ("MIPS: Provide
    unroll() macro, use it for cache ops") since the GCC_VERSION macro
    is defined in include/linux/compiler-gcc.h, which is only included
    in compiler.h when using GCC:
    
    In file included from arch/mips/kernel/mips-mt.c:20:
    ./arch/mips/include/asm/r4kcache.h:254:1: error: use of undeclared
    identifier 'GCC_VERSION'; did you mean 'S_VERSION'?
    __BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 32,
    )
    ^
    ./arch/mips/include/asm/r4kcache.h:219:4: note: expanded from macro
    '__BUILD_BLAST_CACHE'
                            cache_unroll(32, kernel_cache, indexop,
                            ^
    ./arch/mips/include/asm/r4kcache.h:203:2: note: expanded from macro
    'cache_unroll'
            unroll(times, _cache_op, insn, op, (addr) + (i++ * (lsize)));
            ^
    ./arch/mips/include/asm/unroll.h:28:15: note: expanded from macro
    'unroll'
            BUILD_BUG_ON(GCC_VERSION >= 40700 &&                    \
                         ^
    
    Use CONFIG_GCC_VERSION, which will always be set by Kconfig.
    Additionally, Clang 8 had improvements around __builtin_constant_p so
    use that as a lower limit for this check with Clang (although MIPS
    wasn't buildable until Clang 9); building a kernel with Clang 9.0.0
    has no issues after this change.
    
    Fixes: 6baaeada ("MIPS: Provide unroll() macro, use it for cache ops")
    Link: https://github.com/ClangBuiltLinux/linux/issues/736Signed-off-by: default avatarNathan Chancellor <natechancellor@gmail.com>
    Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
    Cc: Ralf Baechle <ralf@linux-mips.org>
    Cc: James Hogan <jhogan@kernel.org>
    Cc: linux-mips@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Cc: clang-built-linux@googlegroups.com
    Cc: Nick Desaulniers <ndesaulniers@google.com>
    df3da048
unroll.h 3.03 KB