Skip to contentSkip to conversation

kbuild: Set CLANG_VERSION only when Clang is used

PATCH In review Sedat Dilek 3 participants 3 messages Apr 19, 2020 – Apr 21, 2020 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: Set CLANG_VERSION only when Clang is used

Do like GCC_VERSION is set when GCC (see CC_IS_GCC) is used.

---
 init/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
init/Kconfig +1 -1
index 9e22ee8fbd75..c23f9d3d6d6c 100644
@@ -25,7 +25,7 @@ config CC_IS_CLANG
 
 config CLANG_VERSION
 	int
-	default $(shell,$(srctree)/scripts/clang-version.sh $(CC))
+	default $(shell,$(srctree)/scripts/clang-version.sh $(CC)) if CC_IS_CLANG
 
 config CC_CAN_LINK
 	def_bool $(success,$(srctree)/scripts/cc-can-link.sh $(CC))
Signature · 1 line
2.26.1
#1 lore raw
Quoted 23 lines · Sedat Dilek

Do like GCC_VERSION is set when GCC (see CC_IS_GCC) is used.

---
 init/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
init/Kconfig +1 -1
index 9e22ee8fbd75..c23f9d3d6d6c 100644
@@ -25,7 +25,7 @@ config CC_IS_CLANG
 
 config CLANG_VERSION
 	int
-	default $(shell,$(srctree)/scripts/clang-version.sh $(CC))
+	default $(shell,$(srctree)/scripts/clang-version.sh $(CC)) if CC_IS_CLANG
 
 config CC_CAN_LINK
 	def_bool $(success,$(srctree)/scripts/cc-can-link.sh $(CC))
Signature · 1 line
2.26.1

I don't understand the motivation behind this. The commit message needs to be expanded upon or further clarification is needed.

CONFIG_GCC_VERSION is always set, either to 0 if using clang or the actual version spit out by GCC so the commit message is not entirely accurate.

It is done in the

    default $(shell,$(srctree)/scripts/gcc-version.sh $(CC)) if CC_IS_GCC
    default 0

way because it relies on the __GNUC__, __GNUC_MINOR__, and __GNUC_PATCHLEVEL__ preprocessor macros to figure out the verison, which clang also defines (to 4, 2, and 1 respectively) so it has to be done this way to avoid confusing clang for GCC.

We can handle this in clang-version.sh so that CONFIG_CLANG_VERSION is set to zero if CONFIG_CC_IS_GCC is set, just like CONFIG_GCC_VERSION:

if ! ( $compiler --version | grep -q clang) ; then
echo 0
exit 1
fi

CONFIG_CLANG_VERSION needs to be defined, otherwise we are breaking the assumption that I made in commit df3da04880b4 ("mips: Fix unroll macro when building with Clang").

With your patch and GCC 9.3.0 building malta_defconfig:

arch/mips/include/asm/r4kcache.h: In function 'blast_scache64_node':
arch/mips/include/asm/unroll.h:29:9: error: 'CONFIG_CLANG_VERSION' undeclared (first use in this function); did you mean 'CONFIG_LD_VERSION'?

   29 |         CONFIG_CLANG_VERSION >= 80000) &&  \
      |         ^~~~~~~~~~~~~~~~~~~~
/home/nathan/src/linux/include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
  330 |   if (!(condition))     \
      |         ^~~~~~~~~
/home/nathan/src/linux/include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert'
  350 |  _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
      |  ^~~~~~~~~~~~~~~~~~~
/home/nathan/src/linux/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)
      |                                     ^~~~~~~~~~~~~~~~~~
/home/nathan/src/linux/include/linux/build_bug.h:50:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
   50 |  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
      |  ^~~~~~~~~~~~~~~~
/home/nathan/src/linux/arch/mips/include/asm/unroll.h:28:2: note: in expansion of macro 'BUILD_BUG_ON'
   28 |  BUILD_BUG_ON((CONFIG_GCC_VERSION >= 40700 ||  \
      |  ^~~~~~~~~~~~
/home/nathan/src/linux/arch/mips/include/asm/r4kcache.h:203:2: note: in expansion of macro 'unroll'
  203 |  unroll(times, _cache_op, insn, op, (addr) + (i++ * (lsize))); \
      |  ^~~~~~
/home/nathan/src/linux/arch/mips/include/asm/r4kcache.h:370:4: note: in expansion of macro 'cache_unroll'
  370 |    cache_unroll(32, kernel_cache, indexop,  \
      |    ^~~~~~~~~~~~
/home/nathan/src/linux/arch/mips/include/asm/r4kcache.h:376:1: note: in expansion of macro '__BUILD_BLAST_CACHE_NODE'
  376 | __BUILD_BLAST_CACHE_NODE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 64)
      | ^~~~~~~~~~~~~~~~~~~~~~~~

Cheers,
Nathan

#2 lore raw
In reply to Sedat Dilek
Thank you for the patch! Yet something to improve:

Hi Sedat,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on kbuild/for-next]
[also build test ERROR on jeyu/modules-next linus/master v5.7-rc2 next-20200420] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Sedat-Dilek/kbuild-Set-CLANG_VERSION-only-when-Clang-is-used/20200421-110637
base:   https://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git for-next
config: mips-fuloong2e_defconfig (attached as .config)
compiler: mips64el-linux-gcc (GCC) 9.3.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=mips

If you fix the issue, kindly add following tag as appropriate

All error/warnings (new ones prefixed by >>):

In file included from include/linux/kernel.h:11,

                    from include/linux/cpu_pm.h:12,
                    from arch/mips/mm/c-r4k.c:10:
   arch/mips/include/asm/r4kcache.h: In function 'blast_dcache16':
>> arch/mips/include/asm/unroll.h:29:9: error: 'CONFIG_CLANG_VERSION' undeclared (first use in this function); did you mean 'CONFIG_LD_VERSION'?
      29 |         CONFIG_CLANG_VERSION >= 80000) &&  \
         |         ^~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
     330 |   if (!(condition))     \
         |         ^~~~~~~~~
   include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert'
     350 |  _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:50:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |  ^~~~~~~~~~~~~~~~
>> arch/mips/include/asm/unroll.h:28:2: note: in expansion of macro 'BUILD_BUG_ON'
      28 |  BUILD_BUG_ON((CONFIG_GCC_VERSION >= 40700 ||  \
         |  ^~~~~~~~~~~~
>> arch/mips/include/asm/r4kcache.h:203:2: note: in expansion of macro 'unroll'
     203 |  unroll(times, _cache_op, insn, op, (addr) + (i++ * (lsize))); \
         |  ^~~~~~
>> arch/mips/include/asm/r4kcache.h:219:4: note: in expansion of macro 'cache_unroll'
     219 |    cache_unroll(32, kernel_cache, indexop,  \
         |    ^~~~~~~~~~~~
>> arch/mips/include/asm/r4kcache.h:250:1: note: in expansion of macro '__BUILD_BLAST_CACHE'
     250 | __BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 16, )
         | ^~~~~~~~~~~~~~~~~~~
   arch/mips/include/asm/unroll.h:29:9: note: each undeclared identifier is reported only once for each function it appears in
      29 |         CONFIG_CLANG_VERSION >= 80000) &&  \
         |         ^~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
     330 |   if (!(condition))     \
         |         ^~~~~~~~~
   include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert'
     350 |  _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:50:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |  ^~~~~~~~~~~~~~~~
>> arch/mips/include/asm/unroll.h:28:2: note: in expansion of macro 'BUILD_BUG_ON'
      28 |  BUILD_BUG_ON((CONFIG_GCC_VERSION >= 40700 ||  \
         |  ^~~~~~~~~~~~
>> arch/mips/include/asm/r4kcache.h:203:2: note: in expansion of macro 'unroll'
     203 |  unroll(times, _cache_op, insn, op, (addr) + (i++ * (lsize))); \
         |  ^~~~~~
>> arch/mips/include/asm/r4kcache.h:219:4: note: in expansion of macro 'cache_unroll'
     219 |    cache_unroll(32, kernel_cache, indexop,  \
         |    ^~~~~~~~~~~~
>> arch/mips/include/asm/r4kcache.h:250:1: note: in expansion of macro '__BUILD_BLAST_CACHE'
     250 | __BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 16, )
         | ^~~~~~~~~~~~~~~~~~~
   arch/mips/include/asm/r4kcache.h: In function 'blast_dcache16_page':
>> arch/mips/include/asm/unroll.h:29:9: error: 'CONFIG_CLANG_VERSION' undeclared (first use in this function); did you mean 'CONFIG_LD_VERSION'?
      29 |         CONFIG_CLANG_VERSION >= 80000) &&  \
         |         ^~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
     330 |   if (!(condition))     \
         |         ^~~~~~~~~
   include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert'
     350 |  _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:50:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |  ^~~~~~~~~~~~~~~~
>> arch/mips/include/asm/unroll.h:28:2: note: in expansion of macro 'BUILD_BUG_ON'
      28 |  BUILD_BUG_ON((CONFIG_GCC_VERSION >= 40700 ||  \
         |  ^~~~~~~~~~~~
>> arch/mips/include/asm/r4kcache.h:203:2: note: in expansion of macro 'unroll'
     203 |  unroll(times, _cache_op, insn, op, (addr) + (i++ * (lsize))); \
         |  ^~~~~~
   arch/mips/include/asm/r4kcache.h:229:3: note: in expansion of macro 'cache_unroll'
     229 |   cache_unroll(32, kernel_cache, hitop, start, lsize); \
         |   ^~~~~~~~~~~~
>> arch/mips/include/asm/r4kcache.h:250:1: note: in expansion of macro '__BUILD_BLAST_CACHE'
     250 | __BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 16, )
         | ^~~~~~~~~~~~~~~~~~~
   arch/mips/include/asm/r4kcache.h: In function 'blast_dcache16_page_indexed':
>> arch/mips/include/asm/unroll.h:29:9: error: 'CONFIG_CLANG_VERSION' undeclared (first use in this function); did you mean 'CONFIG_LD_VERSION'?
      29 |         CONFIG_CLANG_VERSION >= 80000) &&  \
         |         ^~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
     330 |   if (!(condition))     \
         |         ^~~~~~~~~
   include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert'
     350 |  _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:50:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |  ^~~~~~~~~~~~~~~~
>> arch/mips/include/asm/unroll.h:28:2: note: in expansion of macro 'BUILD_BUG_ON'
      28 |  BUILD_BUG_ON((CONFIG_GCC_VERSION >= 40700 ||  \
         |  ^~~~~~~~~~~~
>> arch/mips/include/asm/r4kcache.h:203:2: note: in expansion of macro 'unroll'
     203 |  unroll(times, _cache_op, insn, op, (addr) + (i++ * (lsize))); \
         |  ^~~~~~
   arch/mips/include/asm/r4kcache.h:246:4: note: in expansion of macro 'cache_unroll'
     246 |    cache_unroll(32, kernel_cache, indexop,  \
         |    ^~~~~~~~~~~~
>> arch/mips/include/asm/r4kcache.h:250:1: note: in expansion of macro '__BUILD_BLAST_CACHE'
     250 | __BUILD_BLAST_CACHE(d, dcache, Index_Writeback_Inv_D, Hit_Writeback_Inv_D, 16, )
         | ^~~~~~~~~~~~~~~~~~~
   arch/mips/include/asm/r4kcache.h: In function 'blast_icache16':
>> arch/mips/include/asm/unroll.h:29:9: error: 'CONFIG_CLANG_VERSION' undeclared (first use in this function); did you mean 'CONFIG_LD_VERSION'?
      29 |         CONFIG_CLANG_VERSION >= 80000) &&  \
         |         ^~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
     330 |   if (!(condition))     \
         |         ^~~~~~~~~
   include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert'
     350 |  _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:50:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |  ^~~~~~~~~~~~~~~~
>> arch/mips/include/asm/unroll.h:28:2: note: in expansion of macro 'BUILD_BUG_ON'
      28 |  BUILD_BUG_ON((CONFIG_GCC_VERSION >= 40700 ||  \
         |  ^~~~~~~~~~~~
>> arch/mips/include/asm/r4kcache.h:203:2: note: in expansion of macro 'unroll'
     203 |  unroll(times, _cache_op, insn, op, (addr) + (i++ * (lsize))); \
         |  ^~~~~~
   arch/mips/include/asm/r4kcache.h:219:4: note: in expansion of macro 'cache_unroll'
     219 |    cache_unroll(32, kernel_cache, indexop,  \
         |    ^~~~~~~~~~~~
   arch/mips/include/asm/r4kcache.h:251:1: note: in expansion of macro '__BUILD_BLAST_CACHE'
     251 | __BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 16, )
         | ^~~~~~~~~~~~~~~~~~~
   arch/mips/include/asm/r4kcache.h: In function 'blast_icache16_page':
   arch/mips/include/asm/unroll.h:29:9: error: 'CONFIG_CLANG_VERSION' undeclared (first use in this function); did you mean 'CONFIG_LD_VERSION'?
      29 |         CONFIG_CLANG_VERSION >= 80000) &&  \
         |         ^~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
     330 |   if (!(condition))     \
         |         ^~~~~~~~~
   include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert'
     350 |  _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:50:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |  ^~~~~~~~~~~~~~~~
   arch/mips/include/asm/unroll.h:28:2: note: in expansion of macro 'BUILD_BUG_ON'
      28 |  BUILD_BUG_ON((CONFIG_GCC_VERSION >= 40700 ||  \
         |  ^~~~~~~~~~~~
   arch/mips/include/asm/r4kcache.h:203:2: note: in expansion of macro 'unroll'
     203 |  unroll(times, _cache_op, insn, op, (addr) + (i++ * (lsize))); \
         |  ^~~~~~
   arch/mips/include/asm/r4kcache.h:229:3: note: in expansion of macro 'cache_unroll'
     229 |   cache_unroll(32, kernel_cache, hitop, start, lsize); \
         |   ^~~~~~~~~~~~
   arch/mips/include/asm/r4kcache.h:251:1: note: in expansion of macro '__BUILD_BLAST_CACHE'
     251 | __BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 16, )
         | ^~~~~~~~~~~~~~~~~~~
   arch/mips/include/asm/r4kcache.h: In function 'blast_icache16_page_indexed':
   arch/mips/include/asm/unroll.h:29:9: error: 'CONFIG_CLANG_VERSION' undeclared (first use in this function); did you mean 'CONFIG_LD_VERSION'?
      29 |         CONFIG_CLANG_VERSION >= 80000) &&  \
         |         ^~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
     330 |   if (!(condition))     \
         |         ^~~~~~~~~
   include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert'
     350 |  _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:50:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |  ^~~~~~~~~~~~~~~~
   arch/mips/include/asm/unroll.h:28:2: note: in expansion of macro 'BUILD_BUG_ON'
      28 |  BUILD_BUG_ON((CONFIG_GCC_VERSION >= 40700 ||  \
         |  ^~~~~~~~~~~~
   arch/mips/include/asm/r4kcache.h:203:2: note: in expansion of macro 'unroll'
     203 |  unroll(times, _cache_op, insn, op, (addr) + (i++ * (lsize))); \
         |  ^~~~~~
   arch/mips/include/asm/r4kcache.h:246:4: note: in expansion of macro 'cache_unroll'
     246 |    cache_unroll(32, kernel_cache, indexop,  \
         |    ^~~~~~~~~~~~
   arch/mips/include/asm/r4kcache.h:251:1: note: in expansion of macro '__BUILD_BLAST_CACHE'
     251 | __BUILD_BLAST_CACHE(i, icache, Index_Invalidate_I, Hit_Invalidate_I, 16, )
         | ^~~~~~~~~~~~~~~~~~~
   arch/mips/include/asm/r4kcache.h: In function 'blast_scache16':
   arch/mips/include/asm/unroll.h:29:9: error: 'CONFIG_CLANG_VERSION' undeclared (first use in this function); did you mean 'CONFIG_LD_VERSION'?
      29 |         CONFIG_CLANG_VERSION >= 80000) &&  \
         |         ^~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
     330 |   if (!(condition))     \
         |         ^~~~~~~~~
   include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert'
     350 |  _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:50:2: note: in expansion of macro 'BUILD_BUG_ON_MSG'
      50 |  BUILD_BUG_ON_MSG(condition, "BUILD_BUG_ON failed: " #condition)
         |  ^~~~~~~~~~~~~~~~
   arch/mips/include/asm/unroll.h:28:2: note: in expansion of macro 'BUILD_BUG_ON'
      28 |  BUILD_BUG_ON((CONFIG_GCC_VERSION >= 40700 ||  \
         |  ^~~~~~~~~~~~
   arch/mips/include/asm/r4kcache.h:203:2: note: in expansion of macro 'unroll'
     203 |  unroll(times, _cache_op, insn, op, (addr) + (i++ * (lsize))); \
         |  ^~~~~~
   arch/mips/include/asm/r4kcache.h:219:4: note: in expansion of macro 'cache_unroll'
     219 |    cache_unroll(32, kernel_cache, indexop,  \
         |    ^~~~~~~~~~~~
   arch/mips/include/asm/r4kcache.h:252:1: note: in expansion of macro '__BUILD_BLAST_CACHE'
     252 | __BUILD_BLAST_CACHE(s, scache, Index_Writeback_Inv_SD, Hit_Writeback_Inv_SD, 16, )
         | ^~~~~~~~~~~~~~~~~~~
   arch/mips/include/asm/r4kcache.h: In function 'blast_scache16_page':
   arch/mips/include/asm/unroll.h:29:9: error: 'CONFIG_CLANG_VERSION' undeclared (first use in this function); did you mean 'CONFIG_LD_VERSION'?
      29 |         CONFIG_CLANG_VERSION >= 80000) &&  \
         |         ^~~~~~~~~~~~~~~~~~~~
   include/linux/compiler.h:330:9: note: in definition of macro '__compiletime_assert'
     330 |   if (!(condition))     \
         |         ^~~~~~~~~

include/linux/compiler.h:350:2: note: in expansion of macro '_compiletime_assert'

vim +29 arch/mips/include/asm/unroll.h

6baaeadae911ba9 Paul Burton       2019-10-08   4  
6baaeadae911ba9 Paul Burton       2019-10-08   5  /*
6baaeadae911ba9 Paul Burton       2019-10-08   6   * Explicitly unroll a loop, for use in cases where doing so is performance
6baaeadae911ba9 Paul Burton       2019-10-08   7   * critical.
6baaeadae911ba9 Paul Burton       2019-10-08   8   *
6baaeadae911ba9 Paul Burton       2019-10-08   9   * Ideally we'd rely upon the compiler to provide this but there's no commonly
6baaeadae911ba9 Paul Burton       2019-10-08  10   * available means to do so. For example GCC's "#pragma GCC unroll"
6baaeadae911ba9 Paul Burton       2019-10-08  11   * functionality would be ideal but is only available from GCC 8 onwards. Using
6baaeadae911ba9 Paul Burton       2019-10-08  12   * -funroll-loops is an option but GCC tends to make poor choices when
6baaeadae911ba9 Paul Burton       2019-10-08  13   * compiling our string functions. -funroll-all-loops leads to massive code
6baaeadae911ba9 Paul Burton       2019-10-08  14   * bloat, even if only applied to the string functions.
6baaeadae911ba9 Paul Burton       2019-10-08  15   */
6baaeadae911ba9 Paul Burton       2019-10-08  16  #define unroll(times, fn, ...) do {				\
6baaeadae911ba9 Paul Burton       2019-10-08  17  	extern void bad_unroll(void)				\
6baaeadae911ba9 Paul Burton       2019-10-08  18  		__compiletime_error("Unsupported unroll");	\
6baaeadae911ba9 Paul Burton       2019-10-08  19  								\
6baaeadae911ba9 Paul Burton       2019-10-08  20  	/*							\
6baaeadae911ba9 Paul Burton       2019-10-08  21  	 * We can't unroll if the number of iterations isn't	\
6baaeadae911ba9 Paul Burton       2019-10-08  22  	 * compile-time constant. Unfortunately GCC versions	\
6baaeadae911ba9 Paul Burton       2019-10-08  23  	 * up until 4.6 tend to miss obvious constants & cause	\
6baaeadae911ba9 Paul Burton       2019-10-08  24  	 * this check to fail, even though they go on to	\
6baaeadae911ba9 Paul Burton       2019-10-08  25  	 * generate reasonable code for the switch statement,	\
6baaeadae911ba9 Paul Burton       2019-10-08  26  	 * so we skip the sanity check for those compilers.	\
6baaeadae911ba9 Paul Burton       2019-10-08  27  	 */							\
df3da04880b45b0 Nathan Chancellor 2019-10-10 @28  	BUILD_BUG_ON((CONFIG_GCC_VERSION >= 40700 ||		\
df3da04880b45b0 Nathan Chancellor 2019-10-10 @29  		      CONFIG_CLANG_VERSION >= 80000) &&		\
6baaeadae911ba9 Paul Burton       2019-10-08  30  		     !__builtin_constant_p(times));		\
6baaeadae911ba9 Paul Burton       2019-10-08  31  								\
6baaeadae911ba9 Paul Burton       2019-10-08  32  	switch (times) {					\
6baaeadae911ba9 Paul Burton       2019-10-08  33  	case 32: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  34  	case 31: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  35  	case 30: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  36  	case 29: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  37  	case 28: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  38  	case 27: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  39  	case 26: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  40  	case 25: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  41  	case 24: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  42  	case 23: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  43  	case 22: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  44  	case 21: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  45  	case 20: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  46  	case 19: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  47  	case 18: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  48  	case 17: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  49  	case 16: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  50  	case 15: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  51  	case 14: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  52  	case 13: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  53  	case 12: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  54  	case 11: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  55  	case 10: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  56  	case 9: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  57  	case 8: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  58  	case 7: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  59  	case 6: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  60  	case 5: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  61  	case 4: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  62  	case 3: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  63  	case 2: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  64  	case 1: fn(__VA_ARGS__); /* fall through */		\
6baaeadae911ba9 Paul Burton       2019-10-08  65  	case 0: break;						\
6baaeadae911ba9 Paul Burton       2019-10-08  66  								\
6baaeadae911ba9 Paul Burton       2019-10-08  67  	default:						\
6baaeadae911ba9 Paul Burton       2019-10-08  68  		/*						\
6baaeadae911ba9 Paul Burton       2019-10-08  69  		 * Either the iteration count is unreasonable	\
6baaeadae911ba9 Paul Burton       2019-10-08  70  		 * or we need to add more cases above.		\
6baaeadae911ba9 Paul Burton       2019-10-08  71  		 */						\
6baaeadae911ba9 Paul Burton       2019-10-08  72  		bad_unroll();					\
6baaeadae911ba9 Paul Burton       2019-10-08  73  		break;						\
6baaeadae911ba9 Paul Burton       2019-10-08  74  	}							\
6baaeadae911ba9 Paul Burton       2019-10-08  75  } while (0)

6baaeadae911ba9 Paul Burton 2019-10-08 76

:::::: The code at line 29 was first introduced by commit
:::::: df3da04880b45b059b8b064c2dd67289a793109e mips: Fix unroll macro when building with Clang

:::::: TO: Nathan Chancellor <[email protected]> :::::: CC: Paul Burton <[email protected]>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org