Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] app-emulation/qemu fails to build on musl
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
yamabiko
n00b
n00b


Joined: 22 Jul 2017
Posts: 10

PostPosted: Sat Jul 29, 2017 6:34 pm    Post subject: [SOLVED] app-emulation/qemu fails to build on musl Reply with quote

Hello,
when I try to compile qemu I run in the following error:
Code:
 gcc -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/user-build/linux-user -Ilinux-user -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/tcg -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/tcg/i386 -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/linux-headers -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/user-build/linux-headers -I. -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0 -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/include -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -fPIE -DPIE -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv  -Wendif-labels -Wno-missing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-strong  -I../linux-headers -I.. -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/target/i386 -DNEED_CPU_H -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/include -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/linux-user/x86_64 -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/linux-user/host/x86_64 -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/linux-user -MMD -MP -MT linux-user/syscall.o -MF linux-user/syscall.d -march=core2 -Os -pipe  -c -o linux-user/syscall.o /var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/linux-user/syscall.c
/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/linux-user/ioctls.h:174:9: error: ‘SIOCGSTAMPNS’ undeclared here (not in a function)
   IOCTL(SIOCGSTAMPNS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timespec)))
         ^
/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/linux-user/syscall.c:5597:23: note: in definition of macro ‘IOCTL’
     { TARGET_ ## cmd, cmd, #cmd, access, 0, {  __VA_ARGS__ } },
                       ^
gcc -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/user-build/linux-user -Ilinux-user -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/tcg -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/tcg/i386 -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/linux-headers -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/user-build/linux-headers -I. -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0 -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/include -pthread -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -fPIE -DPIE -m64 -mcx16 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -fwrapv  -Wendif-labels -Wno-missing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-declaration -Wold-style-definition -Wtype-limits -fstack-protector-strong  -I../linux-headers -I.. -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/target/i386 -DNEED_CPU_H -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/include -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/linux-user/x86_64 -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/linux-user/host/x86_64 -I/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/linux-user -MMD -MP -MT linux-user/strace.o -MF linux-user/strace.d -march=core2 -Os -pipe  -c -o linux-user/strace.o /var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/linux-user/strace.c
make[1]: *** [/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/rules.mak:69: linux-user/syscall.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/var/tmp/portage/app-emulation/qemu-2.9.0-r2/work/qemu-2.9.0/user-build/x86_64-linux-user'
make: *** [Makefile:327: subdir-x86_64-linux-user] Error 2
 * ERROR: app-emulation/qemu-2.9.0-r2::musl failed (compile phase):
 *   emake failed

I'm on the hardened musl profile. Any idea?


Last edited by yamabiko on Tue Aug 01, 2017 7:13 am; edited 1 time in total
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Sat Jul 29, 2017 10:59 pm    Post subject: Reply with quote

Looks like it's missing. Best thing to do is file a bug upstream.

As a temporary workaround, you could try adding "-DSIOCGSTAMPNS=0x8907" to CFLAGS for this one package.
Back to top
View user's profile Send private message
ntnn
n00b
n00b


Joined: 20 Mar 2017
Posts: 10

PostPosted: Sun Jul 30, 2017 7:36 am    Post subject: Reply with quote

Are you using the musl overlay?
Back to top
View user's profile Send private message
Mr. T.
Guru
Guru


Joined: 26 Dec 2016
Posts: 477

PostPosted: Sun Jul 30, 2017 5:41 pm    Post subject: Reply with quote

The macro SIOCGSTAMPNS is defined in the linux header file named /usr/include/asm/sockios.h

grep -Rl "SIOCGSTAMPNS" /usr/include:
/usr/include/asm/sockios.h

qfile /usr/include/asm:
sys-kernel/linux-headers

In a glibc based system, the header file <asm/sockios.h> is probably imported in this way:

Code:
linux-user/syscall.c
-> ./glibc/include/sys/socket.h         # /usr/include/sys/socket.h or <sys/socket.h>
--> ./glibc/socket/sys/socket.h
---> ./glibc/include/bits/socket.h              # <bits/socket.h>
----> /usr/include/asm/socket.h                 # <asm/socket.h>
-----> /usr/include/asm-generic/socket.h        # <asm-generic/socket.h>
------> /usr/include/asm/sockios.h              # <asm/sockios.h>

grep -Rl "SIOCGSTAMPNS" ./glibc/:
sysdeps/unix/sysv/linux/bits/socket.h

head ./glibc/sysdeps/unix/sysv/linux/bits/socket.h:
...
error "Never include <bits/socket.h> directly: use <sys/socket.h> instead."
...


In a musl libc based system, however, the header file <asm/sockios.h> is probably not imported:

Code:
linux-user/syscall.c
-> /usr/include/sys/socket.h
--> /usr/include/bits/socket.h

qfile /usr/include/bits:
sys-libs/musl

Code:
helecho $ grep -Rl "sockios\.h" ./qemu-2.9.0/
./qemu-bridge-helper.c
helecho $ grep -n "#include" ./qemu-2.9.0/qemu-bridge-helper.c
#include <linux/sockios.h>
helecho $ grep -n "#include" /usr/include/linux/sockios.h
#include <asm/sockios.h>


In my opinion, I would have added #include <linux/sockios.h> in the header file ./qemu-2.9.0/linux-user/ioctls.h
Back to top
View user's profile Send private message
Ant P.
Watchman
Watchman


Joined: 18 Apr 2009
Posts: 6920

PostPosted: Sun Jul 30, 2017 6:01 pm    Post subject: Reply with quote

helecho wrote:
In my opinion, I would have added #include <linux/sockios.h> in the header file ./qemu-2.9.0/linux-user/ioctls.h

Great, so now instead of one missing define you've caused an entire file not found error. Don't post misleading crap where you clearly don't know what you're talking about, this is an obnoxiously common theme with your posts.
Back to top
View user's profile Send private message
Mr. T.
Guru
Guru


Joined: 26 Dec 2016
Posts: 477

PostPosted: Sun Jul 30, 2017 6:13 pm    Post subject: Reply with quote

I do not understand your fuzzy/crazy answer! Please, at least, you have to be polite and respectful.

I may have had to clarify that I did not install qemu. I have only fetch qemu-2.9.0!

edit:

./qemu-2.9.0/linux-user/syscall.c:
 117: #include "qemu.h" # -> ./qemu-2.9.0/linux-user/syscall_defs.h (l.997): #define TARGET_SIOCGSTAMPNS 0x8907
5596: #include "ioctls.h"

grep -n "SIOCGSTAMPNS" ./qemu-2.9.0/linux-user/ioctls.h:
174: IOCTL(SIOCGSTAMPNS, IOC_R, MK_PTR(MK_STRUCT(STRUCT_timespec)))

./qemu-2.9.0/linux-user/syscall.c (line 5589):
static IOCTLEntry ioctl_entries[] = {
#define IOCTL(cmd, access, ...) \
    { TARGET_ ##cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } },
#define IOCTL_SPECIAL(cmd, access, dofn, ...)
    { TARGET_ ##cmd, cmd, #cmd, acces, dofn, { __VA_ARGS__ } },
#define IOCTL_IGNORE(cmd) \
    { TARGET_ ##cmd, 0, #cmd },
#include "ioctls.h"
    { 0, 0, },
};


Maybe, the #include <linux/sockios.h> directive/instruction should be added at the beginning of the ./qemu-2.9.0/linux-user/syscall.c file?

I feel that the above structure is strange!
Back to top
View user's profile Send private message
Mr. T.
Guru
Guru


Joined: 26 Dec 2016
Posts: 477

PostPosted: Mon Jul 31, 2017 6:27 am    Post subject: Reply with quote

Ant. P wrote:
[...] you've caused an entire file not found error [...]

Please, could you post the complete build log? I could make progress as well.

Yamabiko, have you solved the issue? Could you post the complete build log, please? If your issue is solved, please edit your first post and add [SOLVED] to the title.

In addition, in case of resolution, you should indicate how the problem has been solved!

N.B n°1:
We can read the source code of QEMU on GitHub.

N.B n°2: I do not know how the preprocessor parses its content (files) (separately or in a whole). Moreover, the issue could be solved in a more suitable way (e.g. using the "configure" script)?
Back to top
View user's profile Send private message
Mr. T.
Guru
Guru


Joined: 26 Dec 2016
Posts: 477

PostPosted: Tue Aug 01, 2017 6:52 am    Post subject: Reply with quote

yamabiko,

the extract of the build log indicates that the symbol SIOCGSTAMPNS is not declared. The bug tracker of the software does not indicate a build failure related to this symbol.
This symbol must be declared somewhere: either in the source file where it appears or in a header file. We know this symbol is not defined in the header files of glibc,
musl libc or in the header files of the software. Nevertheless, this symbol is defined in the Linux header file <asm/sockios.h> (/usr/include/asm/sockios.h) and is indirectly
included in the glibc header file <sys/socket.h> whereas it is *not included* in the same header file of musl libc. However, we know that the file ./quemu-2.9.0/qemu-bridge-helper.c
includes it indirectly via <linux/sockios.h> so it may be a good idea to include this last one in the file where the undeclared symbol appears: ./qemu-2.9.0/linux-user/syscall.c

helecho.
Back to top
View user's profile Send private message
yamabiko
n00b
n00b


Joined: 22 Jul 2017
Posts: 10

PostPosted: Tue Aug 01, 2017 7:13 am    Post subject: Reply with quote

The workaround suggested by Ant P. works fine. Sorry for the late reply.
Back to top
View user's profile Send private message
Mr. T.
Guru
Guru


Joined: 26 Dec 2016
Posts: 477

PostPosted: Tue Aug 01, 2017 7:28 am    Post subject: Reply with quote

yamabiko wrote:
The workaround suggested by Ant P. works fine. Sorry for the late reply.

Ant. P wrote:
As a temporary workaround, you could try adding "-DSIOCGSTAMPNS=0x8907" to CFLAGS for this one package.

This is a temporary workaround and it is not the best one. Moreover, the issue may be met by other than you: it would have been nice to propose a patch to the musl libc team.

  1. We do not know why the symbol is not declared.
  2. The symbol is only declared during one compilation and for each source file.
  3. This issue will appear again with newer version of qemu.
Back to top
View user's profile Send private message
yamabiko
n00b
n00b


Joined: 22 Jul 2017
Posts: 10

PostPosted: Tue Aug 01, 2017 8:53 am    Post subject: Reply with quote

I'll report the bug to the musl mailing list.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum