Patchwork [1/1] grub 1.99: fix build for gcc 4.7

login
register
mail settings
Submitter Robert Yang
Date April 13, 2012, 9:41 a.m.
Message ID <638c4f827223820ee30ff0820df4179d41acfb60.1334308316.git.liezhi.yang@windriver.com>
Download mbox | patch
Permalink /patch/25727/
State New
Headers show

Comments

Robert Yang - April 13, 2012, 9:41 a.m.
There was an error when build with gcc 4.7 (FC 17 64bit):
| fs/zfs/zfs.c: In function 'get_filesystem_dnode':
| fs/zfs/zfs.c:1449:7: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
......
cc1: all warnings being treated as errors

While compare the compile command between gcc 4.4.4 and gcc 4.7.0, they
are the same (both of them have -Wall and -Werror), it seems that gcc
4.7.0 has changed its algorithm for the strict aliasing check, but I
didn't find the related information from its release note.

Add "-fno-strict-aliasing" to gcc's option would fix the problem, this
would disable the optimization for strict-aliasing.

[YOCTO #2291]

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
---
 meta/recipes-bsp/grub/grub_1.99.bb |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
Khem Raj - April 13, 2012, 8:20 p.m.
On Fri, Apr 13, 2012 at 2:41 AM, Robert Yang <liezhi.yang@windriver.com> wrote:
> There was an error when build with gcc 4.7 (FC 17 64bit):
> | fs/zfs/zfs.c: In function 'get_filesystem_dnode':
> | fs/zfs/zfs.c:1449:7: error: dereferencing type-punned pointer will break strict-aliasing rules [-Werror=strict-aliasing]
> ......
> cc1: all warnings being treated as errors
>
> While compare the compile command between gcc 4.4.4 and gcc 4.7.0, they
> are the same (both of them have -Wall and -Werror), it seems that gcc
> 4.7.0 has changed its algorithm for the strict aliasing check, but I
> didn't find the related information from its release note.
>
> Add "-fno-strict-aliasing" to gcc's option would fix the problem, this
> would disable the optimization for strict-aliasing.

This seems a bit more than whats needed. You could try adding
-Wno-error=strict-aliasing to CFLAGS

on another note. I do not see this failing with gcc-4.7(target compiler) here
when I build grub for qemux86 so I am a bit puzzled

>
> [YOCTO #2291]
>
> Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
> ---
>  meta/recipes-bsp/grub/grub_1.99.bb |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/meta/recipes-bsp/grub/grub_1.99.bb b/meta/recipes-bsp/grub/grub_1.99.bb
> index ac66e83..f45b634 100644
> --- a/meta/recipes-bsp/grub/grub_1.99.bb
> +++ b/meta/recipes-bsp/grub/grub_1.99.bb
> @@ -12,7 +12,7 @@ LICENSE = "GPLv3"
>  LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
>
>  RDEPENDS_${PN} = "diffutils freetype"
> -PR = "r3"
> +PR = "r4"
>
>  SRC_URI = "ftp://ftp.gnu.org/gnu/grub/grub-${PV}.tar.gz \
>           file://grub-install.in.patch \
> @@ -29,6 +29,11 @@ inherit gettext
>  EXTRA_OECONF = "--with-platform=pc --disable-grub-mkfont --target=${TARGET_ARCH} --program-prefix="""
>
>  do_configure() {
> +    # Fix build error for gcc 4.7
> +    echo "CPPFLAGS_DEFAULT += -fno-strict-aliasing" >> conf/Makefile.common
> +    # Also modify Makefile.in, we can remove this when we can run autoreconf
> +    sed -i 's/^CPPFLAGS_DEFAULT = \(.*\)/CPPFLAGS_DEFAULT = -fno-strict-aliasing \1/' \
> +       Makefile.in grub-core/Makefile.in
>     oe_runconf
>  }
>
> --
> 1.7.1
>
>
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Nitin A Kamble - April 13, 2012, 11:43 p.m.
> -----Original Message-----

> From: openembedded-core-bounces@lists.openembedded.org

> [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of

> Khem Raj

> Sent: Friday, April 13, 2012 1:21 PM

> To: Patches and discussions about the oe-core layer

> Subject: Re: [OE-core] [PATCH 1/1] grub 1.99: fix build for gcc 4.7

> 

> On Fri, Apr 13, 2012 at 2:41 AM, Robert Yang

> <liezhi.yang@windriver.com> wrote:

> > There was an error when build with gcc 4.7 (FC 17 64bit):

> > | fs/zfs/zfs.c: In function 'get_filesystem_dnode':

> > | fs/zfs/zfs.c:1449:7: error: dereferencing type-punned pointer will

> > | break strict-aliasing rules [-Werror=strict-aliasing]

> > ......

> > cc1: all warnings being treated as errors

> >

> > While compare the compile command between gcc 4.4.4 and gcc 4.7.0,

> > they are the same (both of them have -Wall and -Werror), it seems

> that

> > gcc

> > 4.7.0 has changed its algorithm for the strict aliasing check, but I

> > didn't find the related information from its release note.

> >

> > Add "-fno-strict-aliasing" to gcc's option would fix the problem,

> this

> > would disable the optimization for strict-aliasing.

> 

> This seems a bit more than whats needed. You could try adding -Wno-

> error=strict-aliasing to CFLAGS

> 

> on another note. I do not see this failing with gcc-4.7(target

> compiler) here when I build grub for qemux86 so I am a bit puzzled

> 



Khem,
  There is another grub recipe issue, it is building target binaries with distro compiler. Probably because of that you did not see issue with 4.7 cross compiler. We have fix for that issue now. 

Nitin



> >

> > [YOCTO #2291]

> >

> > Signed-off-by: Robert Yang <liezhi.yang@windriver.com>

> > ---

> >  meta/recipes-bsp/grub/grub_1.99.bb |    7 ++++++-

> >  1 files changed, 6 insertions(+), 1 deletions(-)

> >

> > diff --git a/meta/recipes-bsp/grub/grub_1.99.bb

> > b/meta/recipes-bsp/grub/grub_1.99.bb

> > index ac66e83..f45b634 100644

> > --- a/meta/recipes-bsp/grub/grub_1.99.bb

> > +++ b/meta/recipes-bsp/grub/grub_1.99.bb

> > @@ -12,7 +12,7 @@ LICENSE = "GPLv3"

> >  LIC_FILES_CHKSUM =

> "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"

> >

> >  RDEPENDS_${PN} = "diffutils freetype"

> > -PR = "r3"

> > +PR = "r4"

> >

> >  SRC_URI = "ftp://ftp.gnu.org/gnu/grub/grub-${PV}.tar.gz \

> >           file://grub-install.in.patch \ @@ -29,6 +29,11 @@ inherit

> > gettext

> >  EXTRA_OECONF = "--with-platform=pc --disable-grub-mkfont --

> target=${TARGET_ARCH} --program-prefix="""

> >

> >  do_configure() {

> > +    # Fix build error for gcc 4.7

> > +    echo "CPPFLAGS_DEFAULT += -fno-strict-aliasing" >>

> > + conf/Makefile.common

> > +    # Also modify Makefile.in, we can remove this when we can run

> > + autoreconf

> > +    sed -i 's/^CPPFLAGS_DEFAULT = \(.*\)/CPPFLAGS_DEFAULT =

> > + -fno-strict-aliasing \1/' \

> > +       Makefile.in grub-core/Makefile.in

> >     oe_runconf

> >  }

> >

> > --

> > 1.7.1

> >

> >

> > _______________________________________________

> > Openembedded-core mailing list

> > Openembedded-core@lists.openembedded.org

> > http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

> 

> _______________________________________________

> Openembedded-core mailing list

> Openembedded-core@lists.openembedded.org

> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Nitin A Kamble - April 14, 2012, 12:41 a.m.
> -----Original Message-----

> From: openembedded-core-bounces@lists.openembedded.org

> [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of

> Kamble, Nitin A

> Sent: Friday, April 13, 2012 4:43 PM

> To: Patches and discussions about the oe-core layer

> Subject: Re: [OE-core] [PATCH 1/1] grub 1.99: fix build for gcc 4.7

> 

> 

> 

> > -----Original Message-----

> > From: openembedded-core-bounces@lists.openembedded.org

> > [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf

> Of

> > Khem Raj

> > Sent: Friday, April 13, 2012 1:21 PM

> > To: Patches and discussions about the oe-core layer

> > Subject: Re: [OE-core] [PATCH 1/1] grub 1.99: fix build for gcc 4.7

> >

> > On Fri, Apr 13, 2012 at 2:41 AM, Robert Yang

> > <liezhi.yang@windriver.com> wrote:

> > > There was an error when build with gcc 4.7 (FC 17 64bit):

> > > | fs/zfs/zfs.c: In function 'get_filesystem_dnode':

> > > | fs/zfs/zfs.c:1449:7: error: dereferencing type-punned pointer

> will

> > > | break strict-aliasing rules [-Werror=strict-aliasing]

> > > ......

> > > cc1: all warnings being treated as errors

> > >

> > > While compare the compile command between gcc 4.4.4 and gcc 4.7.0,

> > > they are the same (both of them have -Wall and -Werror), it seems

> > that

> > > gcc

> > > 4.7.0 has changed its algorithm for the strict aliasing check, but

> I

> > > didn't find the related information from its release note.

> > >

> > > Add "-fno-strict-aliasing" to gcc's option would fix the problem,

> > this

> > > would disable the optimization for strict-aliasing.

> >

> > This seems a bit more than whats needed. You could try adding -Wno-

> > error=strict-aliasing to CFLAGS

> >

> > on another note. I do not see this failing with gcc-4.7(target

> > compiler) here when I build grub for qemux86 so I am a bit puzzled

> >

> 

> 

> Khem,

>   There is another grub recipe issue, it is building target binaries

> with distro compiler. Probably because of that you did not see issue

> with 4.7 cross compiler. We have fix for that issue now.

> 

> Nitin

> 


Khem, Look at these:

https://bugzilla.yoctoproject.org/show_bug.cgi?id=2291
https://bugzilla.yoctoproject.org/show_bug.cgi?id=2293

And both have been fixed.

Nitin

> 

> 

> > >

> > > [YOCTO #2291]

> > >

> > > Signed-off-by: Robert Yang <liezhi.yang@windriver.com>

> > > ---

> > >  meta/recipes-bsp/grub/grub_1.99.bb |    7 ++++++-

> > >  1 files changed, 6 insertions(+), 1 deletions(-)

> > >

> > > diff --git a/meta/recipes-bsp/grub/grub_1.99.bb

> > > b/meta/recipes-bsp/grub/grub_1.99.bb

> > > index ac66e83..f45b634 100644

> > > --- a/meta/recipes-bsp/grub/grub_1.99.bb

> > > +++ b/meta/recipes-bsp/grub/grub_1.99.bb

> > > @@ -12,7 +12,7 @@ LICENSE = "GPLv3"

> > >  LIC_FILES_CHKSUM =

> > "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"

> > >

> > >  RDEPENDS_${PN} = "diffutils freetype"

> > > -PR = "r3"

> > > +PR = "r4"

> > >

> > >  SRC_URI = "ftp://ftp.gnu.org/gnu/grub/grub-${PV}.tar.gz \

> > >           file://grub-install.in.patch \ @@ -29,6 +29,11 @@ inherit

> > > gettext

> > >  EXTRA_OECONF = "--with-platform=pc --disable-grub-mkfont --

> > target=${TARGET_ARCH} --program-prefix="""

> > >

> > >  do_configure() {

> > > +    # Fix build error for gcc 4.7

> > > +    echo "CPPFLAGS_DEFAULT += -fno-strict-aliasing" >>

> > > + conf/Makefile.common

> > > +    # Also modify Makefile.in, we can remove this when we can run

> > > + autoreconf

> > > +    sed -i 's/^CPPFLAGS_DEFAULT = \(.*\)/CPPFLAGS_DEFAULT =

> > > + -fno-strict-aliasing \1/' \

> > > +       Makefile.in grub-core/Makefile.in

> > >     oe_runconf

> > >  }

> > >

> > > --

> > > 1.7.1

> > >

> > >

> > > _______________________________________________

> > > Openembedded-core mailing list

> > > Openembedded-core@lists.openembedded.org

> > > http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-

> cor

> > > e

> >

> > _______________________________________________

> > Openembedded-core mailing list

> > Openembedded-core@lists.openembedded.org

> > http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

> _______________________________________________

> Openembedded-core mailing list

> Openembedded-core@lists.openembedded.org

> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core
Khem Raj - April 14, 2012, 3:20 a.m.
On Fri, Apr 13, 2012 at 4:43 PM, Kamble, Nitin A
<nitin.a.kamble@intel.com> wrote:
>
>
>> -----Original Message-----
>> From: openembedded-core-bounces@lists.openembedded.org
>> [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of
>> Khem Raj
>> Sent: Friday, April 13, 2012 1:21 PM
>> To: Patches and discussions about the oe-core layer
>> Subject: Re: [OE-core] [PATCH 1/1] grub 1.99: fix build for gcc 4.7
>>
>> On Fri, Apr 13, 2012 at 2:41 AM, Robert Yang
>> <liezhi.yang@windriver.com> wrote:
>> > There was an error when build with gcc 4.7 (FC 17 64bit):
>> > | fs/zfs/zfs.c: In function 'get_filesystem_dnode':
>> > | fs/zfs/zfs.c:1449:7: error: dereferencing type-punned pointer will
>> > | break strict-aliasing rules [-Werror=strict-aliasing]
>> > ......
>> > cc1: all warnings being treated as errors
>> >
>> > While compare the compile command between gcc 4.4.4 and gcc 4.7.0,
>> > they are the same (both of them have -Wall and -Werror), it seems
>> that
>> > gcc
>> > 4.7.0 has changed its algorithm for the strict aliasing check, but I
>> > didn't find the related information from its release note.
>> >
>> > Add "-fno-strict-aliasing" to gcc's option would fix the problem,
>> this
>> > would disable the optimization for strict-aliasing.
>>
>> This seems a bit more than whats needed. You could try adding -Wno-
>> error=strict-aliasing to CFLAGS
>>
>> on another note. I do not see this failing with gcc-4.7(target
>> compiler) here when I build grub for qemux86 so I am a bit puzzled
>>
>
>
> Khem,
>  There is another grub recipe issue, it is building target binaries with distro compiler. Probably because of that you did not see issue with 4.7 cross compiler. We have fix for that issue now.

hmmm interesting that clarifies. So I guess once you fix it to do
_proper_ cross compile build then I guess the problem gets fixed when
we use gcc 4.6 but as soon as we move to gcc-4.7 this will reappear so
in any case this issue needs to fixed in a good manner I think
in anycase.
Nitin A Kamble - April 14, 2012, 4:45 a.m.
> -----Original Message-----

> From: openembedded-core-bounces@lists.openembedded.org

> [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf Of

> Khem Raj

> Sent: Friday, April 13, 2012 8:20 PM

> To: Patches and discussions about the oe-core layer

> Subject: Re: [OE-core] [PATCH 1/1] grub 1.99: fix build for gcc 4.7

> 

> On Fri, Apr 13, 2012 at 4:43 PM, Kamble, Nitin A

> <nitin.a.kamble@intel.com> wrote:

> >

> >

> >> -----Original Message-----

> >> From: openembedded-core-bounces@lists.openembedded.org

> >> [mailto:openembedded-core-bounces@lists.openembedded.org] On Behalf

> >> Of Khem Raj

> >> Sent: Friday, April 13, 2012 1:21 PM

> >> To: Patches and discussions about the oe-core layer

> >> Subject: Re: [OE-core] [PATCH 1/1] grub 1.99: fix build for gcc 4.7

> >>

> >> On Fri, Apr 13, 2012 at 2:41 AM, Robert Yang

> >> <liezhi.yang@windriver.com> wrote:

> >> > There was an error when build with gcc 4.7 (FC 17 64bit):

> >> > | fs/zfs/zfs.c: In function 'get_filesystem_dnode':

> >> > | fs/zfs/zfs.c:1449:7: error: dereferencing type-punned pointer

> >> > | will break strict-aliasing rules [-Werror=strict-aliasing]

> >> > ......

> >> > cc1: all warnings being treated as errors

> >> >

> >> > While compare the compile command between gcc 4.4.4 and gcc 4.7.0,

> >> > they are the same (both of them have -Wall and -Werror), it seems

> >> that

> >> > gcc

> >> > 4.7.0 has changed its algorithm for the strict aliasing check, but

> >> > I didn't find the related information from its release note.

> >> >

> >> > Add "-fno-strict-aliasing" to gcc's option would fix the problem,

> >> this

> >> > would disable the optimization for strict-aliasing.

> >>

> >> This seems a bit more than whats needed. You could try adding -Wno-

> >> error=strict-aliasing to CFLAGS

> >>

> >> on another note. I do not see this failing with gcc-4.7(target

> >> compiler) here when I build grub for qemux86 so I am a bit puzzled

> >>

> >

> >

> > Khem,

> >  There is another grub recipe issue, it is building target binaries

> with distro compiler. Probably because of that you did not see issue

> with 4.7 cross compiler. We have fix for that issue now.

> 

> hmmm interesting that clarifies. So I guess once you fix it to do

> _proper_ cross compile build then I guess the problem gets fixed when

> we use gcc 4.6 but as soon as we move to gcc-4.7 this will reappear so

> in any case this issue needs to fixed in a good manner I think in

> anycase.

> 



The 2293 bug is about grub-efi-native which correctly uses the distro compiler. And it hits gcc 4.7 issue on fedora 17 alpha, and that is also fixed. I will send out commits in few mins.

Nitin


> _______________________________________________

> Openembedded-core mailing list

> Openembedded-core@lists.openembedded.org

> http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-core

Patch

diff --git a/meta/recipes-bsp/grub/grub_1.99.bb b/meta/recipes-bsp/grub/grub_1.99.bb
index ac66e83..f45b634 100644
--- a/meta/recipes-bsp/grub/grub_1.99.bb
+++ b/meta/recipes-bsp/grub/grub_1.99.bb
@@ -12,7 +12,7 @@  LICENSE = "GPLv3"
 LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
 
 RDEPENDS_${PN} = "diffutils freetype"
-PR = "r3"
+PR = "r4"
 
 SRC_URI = "ftp://ftp.gnu.org/gnu/grub/grub-${PV}.tar.gz \
           file://grub-install.in.patch \
@@ -29,6 +29,11 @@  inherit gettext
 EXTRA_OECONF = "--with-platform=pc --disable-grub-mkfont --target=${TARGET_ARCH} --program-prefix="""
 
 do_configure() {
+    # Fix build error for gcc 4.7
+    echo "CPPFLAGS_DEFAULT += -fno-strict-aliasing" >> conf/Makefile.common
+    # Also modify Makefile.in, we can remove this when we can run autoreconf
+    sed -i 's/^CPPFLAGS_DEFAULT = \(.*\)/CPPFLAGS_DEFAULT = -fno-strict-aliasing \1/' \
+	Makefile.in grub-core/Makefile.in
     oe_runconf
 }