diff mbox series

[15/39] Handle pragma GCC optimize for clang

Message ID 20241222000509.2205895-16-hjl.tools@gmail.com
State New
Headers show
Series [01/39] conform: Use -dD instead of -dN on compiler invocation | expand

Commit Message

H.J. Lu Dec. 22, 2024, 12:04 a.m. UTC
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>

---
 libio/tst-bz24051.c | 6 +++++-
 libio/tst-bz24153.c | 6 +++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

Comments

Sam James Dec. 22, 2024, 4:31 a.m. UTC | #1
"H.J. Lu" <hjl.tools@gmail.com> writes:

> From: Adhemerval Zanella <adhemerval.zanella@linaro.org>

Reviewed-by: Sam James <sam@gentoo.org>

>
> ---
>  libio/tst-bz24051.c | 6 +++++-
>  libio/tst-bz24153.c | 6 +++++-
>  2 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/libio/tst-bz24051.c b/libio/tst-bz24051.c
> index a9903f20a3..2d32aae74a 100644
> --- a/libio/tst-bz24051.c
> +++ b/libio/tst-bz24051.c
> @@ -19,7 +19,11 @@
>  
>  /* Prevent putchar -> _IO_putc inline expansion.  */
>  #define __NO_INLINE__
> -#pragma GCC optimize("O0")
> +#ifdef __clang__
> +# pragma clang optimize off
> +#else
> +# pragma GCC optimize("O0")
> +#endif

OK. Per
https://clang.llvm.org/docs/LanguageExtensions.html#extensions-for-selectively-disabling-optimization,
optnone is only for the attribute, so optimize off is correct.

>  
>  #include <stdio.h>
>  #include <string.h>
> diff --git a/libio/tst-bz24153.c b/libio/tst-bz24153.c
> index 023f07ca20..c379876fcc 100644
> --- a/libio/tst-bz24153.c
> +++ b/libio/tst-bz24153.c
> @@ -18,7 +18,11 @@
>  
>  /* Prevent getchar -> getc inline expansion.  */
>  #define __NO_INLINE__
> -#pragma GCC optimize ("O0")
> +#ifdef __clang__
> +# pragma clang optimize off
> +#else
> +# pragma GCC optimize("O0")
> +#endif
>  
>  #include <stdarg.h>
>  #include <stdio.h>
diff mbox series

Patch

diff --git a/libio/tst-bz24051.c b/libio/tst-bz24051.c
index a9903f20a3..2d32aae74a 100644
--- a/libio/tst-bz24051.c
+++ b/libio/tst-bz24051.c
@@ -19,7 +19,11 @@ 
 
 /* Prevent putchar -> _IO_putc inline expansion.  */
 #define __NO_INLINE__
-#pragma GCC optimize("O0")
+#ifdef __clang__
+# pragma clang optimize off
+#else
+# pragma GCC optimize("O0")
+#endif
 
 #include <stdio.h>
 #include <string.h>
diff --git a/libio/tst-bz24153.c b/libio/tst-bz24153.c
index 023f07ca20..c379876fcc 100644
--- a/libio/tst-bz24153.c
+++ b/libio/tst-bz24153.c
@@ -18,7 +18,11 @@ 
 
 /* Prevent getchar -> getc inline expansion.  */
 #define __NO_INLINE__
-#pragma GCC optimize ("O0")
+#ifdef __clang__
+# pragma clang optimize off
+#else
+# pragma GCC optimize("O0")
+#endif
 
 #include <stdarg.h>
 #include <stdio.h>