All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] squashfs: fix build with glibc-2.26
@ 2017-08-21 20:57 Martin Jansa
  2017-08-21 20:57 ` [PATCH 2/2] grub2: fix build with gcc-7 Martin Jansa
  0 siblings, 1 reply; 10+ messages in thread
From: Martin Jansa @ 2017-08-21 20:57 UTC (permalink / raw)
  To: openembedded-core

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 .../squashfs-tools-4.3-sysmacros.patch             | 32 ++++++++++++++++++++++
 .../squashfs-tools/squashfs-tools_git.bb           |  1 +
 2 files changed, 33 insertions(+)
 create mode 100644 meta/recipes-devtools/squashfs-tools/squashfs-tools/squashfs-tools-4.3-sysmacros.patch

diff --git a/meta/recipes-devtools/squashfs-tools/squashfs-tools/squashfs-tools-4.3-sysmacros.patch b/meta/recipes-devtools/squashfs-tools/squashfs-tools/squashfs-tools-4.3-sysmacros.patch
new file mode 100644
index 0000000000..39521a7d8b
--- /dev/null
+++ b/meta/recipes-devtools/squashfs-tools/squashfs-tools/squashfs-tools-4.3-sysmacros.patch
@@ -0,0 +1,32 @@
+From https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-fs/squashfs-tools/files/squashfs-tools-4.3-sysmacros.patch
+
+Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
+
+Upstream-Status: Pending
+
+
+sys/types.h might not always include sys/sysmacros.h for major/minor/makedev
+
+--- a/squashfs-tools/mksquashfs.c
++++ b/squashfs-tools/mksquashfs.c
+@@ -59,6 +59,7 @@
+ #else
+ #include <endian.h>
+ #include <sys/sysinfo.h>
++#include <sys/sysmacros.h>
+ #endif
+ 
+ #include "squashfs_fs.h"
+--- a/squashfs-tools/unsquashfs.c
++++ b/squashfs-tools/unsquashfs.c
+@@ -38,6 +38,10 @@
+ #include <limits.h>
+ #include <ctype.h>
+ 
++#ifdef linux
++#include <sys/sysmacros.h>
++#endif
++
+ struct cache *fragment_cache, *data_cache;
+ struct queue *to_reader, *to_inflate, *to_writer, *from_writer;
+ pthread_t *thread, *inflator_thread;
diff --git a/meta/recipes-devtools/squashfs-tools/squashfs-tools_git.bb b/meta/recipes-devtools/squashfs-tools/squashfs-tools_git.bb
index 4f68d01131..0f991706c1 100644
--- a/meta/recipes-devtools/squashfs-tools/squashfs-tools_git.bb
+++ b/meta/recipes-devtools/squashfs-tools/squashfs-tools_git.bb
@@ -13,6 +13,7 @@ SRCREV = "9c1db6d13a51a2e009f0027ef336ce03624eac0d"
 SRC_URI = "git://github.com/plougher/squashfs-tools.git;protocol=https \
            http://downloads.sourceforge.net/sevenzip/lzma465.tar.bz2;name=lzma \
            file://0001-mksquashfs.c-get-inline-functions-work-with-C99.patch;striplevel=2 \
+           file://squashfs-tools-4.3-sysmacros.patch;striplevel=2 \
            file://fix-compat.patch \
 "
 UPSTREAM_VERSION_UNKNOWN = "1"
-- 
2.14.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH 2/2] grub2: fix build with gcc-7
  2017-08-21 20:57 [PATCH 1/2] squashfs: fix build with glibc-2.26 Martin Jansa
@ 2017-08-21 20:57 ` Martin Jansa
  2017-08-21 23:52   ` Khem Raj
  2017-08-22 10:22   ` [PATCH 2/2] grub2: fix build with gcc-7 Richard Purdie
  0 siblings, 2 replies; 10+ messages in thread
From: Martin Jansa @ 2017-08-21 20:57 UTC (permalink / raw)
  To: openembedded-core

* build with gcc-7 fails with:
  | ./config-util.h:1504:48: error: this use of "defined" may not be   portable [-Werror=expansion-to-defined]
  |              || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
  |                                                 ^~~~~~~~~~~~~~~
  and we're not building on Apple or BSD, so we should be able
  to just ignoreit until it's resolved properly in some newer gnulib
  and imported from gnulib to grub-2

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---
 meta/recipes-bsp/grub/grub-efi_2.02.bb | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/meta/recipes-bsp/grub/grub-efi_2.02.bb b/meta/recipes-bsp/grub/grub-efi_2.02.bb
index b949bebced..45f4c1ed34 100644
--- a/meta/recipes-bsp/grub/grub-efi_2.02.bb
+++ b/meta/recipes-bsp/grub/grub-efi_2.02.bb
@@ -36,6 +36,12 @@ EXTRA_OECONF += "--enable-efiemu=no"
 # and many other places in the grub code when compiled with some native gcc compilers (specifically, gentoo)
 CFLAGS_append_class-native = " -Wno-error=trampolines"
 
+# this comes from gnulib and it's used only for Apple and BSD, so we can ignore it
+# ./config-util.h:1504:48: error: this use of "defined" may not be portable [-Werror=expansion-to-defined]
+#             || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
+#                                                ^~~~~~~~~~~~~~~
+CFLAGS_append_class-native = " -Wno-error=expansion-to-defined"
+
 do_install_class-native() {
 	install -d ${D}${bindir}
 	install -m 755 grub-mkimage ${D}${bindir}
-- 
2.14.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] grub2: fix build with gcc-7
  2017-08-21 20:57 ` [PATCH 2/2] grub2: fix build with gcc-7 Martin Jansa
@ 2017-08-21 23:52   ` Khem Raj
  2017-08-22 17:21     ` Martin Jansa
  2017-08-22 10:22   ` [PATCH 2/2] grub2: fix build with gcc-7 Richard Purdie
  1 sibling, 1 reply; 10+ messages in thread
From: Khem Raj @ 2017-08-21 23:52 UTC (permalink / raw)
  To: Martin Jansa; +Cc: Patches and discussions about the oe-core layer

On Mon, Aug 21, 2017 at 1:57 PM, Martin Jansa <martin.jansa@gmail.com> wrote:
> * build with gcc-7 fails with:
>   | ./config-util.h:1504:48: error: this use of "defined" may not be   portable [-Werror=expansion-to-defined]
>   |              || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
>   |
                                            ^~~~~~~~~~~~~~~
>   and we're not building on Apple or BSD, so we should be able
>   to just ignoreit until it's resolved properly in some newer gnulib
>   and imported from gnulib to grub-2
>
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> ---
>  meta/recipes-bsp/grub/grub-efi_2.02.bb | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/meta/recipes-bsp/grub/grub-efi_2.02.bb b/meta/recipes-bsp/grub/grub-efi_2.02.bb
> index b949bebced..45f4c1ed34 100644
> --- a/meta/recipes-bsp/grub/grub-efi_2.02.bb
> +++ b/meta/recipes-bsp/grub/grub-efi_2.02.bb
> @@ -36,6 +36,12 @@ EXTRA_OECONF += "--enable-efiemu=no"
>  # and many other places in the grub code when compiled with some native gcc compilers (specifically, gentoo)
>  CFLAGS_append_class-native = " -Wno-error=trampolines"
>
> +# this comes from gnulib and it's used only for Apple and BSD, so we can ignore it
> +# ./config-util.h:1504:48: error: this use of "defined" may not be portable [-Werror=expansion-to-defined]
> +#             || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
> +#                                                ^~~~~~~~~~~~~~~
> +CFLAGS_append_class-native = " -Wno-error=expansion-to-defined"
> +

This workaround seems reasonable but I wonder why it fails on build host
for you. how is your build hosts toolchain configured to generate this
warning. Since you mentioned gcc7 then why doesnt it fail for OE
targets
in same way.

An upstreamable fix would be to break this define into another #if ..
#else macros and define the new macro to 1 or 0 depending upon the
conditions
being tested.

>  do_install_class-native() {
>         install -d ${D}${bindir}
>         install -m 755 grub-mkimage ${D}${bindir}
> --
> 2.14.1
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] grub2: fix build with gcc-7
  2017-08-21 20:57 ` [PATCH 2/2] grub2: fix build with gcc-7 Martin Jansa
  2017-08-21 23:52   ` Khem Raj
@ 2017-08-22 10:22   ` Richard Purdie
  2017-08-22 10:26     ` Martin Jansa
  2017-08-22 16:32     ` Khem Raj
  1 sibling, 2 replies; 10+ messages in thread
From: Richard Purdie @ 2017-08-22 10:22 UTC (permalink / raw)
  To: Martin Jansa, openembedded-core

On Mon, 2017-08-21 at 22:57 +0200, Martin Jansa wrote:
> * build with gcc-7 fails with:
>   | ./config-util.h:1504:48: error: this use of "defined" may not
> be   portable [-Werror=expansion-to-defined]
>   |              || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
>   |                                                 ^~~~~~~~~~~~~~~
>   and we're not building on Apple or BSD, so we should be able
>   to just ignoreit until it's resolved properly in some newer gnulib
>   and imported from gnulib to grub-2
> 
> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> ---
>  meta/recipes-bsp/grub/grub-efi_2.02.bb | 6 ++++++
>  1 file changed, 6 insertions(+)

Sadly this appears to break grub-efi everywhere on the autobuilder,
e.g.:

https://autobuilder.yocto.io/builders/nightly-no-x11/builds/428/steps/BuildImages/logs/stdio

I took a risk and tried to get this into M3 buts its not paid off and
we'll need another rebuild :(.

Cheers,

Richard




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] grub2: fix build with gcc-7
  2017-08-22 10:22   ` [PATCH 2/2] grub2: fix build with gcc-7 Richard Purdie
@ 2017-08-22 10:26     ` Martin Jansa
  2017-08-22 10:28       ` Richard Purdie
  2017-08-22 16:32     ` Khem Raj
  1 sibling, 1 reply; 10+ messages in thread
From: Martin Jansa @ 2017-08-22 10:26 UTC (permalink / raw)
  To: Richard Purdie; +Cc: Patches and discussions about the oe-core layer

[-- Attachment #1: Type: text/plain, Size: 1306 bytes --]

I'm sorry for the issues caused by this, can you share config.log from that
build? Maybe the native compiler on that build host doesn't support this
option?

On Tue, Aug 22, 2017 at 11:22 AM, Richard Purdie <
richard.purdie@linuxfoundation.org> wrote:

> On Mon, 2017-08-21 at 22:57 +0200, Martin Jansa wrote:
> > * build with gcc-7 fails with:
> >   | ./config-util.h:1504:48: error: this use of "defined" may not
> > be   portable [-Werror=expansion-to-defined]
> >   |              || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
> >   |                                                 ^~~~~~~~~~~~~~~
> >   and we're not building on Apple or BSD, so we should be able
> >   to just ignoreit until it's resolved properly in some newer gnulib
> >   and imported from gnulib to grub-2
> >
> > Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> > ---
> >  meta/recipes-bsp/grub/grub-efi_2.02.bb | 6 ++++++
> >  1 file changed, 6 insertions(+)
>
> Sadly this appears to break grub-efi everywhere on the autobuilder,
> e.g.:
>
> https://autobuilder.yocto.io/builders/nightly-no-x11/
> builds/428/steps/BuildImages/logs/stdio
>
> I took a risk and tried to get this into M3 buts its not paid off and
> we'll need another rebuild :(.
>
> Cheers,
>
> Richard
>
>
>

[-- Attachment #2: Type: text/html, Size: 2131 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] grub2: fix build with gcc-7
  2017-08-22 10:26     ` Martin Jansa
@ 2017-08-22 10:28       ` Richard Purdie
  0 siblings, 0 replies; 10+ messages in thread
From: Richard Purdie @ 2017-08-22 10:28 UTC (permalink / raw)
  To: Martin Jansa; +Cc: Patches and discussions about the oe-core layer

On Tue, 2017-08-22 at 11:26 +0100, Martin Jansa wrote:
> I'm sorry for the issues caused by this, can you share config.log
> from that build? Maybe the native compiler on that build host doesn't
> support this option?

The one I linked to was a debian9 system, config.log says:

gcc: error: unrecognized command line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
configure:5052: $? = 1
configure:5072: checking whether the C compiler works
configure:5094: gcc   -Wno-error=trampolines -Wno-error=expansion-to-defined   conftest.c  >&5
cc1: error: -Werror=expansion-to-defined: no option -Wexpansion-to-defined
configure:5098: $? = 1
configure:5136: result: no
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GRUB"
| #define PACKAGE_TARNAME "grub"
| #define PACKAGE_VERSION "2.02"
| #define PACKAGE_STRING "GRUB 2.02"
| #define PACKAGE_BUGREPORT "bug-grub@gnu.org"
| #define PACKAGE_URL ""
| #define PACKAGE "grub"
| #define VERSION "2.02"
| #define GRUB_BOOT_DIR_NAME "boot"
| #define GRUB_DIR_NAME "grub"
| /* end confdefs.h.  */
| 
| int
| main (void)
| {
| 
|   ;
|   return 0;
| }
configure:5141: error: in `/home/pokybuild/yocto-autobuilder/yocto-worker/nightly-no-x11/build/build/tmp/work/x86_64-linux/grub-efi-native/2.02-r0/build':
configure:5143: error: C compiler cannot create executables
See `config.log' for more details

So yes, it doesn't understand the option.

Cheers,

Richard



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] grub2: fix build with gcc-7
  2017-08-22 10:22   ` [PATCH 2/2] grub2: fix build with gcc-7 Richard Purdie
  2017-08-22 10:26     ` Martin Jansa
@ 2017-08-22 16:32     ` Khem Raj
  1 sibling, 0 replies; 10+ messages in thread
From: Khem Raj @ 2017-08-22 16:32 UTC (permalink / raw)
  To: Richard Purdie; +Cc: Patches and discussions about the oe-core layer

On Tue, Aug 22, 2017 at 3:22 AM, Richard Purdie
<richard.purdie@linuxfoundation.org> wrote:
> On Mon, 2017-08-21 at 22:57 +0200, Martin Jansa wrote:
>> * build with gcc-7 fails with:
>>   | ./config-util.h:1504:48: error: this use of "defined" may not
>> be   portable [-Werror=expansion-to-defined]
>>   |              || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
>>   |                                                 ^~~~~~~~~~~~~~~
>>   and we're not building on Apple or BSD, so we should be able
>>   to just ignoreit until it's resolved properly in some newer gnulib
>>   and imported from gnulib to grub-2
>>
>> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
>> ---
>>  meta/recipes-bsp/grub/grub-efi_2.02.bb | 6 ++++++
>>  1 file changed, 6 insertions(+)
>
> Sadly this appears to break grub-efi everywhere on the autobuilder,
> e.g.:
>
> https://autobuilder.yocto.io/builders/nightly-no-x11/builds/428/steps/BuildImages/logs/stdio
>
> I took a risk and tried to get this into M3 buts its not paid off and
> we'll need another rebuild :(.
>

It did not occur to me that this option is introduced in gcc7+ which means
it will not work on hosts using old gcc versions. Sorry

> Cheers,
>
> Richard
>
>
> --
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] grub2: fix build with gcc-7
  2017-08-21 23:52   ` Khem Raj
@ 2017-08-22 17:21     ` Martin Jansa
  2017-08-22 17:28       ` Khem Raj
  2017-08-22 22:10       ` [PATCHv2] grub2: fix build on gcc where _FORTIFY_SOURCE is defined Martin Jansa
  0 siblings, 2 replies; 10+ messages in thread
From: Martin Jansa @ 2017-08-22 17:21 UTC (permalink / raw)
  To: Khem Raj; +Cc: Patches and discussions about the oe-core layer

[-- Attachment #1: Type: text/plain, Size: 6946 bytes --]

Nothing special on my build host, just gcc 7.1 from gentoo. But the option
was introduced probably only in gcc-7, on 5.4.0 used in Ubuntu 16.04 it's
also missing:

OE qemux86@ ~/oe/world/shr-core $ gcc --help=warnings | grep
expansion-to-defined
OE qemux86@ ~/oe/world/shr-core $ gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

OE @ ~ $ gcc --help=warnings | grep expansion-to-defined
  -Wexpansion-to-defined      Warn if "defined" is used outside #if.
OE @ ~ $ gcc --version
gcc (Gentoo 7.1.0-r1 p1.1) 7.1.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

OE @ ~/build/oe-core/tmp-glibc/work/i586-oe-linux/grub-efi/2.02-r0 $
recipe-sysroot-native/usr/bin/i586-oe-linux/i586-oe-linux-gcc
--help=warnings | grep expansion-to-defined
  -Wexpansion-to-defined      Warn if "defined" is used outside #if.
OE @ ~/build/oe-core/tmp-glibc/work/i586-oe-linux/grub-efi/2.02-r0 $
recipe-sysroot-native/usr/bin/i586-oe-linux/i586-oe-linux-gcc --version
i586-oe-linux-gcc (GCC) 7.2.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Applying the flags based on `gcc --version` output also doesn't seem good
way forward and we don't have gcc-native recipes.

We can probably use gcc pragma to disable this warning (which IIRC doesn't
test if the disabled warning is supported or not), but that might be a bit
complicated as this file is generated in configure. I'll check it.

The target grub-efi build doesn't fail probably because target gcc doesn't
define _FORTIFY_SOURCE

I've tried to compare native and target build and it's reproducible e.g.
with this command:

gcc  -DHAVE_CONFIG_H -I. -I../grub-2.02  -Wall -W -DGRUB_UTIL=1
-D_FILE_OFFSET_BITS=64 -I./include -DGRUB_FILE=\"grub-core/lib/crypto.c\"
-I. -I../grub-2.02 -I. -I../grub-2.02 -I../grub-2.02/include -I./include
-I../grub-2.02/grub-core/lib/libgcrypt-grub/src/  -I./grub-core/gnulib
-I../grub-2.02/grub-core/gnulib -D_FILE_OFFSET_BITS=64 -fno-builtin-gettext
-Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment
-Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero
-Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit
-Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces
-Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type
-Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs
-Wunknown-pragmas -Wunused -Wunused-function -Wunused-label
-Wunused-parameter -Wunused-value  -Wunused-variable -Wwrite-strings
-Wnested-externs -Wstrict-prototypes -Wcast-align  -Wextra -Wattributes
-Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch
-Wmissing-field-initializers -Wnonnull -Woverflow -Wvla
-Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros
-Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs
-Wmissing-prototypes -Wmissing-declarations -Wformat=2 -Werror  -Wno-undef
-Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls
-Wno-unreachable-code -Wno-conversion -Wno-error=trampolines -c -o
grub-core/lib/libgrubkern_a-crypto.o `test -f 'grub-core/lib/crypto.c' ||
echo '../grub-2.02/'`grub-core/lib/crypto.c

After adding -dM -E and comparing the output between target and native I
can see that my native gcc defines _FORTIFY_SOURCE as:
#define _FORTIFY_SOURCE ((defined __OPTIMIZE__ && __OPTIMIZE__ > 0) ? 2 : 0)

while target build doesn't.

Just to confirm it's caused by this I've added the same line:
#define _FORTIFY_SOURCE ((defined __OPTIMIZE__ && __OPTIMIZE__ > 0) ? 2 : 0)
at the top of grub-2.02/grub-core/lib/crypto.c and the target build fails
the same.

And the  _FORTIFY_SOURCE in native gcc comes from gentoo gcc patches, this
one:
https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo/src/patchsets/gcc/7.1.0/gentoo/10_all_default-fortify-source.patch?view=markup

PATCHv2 with #pragma coming soon.



On Tue, Aug 22, 2017 at 1:52 AM, Khem Raj <raj.khem@gmail.com> wrote:

> On Mon, Aug 21, 2017 at 1:57 PM, Martin Jansa <martin.jansa@gmail.com>
> wrote:
> > * build with gcc-7 fails with:
> >   | ./config-util.h:1504:48: error: this use of "defined" may not be
>  portable [-Werror=expansion-to-defined]
> >   |              || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
> >   |
>                                             ^~~~~~~~~~~~~~~
> >   and we're not building on Apple or BSD, so we should be able
> >   to just ignoreit until it's resolved properly in some newer gnulib
> >   and imported from gnulib to grub-2
> >
> > Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
> > ---
> >  meta/recipes-bsp/grub/grub-efi_2.02.bb | 6 ++++++
> >  1 file changed, 6 insertions(+)
> >
> > diff --git a/meta/recipes-bsp/grub/grub-efi_2.02.bb
> b/meta/recipes-bsp/grub/grub-efi_2.02.bb
> > index b949bebced..45f4c1ed34 100644
> > --- a/meta/recipes-bsp/grub/grub-efi_2.02.bb
> > +++ b/meta/recipes-bsp/grub/grub-efi_2.02.bb
> > @@ -36,6 +36,12 @@ EXTRA_OECONF += "--enable-efiemu=no"
> >  # and many other places in the grub code when compiled with some native
> gcc compilers (specifically, gentoo)
> >  CFLAGS_append_class-native = " -Wno-error=trampolines"
> >
> > +# this comes from gnulib and it's used only for Apple and BSD, so we
> can ignore it
> > +# ./config-util.h:1504:48: error: this use of "defined" may not be
> portable [-Werror=expansion-to-defined]
> > +#             || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
> > +#                                                ^~~~~~~~~~~~~~~
> > +CFLAGS_append_class-native = " -Wno-error=expansion-to-defined"
> > +
>
> This workaround seems reasonable but I wonder why it fails on build host
> for you. how is your build hosts toolchain configured to generate this
> warning. Since you mentioned gcc7 then why doesnt it fail for OE
> targets
> in same way.
>
> An upstreamable fix would be to break this define into another #if ..
> #else macros and define the new macro to 1 or 0 depending upon the
> conditions
> being tested.
>
> >  do_install_class-native() {
> >         install -d ${D}${bindir}
> >         install -m 755 grub-mkimage ${D}${bindir}
> > --
> > 2.14.1
> >
> > --
> > _______________________________________________
> > Openembedded-core mailing list
> > Openembedded-core@lists.openembedded.org
> > http://lists.openembedded.org/mailman/listinfo/openembedded-core
>

[-- Attachment #2: Type: text/html, Size: 9286 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] grub2: fix build with gcc-7
  2017-08-22 17:21     ` Martin Jansa
@ 2017-08-22 17:28       ` Khem Raj
  2017-08-22 22:10       ` [PATCHv2] grub2: fix build on gcc where _FORTIFY_SOURCE is defined Martin Jansa
  1 sibling, 0 replies; 10+ messages in thread
From: Khem Raj @ 2017-08-22 17:28 UTC (permalink / raw)
  To: Martin Jansa; +Cc: Patches and discussions about the oe-core layer

[-- Attachment #1: Type: text/plain, Size: 7440 bytes --]

I have sent few patches to meta oe to fix similar issues earlier found with
clang I think changes to code to define the macros in compliant way are
better and upstreamable

On Tue, Aug 22, 2017 at 10:21 AM Martin Jansa <martin.jansa@gmail.com>
wrote:

> Nothing special on my build host, just gcc 7.1 from gentoo. But the option
> was introduced probably only in gcc-7, on 5.4.0 used in Ubuntu 16.04 it's
> also missing:
>
> OE qemux86@ ~/oe/world/shr-core $ gcc --help=warnings | grep
> expansion-to-defined
> OE qemux86@ ~/oe/world/shr-core $ gcc --version
> gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
> Copyright (C) 2015 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> OE @ ~ $ gcc --help=warnings | grep expansion-to-defined
>   -Wexpansion-to-defined      Warn if "defined" is used outside #if.
> OE @ ~ $ gcc --version
> gcc (Gentoo 7.1.0-r1 p1.1) 7.1.0
> Copyright (C) 2017 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> OE @ ~/build/oe-core/tmp-glibc/work/i586-oe-linux/grub-efi/2.02-r0 $
> recipe-sysroot-native/usr/bin/i586-oe-linux/i586-oe-linux-gcc
> --help=warnings | grep expansion-to-defined
>   -Wexpansion-to-defined      Warn if "defined" is used outside #if.
> OE @ ~/build/oe-core/tmp-glibc/work/i586-oe-linux/grub-efi/2.02-r0 $
> recipe-sysroot-native/usr/bin/i586-oe-linux/i586-oe-linux-gcc --version
> i586-oe-linux-gcc (GCC) 7.2.0
> Copyright (C) 2017 Free Software Foundation, Inc.
> This is free software; see the source for copying conditions.  There is NO
> warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
>
> Applying the flags based on `gcc --version` output also doesn't seem good
> way forward and we don't have gcc-native recipes.
>
> We can probably use gcc pragma to disable this warning (which IIRC doesn't
> test if the disabled warning is supported or not), but that might be a bit
> complicated as this file is generated in configure. I'll check it.
>
> The target grub-efi build doesn't fail probably because target gcc doesn't
> define _FORTIFY_SOURCE
>
> I've tried to compare native and target build and it's reproducible e.g.
> with this command:
>
> gcc  -DHAVE_CONFIG_H -I. -I../grub-2.02  -Wall -W -DGRUB_UTIL=1
> -D_FILE_OFFSET_BITS=64 -I./include -DGRUB_FILE=\"grub-core/lib/crypto.c\"
> -I. -I../grub-2.02 -I. -I../grub-2.02 -I../grub-2.02/include -I./include
> -I../grub-2.02/grub-core/lib/libgcrypt-grub/src/  -I./grub-core/gnulib
> -I../grub-2.02/grub-core/gnulib -D_FILE_OFFSET_BITS=64 -fno-builtin-gettext
> -Wall -W -Wshadow -Wpointer-arith -Wundef -Wchar-subscripts -Wcomment
> -Wdeprecated-declarations -Wdisabled-optimization -Wdiv-by-zero
> -Wfloat-equal -Wformat-extra-args -Wformat-security -Wformat-y2k -Wimplicit
> -Wimplicit-function-declaration -Wimplicit-int -Wmain -Wmissing-braces
> -Wmissing-format-attribute -Wmultichar -Wparentheses -Wreturn-type
> -Wsequence-point -Wshadow -Wsign-compare -Wswitch -Wtrigraphs
> -Wunknown-pragmas -Wunused -Wunused-function -Wunused-label
> -Wunused-parameter -Wunused-value  -Wunused-variable -Wwrite-strings
> -Wnested-externs -Wstrict-prototypes -Wcast-align  -Wextra -Wattributes
> -Wendif-labels -Winit-self -Wint-to-pointer-cast -Winvalid-pch
> -Wmissing-field-initializers -Wnonnull -Woverflow -Wvla
> -Wpointer-to-int-cast -Wstrict-aliasing -Wvariadic-macros
> -Wvolatile-register-var -Wpointer-sign -Wmissing-include-dirs
> -Wmissing-prototypes -Wmissing-declarations -Wformat=2 -Werror  -Wno-undef
> -Wno-sign-compare -Wno-unused -Wno-unused-parameter -Wno-redundant-decls
> -Wno-unreachable-code -Wno-conversion -Wno-error=trampolines -c -o
> grub-core/lib/libgrubkern_a-crypto.o `test -f 'grub-core/lib/crypto.c' ||
> echo '../grub-2.02/'`grub-core/lib/crypto.c
>
> After adding -dM -E and comparing the output between target and native I
> can see that my native gcc defines _FORTIFY_SOURCE as:
> #define _FORTIFY_SOURCE ((defined __OPTIMIZE__ && __OPTIMIZE__ > 0) ? 2 :
> 0)
>
> while target build doesn't.
>
> Just to confirm it's caused by this I've added the same line:
> #define _FORTIFY_SOURCE ((defined __OPTIMIZE__ && __OPTIMIZE__ > 0) ? 2 :
> 0)
> at the top of grub-2.02/grub-core/lib/crypto.c and the target build fails
> the same.
>
> And the  _FORTIFY_SOURCE in native gcc comes from gentoo gcc patches, this
> one:
>
> https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo/src/patchsets/gcc/7.1.0/gentoo/10_all_default-fortify-source.patch?view=markup
>
> PATCHv2 with #pragma coming soon.
>
>
>
> On Tue, Aug 22, 2017 at 1:52 AM, Khem Raj <raj.khem@gmail.com> wrote:
>
>> On Mon, Aug 21, 2017 at 1:57 PM, Martin Jansa <martin.jansa@gmail.com>
>> wrote:
>> > * build with gcc-7 fails with:
>> >   | ./config-util.h:1504:48: error: this use of "defined" may not be
>>  portable [-Werror=expansion-to-defined]
>> >   |              || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
>> >   |
>>                                             ^~~~~~~~~~~~~~~
>> >   and we're not building on Apple or BSD, so we should be able
>> >   to just ignoreit until it's resolved properly in some newer gnulib
>> >   and imported from gnulib to grub-2
>> >
>> > Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
>> > ---
>> >  meta/recipes-bsp/grub/grub-efi_2.02.bb | 6 ++++++
>> >  1 file changed, 6 insertions(+)
>> >
>> > diff --git a/meta/recipes-bsp/grub/grub-efi_2.02.bb
>> b/meta/recipes-bsp/grub/grub-efi_2.02.bb
>> > index b949bebced..45f4c1ed34 100644
>> > --- a/meta/recipes-bsp/grub/grub-efi_2.02.bb
>> > +++ b/meta/recipes-bsp/grub/grub-efi_2.02.bb
>> > @@ -36,6 +36,12 @@ EXTRA_OECONF += "--enable-efiemu=no"
>> >  # and many other places in the grub code when compiled with some
>> native gcc compilers (specifically, gentoo)
>> >  CFLAGS_append_class-native = " -Wno-error=trampolines"
>> >
>> > +# this comes from gnulib and it's used only for Apple and BSD, so we
>> can ignore it
>> > +# ./config-util.h:1504:48: error: this use of "defined" may not be
>> portable [-Werror=expansion-to-defined]
>> > +#             || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
>> > +#                                                ^~~~~~~~~~~~~~~
>> > +CFLAGS_append_class-native = " -Wno-error=expansion-to-defined"
>> > +
>>
>> This workaround seems reasonable but I wonder why it fails on build host
>> for you. how is your build hosts toolchain configured to generate this
>> warning. Since you mentioned gcc7 then why doesnt it fail for OE
>> targets
>> in same way.
>>
>> An upstreamable fix would be to break this define into another #if ..
>> #else macros and define the new macro to 1 or 0 depending upon the
>> conditions
>> being tested.
>>
>> >  do_install_class-native() {
>> >         install -d ${D}${bindir}
>> >         install -m 755 grub-mkimage ${D}${bindir}
>> > --
>> > 2.14.1
>> >
>> > --
>> > _______________________________________________
>> > Openembedded-core mailing list
>> > Openembedded-core@lists.openembedded.org
>> > http://lists.openembedded.org/mailman/listinfo/openembedded-core
>>
>
>

[-- Attachment #2: Type: text/html, Size: 9843 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCHv2] grub2: fix build on gcc where _FORTIFY_SOURCE is defined
  2017-08-22 17:21     ` Martin Jansa
  2017-08-22 17:28       ` Khem Raj
@ 2017-08-22 22:10       ` Martin Jansa
  1 sibling, 0 replies; 10+ messages in thread
From: Martin Jansa @ 2017-08-22 22:10 UTC (permalink / raw)
  To: openembedded-core

* e.g. with gentoo gcc-7.1 they define _FORTIFY_SOURCE by default with:
  https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo/src/patchsets/gcc/7.1.0/gentoo/10_all_default-fortify-source.patch?view=markup
  which results in following error while building grub-efi-native:
  ./config-util.h:1504:48: error: this use of "defined" may not be portable [-Werror=expansion-to-defined]
               || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
                                                  ^~~~~~~~~~~~~~~
  this part comes from gnulib and it's used only for Apple and BSD,
  so we can ignore it, but we cannot add -Wno-error=expansion-to-defined
  because this warning was introduced only in gcc-7 and older gcc
  will fail with:
  cc1: error: -Werror=expansion-to-defined: no option -Wexpansion-to-defined
  use #pragma to work around this

Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
---

v2: this version works on hosts with older gcc, tested on Ubuntu-16.04
    with gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.4)

 .../grub/files/fix.build.with.gcc-7.patch          | 39 ++++++++++++++++++++++
 meta/recipes-bsp/grub/grub2.inc                    |  1 +
 2 files changed, 40 insertions(+)
 create mode 100644 meta/recipes-bsp/grub/files/fix.build.with.gcc-7.patch

diff --git a/meta/recipes-bsp/grub/files/fix.build.with.gcc-7.patch b/meta/recipes-bsp/grub/files/fix.build.with.gcc-7.patch
new file mode 100644
index 0000000000..f35df97bfc
--- /dev/null
+++ b/meta/recipes-bsp/grub/files/fix.build.with.gcc-7.patch
@@ -0,0 +1,39 @@
+* e.g. with gentoo gcc-7.1 they define _FORTIFY_SOURCE by default with:
+  https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo/src/patchsets/gcc/7.1.0/gentoo/10_all_default-fortify-source.patch?view=markup
+  which results in following error while building grub-efi-native:
+  ./config-util.h:1504:48: error: this use of "defined" may not be portable [-Werror=expansion-to-defined]
+               || (defined _FORTIFY_SOURCE && 0 < _FORTIFY_SOURCE \
+                                                  ^~~~~~~~~~~~~~~
+  this part comes from gnulib and it's used only for Apple and BSD,
+  so we can ignore it, but we cannot add -Wno-error=expansion-to-defined
+  because this warning was introduced only in gcc-7 and older gcc
+  will fail with:
+  cc1: error: -Werror=expansion-to-defined: no option -Wexpansion-to-defined
+  use #pragma to work around this
+
+Upstream-Status: Pending (should be fixed in gnulib which is then rarely updated in grub)
+
+Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
+
+diff -uNr grub-2.02.old/m4/extern-inline.m4 grub-2.02/m4/extern-inline.m4
+--- grub-2.02.old/m4/extern-inline.m4	2016-02-28 15:22:21.000000000 +0100
++++ grub-2.02/m4/extern-inline.m4	2017-08-22 19:26:45.213637276 +0200
+@@ -39,6 +39,10 @@
+    OS X 10.9 has a macro __header_inline indicating the bug is fixed for C and
+    for clang but remains for g++; see <http://trac.macports.org/ticket/41033>.
+    Assume DragonFly and FreeBSD will be similar.  */
++#pragma GCC diagnostic push
++#if __GNUC__ >= 7
++#pragma GCC diagnostic ignored "-Wexpansion-to-defined"
++#endif
+ #if (((defined __APPLE__ && defined __MACH__) \
+       || defined __DragonFly__ || defined __FreeBSD__) \
+      && (defined __header_inline \
+@@ -50,6 +52,7 @@
+                 && defined __GNUC__ && ! defined __cplusplus))))
+ # define _GL_EXTERN_INLINE_STDHEADER_BUG
+ #endif
++#pragma GCC diagnostic pop
+ #if ((__GNUC__ \
+       ? defined __GNUC_STDC_INLINE__ && __GNUC_STDC_INLINE__ \
+       : (199901L <= __STDC_VERSION__ \
diff --git a/meta/recipes-bsp/grub/grub2.inc b/meta/recipes-bsp/grub/grub2.inc
index 240a1f9286..a56fbe7bf8 100644
--- a/meta/recipes-bsp/grub/grub2.inc
+++ b/meta/recipes-bsp/grub/grub2.inc
@@ -17,6 +17,7 @@ SRC_URI = "https://ftp.gnu.org/gnu/grub/grub-${PV}.tar.gz \
            file://autogen.sh-exclude-pc.patch \
            file://grub-module-explicitly-keeps-symbole-.module_license.patch \
            file://0001-grub.d-10_linux.in-add-oe-s-kernel-name.patch \
+	   file://fix.build.with.gcc-7.patch \
 "
 SRC_URI[md5sum] = "1116d1f60c840e6dbd67abbc99acb45d"
 SRC_URI[sha256sum] = "660ee136fbcee08858516ed4de2ad87068bfe1b6b8b37896ce3529ff054a726d"
-- 
2.14.1



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-08-22 22:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-21 20:57 [PATCH 1/2] squashfs: fix build with glibc-2.26 Martin Jansa
2017-08-21 20:57 ` [PATCH 2/2] grub2: fix build with gcc-7 Martin Jansa
2017-08-21 23:52   ` Khem Raj
2017-08-22 17:21     ` Martin Jansa
2017-08-22 17:28       ` Khem Raj
2017-08-22 22:10       ` [PATCHv2] grub2: fix build on gcc where _FORTIFY_SOURCE is defined Martin Jansa
2017-08-22 10:22   ` [PATCH 2/2] grub2: fix build with gcc-7 Richard Purdie
2017-08-22 10:26     ` Martin Jansa
2017-08-22 10:28       ` Richard Purdie
2017-08-22 16:32     ` Khem Raj

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.