[yocto] [meta][PATCH] qemu: add a patch fixing the native build on newer kernels

2019-07-23 Thread Bartosz Golaszewski
From: Bartosz Golaszewski 

The build fails on qemu-native if we're using kernels after commit
0768e17073dc527ccd18ed5f96ce85f9985e9115. This adds an upstream
patch that fixes the issue.

Signed-off-by: Bartosz Golaszewski 
---
 meta/recipes-devtools/qemu/qemu.inc   |   1 +
 ...o-handle-variably-sized-SIOCGSTAMP-w.patch | 339 ++
 2 files changed, 340 insertions(+)
 create mode 100644 
meta/recipes-devtools/qemu/qemu/0014-linux-user-fix-to-handle-variably-sized-SIOCGSTAMP-w.patch

diff --git a/meta/recipes-devtools/qemu/qemu.inc 
b/meta/recipes-devtools/qemu/qemu.inc
index 7f0b3a7a73..46c40b7d4f 100644
--- a/meta/recipes-devtools/qemu/qemu.inc
+++ b/meta/recipes-devtools/qemu/qemu.inc
@@ -24,6 +24,7 @@ SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \

file://0009-linux-user-Fix-webkitgtk-hangs-on-32-bit-x86-target.patch \

file://0010-Revert-linux-user-fix-mmap-munmap-mprotect-mremap-sh.patch \
file://0013-target-arm-Fix-vector-operation-segfault.patch \
+   
file://0014-linux-user-fix-to-handle-variably-sized-SIOCGSTAMP-w.patch \
   file://CVE-2019-12155.patch \
"
 UPSTREAM_CHECK_REGEX = "qemu-(?P\d+(\.\d+)+)\.tar"
diff --git 
a/meta/recipes-devtools/qemu/qemu/0014-linux-user-fix-to-handle-variably-sized-SIOCGSTAMP-w.patch
 
b/meta/recipes-devtools/qemu/qemu/0014-linux-user-fix-to-handle-variably-sized-SIOCGSTAMP-w.patch
new file mode 100644
index 00..2feb567f1c
--- /dev/null
+++ 
b/meta/recipes-devtools/qemu/qemu/0014-linux-user-fix-to-handle-variably-sized-SIOCGSTAMP-w.patch
@@ -0,0 +1,339 @@
+From 8104018ba4c66e568d2583a3a0ee940851ee7471 Mon Sep 17 00:00:00 2001
+From: Bartosz Golaszewski 
+Date: Tue, 23 Jul 2019 17:50:00 +0200
+Subject: [PATCH] linux-user: fix to handle variably sized SIOCGSTAMP with new
+ kernels
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The SIOCGSTAMP symbol was previously defined in the
+asm-generic/sockios.h header file. QEMU sees that header
+indirectly via sys/socket.h
+
+In linux kernel commit 0768e17073dc527ccd18ed5f96ce85f9985e9115
+the asm-generic/sockios.h header no longer defines SIOCGSTAMP.
+Instead it provides only SIOCGSTAMP_OLD, which only uses a
+32-bit time_t on 32-bit architectures.
+
+The linux/sockios.h header then defines SIOCGSTAMP using
+either SIOCGSTAMP_OLD or SIOCGSTAMP_NEW as appropriate. If
+SIOCGSTAMP_NEW is used, then the tv_sec field is 64-bit even
+on 32-bit architectures
+
+To cope with this we must now convert the old and new type from
+the target to the host one.
+
+Signed-off-by: Daniel P. Berrangé 
+Signed-off-by: Laurent Vivier 
+Reviewed-by: Arnd Bergmann 
+Message-Id: <20190718130641.15294-1-laur...@vivier.eu>
+Signed-off-by: Laurent Vivier 
+Signed-off-by: Bartosz Golaszewski 
+---
+Uptream-status: Backport (upstream commit: 
6d5d5dde9adb5acb32e6b8e3dfbf47fff0f308d2)
+
+ linux-user/ioctls.h|  21 +-
+ linux-user/syscall.c   | 140 +
+ linux-user/syscall_defs.h  |  30 +++-
+ linux-user/syscall_types.h |   6 --
+ 4 files changed, 159 insertions(+), 38 deletions(-)
+
+diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
+index ae8951625f..e6a27ad9d6 100644
+--- a/linux-user/ioctls.h
 b/linux-user/ioctls.h
+@@ -219,8 +219,25 @@
+   IOCTL(SIOCGRARP, IOC_R, MK_PTR(MK_STRUCT(STRUCT_arpreq)))
+   IOCTL(SIOCGIWNAME, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_char_ifreq)))
+   IOCTL(SIOCGPGRP, IOC_R, MK_PTR(TYPE_INT)) /* pid_t */
+-  IOCTL(SIOCGSTAMP, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timeval)))
+-  IOCTL(SIOCGSTAMPNS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timespec)))
++
++  /*
++   * We can't use IOCTL_SPECIAL() because it will set
++   * host_cmd to XXX_OLD and XXX_NEW and these macros
++   * are not defined with kernel prior to 5.2.
++   * We must set host_cmd to the same value as in target_cmd
++   * otherwise the consistency check in syscall_init()
++   * will trigger an error.
++   * host_cmd is ignored by the do_ioctl_XXX() helpers.
++   * FIXME: create a macro to define this kind of entry
++   */
++  { TARGET_SIOCGSTAMP_OLD, TARGET_SIOCGSTAMP_OLD,
++"SIOCGSTAMP_OLD", IOC_R, do_ioctl_SIOCGSTAMP },
++  { TARGET_SIOCGSTAMPNS_OLD, TARGET_SIOCGSTAMPNS_OLD,
++"SIOCGSTAMPNS_OLD", IOC_R, do_ioctl_SIOCGSTAMPNS },
++  { TARGET_SIOCGSTAMP_NEW, TARGET_SIOCGSTAMP_NEW,
++"SIOCGSTAMP_NEW", IOC_R, do_ioctl_SIOCGSTAMP },
++  { TARGET_SIOCGSTAMPNS_NEW, TARGET_SIOCGSTAMPNS_NEW,
++"SIOCGSTAMPNS_NEW", IOC_R, do_ioctl_SIOCGSTAMPNS },
+ 
+   IOCTL(RNDGETENTCNT, IOC_R, MK_PTR(TYPE_INT))
+   IOCTL(RNDADDTOENTCNT, IOC_W, MK_PTR(TYPE_INT))
+diff --git a/linux-user/syscall.c b/linux-user/syscall.c
+index 96cd4bf86d..6df480e13d 100644
+--- a/linux-user/syscall.c
 b/linux-user/syscall.c
+@@ -37,6 +37,7 @@
+ #include 
+ #include 
+ #include 
++#include 
+ #include 
+ #

Re: [yocto] native perl build wants to run target shared object

2018-10-05 Thread Bartosz Golaszewski
pon., 3 wrz 2018 o 17:59 Bartosz Golaszewski  napisał(a):
>
> Hi,
>
> I'm trying to add a recipe for a new perl package: linux-inotify.
>
> It's fairly standard package available in cpan[1].
>
> I added the following DEPENDS and RDEPENDS:
>
> RDEPENDS_${PN} += " \
> perl \
> perl-module-base \
> "
>
> DEPENDS += " \
> perl-native \
> libmodule-build-perl-native \
> "
>
> But I'm getting the following build error:
>
> ERROR: linux-inotify-perl-0.05-r0 do_compile: oe_runmake failed
> ERROR: linux-inotify-perl-0.05-r0 do_compile: Function failed:
> do_compile (log file is located at
> //build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/temp/log.do_compile.15693)
> ERROR: Logfile of failure stored in:
> //build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/temp/log.do_compile.15693
> Log data follows:
> | DEBUG: Executing shell function do_compile
> | NOTE: make -j 40 PASTHRU_INC= -O2 -pipe -g
> -feliminate-unused-debug-types
> -fdebug-prefix-map=//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0=/usr/src/debug/linux-inotify-perl/0.05-r0
> -fdebug-prefix-map=//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot=
> -fdebug-prefix-map=//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot-native=
>  LD=aarch64-poky-linux-gcc
> --sysroot=//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot
> | 
> //build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot-native/usr/bin/perl-native/perl
> Build --makefile_env_macros 1
> | Can't load 
> '//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot/usr/lib/perl/5.24.1/auto/File/Glob/Glob.so'
> for module File::Glob:
> //build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot/usr/lib/perl/5.24.1/auto/File/Glob/Glob.so:
> cannot open shared object file: No such file or directory at
> //build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot-native/usr/bin/perl-native/../../../usr/lib/perl-native/perl/5.24.1/XSLoader.pm
> line 96.
> |  at 
> //build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot/usr/lib/perl/5.24.1/File/Glob.pm
> line 68.
> | Compilation failed in require at
> //build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot-native/usr/bin/perl-native/../../../usr/lib/perl-native/perl/vendor_perl/5.24.1/Module/Build/Base.pm
> line 1263.
> | BEGIN failed--compilation aborted at
> //build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot-native/usr/bin/perl-native/../../../usr/lib/perl-native/perl/vendor_perl/5.24.1/Module/Build/Base.pm
> line 1263.
> | Compilation failed in require at
> //build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot-native/usr/bin/perl-native/../../../usr/lib/perl-native/perl/vendor_perl/5.24.1/Module/Build.pm
> line 17.
> | BEGIN failed--compilation aborted at
> //build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot-native/usr/bin/perl-native/../../../usr/lib/perl-native/perl/vendor_perl/5.24.1/Module/Build.pm
> line 17.
> | Compilation failed in require at Build line 47.
> | BEGIN failed--compilation aborted at Build line 47.
> | Makefile:33: recipe for target 'all' failed
> | make: *** [all] Error 2
> | ERROR: oe_runmake failed
> | WARNING: 
> //build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/temp/run.do_compile.15693:1
> exit 1 from 'exit 1'
> | ERROR: Function failed: do_compile (log file is located at
> //build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/temp/log.do_compile.15693)
> ERROR: Task 
> (//meta-/recipes-perl/linux-inotify/linux-inotify-perl_0.05.bb:do_compile)
> failed with exit code '1'
> NOTE: Tasks Summary: Attempted 3669 tasks of which 3667 didn't need to
> be rerun and 1 failed.
>
> Apparently the XSLoader module tries to use glob but instead of
> loading the host shared object it opens the target shared object and
> fails.
>
> I couldn't find any reason nor fix for that. Would appreciate any help.
>
> Best regards,
> Bartosz Golaszewski
>
> [1] https://metacpan.org/pod/Linux::Inotify

I still wasn't able to figure out the problem. Any help is appreciated.

Bart
-- 
___
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


[yocto] native perl build wants to run target shared object

2018-09-03 Thread Bartosz Golaszewski
Hi,

I'm trying to add a recipe for a new perl package: linux-inotify.

It's fairly standard package available in cpan[1].

I added the following DEPENDS and RDEPENDS:

RDEPENDS_${PN} += " \
perl \
perl-module-base \
"

DEPENDS += " \
perl-native \
libmodule-build-perl-native \
"

But I'm getting the following build error:

ERROR: linux-inotify-perl-0.05-r0 do_compile: oe_runmake failed
ERROR: linux-inotify-perl-0.05-r0 do_compile: Function failed:
do_compile (log file is located at
//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/temp/log.do_compile.15693)
ERROR: Logfile of failure stored in:
//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/temp/log.do_compile.15693
Log data follows:
| DEBUG: Executing shell function do_compile
| NOTE: make -j 40 PASTHRU_INC= -O2 -pipe -g
-feliminate-unused-debug-types
-fdebug-prefix-map=//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0=/usr/src/debug/linux-inotify-perl/0.05-r0
-fdebug-prefix-map=//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot=
-fdebug-prefix-map=//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot-native=
 LD=aarch64-poky-linux-gcc
--sysroot=//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot
| 
//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot-native/usr/bin/perl-native/perl
Build --makefile_env_macros 1
| Can't load 
'//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot/usr/lib/perl/5.24.1/auto/File/Glob/Glob.so'
for module File::Glob:
//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot/usr/lib/perl/5.24.1/auto/File/Glob/Glob.so:
cannot open shared object file: No such file or directory at
//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot-native/usr/bin/perl-native/../../../usr/lib/perl-native/perl/5.24.1/XSLoader.pm
line 96.
|  at 
//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot/usr/lib/perl/5.24.1/File/Glob.pm
line 68.
| Compilation failed in require at
//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot-native/usr/bin/perl-native/../../../usr/lib/perl-native/perl/vendor_perl/5.24.1/Module/Build/Base.pm
line 1263.
| BEGIN failed--compilation aborted at
//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot-native/usr/bin/perl-native/../../../usr/lib/perl-native/perl/vendor_perl/5.24.1/Module/Build/Base.pm
line 1263.
| Compilation failed in require at
//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot-native/usr/bin/perl-native/../../../usr/lib/perl-native/perl/vendor_perl/5.24.1/Module/Build.pm
line 17.
| BEGIN failed--compilation aborted at
//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/recipe-sysroot-native/usr/bin/perl-native/../../../usr/lib/perl-native/perl/vendor_perl/5.24.1/Module/Build.pm
line 17.
| Compilation failed in require at Build line 47.
| BEGIN failed--compilation aborted at Build line 47.
| Makefile:33: recipe for target 'all' failed
| make: *** [all] Error 2
| ERROR: oe_runmake failed
| WARNING: 
//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/temp/run.do_compile.15693:1
exit 1 from 'exit 1'
| ERROR: Function failed: do_compile (log file is located at
//build/tmp/work/aarch64-poky-linux/linux-inotify-perl/0.05-r0/temp/log.do_compile.15693)
ERROR: Task 
(//meta-/recipes-perl/linux-inotify/linux-inotify-perl_0.05.bb:do_compile)
failed with exit code '1'
NOTE: Tasks Summary: Attempted 3669 tasks of which 3667 didn't need to
be rerun and 1 failed.

Apparently the XSLoader module tries to use glob but instead of
loading the host shared object it opens the target shared object and
fails.

I couldn't find any reason nor fix for that. Would appreciate any help.

Best regards,
Bartosz Golaszewski

[1] https://metacpan.org/pod/Linux::Inotify
-- 
___
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


Re: [yocto] Running cmake in the SDK environment from a script fails

2018-01-18 Thread Bartosz Golaszewski
2018-01-17 20:30 GMT+01:00 Bartosz Golaszewski <b...@bgdev.pl>:
> Hi,
>
> I'm working on a project in which a base linux distribution is built
> using yocto while a set of proprietary components is built with the
> generated SDK (-c populate_sdk).
>
> These components use cmake for building. While they build just fine
> when the 'cmake' command is invoked from command-line, as soon as
> there's a fork() and execve() in between (e.g. when cmake is invoked
> from a script or even when I tried tracing it with strace), the build
> fails on finding any external library:
>
> -- Could NOT find ZLIB (missing:  ZLIB_LIBRARY) (found version "1.2.8")
> CMake Error at cmake/external_dependencies.cmake:10 (message):
>   Could not find zlib
> Call Stack (most recent call first):
>   CMakeLists.txt:109 (include)
>
> The 'found' message is there because it eventually 'found' my host's
> header as visible in the strace output[1].
>
> The target arch is core2-64 while the host is x86_64. Both host and
> target dirs are present in sysroots/.
>
> What's clear when browsing the strace output is that the headers are
> not searched for in the right directory which would in this case be
> sysroots/core2-64-poky-linux/usr/include/ but in
> /sysroots/x86_64-pokysdk-linux/ instead.
>
> I initially thought this to be a problem with the project's
> CMakeLists.txt but it seems fine given the fact that it builds when
> used manually.
>
> Any idea what could be the culprit here?
>
> Best regards,
> Bartosz Golaszewski
>
> [1] https://pastebin.com/1pqmbh7R

After some more debugging I found the culprit. The environment setup
script in the SDK aliases cmake to 'cmake
-DCMAKE_TOOLCHAIN_FILE=$OECORE_NATIVE_SYSROOT/usr/share/cmake/OEToolchainConfig.cmake'
but aliases are not expanded in non-interactive shells by default.

It can be fixed with shopt or by passing this parameter explicitly to cmake.

I didn't find any mention of that anywhere in docs. Any idea for a
right place to put it in?

Thanks,
Bartosz
-- 
___
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto


[yocto] Running cmake in the SDK environment from a script fails

2018-01-17 Thread Bartosz Golaszewski
Hi,

I'm working on a project in which a base linux distribution is built
using yocto while a set of proprietary components is built with the
generated SDK (-c populate_sdk).

These components use cmake for building. While they build just fine
when the 'cmake' command is invoked from command-line, as soon as
there's a fork() and execve() in between (e.g. when cmake is invoked
from a script or even when I tried tracing it with strace), the build
fails on finding any external library:

-- Could NOT find ZLIB (missing:  ZLIB_LIBRARY) (found version "1.2.8")
CMake Error at cmake/external_dependencies.cmake:10 (message):
  Could not find zlib
Call Stack (most recent call first):
  CMakeLists.txt:109 (include)

The 'found' message is there because it eventually 'found' my host's
header as visible in the strace output[1].

The target arch is core2-64 while the host is x86_64. Both host and
target dirs are present in sysroots/.

What's clear when browsing the strace output is that the headers are
not searched for in the right directory which would in this case be
sysroots/core2-64-poky-linux/usr/include/ but in
/sysroots/x86_64-pokysdk-linux/ instead.

I initially thought this to be a problem with the project's
CMakeLists.txt but it seems fine given the fact that it builds when
used manually.

Any idea what could be the culprit here?

Best regards,
Bartosz Golaszewski

[1] https://pastebin.com/1pqmbh7R
-- 
___
yocto mailing list
yocto@yoctoproject.org
https://lists.yoctoproject.org/listinfo/yocto