gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 19:18:39 26 4
gpt4 key购买 nike

只是为了好玩,我试图将irixxxxqemu-irix构建为Docker镜像。

它在Debian Buster(使用GCC 8容器)下成功构建。但是,它无法在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

我研究了Debian和Alpine的GCC(实际上是libc6和musl)之间关于相似失败的区别,但是我没有找到有关如何在不修改代码的情况下解决此问题的任何信息。

因此,在哪里可以找到有关此问题的更多信息,哪些软件包可以解决该问题?谢谢。

Dockerfile和完整日志 here。 Docker容器镜像(Debian Buster) here

最佳答案

差异似乎是由底层libc实现引起的:Debian的glibc与Alpine的musl-libc

虽然GNU libc是Linux中的事实上的标准libc实现,但少数发行版(例如Alpine Linux和Void Linux)使用musl libc。 musl是一个简约的strict-POSIX libc实现,通常与glibc不兼容。通常,必须将软件项目移植到musl libc上,以在Alpine(尤其是非琐碎的应用程序)上得到支持。
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)

must libc的 F_EXLCK中未定义 fcntl.h是宏。但是,可以通过手动定义(例如 make CFLAGS='"-DF_EXLCK=4"')轻松对其进行修补。这是qemu为非虹膜目标( patch link)的肌肉修补的方式。

但是,还有更多未定义的宏,例如 __SIGRTMIN__SIGRTMAX,宏 TRANSTBL_CONVERT,可能还有其他宏。临时修补它们可能还不够-因此,似乎必须为Alpine和musl libc正确移植 qemu-irix项目。

如果愿意,您可以尝试遵循现有的qemu musl补丁,并尝试自己为 qemu-irix对其进行补丁:
- https://lists.gnu.org/archive/html/qemu-devel/2014-04/msg04773.html
- https://github.com/NixOS/nixpkgs/pull/46449/files

脱离主题注释,使用 make -j构建并行,这将以更快的速度结束。

关于docker - qemu-irix无法在Alpine 3.10(GCC 8.3)下构建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61672144/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com