linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] printk: fix _entry_ptr build warning
@ 2024-03-06  9:26 Chunhui Li
  2024-03-06 19:40 ` Nathan Chancellor
  0 siblings, 1 reply; 3+ messages in thread
From: Chunhui Li @ 2024-03-06  9:26 UTC (permalink / raw)
  To: Petr Mladek, Steven Rostedt, John Ogness, Sergey Senozhatsky,
	Matthias Brugger, AngeloGioacchino Del Regno
  Cc: linux-kernel, linux-arm-kernel, linux-mediatek, wsd_upstream, Chunhui Li

We build with Werror and suffer build error when
enable CONFIG_PRINTK_INDEX, such as
gfp.h:223:2: error: unused variable '_entry_ptr'
ratelimit.h:31:3: error: unused variable '_entry_ptr'
kallsyms.h:172:2: error: unused variable '_entry_ptr'
[-Werror,-Wunused-variable]

Fix the warning by appending __attribute__((unused)).

Signed-off-by: Chunhui Li <chunhui.li@mediatek.com>
---
 include/linux/printk.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index 8ef499ab3c1e..749c1c4257f1 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -392,7 +392,7 @@ struct pi_entry {
 				.level = __builtin_constant_p(_level) ? (_level) : NULL, \
 				.subsys_fmt_prefix = _subsys_fmt_prefix,\
 			};						\
-			static const struct pi_entry *_entry_ptr	\
+			static const struct pi_entry *_entry_ptr __attribute__((unused)) \
 			__used __section(".printk_index") = &_entry;	\
 		}							\
 	} while (0)
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] printk: fix _entry_ptr build warning
  2024-03-06  9:26 [PATCH] printk: fix _entry_ptr build warning Chunhui Li
@ 2024-03-06 19:40 ` Nathan Chancellor
  2024-03-07  8:46   ` Chunhui Li (李春辉)
  0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2024-03-06 19:40 UTC (permalink / raw)
  To: Chunhui Li
  Cc: Petr Mladek, Steven Rostedt, John Ogness, Sergey Senozhatsky,
	Matthias Brugger, AngeloGioacchino Del Regno, linux-kernel,
	linux-arm-kernel, linux-mediatek, wsd_upstream

On Wed, Mar 06, 2024 at 05:26:47PM +0800, Chunhui Li wrote:
> We build with Werror and suffer build error when
> enable CONFIG_PRINTK_INDEX, such as
> gfp.h:223:2: error: unused variable '_entry_ptr'
> ratelimit.h:31:3: error: unused variable '_entry_ptr'
> kallsyms.h:172:2: error: unused variable '_entry_ptr'
> [-Werror,-Wunused-variable]
> 
> Fix the warning by appending __attribute__((unused)).
> 
> Signed-off-by: Chunhui Li <chunhui.li@mediatek.com>

Are these warnings being emitted from an Android version of clang,
specifically 18.0.0 with the build ID of 11209041 (you should be able to
tell this from the "bid" field in the BUILD_INFO file in the clang
toolchain folder)? This seems remarkably similar to
https://github.com/ClangBuiltLinux/linux/issues/1977, which was a report
using that version of Android clang.

Ultimately, this warning is a bug in a clang change that was quickly
found and reverted upstream

  https://github.com/llvm/llvm-project/commit/f0f395e00e2ec3f1f20ca9021d1554fde73d56c9
  https://github.com/llvm/llvm-project/commit/cfa578cde0314935c6eb5d7fa19ec26390d431dd

but unfortunately, Android picked a revision for the 11209041 build that
was between the landing of the broken commit and its revert. It was
quickly fixed with the 11368308 build

  https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+/42d100b025eb5f4a41781348016c148e9e912cf9

so you should just be able to update to that version to resolve this.

Cheers,
Nathan

> ---
>  include/linux/printk.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/printk.h b/include/linux/printk.h
> index 8ef499ab3c1e..749c1c4257f1 100644
> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
> @@ -392,7 +392,7 @@ struct pi_entry {
>  				.level = __builtin_constant_p(_level) ? (_level) : NULL, \
>  				.subsys_fmt_prefix = _subsys_fmt_prefix,\
>  			};						\
> -			static const struct pi_entry *_entry_ptr	\
> +			static const struct pi_entry *_entry_ptr __attribute__((unused)) \
>  			__used __section(".printk_index") = &_entry;	\
>  		}							\
>  	} while (0)
> -- 
> 2.18.0
> 
> 
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] printk: fix _entry_ptr build warning
  2024-03-06 19:40 ` Nathan Chancellor
@ 2024-03-07  8:46   ` Chunhui Li (李春辉)
  0 siblings, 0 replies; 3+ messages in thread
From: Chunhui Li (李春辉) @ 2024-03-07  8:46 UTC (permalink / raw)
  To: nathan
  Cc: linux-kernel, linux-mediatek, rostedt, wsd_upstream, pmladek,
	senozhatsky, linux-arm-kernel, john.ogness, matthias.bgg,
	angelogioacchino.delregno

Yes, the build warning suffer after Clang upgraded to 18.0.0 in below
bellow patch. We will discuss with Google about Clang.

ANDROID: Kleaf: Switch to Clang 18.0.0 (r510928)
https://android.googlesource.com/kernel/common/+log/ff9fc702b8c3

Thanks for your valuable information 
Chunhui.Li

On Wed, 2024-03-06 at 12:40 -0700, Nathan Chancellor wrote:
>  	 
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>  On Wed, Mar 06, 2024 at 05:26:47PM +0800, Chunhui Li wrote:
> > We build with Werror and suffer build error when
> > enable CONFIG_PRINTK_INDEX, such as
> > gfp.h:223:2: error: unused variable '_entry_ptr'
> > ratelimit.h:31:3: error: unused variable '_entry_ptr'
> > kallsyms.h:172:2: error: unused variable '_entry_ptr'
> > [-Werror,-Wunused-variable]
> > 
> > Fix the warning by appending __attribute__((unused)).
> > 
> > Signed-off-by: Chunhui Li <chunhui.li@mediatek.com>
> 
> Are these warnings being emitted from an Android version of clang,
> specifically 18.0.0 with the build ID of 11209041 (you should be able
> to
> tell this from the "bid" field in the BUILD_INFO file in the clang
> toolchain folder)? This seems remarkably similar to
> https://github.com/ClangBuiltLinux/linux/issues/1977, which was a
> report
> using that version of Android clang.
> 
> Ultimately, this warning is a bug in a clang change that was quickly
> found and reverted upstream
> 
>   
> https://github.com/llvm/llvm-project/commit/f0f395e00e2ec3f1f20ca9021d1554fde73d56c9
>   
> https://github.com/llvm/llvm-project/commit/cfa578cde0314935c6eb5d7fa19ec26390d431dd
> 
> but unfortunately, Android picked a revision for the 11209041 build
> that
> was between the landing of the broken commit and its revert. It was
> quickly fixed with the 11368308 build
> 
>   
> https://android.googlesource.com/platform/prebuilts/clang/host/linux-x86/+/42d100b025eb5f4a41781348016c148e9e912cf9
> 
> so you should just be able to update to that version to resolve this.
> 
> Cheers,
> Nathan
> 
> > ---
> >  include/linux/printk.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/include/linux/printk.h b/include/linux/printk.h
> > index 8ef499ab3c1e..749c1c4257f1 100644
> > --- a/include/linux/printk.h
> > +++ b/include/linux/printk.h
> > @@ -392,7 +392,7 @@ struct pi_entry {
> >  .level = __builtin_constant_p(_level) ? (_level) : NULL, \
> >  .subsys_fmt_prefix = _subsys_fmt_prefix,\
> >  };\
> > -static const struct pi_entry *_entry_ptr\
> > +static const struct pi_entry *_entry_ptr __attribute__((unused)) \
> >  __used __section(".printk_index") = &_entry;\
> >  }\
> >  } while (0)
> > -- 
> > 2.18.0
> > 
> > 
> > _______________________________________________
> > linux-arm-kernel mailing list
> > linux-arm-kernel@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-03-07  8:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-06  9:26 [PATCH] printk: fix _entry_ptr build warning Chunhui Li
2024-03-06 19:40 ` Nathan Chancellor
2024-03-07  8:46   ` Chunhui Li (李春辉)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).