ubuntu 20.04 编译yocto 错误集锦

4. ubuntu 20.04 编译yocto

4.1 错误1:m4-native failed

|    92 |  #error "Please port gnulib freadahead.c to your platform! Look at the definition of fflush, fread, ungetc on your system, then report this to bug-gnulib."
|       |   ^~~~~
| make[3]: *** [Makefile:1915: freadahead.o] Error 1
| make[3]: *** Waiting for unfinished jobs....
| ../../m4-1.4.18/lib/fseeko.c: In function ‘rpl_fseeko’:
| ../../m4-1.4.18/lib/fseeko.c:110:4: error: #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
|   110 |   #error "Please port gnulib fseeko.c to your platform! Look at the code in fseeko.c, then report this to bug-gnulib."
|       |    ^~~~~
| make[3]: *** [Makefile:1915: fseeko.o] Error 1
| make[3]: Leaving directory '/home/qiao/yocto-code/build/tmp/work/x86_64-linux/m4-native/1.4.18-r0/build/lib'
| make[2]: *** [Makefile:1674: all] Error 2
| make[2]: Leaving directory '/home/qiao/yocto-code/build/tmp/work/x86_64-linux/m4-native/1.4.18-r0/build/lib'
| make[1]: *** [Makefile:1572: all-recursive] Error 1
| make[1]: Leaving directory '/home/qiao/yocto-code/build/tmp/work/x86_64-linux/m4-native/1.4.18-r0/build'
| make: *** [Makefile:1528: all] Error 2
| ERROR: oe_runmake failed
| WARNING: /home/qiao/yocto-code/build/tmp/work/x86_64-linux/m4-native/1.4.18-r0/temp/run.do_compile.22011:1 exit 1 from 'exit 1'

类似于这种问题,基本都是版本问题,这里搜索下gnulib 版本情况,找到新版或者旧版的来测试:

wget https://ftp.gnu.org/gnu/m4/m4-1.4.1.tar.gz
tar -xf m4-1.4.1.tar.gz
cd m4-1.4.1
./configure --prefix=/usr/local
make 
sudo make install

这是个悲伤的故事,思路是对的,但是实际操作时搞错了,这里应该是依赖于gnulib,也就是需要替换gnulib相关库,所以上述方案测试失败yocto poky已经于2018年解决了此问题,并且提供了patch,处理方案如下:

  1. 抓取该patch:

    wget https://src.fedoraproject.org/rpms/m4/raw/814d592134fad36df757f9a61422d164ea2c6c9b/f/m4-1.4.18-glibc-change-work-around.patch   
    
  2. 在m4_1.4.18.inc中添加该patch使用:

    SRC_URI = "${GNU_MIRROR}/m4/m4-${PV}.tar.gz \
               file://ac_config_links.patch \
               file://remove-gets.patch \
               file://m4-1.4.18-glibc-change-work-around.patch \
               "
    
  3. 进入编译:

    source setup
    bitbake -c compile m4-native
    
  4. patch内容:

    diff --git a/lib/fflush.c b/lib/fflush.c
    index 983ade0ff..a6edfa105 100644
    --- a/lib/fflush.c
    +++ b/lib/fflush.c
    @@ -33,7 +33,7 @@
     #undef fflush
     
     
    -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
    +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
     
     /* Clear the stream's ungetc buffer, preserving the value of ftello (fp).  */
     static void
    @@ -72,7 +72,7 @@ clear_ungetc_buffer (FILE *fp)
     
     #endif
     
    -#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
    +#if ! (defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
     
     # if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
     /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Minix 3, Android */
    @@ -148,7 +148,7 @@ rpl_fflush (FILE *stream)
       if (stream == NULL || ! freading (stream))
         return fflush (stream);
     
    -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
    +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
     
       clear_ungetc_buffer_preserving_position (stream);
     
    diff --git a/lib/fpurge.c b/lib/fpurge.c
    index b1d417c7a..3aedcc373 100644
    --- a/lib/fpurge.c
    +++ b/lib/fpurge.c
    @@ -62,7 +62,7 @@ fpurge (FILE *fp)
       /* Most systems provide FILE as a struct and the necessary bitmask in
          , because they need it for implementing getc() and putc() as
          fast macros.  */
    -# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
    +# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
       fp->_IO_read_end = fp->_IO_read_ptr;
       fp->_IO_write_ptr = fp->_IO_write_base;
       /* Avoid memory leak when there is an active ungetc buffer.  */
    diff --git a/lib/freading.c b/lib/freading.c
    index 73c28acdd..c24d0c88a 100644
    --- a/lib/freading.c
    +++ b/lib/freading.c
    @@ -31,7 +31,7 @@ freading (FILE *fp)
       /* Most systems provide FILE as a struct and the necessary bitmask in
          , because they need it for implementing getc() and putc() as
          fast macros.  */
    -# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
    +# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
       return ((fp->_flags & _IO_NO_WRITES) != 0
               || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
                   && fp->_IO_read_base != NULL));
    diff --git a/lib/fseeko.c b/lib/fseeko.c
    index 0101ab55f..193f4e8ce 100644
    --- a/lib/fseeko.c
    +++ b/lib/fseeko.c
    @@ -47,7 +47,7 @@ fseeko (FILE *fp, off_t offset, int whence)
     #endif
     
       /* These tests are based on fpurge.c.  */
    -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
    +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
       if (fp->_IO_read_end == fp->_IO_read_ptr
           && fp->_IO_write_ptr == fp->_IO_write_base
           && fp->_IO_save_base == NULL)
    @@ -123,7 +123,7 @@ fseeko (FILE *fp, off_t offset, int whence)
               return -1;
             }
     
    -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
    +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
           fp->_flags &= ~_IO_EOF_SEEN;
           fp->_offset = pos;
     #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
    diff --git a/lib/stdio-impl.h b/lib/stdio-impl.h
    index 78d896e9f..05c5752a2 100644
    --- a/lib/stdio-impl.h
    +++ b/lib/stdio-impl.h
    @@ -18,6 +18,12 @@
        the same implementation of stdio extension API, except that some fields
        have different naming conventions, or their access requires some casts.  */
     
    +/* Glibc 2.28 made _IO_IN_BACKUP private.  For now, work around this
    +   problem by defining it ourselves.  FIXME: Do not rely on glibc
    +   internals.  */
    +#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
    +# define _IO_IN_BACKUP 0x100
    +#endif
     
     /* BSD stdio derived implementations.  */
     
    -- 
    2.17.1
    

4.2 错误2:elfutils failed 2个报错

这里是bison异常,与上述m4原因一致,新版本gnulib问题,需要导入对应的patch:

https://raw.githubusercontent.com/rdslw/openwrt/e5d47f32131849a69a9267de51a30d6be1f0d0ac/tools/bison/patches/110-glibc-change-work-around.patch

  1. 将该patch放入bison 目录

     cp 110-glibc-bison.patch  /home/oem/code/yocto-sumo-ac8015/meta/poky/meta/recipes-devtools/bison/bison/ 
    
  2. 在bb文件中添加对应patch

    SRC_URI = "${GNU_MIRROR}/bison/bison-${PV}.tar.xz \
               file://0001-Unset-need_charset_alias-when-building-for-musl.patch \
               file://dont-depend-on-help2man.patch.patch \
               file://0001-src-local.mk-fix-parallel-issue.patch \
               file://add-with-bisonlocaledir.patch \
               file://110-glibc-bison.patch \
               "
    

    patch内容:

    --- a/lib/stdio-impl.h
    +++ b/lib/stdio-impl.h
    @@ -18,6 +18,12 @@
        the same implementation of stdio extension API, except that some fields
        have different naming conventions, or their access requires some casts.  */
     
    +/* Glibc 2.28 made _IO_IN_BACKUP private.  For now, work around this
    +   problem by defining it ourselves.  FIXME: Do not rely on glibc
    +   internals.  */
    +#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
    +# define _IO_IN_BACKUP 0x100
    +#endif
     
     /* BSD stdio derived implementations.  */
     
    --- a/lib/fseterr.c
    +++ b/lib/fseterr.c
    @@ -29,7 +29,7 @@
       /* Most systems provide FILE as a struct and the necessary bitmask in
          , because they need it for implementing getc() and putc() as
          fast macros.  */
    -#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
    +#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
       fp->_flags |= _IO_ERR_SEEN;
     #elif defined __sferror || defined __DragonFly__ /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin */
       fp_->_flags |= __SERR;
    
  3. 添加上述patch后仍存在elf错误需要继续check,参考yocto官方patch:

    https://www.yoctoproject.org/pipermail/yocto/2019-June/045575.html

    报错原因为warning被看作error,实质是elf中__elf64_msize变量为const,但是这里使用的时候没有标记,所以需要添加对应属性;

    vim ./elfutils-0.170/libelf/libelfP.h 
    

    ubuntu 20.04 编译yocto 错误集锦_第1张图片

PS:由于Gnulib版本问题导致很多模块编译都有问题,所以需要将上述问题patch打入到gnulib中,但是由于sumo中独立于各个应用自行编译,所以这里添加patch独立导入;

4.3 错误3:directive argument is null

| …/…/glib-2.54.3/gio/gdbusauth.c: In function ‘_g_dbus_auth_run_server’:
| …/…/glib-2.54.3/gio/gdbusauth.c:1305:11: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
| 1305 | debug_print (“SERVER: WaitingForBegin, read ‘%s’”, line);

根据提示,%s的值可能为空,所以添加为空判断

| cc1: some warnings being treated as errors
| make[4]: *** [Makefile:3617: libgio_2_0_la-gdbusauth.lo] Error 1
| make[4]: *** Waiting for unfinished jobs…
| …/…/glib-2.54.3/gio/gdbusmessage.c: In function ‘g_dbus_message_to_blob’:
| …/…/glib-2.54.3/gio/gdbusmessage.c:2700:30: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
| 2700 | tupled_signature_str = g_strdup_printf (“(%s)”, signature_str);

根据提示,%s的值可能为空,所以添加为空判断

4.4 错误4:cross-localedef-native 编译2个报错

/home/oem/code/yocto-sumo-ac8015/build/tmp/hosttools/ld: argp-fmtstream.o: in function _argp_fmtstream_update': | argp-fmtstream.c:(.text+0x4da): undefined reference to _IO_fwide’
| /home/oem/code/yocto-sumo-ac8015/build/tmp/hosttools/ld: argp-fmtstream.c:(.text+0x52d): undefined reference to _IO_fwide' | /home/oem/code/yocto-sumo-ac8015/build/tmp/hosttools/ld: argp-help.o: in function argp_failure’:
| argp-help.c:(.text+0x2067): undefined reference to `_IO_fwide’
| collect2: error: ld returned 1 exit status
| make: *** [Makefile:60: localedef] Error 1
| ERROR: oe_runmake failed

这种问题显然是glibc与调用者版本不匹配,google搜索上述cross-localedef-native信息,可以找到对应patch:

diff --git a/meta/recipes-core/glibc/cross-localedef-native_2.27.bb b/meta/recipes-core/glibc/cross-localedef-native_2.27.bb
index 5e92eb71d55..a999d35201a 100644
--- a/meta/recipes-core/glibc/cross-localedef-native_2.27.bb
+++ b/meta/recipes-core/glibc/cross-localedef-native_2.27.bb
@@ -35,6 +35,7 @@ SRC_URI = "${GLIBC_GIT_URI};branch=${SRCBRANCH};name=glibc \
            file://0021-eglibc-Install-PIC-archives.patch \
            file://0022-eglibc-Forward-port-cross-locale-generation-support.patch \
            file://0023-Define-DUMMY_LOCALE_T-if-not-defined.patch \
+           file://0032-argp-do-not-call-_IO_fwide-if-_LIBC-is-not-defined.patch \
            file://archive-path.patch \
 "
 # Makes for a rather long rev (22 characters), but...
diff --git a/meta/recipes-core/glibc/glibc/0032-argp-do-not-call-_IO_fwide-if-_LIBC-is-not-defined.patch b/meta/recipes-core/glibc/glibc/0032-argp-do-not-call-_IO_fwide-if-_LIBC-is-not-defined.patch
new file mode 100644
index 00000000000..edeb27da0c1
--- /dev/null
+++ b/meta/recipes-core/glibc/glibc/0032-argp-do-not-call-_IO_fwide-if-_LIBC-is-not-defined.patch
@@ -0,0 +1,78 @@
+From 3a67e81d7527363a96af095a5af03b6201b82e9d Mon Sep 17 00:00:00 2001
+From: Charles-Antoine Couret <charles-antoine.couret@essensium.com>
+Date: Thu, 29 Nov 2018 17:56:55 +0000
+Subject: [PATCH] argp: do not call _IO_fwide() if _LIBC is not defined
+
+_IO_fwide() is defined in libio.h file. This file is included only
+when _LIBC is defined.
+
+So, in case of compilation of these files without _LIBC definition,
+the compilation failed due to this unknown function.
+
+Now this function is called when libio.h file is included.
+
+(Change merged from gnulib.  Tested on x86_64.)
+
+	* argp/argp-fmtstream.c (__argp_fmtstream_update): Use [_LIBC]
+	conditional on calls to _IO_fwide and putwc_unlocked.  (Merge from
+	gnulib.)
+	* argp/argp-help.c (__argp_failure): Likewise.
+	
+Upstream-Status: Backport [1]
+
+[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=3a67e81d7527363a96af095a5af03b6201b82e9d
+
+Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
+---
+ ChangeLog             | 7 +++++++
+ argp/argp-fmtstream.c | 4 ++++
+ argp/argp-help.c      | 2 ++
+ 3 files changed, 13 insertions(+)
+
+diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
+index e43a0c7cf1..e9e4c0e5cc 100644
+--- a/argp/argp-fmtstream.c
++++ b/argp/argp-fmtstream.c
+@@ -149,9 +149,11 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
+ 	      size_t i;
+ 	      for (i = 0; i < pad; i++)
+ 		{
++#ifdef _LIBC
+ 		  if (_IO_fwide (fs->stream, 0) > 0)
+ 		    putwc_unlocked (L' ', fs->stream);
+ 		  else
++#endif
+ 		    putc_unlocked (' ', fs->stream);
+ 		}
+ 	    }
+@@ -312,9 +314,11 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
+ 	      *nl++ = ' ';
+ 	  else
+ 	    for (i = 0; i < fs->wmargin; ++i)
++#ifdef _LIBC
+ 	      if (_IO_fwide (fs->stream, 0) > 0)
+ 		putwc_unlocked (L' ', fs->stream);
+ 	      else
++#endif
+ 		putc_unlocked (' ', fs->stream);
+ 
+ 	  /* Copy the tail of the original buffer into the current buffer
+diff --git a/argp/argp-help.c b/argp/argp-help.c
+index 2b6b0775d6..a17260378c 100644
+--- a/argp/argp-help.c
++++ b/argp/argp-help.c
+@@ -1873,9 +1873,11 @@ __argp_failure (const struct argp_state *state, int status, int errnum,
+ #endif
+ 	    }
+ 
++#ifdef _LIBC
+ 	  if (_IO_fwide (stream, 0) > 0)
+ 	    putwc_unlocked (L'\n', stream);
+ 	  else
++#endif
+ 	    putc_unlocked ('\n', stream);
+ 
+ #if _LIBC || (HAVE_FLOCKFILE && HAVE_FUNLOCKFILE)
+-- 
+2.21.0
+

导入即可;

4.5 错误5:qemu-native 模块存在3个错误

ERROR: oe_runmake failed
| WARNING: /home/oem/code/yocto-sumo-ac8015/build/tmp/work/x86_64-linux/qemu-native/2.11.1-r0/temp/run.do_compile.732258:1 exit 1 from ‘exit 1’
| ERROR: Function failed: do_compile (log file is located at /home/oem/code/yocto-sumo-ac8015/build/tmp/work/x86_64-linux/qemu-native/2.11.1-r0/temp/log.do_compile.732258)
ERROR: Task (virtual:native:/home/oem/code/yocto-sumo-ac8015/meta/poky/meta/recipes-devtools/qemu/qemu_2.11.1.bb:do_compile) failed with exit code ‘1’

单独编译qemu-native查看其中详细错误项:

syscall.c:260:16: error: static declaration of ‘gettid’ follows non-static declaration

/ioctls.h:173:9: error: ‘SIOCGSTAMP’ undeclared here (not in a function); did you mean ‘SIOCSRARP’?

google 上述错误,果不其然相关问题已经有patch存在(基于3.0.0版本,则本地编译需要手动修改):

diff --git a/meta/recipes-devtools/qemu/qemu/0001-linux-user-assume-__NR_gettid-always-exists.patch b/meta/recipes-devtools/qemu/qemu/0001-linux-user-assume-__NR_gettid-always-exists.patch
new file mode 100644
index 0000000..767b200
--- /dev/null
+++ b/meta/recipes-devtools/qemu/qemu/0001-linux-user-assume-__NR_gettid-always-exists.patch
@@ -0,0 +1,49 @@ 
+From 184943d827ce09375284e6fbb9fd5eeb9e369529 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= <berrange@redhat.com>
+Date: Wed, 20 Mar 2019 16:18:41 +0000
+Subject: [PATCH] linux-user: assume __NR_gettid always exists
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The gettid syscall was introduced in Linux 2.4.11. This is old enough
+that we can assume it always exists and thus not bother with the
+conditional backcompat logic.
+
+Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
+Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
+Reviewed-by: Laurent Vivier <laurent@vivier.eu>
+Message-Id: <20190320161842.13908-2-berrange@redhat.com>
+Signed-off-by: Laurent Vivier <laurent@vivier.eu>
+
+Upstream-Status: Backport
+dependancy patch for fix
+
+Signed-off-by: Armin Kuster <akuster808@gmail.com>
+
+---
+
+
+ linux-user/syscall.c | 8 --------
+ 1 file changed, 8 deletions(-)
+
+Index: qemu-3.0.0/linux-user/syscall.c
+===================================================================
+--- qemu-3.0.0.orig/linux-user/syscall.c
++++ qemu-3.0.0/linux-user/syscall.c
+@@ -251,15 +251,7 @@ static type name (type1 arg1,type2 arg2,
+ #define TARGET_NR__llseek TARGET_NR_llseek
+ #endif
+ 
+-#ifdef __NR_gettid
+ _syscall0(int, gettid)
+-#else
+-/* This is a replacement for the host gettid() and must return a host
+-   errno. */
+-static int gettid(void) {
+-    return -ENOSYS;
+-}
+-#endif
+ 
+ /* For the 64-bit guest on 32-bit host case we must emulate
+  * getdents using getdents64, because otherwise the host
diff --git a/meta/recipes-devtools/qemu/qemu/0001-linux-user-rename-gettid-to-sys_gettid-to-avoid-clas.patch b/meta/recipes-devtools/qemu/qemu/0001-linux-user-rename-gettid-to-sys_gettid-to-avoid-clas.patch
new file mode 100644
index 0000000..ab3b71d
--- /dev/null
+++ b/meta/recipes-devtools/qemu/qemu/0001-linux-user-rename-gettid-to-sys_gettid-to-avoid-clas.patch
@@ -0,0 +1,95 @@ 
+From 71ba74f67eaca21b0cc9d96f534ad3b9a7161400 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= 
+Date: Wed, 20 Mar 2019 16:18:42 +0000
+Subject: [PATCH] linux-user: rename gettid() to sys_gettid() to avoid clash
+ with glibc
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+The glibc-2.29.9000-6.fc31.x86_64 package finally includes the gettid()
+function as part of unistd.h when __USE_GNU is defined. This clashes
+with linux-user code which unconditionally defines this function name
+itself.
+
+/home/berrange/src/virt/qemu/linux-user/syscall.c:253:16: error: static declaration of ‘gettid’ follows non-static declaration
+  253 | _syscall0(int, gettid)
+      |                ^~~~~~
+/home/berrange/src/virt/qemu/linux-user/syscall.c:184:13: note: in definition of macro ‘_syscall0’
+  184 | static type name (void)   \
+      |             ^~~~
+In file included from /usr/include/unistd.h:1170,
+                 from /home/berrange/src/virt/qemu/include/qemu/osdep.h:107,
+                 from /home/berrange/src/virt/qemu/linux-user/syscall.c:20:
+/usr/include/bits/unistd_ext.h:34:16: note: previous declaration of ‘gettid’ was here
+   34 | extern __pid_t gettid (void) __THROW;
+      |                ^~~~~~
+  CC      aarch64-linux-user/linux-user/signal.o
+make[1]: *** [/home/berrange/src/virt/qemu/rules.mak:69: linux-user/syscall.o] Error 1
+make[1]: *** Waiting for unfinished jobs....
+make: *** [Makefile:449: subdir-aarch64-linux-user] Error 2
+
+While we could make our definition conditional and rely on glibc's impl,
+this patch simply renames our definition to sys_gettid() which is a
+common pattern in this file.
+
+Signed-off-by: Daniel P. Berrangé 
+Reviewed-by: Richard Henderson 
+Reviewed-by: Laurent Vivier 
+Message-Id: <[email protected]>
+Signed-off-by: Laurent Vivier 
+
+Upstream-status: Backport
+
+Fixes issue found on tumbleweed-ty-1
+Yocto bug: https://bugzilla.yoctoproject.org/show_bug.cgi?id=13577
+Signed-off-by: Armin Kuster 
+
+---
+ linux-user/syscall.c | 11 ++++++-----
+ 1 file changed, 6 insertions(+), 5 deletions(-)
+
+Index: qemu-3.0.0/linux-user/syscall.c
+===================================================================
+--- qemu-3.0.0.orig/linux-user/syscall.c
++++ qemu-3.0.0/linux-user/syscall.c
+@@ -251,7 +251,8 @@ static type name (type1 arg1,type2 arg2,
+ #define TARGET_NR__llseek TARGET_NR_llseek
+ #endif
+ 
+-_syscall0(int, gettid)
++#define __NR_sys_gettid __NR_gettid
++_syscall0(int, sys_gettid)
+ 
+ /* For the 64-bit guest on 32-bit host case we must emulate
+  * getdents using getdents64, because otherwise the host
+@@ -6483,7 +6484,7 @@ static void *clone_func(void *arg)
+     cpu = ENV_GET_CPU(env);
+     thread_cpu = cpu;
+     ts = (TaskState *)cpu->opaque;
+-    info->tid = gettid();
++    info->tid = sys_gettid();
+     task_settid(ts);
+     if (info->child_tidptr)
+         put_user_u32(info->tid, info->child_tidptr);
+@@ -6628,9 +6629,9 @@ static int do_fork(CPUArchState *env, un
+                mapping.  We can't repeat the spinlock hack used above because
+                the child process gets its own copy of the lock.  */
+             if (flags & CLONE_CHILD_SETTID)
+-                put_user_u32(gettid(), child_tidptr);
++                put_user_u32(sys_gettid(), child_tidptr);
+             if (flags & CLONE_PARENT_SETTID)
+-                put_user_u32(gettid(), parent_tidptr);
++                put_user_u32(sys_gettid(), parent_tidptr);
+             ts = (TaskState *)cpu->opaque;
+             if (flags & CLONE_SETTLS)
+                 cpu_set_tls (env, newtls);
+@@ -11876,7 +11877,7 @@ abi_long do_syscall(void *cpu_env, int n
+         break;
+ #endif
+     case TARGET_NR_gettid:
+-        ret = get_errno(gettid());
++        ret = get_errno(sys_gettid());
+         break;
+ #ifdef TARGET_NR_readahead
+     case TARGET_NR_readahead:
diff --git a/meta/recipes-devtools/qemu/qemu_3.0.0.bb b/meta/recipes-devtools/qemu/qemu_3.0.0.bb
index 6c3049b..e483aca 100644
--- a/meta/recipes-devtools/qemu/qemu_3.0.0.bb
+++ b/meta/recipes-devtools/qemu/qemu_3.0.0.bb
@@ -40,6 +40,8 @@  SRC_URI = "https://download.qemu.org/${BPN}-${PV}.tar.xz \
            file://CVE-2019-3812.patch \
            file://CVE-2019-6778.patch \
            file://CVE-2019-8934.patch \
+           file://0001-linux-user-assume-__NR_gettid-always-exists.patch \
+           file://0001-linux-user-rename-gettid-to-sys_gettid-to-avoid-clas.patch \
            "
 UPSTREAM_CHECK_REGEX = "qemu-(?P\d+(\.\d+)+)\.tar"

由于上述存在版本差异,所以本地手动修改源码中gettid部分后即可编译通过

qemu中需要修改3个点:

1. gettid 需要rename 为 sys_gettid
2. stime 更新为 clock_settime
3. ‘SIOCGSTAMP’ undeclaration ,需要导入头文件

未完待续,持续更新

你可能感兴趣的:(#,编译问题,linux,linux,yocto)