diff mbox

[v2,5/5] asm-generic: fix build error in fix_to_virt with CONFIG_DEBUG_EXPERIENCE

Message ID 1525268700-10631-6-git-send-email-changbin.du@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Du, Changbin May 2, 2018, 1:45 p.m. UTC
From: Changbin Du <changbin.du@intel.com>

With '-Og' optimization level, GCC would not optimize a count for a loop
as a constant value. But BUILD_BUG_ON() only accept compile-time constant
values.

arch/arm/mm/mmu.o: In function `fix_to_virt':
/home/changbin/work/linux/./include/asm-generic/fixmap.h:31: undefined reference to `__compiletime_assert_31'
Makefile:1051: recipe for target 'vmlinux' failed
make: *** [vmlinux] Error 1

Signed-off-by: Changbin Du <changbin.du@intel.com>
---
 include/asm-generic/fixmap.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Steven Rostedt May 2, 2018, 2:19 p.m. UTC | #1
On Wed,  2 May 2018 21:45:00 +0800
changbin.du@intel.com wrote:

> From: Changbin Du <changbin.du@intel.com>
> 
> With '-Og' optimization level, GCC would not optimize a count for a loop
> as a constant value. But BUILD_BUG_ON() only accept compile-time constant
> values.
> 
> arch/arm/mm/mmu.o: In function `fix_to_virt':
> /home/changbin/work/linux/./include/asm-generic/fixmap.h:31: undefined reference to `__compiletime_assert_31'
> Makefile:1051: recipe for target 'vmlinux' failed
> make: *** [vmlinux] Error 1
> 
> Signed-off-by: Changbin Du <changbin.du@intel.com>
> ---
>  include/asm-generic/fixmap.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/include/asm-generic/fixmap.h b/include/asm-generic/fixmap.h
> index 827e4d3..a6576d4 100644
> --- a/include/asm-generic/fixmap.h
> +++ b/include/asm-generic/fixmap.h
> @@ -28,7 +28,8 @@
>   */
>  static __always_inline unsigned long fix_to_virt(const unsigned int idx)
>  {
> -	BUILD_BUG_ON(idx >= __end_of_fixed_addresses);
> +	BUILD_BUG_ON(__builtin_constant_p(idx) &&
> +		     idx >= __end_of_fixed_addresses);

Hmm, this changes the check slightly. Perhaps we should only do this
when your config is active:

{
	BUILD_BUG_ON(
/* CONFIG_DEBUG_OPTIMIZE may cause idx not to be constant */
#ifdef CONFIG_DEBUG_OPTIMIZE
		__builtin_constant_p(idx) &&
#endif
		idx >= __end_of_fixed_addresses);

}

-- Steve

>  	return __fix_to_virt(idx);
>  }
>  

--
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/asm-generic/fixmap.h b/include/asm-generic/fixmap.h
index 827e4d3..a6576d4 100644
--- a/include/asm-generic/fixmap.h
+++ b/include/asm-generic/fixmap.h
@@ -28,7 +28,8 @@ 
  */
 static __always_inline unsigned long fix_to_virt(const unsigned int idx)
 {
-	BUILD_BUG_ON(idx >= __end_of_fixed_addresses);
+	BUILD_BUG_ON(__builtin_constant_p(idx) &&
+		     idx >= __end_of_fixed_addresses);
 	return __fix_to_virt(idx);
 }