Re: [OE-core] [PATCH 3/3] glibc: fix build with -O

2018-09-19 Thread Martin Jansa
I've submitted them now:

https://www.sourceware.org/ml/libc-alpha/2018-09/msg00299.html
https://www.sourceware.org/ml/libc-alpha/2018-09/msg00300.html

I didn't update the Upstream-Status, because it would cause whole world to
rebuild again.

On Wed, Sep 19, 2018 at 6:13 AM Khem Raj  wrote:

> please submit upstream as well
> On Sun, Sep 16, 2018 at 10:49 PM Martin Jansa 
> wrote:
> >
> > * tested for qemuarm, qemux86 with -O, -O0, -Os, with gcc
> > * to build with -O0 I had to remove restriction from systemtap first
> >
> > Signed-off-by: Martin Jansa 
> > ---
> >  meta/recipes-core/glibc/glibc.inc | 12 ---
> >  ...4-prevent-maybe-uninitialized-errors.patch | 95 +++
> >  ...2-soft-fp-ignore-maybe-uninitialized.patch | 72 ++
> >  meta/recipes-core/glibc/glibc_2.28.bb |  2 +
> >  4 files changed, 169 insertions(+), 12 deletions(-)
> >  create mode 100644
> meta/recipes-core/glibc/glibc/0031-sysdeps-ieee754-prevent-maybe-uninitialized-errors.patch
> >  create mode 100644
> meta/recipes-core/glibc/glibc/0032-soft-fp-ignore-maybe-uninitialized.patch
> >
> > diff --git a/meta/recipes-core/glibc/glibc.inc
> b/meta/recipes-core/glibc/glibc.inc
> > index 91491a35f0..e673707369 100644
> > --- a/meta/recipes-core/glibc/glibc.inc
> > +++ b/meta/recipes-core/glibc/glibc.inc
> > @@ -6,18 +6,6 @@ STAGINGCC = "gcc-cross-initial-${TARGET_ARCH}"
> >  STAGINGCC_class-nativesdk = "gcc-crosssdk-initial-${SDK_SYS}"
> >  PATH_prepend = "${STAGING_BINDIR_TOOLCHAIN}.${STAGINGCC}:"
> >
> > -python () {
> > -opt_effective = "-O"
> > -for opt in d.getVar('SELECTED_OPTIMIZATION').split():
> > -if opt in ("-O0", "-O", "-O1", "-O2", "-O3", "-Os"):
> > -opt_effective = opt
> > -if opt_effective == "-O0":
> > -bb.fatal("%s can't be built with %s, try -O1 instead" %
> (d.getVar('PN'), opt_effective))
> > -if opt_effective in ("-O", "-O1", "-Os"):
> > -bb.note("%s doesn't build cleanly with %s, adding -Wno-error to
> SELECTED_OPTIMIZATION" % (d.getVar('PN'), opt_effective))
> > -d.appendVar("SELECTED_OPTIMIZATION", " -Wno-error")
> > -}
> > -
> >  # siteconfig.bbclass runs configure which needs a working compiler
> >  # For the compiler to work we need a working libc yet libc isn't
> >  # in the sysroots directory at this point. This means the libc.so
> > diff --git
> a/meta/recipes-core/glibc/glibc/0031-sysdeps-ieee754-prevent-maybe-uninitialized-errors.patch
> b/meta/recipes-core/glibc/glibc/0031-sysdeps-ieee754-prevent-maybe-uninitialized-errors.patch
> > new file mode 100644
> > index 00..d9d36b8244
> > --- /dev/null
> > +++
> b/meta/recipes-core/glibc/glibc/0031-sysdeps-ieee754-prevent-maybe-uninitialized-errors.patch
> > @@ -0,0 +1,95 @@
> > +From c6cc5a6ef46837e341fe271b5ffa6def23810082 Mon Sep 17 00:00:00 2001
> > +From: Martin Jansa 
> > +Date: Fri, 14 Sep 2018 23:23:03 +
> > +Subject: [PATCH] sysdeps/ieee754: prevent maybe-uninitialized errors
> > +
> > +* with -O included in BUILD_OPTIMIZATION when DEBUG_BUILD
> > +  is used, nativesdk-glibc fails with:
> > +../sysdeps/ieee754/ldbl-96/e_jnl.c: In function '__ieee754_jnl':
> > +../sysdeps/ieee754/ldbl-96/e_jnl.c:146:20: error: 'temp' may be used
> uninitialized in this function [-Werror=maybe-uninitialized]
> > +  b = invsqrtpi * temp / sqrtl (x);
> > +  ~~^~
> > +../sysdeps/ieee754/ldbl-96/e_jnl.c: In function '__ieee754_ynl':
> > +../sysdeps/ieee754/ldbl-96/e_jnl.c:375:16: error: 'temp' may be used
> uninitialized in this function [-Werror=maybe-uninitialized]
> > +  b = invsqrtpi * temp / sqrtl (x);
> > +  ~~^~
> > +
> > +* work around the issue instead of removing -O like we do with
> > +  SELECTED_OPTIMIZATION
> > +
> > +Upstream-Status: Pending
> > +
> > +Signed-off-by: Martin Jansa 
> > +---
> > + sysdeps/ieee754/dbl-64/e_jn.c| 2 ++
> > + sysdeps/ieee754/ldbl-128/e_jnl.c | 4 
> > + sysdeps/ieee754/ldbl-96/e_jnl.c  | 4 
> > + 3 files changed, 10 insertions(+)
> > +
> > +diff --git a/sysdeps/ieee754/dbl-64/e_jn.c
> b/sysdeps/ieee754/dbl-64/e_jn.c
> > +index 9181b22bb8..74a6b5f149 100644
> > +--- a/sysdeps/ieee754/dbl-64/e_jn.c
> >  b/sysdeps/ieee754/dbl-64/e_jn.c
> > +@@ -108,6 +108,7 @@ __ieee754_jn (int n, double x)
> > + case 1: temp = -c + s; break;
> > + case 2: temp = -c - s; break;
> > + case 3: temp = c - s; break;
> > ++default: temp = 0; // just to prevent error: 'temp' may be
> used uninitialized in this function [-Werror=maybe-uninitialized]
> > + }
> > +   b = invsqrtpi * temp / sqrt (x);
> > + }
> > +@@ -315,6 +316,7 @@ __ieee754_yn (int n, double x)
> > + case 1: temp = -s - c; break;
> > + case 2: temp = -s + c; break;
> > + case 3: temp = s + c; break;
> > ++default: temp = 0; // just to prevent error: 'temp' may be
> used uninitialized in this function 

Re: [OE-core] [PATCH 3/3] glibc: fix build with -O

2018-09-18 Thread Khem Raj
please submit upstream as well
On Sun, Sep 16, 2018 at 10:49 PM Martin Jansa  wrote:
>
> * tested for qemuarm, qemux86 with -O, -O0, -Os, with gcc
> * to build with -O0 I had to remove restriction from systemtap first
>
> Signed-off-by: Martin Jansa 
> ---
>  meta/recipes-core/glibc/glibc.inc | 12 ---
>  ...4-prevent-maybe-uninitialized-errors.patch | 95 +++
>  ...2-soft-fp-ignore-maybe-uninitialized.patch | 72 ++
>  meta/recipes-core/glibc/glibc_2.28.bb |  2 +
>  4 files changed, 169 insertions(+), 12 deletions(-)
>  create mode 100644 
> meta/recipes-core/glibc/glibc/0031-sysdeps-ieee754-prevent-maybe-uninitialized-errors.patch
>  create mode 100644 
> meta/recipes-core/glibc/glibc/0032-soft-fp-ignore-maybe-uninitialized.patch
>
> diff --git a/meta/recipes-core/glibc/glibc.inc 
> b/meta/recipes-core/glibc/glibc.inc
> index 91491a35f0..e673707369 100644
> --- a/meta/recipes-core/glibc/glibc.inc
> +++ b/meta/recipes-core/glibc/glibc.inc
> @@ -6,18 +6,6 @@ STAGINGCC = "gcc-cross-initial-${TARGET_ARCH}"
>  STAGINGCC_class-nativesdk = "gcc-crosssdk-initial-${SDK_SYS}"
>  PATH_prepend = "${STAGING_BINDIR_TOOLCHAIN}.${STAGINGCC}:"
>
> -python () {
> -opt_effective = "-O"
> -for opt in d.getVar('SELECTED_OPTIMIZATION').split():
> -if opt in ("-O0", "-O", "-O1", "-O2", "-O3", "-Os"):
> -opt_effective = opt
> -if opt_effective == "-O0":
> -bb.fatal("%s can't be built with %s, try -O1 instead" % 
> (d.getVar('PN'), opt_effective))
> -if opt_effective in ("-O", "-O1", "-Os"):
> -bb.note("%s doesn't build cleanly with %s, adding -Wno-error to 
> SELECTED_OPTIMIZATION" % (d.getVar('PN'), opt_effective))
> -d.appendVar("SELECTED_OPTIMIZATION", " -Wno-error")
> -}
> -
>  # siteconfig.bbclass runs configure which needs a working compiler
>  # For the compiler to work we need a working libc yet libc isn't
>  # in the sysroots directory at this point. This means the libc.so
> diff --git 
> a/meta/recipes-core/glibc/glibc/0031-sysdeps-ieee754-prevent-maybe-uninitialized-errors.patch
>  
> b/meta/recipes-core/glibc/glibc/0031-sysdeps-ieee754-prevent-maybe-uninitialized-errors.patch
> new file mode 100644
> index 00..d9d36b8244
> --- /dev/null
> +++ 
> b/meta/recipes-core/glibc/glibc/0031-sysdeps-ieee754-prevent-maybe-uninitialized-errors.patch
> @@ -0,0 +1,95 @@
> +From c6cc5a6ef46837e341fe271b5ffa6def23810082 Mon Sep 17 00:00:00 2001
> +From: Martin Jansa 
> +Date: Fri, 14 Sep 2018 23:23:03 +
> +Subject: [PATCH] sysdeps/ieee754: prevent maybe-uninitialized errors
> +
> +* with -O included in BUILD_OPTIMIZATION when DEBUG_BUILD
> +  is used, nativesdk-glibc fails with:
> +../sysdeps/ieee754/ldbl-96/e_jnl.c: In function '__ieee754_jnl':
> +../sysdeps/ieee754/ldbl-96/e_jnl.c:146:20: error: 'temp' may be used 
> uninitialized in this function [-Werror=maybe-uninitialized]
> +  b = invsqrtpi * temp / sqrtl (x);
> +  ~~^~
> +../sysdeps/ieee754/ldbl-96/e_jnl.c: In function '__ieee754_ynl':
> +../sysdeps/ieee754/ldbl-96/e_jnl.c:375:16: error: 'temp' may be used 
> uninitialized in this function [-Werror=maybe-uninitialized]
> +  b = invsqrtpi * temp / sqrtl (x);
> +  ~~^~
> +
> +* work around the issue instead of removing -O like we do with
> +  SELECTED_OPTIMIZATION
> +
> +Upstream-Status: Pending
> +
> +Signed-off-by: Martin Jansa 
> +---
> + sysdeps/ieee754/dbl-64/e_jn.c| 2 ++
> + sysdeps/ieee754/ldbl-128/e_jnl.c | 4 
> + sysdeps/ieee754/ldbl-96/e_jnl.c  | 4 
> + 3 files changed, 10 insertions(+)
> +
> +diff --git a/sysdeps/ieee754/dbl-64/e_jn.c b/sysdeps/ieee754/dbl-64/e_jn.c
> +index 9181b22bb8..74a6b5f149 100644
> +--- a/sysdeps/ieee754/dbl-64/e_jn.c
>  b/sysdeps/ieee754/dbl-64/e_jn.c
> +@@ -108,6 +108,7 @@ __ieee754_jn (int n, double x)
> + case 1: temp = -c + s; break;
> + case 2: temp = -c - s; break;
> + case 3: temp = c - s; break;
> ++default: temp = 0; // just to prevent error: 'temp' may be used 
> uninitialized in this function [-Werror=maybe-uninitialized]
> + }
> +   b = invsqrtpi * temp / sqrt (x);
> + }
> +@@ -315,6 +316,7 @@ __ieee754_yn (int n, double x)
> + case 1: temp = -s - c; break;
> + case 2: temp = -s + c; break;
> + case 3: temp = s + c; break;
> ++default: temp = 0; // just to prevent error: 'temp' may be used 
> uninitialized in this function [-Werror=maybe-uninitialized]
> + }
> +   b = invsqrtpi * temp / sqrt (x);
> +   }
> +diff --git a/sysdeps/ieee754/ldbl-128/e_jnl.c 
> b/sysdeps/ieee754/ldbl-128/e_jnl.c
> +index 7739eec291..b6a1275464 100644
> +--- a/sysdeps/ieee754/ldbl-128/e_jnl.c
>  b/sysdeps/ieee754/ldbl-128/e_jnl.c
> +@@ -149,6 +149,8 @@ __ieee754_jnl (int n, _Float128 x)
> + case 3:
> +   temp = c - s;
> +   break;
> ++default:
> ++   

[OE-core] [PATCH 3/3] glibc: fix build with -O

2018-09-16 Thread Martin Jansa
* tested for qemuarm, qemux86 with -O, -O0, -Os, with gcc
* to build with -O0 I had to remove restriction from systemtap first

Signed-off-by: Martin Jansa 
---
 meta/recipes-core/glibc/glibc.inc | 12 ---
 ...4-prevent-maybe-uninitialized-errors.patch | 95 +++
 ...2-soft-fp-ignore-maybe-uninitialized.patch | 72 ++
 meta/recipes-core/glibc/glibc_2.28.bb |  2 +
 4 files changed, 169 insertions(+), 12 deletions(-)
 create mode 100644 
meta/recipes-core/glibc/glibc/0031-sysdeps-ieee754-prevent-maybe-uninitialized-errors.patch
 create mode 100644 
meta/recipes-core/glibc/glibc/0032-soft-fp-ignore-maybe-uninitialized.patch

diff --git a/meta/recipes-core/glibc/glibc.inc 
b/meta/recipes-core/glibc/glibc.inc
index 91491a35f0..e673707369 100644
--- a/meta/recipes-core/glibc/glibc.inc
+++ b/meta/recipes-core/glibc/glibc.inc
@@ -6,18 +6,6 @@ STAGINGCC = "gcc-cross-initial-${TARGET_ARCH}"
 STAGINGCC_class-nativesdk = "gcc-crosssdk-initial-${SDK_SYS}"
 PATH_prepend = "${STAGING_BINDIR_TOOLCHAIN}.${STAGINGCC}:"
 
-python () {
-opt_effective = "-O"
-for opt in d.getVar('SELECTED_OPTIMIZATION').split():
-if opt in ("-O0", "-O", "-O1", "-O2", "-O3", "-Os"):
-opt_effective = opt
-if opt_effective == "-O0":
-bb.fatal("%s can't be built with %s, try -O1 instead" % 
(d.getVar('PN'), opt_effective))
-if opt_effective in ("-O", "-O1", "-Os"):
-bb.note("%s doesn't build cleanly with %s, adding -Wno-error to 
SELECTED_OPTIMIZATION" % (d.getVar('PN'), opt_effective))
-d.appendVar("SELECTED_OPTIMIZATION", " -Wno-error")
-}
-
 # siteconfig.bbclass runs configure which needs a working compiler
 # For the compiler to work we need a working libc yet libc isn't
 # in the sysroots directory at this point. This means the libc.so
diff --git 
a/meta/recipes-core/glibc/glibc/0031-sysdeps-ieee754-prevent-maybe-uninitialized-errors.patch
 
b/meta/recipes-core/glibc/glibc/0031-sysdeps-ieee754-prevent-maybe-uninitialized-errors.patch
new file mode 100644
index 00..d9d36b8244
--- /dev/null
+++ 
b/meta/recipes-core/glibc/glibc/0031-sysdeps-ieee754-prevent-maybe-uninitialized-errors.patch
@@ -0,0 +1,95 @@
+From c6cc5a6ef46837e341fe271b5ffa6def23810082 Mon Sep 17 00:00:00 2001
+From: Martin Jansa 
+Date: Fri, 14 Sep 2018 23:23:03 +
+Subject: [PATCH] sysdeps/ieee754: prevent maybe-uninitialized errors
+
+* with -O included in BUILD_OPTIMIZATION when DEBUG_BUILD
+  is used, nativesdk-glibc fails with:
+../sysdeps/ieee754/ldbl-96/e_jnl.c: In function '__ieee754_jnl':
+../sysdeps/ieee754/ldbl-96/e_jnl.c:146:20: error: 'temp' may be used 
uninitialized in this function [-Werror=maybe-uninitialized]
+  b = invsqrtpi * temp / sqrtl (x);
+  ~~^~
+../sysdeps/ieee754/ldbl-96/e_jnl.c: In function '__ieee754_ynl':
+../sysdeps/ieee754/ldbl-96/e_jnl.c:375:16: error: 'temp' may be used 
uninitialized in this function [-Werror=maybe-uninitialized]
+  b = invsqrtpi * temp / sqrtl (x);
+  ~~^~
+
+* work around the issue instead of removing -O like we do with
+  SELECTED_OPTIMIZATION
+
+Upstream-Status: Pending
+
+Signed-off-by: Martin Jansa 
+---
+ sysdeps/ieee754/dbl-64/e_jn.c| 2 ++
+ sysdeps/ieee754/ldbl-128/e_jnl.c | 4 
+ sysdeps/ieee754/ldbl-96/e_jnl.c  | 4 
+ 3 files changed, 10 insertions(+)
+
+diff --git a/sysdeps/ieee754/dbl-64/e_jn.c b/sysdeps/ieee754/dbl-64/e_jn.c
+index 9181b22bb8..74a6b5f149 100644
+--- a/sysdeps/ieee754/dbl-64/e_jn.c
 b/sysdeps/ieee754/dbl-64/e_jn.c
+@@ -108,6 +108,7 @@ __ieee754_jn (int n, double x)
+ case 1: temp = -c + s; break;
+ case 2: temp = -c - s; break;
+ case 3: temp = c - s; break;
++default: temp = 0; // just to prevent error: 'temp' may be used 
uninitialized in this function [-Werror=maybe-uninitialized]
+ }
+   b = invsqrtpi * temp / sqrt (x);
+ }
+@@ -315,6 +316,7 @@ __ieee754_yn (int n, double x)
+ case 1: temp = -s - c; break;
+ case 2: temp = -s + c; break;
+ case 3: temp = s + c; break;
++default: temp = 0; // just to prevent error: 'temp' may be used 
uninitialized in this function [-Werror=maybe-uninitialized]
+ }
+   b = invsqrtpi * temp / sqrt (x);
+   }
+diff --git a/sysdeps/ieee754/ldbl-128/e_jnl.c 
b/sysdeps/ieee754/ldbl-128/e_jnl.c
+index 7739eec291..b6a1275464 100644
+--- a/sysdeps/ieee754/ldbl-128/e_jnl.c
 b/sysdeps/ieee754/ldbl-128/e_jnl.c
+@@ -149,6 +149,8 @@ __ieee754_jnl (int n, _Float128 x)
+ case 3:
+   temp = c - s;
+   break;
++default:
++  temp = 0; // just to prevent error: 'temp' may be used 
uninitialized in this function [-Werror=maybe-uninitialized]
+ }
+   b = invsqrtpi * temp / sqrtl (x);
+ }
+@@ -385,6 +387,8 @@ __ieee754_ynl (int n, _Float128 x)
+ case 3:
+   temp = s + c;
+