ptitSeb / box64

Box64 - Linux Userspace x86_64 Emulator with a twist, targeted at ARM64 Linux devices
https://box86.org
MIT License
3.9k stars 286 forks source link

Building on alpine fails: error: '__uint16_t' undeclared #998

Closed ghost closed 1 year ago

ghost commented 1 year ago

I'm trying to build box64 on alpine, but these errors occurred during build:

ninja: job failed: /usr/bin/gcc -DCONFIG_64BIT -DHAVE_LD80BITS -DNOALIGN -I/workspaces/box64-alpine/src/box64-0.2.4/src/include -I/workspaces/box64-alpine/src/box64-0.2.4/src -I/workspaces/box64-alpine/src/box64-0.2.4/src/wrapped/generated -Os -Wformat -Werror=format-security   -std=gnu11 -funwind-tables -fvisibility=hidden -MD -MT CMakeFiles/interpreter.dir/src/emu/x64run.c.o -MF CMakeFiles/interpreter.dir/src/emu/x64run.c.o.d -o CMakeFiles/interpreter.dir/src/emu/x64run.c.o -c /workspaces/box64-alpine/src/box64-0.2.4/src/emu/x64run.c
/workspaces/box64-alpine/src/box64-0.2.4/src/emu/x64run.c: In function 'Run':
/workspaces/box64-alpine/src/box64-0.2.4/src/emu/x64run.c:1362:36: error: '__uint16_t' undeclared (first use in this function); did you mean 'u_int16_t'?
 1362 |                 emu->segs[_ES] = *(__uint16_t*)(((char*)ED)+4);
      |                                    ^~~~~~~~~~
      |                                    u_int16_t
/workspaces/box64-alpine/src/box64-0.2.4/src/emu/x64run.c:1362:36: note: each undeclared identifier is reported only once for each function it appears in /workspaces/box64-alpine/src/box64-0.2.4/src/emu/x64run.c:1362:47: error: expected expression before ')' token
 1362 |                 emu->segs[_ES] = *(__uint16_t*)(((char*)ED)+4);
      |                                               ^
/workspaces/box64-alpine/src/box64-0.2.4/src/emu/x64run.c:1375:47: error: expected expression before ')' token
 1375 |                 emu->segs[_DS] = *(__uint16_t*)(((char*)ED)+4);
      |                                               ^

I found __uint16_t in glibc/posix/bits/types.h, but can't find it in musl-libc. Is it safe to replace it with u_int16_t in order to pass build?

ptitSeb commented 1 year ago

Building on musl is not supported, because there is no musl->glibc compatibility layer built-in. You can probably use the "ANDROID" profile for that. But, once build, box64 will be able to only run musl x86_64 binary. Are you sure this is what you want to do?

ghost commented 1 year ago

Building on musl is not supported, because there is no musl->glibc compatibility layer built-in. You can probably use the "ANDROID" profile for that. But, once build, box64 will be able to only run musl x86_64 binary. Are you sure this is what you want to do?

Yes, because alpine have wine package, but it's for x86 or x86_64

ptitSeb commented 1 year ago

I don't understand your answer. Do you want to build box64 to run qemu with it?

ghost commented 1 year ago

sorry :) I want to build box64 to run x86_64 wine from alpine packages

ghost commented 1 year ago

I have made a patch of "MUSL Profile" But I'm still unable to linking box64 because something is missing in musl

ld: CMakeFiles/box64.dir/src/elfs/elfloader.c.o: in function `dl_iterate_phdr_findsymbol':
box64/src/elfs/elfloader.c:1839: undefined reference to `dlvsym'
ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibc.c.o: in function `my_scandirat':
box64/src/wrapped/wrappedlibc.c:1926(1924 before patch): undefined reference to `scandirat'
ld: CMakeFiles/box64.dir/src/libtools/threads.c.o: in function `init_pthread_helper':
box64/src/libtools/threads.c:1105(1101 before patch): undefined reference to `dlvsym'
ld: CMakeFiles/box64.dir/src/libtools/obstack.c.o: in function `my_obstack_vprintf':
box64/src/libtools/obstack.c:230: undefined reference to `obstack_vprintf'

Could you please give me some advice?

ghost commented 1 year ago

Give up