diff mbox series

[v3] fix ___SYNC () build error when PROFILE_ALL_BRANCHES is enabled

Message ID 20230505051953.331080-1-zhanggenjian@kylinos.cn (mailing list archive)
State New
Headers show
Series [v3] fix ___SYNC () build error when PROFILE_ALL_BRANCHES is enabled | expand

Commit Message

Genjian May 5, 2023, 5:19 a.m. UTC
From: Genjian Zhang <zhanggenjian@kylinos.cn>

compiler error (mips-linux-gnu-gcc (Debian 10.2.1-6) 10.2.1 20210110):

{standard input}: Assembler messages:
{standard input}:171: Error: found '(', expected: ')'
{standard input}:171: Error: found '(', expected: ')'
{standard input}:171: Error: non-constant expression in ".if" statement
{standard input}:171: Error: junk at end of line, first unrecognized
character is `('

Expands ___SYNC() macros. However, 'if' statement will be wrong
assembly. This Compilers report a lot of errors like the above.
The problem is caused by the #define of if() in
include/linux/compiler.h when CONFIG_PROFILE_ALL_BRANCHES
is set. Move '.if' into quoted strings to fix it.

Reported-by: k2ci <kernel-bot@kylinos.cn>
Signed-off-by: Genjian Zhang <zhanggenjian@kylinos.cn>
---
 arch/mips/include/asm/sync.h | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/arch/mips/include/asm/sync.h b/arch/mips/include/asm/sync.h
index aabd097933fe..fab3ae758ea6 100644
--- a/arch/mips/include/asm/sync.h
+++ b/arch/mips/include/asm/sync.h
@@ -173,9 +173,8 @@ 
  * when we detect at runtime that we're running on a CPU that doesn't need
  * them.
  */
-#ifdef CONFIG_CPU_HAS_SYNC
 # define ____SYNC(_type, _reason, _else)			\
-	.if	(( _type ) != -1) && ( _reason );		\
+	((_type) != -1) && (_reason);				\
 	.set	push;						\
 	.set	MIPS_ISA_LEVEL_RAW;				\
 	.rept	__SYNC_rpt(_type);				\
@@ -185,21 +184,28 @@ 
 	.else;							\
 	_else;							\
 	.endif
-#else
-# define ____SYNC(_type, _reason, _else)
-#endif
 
 /*
  * Preprocessor magic to expand macros used as arguments before we insert them
  * into assembly code.
+ * In addition,'if' cannot be enabled.
  */
+#ifdef CONFIG_CPU_HAS_SYNC
 #ifdef __ASSEMBLY__
 # define ___SYNC(type, reason, else)				\
-	____SYNC(type, reason, else)
+	.if	____SYNC(type, reason, else)
+#else
+# define ___SYNC(type, reason, else)				\
+	".if"	__stringify(____SYNC(type, reason, else))
+#endif
+#else /* CONFIG_CPU_HAS_SYNC */
+#ifdef __ASSEMBLY__
+# define ___SYNC(type, reason, else)
 #else
 # define ___SYNC(type, reason, else)				\
-	__stringify(____SYNC(type, reason, else))
+	__stringify()
 #endif
+#endif /* CONFIG_CPU_HAS_SYNC */
 
 #define __SYNC(type, reason)					\
 	___SYNC(__SYNC_##type, __SYNC_##reason, )