简体   繁体   English

qemu-irix 无法在 Alpine 3.10 (GCC 8.3) 下构建

[英]qemu-irix fails to build under Alpine 3.10 (GCC 8.3)

Just for fun, I'm attempting to build the irixxxx 's qemu-irix as a Docker image.只是为了好玩,我正在尝试将irixxxxqemu-irix构建为 Docker 图像。

It builds successfuly under Debian Buster (using GCC 8 container).它在 Debian Buster 下成功构建(使用 GCC 8 容器)。 However, it fails to build under Alpine 3.10 (it fails only when I selected the Irix targets), with the following errors (at the make stage):但是,它无法在 Alpine 3.10 下构建(仅当我选择 Irix 目标时才会失败),并出现以下错误(在make阶段):

  CC      util/oslib-posix.o
In file included from util/oslib-posix.c:39:
/usr/include/sys/signal.h:1:2: warning: #warning redirecting incorrect #include <sys/signal.h> to <signal.h> [-Wcpp]
 #warning redirecting incorrect #include <sys/signal.h> to <signal.h>
  ^~~~~~~
  CC      util/qemu-openpty.o
util/qemu-openpty.c: In function 'qemu_openpty_raw':
util/qemu-openpty.c:123:9: warning: implicit declaration of function 'openpty'; did you mean 'openat'? [-Wimplicit-function-declaration]
     if (openpty(&amaster, aslave, pty_buf, NULL, NULL) < 0) {
         ^~~~~~~
         openat
util/qemu-openpty.c:123:9: warning: nested extern declaration of 'openpty' [-Wnested-externs]

(...)

  CC      irix-linux-user/linux-user/syscall.o
/qemu-irix/linux-user/syscall.c:6784:22: error: 'F_EXLCK' undeclared here (not in a function); did you mean 'F_RDLCK'?
     TRANSTBL_CONVERT(F_EXLCK),
                      ^~~~~~~
/qemu-irix/linux-user/syscall.c:6779:51: note: in definition of macro 'TRANSTBL_CONVERT'
 #define TRANSTBL_CONVERT(a) { -1, TARGET_##a, -1, a }
                                                   ^
/qemu-irix/linux-user/syscall.c:6785:22: error: 'F_SHLCK' undeclared here (not in a function); did you mean 'F_RDLCK'?
     TRANSTBL_CONVERT(F_SHLCK),
                      ^~~~~~~
/qemu-irix/linux-user/syscall.c:6779:51: note: in definition of macro 'TRANSTBL_CONVERT'
 #define TRANSTBL_CONVERT(a) { -1, TARGET_##a, -1, a }
                                                   ^
In file included from /qemu-irix/linux-user/syscall.c:121:
/qemu-irix/linux-user/syscall.c: In function 'target_to_host_sigevent':
/qemu-irix/linux-user/syscall.c:7422:27: error: 'struct sigevent' has no member named '_sigev_un'; did you mean 'sigev_value'?
     __get_user(host_sevp->_sigev_un._tid, &target_sevp->_sigev_un._tid);
                           ^~~~~~~~~
/qemu-irix/linux-user/qemu.h:501:5: note: in definition of macro '__get_user_e'
   ((x) = (typeof(*hptr))(                                               \
     ^
/qemu-irix/linux-user/syscall.c:7422:5: note: in expansion of macro '__get_user'
     __get_user(host_sevp->_sigev_un._tid, &target_sevp->_sigev_un._tid);
     ^~~~~~~~~~
/qemu-irix/linux-user/syscall.c:7422:36: error: '(const bitmask_transtbl *)&<erroneous-expression>' is a pointer; did you mean to use '->'?
     __get_user(host_sevp->_sigev_un._tid, &target_sevp->_sigev_un._tid);
                                    ^
/qemu-irix/linux-user/qemu.h:501:5: note: in definition of macro '__get_user_e'
   ((x) = (typeof(*hptr))(                                               \
     ^
/qemu-irix/linux-user/syscall.c:7422:5: note: in expansion of macro '__get_user'
     __get_user(host_sevp->_sigev_un._tid, &target_sevp->_sigev_un._tid);
     ^~~~~~~~~~
/qemu-irix/linux-user/qemu.h:506:13: warning: left-hand operand of comma expression has no effect [-Wunused-value]
      (hptr)), (void)0)
             ^
/qemu-irix/linux-user/qemu.h:510:31: note: in expansion of macro '__get_user_e'
 # define __get_user(x, hptr)  __get_user_e(x, hptr, be)
                               ^~~~~~~~~~~~
/qemu-irix/linux-user/syscall.c:7422:5: note: in expansion of macro '__get_user'
     __get_user(host_sevp->_sigev_un._tid, &target_sevp->_sigev_un._tid);
     ^~~~~~~~~~
/qemu-irix/linux-user/syscall.c: In function 'do_syscall':
/qemu-irix/linux-user/syscall.c:13545:25: warning: implicit declaration of function 'sethostid'; did you mean 'gethostid'? [-Wimplicit-function-declaration]
         ret = get_errno(sethostid(arg1));
                         ^~~~~~~~~
                         gethostid
/qemu-irix/linux-user/syscall.c:13545:25: warning: nested extern declaration of 'sethostid' [-Wnested-externs]
make[1]: *** [/qemu-irix/rules.mak:66: linux-user/syscall.o] Error 1
make: *** [Makefile:472: subdir-irix-linux-user] Error 2
The command '/bin/sh -c make && DESTDIR=/tmp/qemu make install' returned a non-zero code: 2

I researched about the differences between Debian's and Alpine's GCC (in fact, libc6 and musl) about similar failures, but I haven't found any information about how to solve this without modifying the code.我研究了 Debian 和 Alpine 的 GCC(实际上是 libc6 和 musl)关于类似故障的差异,但我没有找到任何关于如何在不修改代码的情况下解决这个问题的信息。

So, where can I find more information about this issue and which packages may solve it?那么,我在哪里可以找到有关此问题的更多信息以及哪些软件包可以解决它? Thanks.谢谢。

Dockerfiles and full log here . Dockerfiles 和完整的日志在这里 Docker container image (Debian Buster) here . Docker 容器镜像(Debian Buster)在这里

The difference seems to be caused by the underlying libc implementations: glibc of Debian, vs musl-libc of Alpine.差异似乎是由底层 libc 实现引起的:Debian 的glibc与 Alpine的 musl-libc

While GNU libc is the defacto standard libc implementation in Linux, musl libc is used by a handful of distributions, such as Alpine Linux and Void Linux.虽然 GNU libc 是 Linux 中事实上的标准 libc 实现,但 musl libc 被少数发行版使用,例如 Alpine Linux 和 Void ZEDC9F0A5A5D577433368E373647。 musl is a minimalistic strict-POSIX libc implementation, and is generally not compatible with glibc. musl 是一个简约的严格 POSIX libc 实现,通常与 glibc 不兼容。 Usually, software projects have to be ported to musl libc to be supported on Alpine, especially non trivial applications.通常,软件项目必须移植到 musl libc 才能在 Alpine 上得到支持,尤其是非平凡的应用程序。

The compilation of syscall.c breaks on several places, the first being: syscall.c的编译在几个地方中断,第一个是:

/qemu-irix/linux-user/syscall.c:6784:22: error: 'F_EXLCK' undeclared here (not in a function); did you mean 'F_RDLCK'?
 TRANSTBL_CONVERT(F_EXLCK)

The F_EXLCK is macro is not defined in musl libc's fcntl.h . F_EXLCK宏未在 musl libc 的fcntl.h中定义。 However, it could be easily patched by defining it manually, for example with make CFLAGS='"-DF_EXLCK=4"' .但是,可以通过手动定义来轻松修补它,例如使用make CFLAGS='"-DF_EXLCK=4"' This is how qemu is patched for musl for non-irix targets ( patch link ).这就是为非 irix 目标( 补丁链接)的 musl 修补 qemu 的方式。

However, there are more undefined macros down the road, such as __SIGRTMIN and __SIGRTMAX , the macro TRANSTBL_CONVERT , and probably others.但是,未来还有更多未定义的宏,例如__SIGRTMIN__SIGRTMAX ,宏TRANSTBL_CONVERT ,可能还有其他。 Patching them ad-hoc may not be enough - so it appears to be that the qemu-irix project has to be properly ported for Alpine and musl libc.临时修补它们可能还不够——因此似乎必须为 Alpine 和 musl libc 正确移植qemu-irix项目。

If you're willing, you could try following existing qemu musl patches, and attempt to patch it yourself for qemu-irix :如果您愿意,您可以尝试遵循现有的 qemu musl 补丁,并尝试自己为qemu-irix打补丁:
- https://lists.gnu.org/archive/html/qemu-devel/2014-04/msg04773.html - https://lists.gnu.org/archive/html/qemu-devel/2014-04/msg04773.html
- https://github.com/NixOS/nixpkgs/pull/46449/files - https://github.com/NixOS/nixpkgs/pull/46449/files

Off topic comment, use make -j to build parallely, which will end much faster.题外话,使用make -j来并行构建,这将更快地结束。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM