Fix build error for tst-printf-bz18872 on arm/aarch64 and s390

Message ID CALoOobN6U4bEXMB3UdW7=6OuH0mJW+iA7+xE8+AiZtVGg3knAw@mail.gmail.com
State Superseded
Headers

Commit Message

Paul Pluzhnikov Oct. 7, 2015, 5:54 a.m. UTC
  Greetings,

Some targets do not support "#pragma GCC push_options", and disabling
optimization in stdio-common/tst-printf-bz18872.c is only known to be
necessary on x86_64 and ix86.

Attached patch should fix build problems reported here:
https://sourceware.org/ml/libc-alpha/2015-09/msg00484.html
https://sourceware.org/ml/libc-alpha/2015-10/msg00063.html


2015-10-06  Paul Pluzhnikov  <ppluzhnikov@google.com>

        * stdio-common/tst-printf-bz18872.sh: Make disabling
optimization conditional on x86_64 or i386.
  

Comments

Florian Weimer Oct. 7, 2015, 7:50 a.m. UTC | #1
On 10/07/2015 07:54 AM, Paul Pluzhnikov wrote:
> Greetings,
> 
> Some targets do not support "#pragma GCC push_options", and disabling
> optimization in stdio-common/tst-printf-bz18872.c is only known to be
> necessary on x86_64 and ix86.
> 
> Attached patch should fix build problems reported here:
> https://sourceware.org/ml/libc-alpha/2015-09/msg00484.html
> https://sourceware.org/ml/libc-alpha/2015-10/msg00063.html

At one point, we need to stop working around compiler bugs.

Another way would be to specify -O0, either as a function attribute
(which GCC 4.6 already supports), or in Makefile.  (The aarch64 etc.
failures are in target option restoring, which the “optimize“ shouldn't
have to do.)

> 2015-10-06  Paul Pluzhnikov  <ppluzhnikov@google.com>
> 
>         * stdio-common/tst-printf-bz18872.sh: Make disabling
> optimization conditional on x86_64 or i386.

This needs proper wrapping

> diff --git a/stdio-common/tst-printf-bz18872.sh b/stdio-common/tst-printf-bz18872.sh
> index 0127e73..1e5f80b 100644
> --- a/stdio-common/tst-printf-bz18872.sh
> +++ b/stdio-common/tst-printf-bz18872.sh
> @@ -27,11 +27,19 @@ cat <<'EOF'
>  #include <stdio.h>
>  #include <mcheck.h>
>  
> +#if defined(__x86_64__) || defined(__i386__)
>  /*
>    Compile do_test without optimization: GCC 4.9/5.0/6.0 takes a long time
>    to build this source. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67396  */
> +#  define DISABLE_OPTIMIZATION 1
> +#else
> +#  define D

Nothing in the patch or changelog says why this is conditional on
__x86_64__ and __i386__.

Florian
  
Paul Pluzhnikov Oct. 8, 2015, 3:11 a.m. UTC | #2
On Wed, Oct 7, 2015 at 12:50 AM, Florian Weimer <fweimer@redhat.com> wrote:

> At one point, we need to stop working around compiler bugs.

Putting -O0 into the Makefile is *still* working around the GCC bug.

> Another way would be to specify -O0, either as a function attribute

Thanks. I'll try that.

> (which GCC 4.6 already supports), or in Makefile.

As I explained here:
https://sourceware.org/ml/libc-alpha/2015-09/msg00029.html
glibc internal headers insist on having __OPTIMIZE__ on, even for
tests, so adding -O0 to the Makefile doesn't work.


>> 2015-10-06  Paul Pluzhnikov  <ppluzhnikov@google.com>
>>
>>         * stdio-common/tst-printf-bz18872.sh: Make disabling
>> optimization conditional on x86_64 or i386.
...
> Nothing in the patch or changelog says why this is conditional on
> __x86_64__ and __i386__.

I beg to differ: the ChangeLog clearly does :-)
  
Paul Pluzhnikov Oct. 8, 2015, 3:13 a.m. UTC | #3
On Wed, Oct 7, 2015 at 8:11 PM, Paul Pluzhnikov <ppluzhnikov@google.com> wrote:

>> Nothing in the patch or changelog says why this is conditional on
>> __x86_64__ and __i386__.

Oh, it's the "why" part. Ok, I'll add that.

Thanks,
  

Patch

diff --git a/stdio-common/tst-printf-bz18872.sh b/stdio-common/tst-printf-bz18872.sh
index 0127e73..1e5f80b 100644
--- a/stdio-common/tst-printf-bz18872.sh
+++ b/stdio-common/tst-printf-bz18872.sh
@@ -27,11 +27,19 @@  cat <<'EOF'
 #include <stdio.h>
 #include <mcheck.h>
 
+#if defined(__x86_64__) || defined(__i386__)
 /*
   Compile do_test without optimization: GCC 4.9/5.0/6.0 takes a long time
   to build this source. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67396  */
+#  define DISABLE_OPTIMIZATION 1
+#else
+#  define DISABLE_OPTIMIZATION 0
+#endif
+
+#if DISABLE_OPTIMIZATION
 #pragma GCC push_options
 #pragma GCC optimize ("-O0")
+#endif
 
 int do_test (void)
 {
@@ -62,7 +70,10 @@  cat <<'EOF'
 
   return 0;
 }
+
+#if DISABLE_OPTIMIZATION
 #pragma GCC pop_options
+#endif
 
 #define TEST_FUNCTION do_test ()
 #include "../test-skeleton.c"