ptitSeb / box64

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

build failed while build static box64 binary #310

Open fish4terrisa-MSDSM opened 2 years ago

fish4terrisa-MSDSM commented 2 years ago

The output of ld: /bin/ld: CMakeFiles/box64.dir/src/box64context.c.o: in function NewBox64Context': /home/fish4terrisa/box64/src/box64context.c:177: 警告: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking /bin/ld: CMakeFiles/box64.dir/src/elfs/elfloader.c.o: in function_dl_tlsdesc_undefweak': /home/fish4terrisa/box64/src/elfs/elfloader.c:569: multiple definition of _dl_tlsdesc_undefweak'; /usr/lib/gcc/aarch64-linux-gnu/11/../../../aarch64-linux-gnu/libc.a(dl-tlsdesc.o):(.text+0xc): first defined here /bin/ld: /usr/lib/gcc/aarch64-linux-gnu/11/../../../aarch64-linux-gnu/libc.a(getopt.o):(.data+0x8): multiple definition ofoptopt'; CMakeFiles/box64.dir/src/librarian/globalsymbols.c.o:/usr/include/aarch64-linux-gnu/bits/getopt_core.h:59: first defined here /bin/ld: /usr/lib/gcc/aarch64-linux-gnu/11/../../../aarch64-linux-gnu/libc.a(getopt.o):(.data+0x4): multiple definition of opterr'; CMakeFiles/box64.dir/src/librarian/globalsymbols.c.o:/usr/include/aarch64-linux-gnu/bits/getopt_core.h:55: first defined here /bin/ld: /usr/lib/gcc/aarch64-linux-gnu/11/../../../aarch64-linux-gnu/libc.a(getopt.o):(.data+0x0): multiple definition ofoptind'; CMakeFiles/box64.dir/src/librarian/globalsymbols.c.o:/usr/include/aarch64-linux-gnu/bits/getopt_core.h:50: first defined here /bin/ld: /usr/lib/gcc/aarch64-linux-gnu/11/../../../aarch64-linux-gnu/libc.a(getopt.o):(.bss+0x38): multiple definition of optarg'; CMakeFiles/box64.dir/src/librarian/globalsymbols.c.o:/usr/include/aarch64-linux-gnu/bits/getopt_core.h:36: first defined here /bin/ld: CMakeFiles/box64.dir/src/emu/x64run0f.c.o: in functionRun0F': /home/fish4terrisa/box64/src/emu/x64run0f.c:363: undefined reference to sqrtf' /home/fish4terrisa/box64/src/emu/x64run0f.c:363:(.text+0x1664): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbolsqrtf' /bin/ld: /home/fish4terrisa/box64/src/emu/x64run0f.c:379: undefined reference to sqrtf' /home/fish4terrisa/box64/src/emu/x64run0f.c:379:(.text+0x4640): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbolsqrtf' /bin/ld: CMakeFiles/box64.dir/src/emu/x64run660f.c.o: in function Run660F': /home/fish4terrisa/box64/src/emu/x64run660f.c:853: undefined reference tosqrt' /home/fish4terrisa/box64/src/emu/x64run660f.c:853:(.text+0x648): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol sqrt' /bin/ld: /home/fish4terrisa/box64/src/emu/x64run660f.c:853: undefined reference tosqrt' /home/fish4terrisa/box64/src/emu/x64run660f.c:853:(.text+0x668): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol sqrt' /bin/ld: CMakeFiles/box64.dir/src/emu/x64rund9.c.o: in functionRunD9': /home/fish4terrisa/box64/src/emu/x64rund9.c:203: undefined reference to cos' /home/fish4terrisa/box64/src/emu/x64rund9.c:203:(.text+0x1a0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbolcos' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:199: undefined reference to sin' /home/fish4terrisa/box64/src/emu/x64rund9.c:199:(.text+0x1d0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbolsin' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:187: undefined reference to sincos' /home/fish4terrisa/box64/src/emu/x64rund9.c:187:(.text+0x298): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbolsincos' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:183: undefined reference to sqrt' /home/fish4terrisa/box64/src/emu/x64rund9.c:183:(.text+0x2d8): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbolsqrt' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:179: undefined reference to log2' /home/fish4terrisa/box64/src/emu/x64rund9.c:179:(.text+0x2fc): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbollog2' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:120: undefined reference to atan2' /home/fish4terrisa/box64/src/emu/x64rund9.c:120:(.text+0x524): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbolatan2' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:114: undefined reference to tan' /home/fish4terrisa/box64/src/emu/x64rund9.c:114:(.text+0x570): 从输出所省略的额外重寻址溢出 /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:107: undefined reference toexp2' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:167: undefined reference to exp2' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:168: undefined reference toexp2' /bin/ld: /home/fish4terrisa/box64/src/emu/x64rund9.c:196: undefined reference to exp2' /bin/ld: CMakeFiles/box64.dir/src/emu/x64runf20f.c.o: in functionRunF20F': /home/fish4terrisa/box64/src/emu/x64runf20f.c:133: undefined reference to sqrt' /bin/ld: CMakeFiles/box64.dir/src/emu/x64runf30f.c.o: in functionRunF30F': /home/fish4terrisa/box64/src/emu/x64runf30f.c:142: undefined reference to sqrtf' /bin/ld: /home/fish4terrisa/box64/src/emu/x64runf30f.c:136: undefined reference tosqrtf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___powf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:49: undefined reference topowf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___pow_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:50: undefined reference topow' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___sinhf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:51: undefined reference tosinhf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___sinh_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:52: undefined reference tosinh' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___sqrtf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:53: undefined reference tosqrtf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___sqrt_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:54: undefined reference tosqrt' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___acosf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:55: undefined reference toacosf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___acos_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:56: undefined reference toacos' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___acoshf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:57: undefined reference toacoshf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___acosh_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:58: undefined reference toacosh' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___asinf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:59: undefined reference toasinf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___asin_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:60: undefined reference toasin' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___atan2f_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:61: undefined reference toatan2f' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___atan2_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:62: undefined reference toatan2' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___coshf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:63: undefined reference tocoshf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___cosh_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:64: undefined reference tocosh' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___exp2f_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:65: undefined reference toexp2f' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___exp2_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:66: undefined reference toexp2' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___expf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:67: undefined reference toexpf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___exp_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:68: undefined reference toexp' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___hypotf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:69: undefined reference tohypotf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___hypot_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:70: undefined reference tohypot' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___log10f_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:71: undefined reference tolog10f' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___log10_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:72: undefined reference tolog10' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___log2f_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:73: undefined reference tolog2f' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___log2_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:74: undefined reference tolog2' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___logf_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:75: undefined reference tologf' /bin/ld: CMakeFiles/box64.dir/src/wrapped/wrappedlibm.c.o: in function my___log_finite': /home/fish4terrisa/box64/src/wrapped/wrappedlibm.c:76: undefined reference tolog' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_f2xm1': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:47: undefined reference toexp2' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_fyl2x': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:51: undefined reference tolog2' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_ftan': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:55: undefined reference totan' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_fpatan': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:60: undefined reference toatan2' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_fxtract': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:66: undefined reference toexp2' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_fyl2xp1': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:80: undefined reference tolog2' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_fsincos': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:84: undefined reference tosincos' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_fscale': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:94: undefined reference toexp2' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_fsin': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:98: undefined reference tosin' /bin/ld: libdynarec.a(dynarec_arm64_functions.c.o): in function arm_fcos': /home/fish4terrisa/box64/src/dynarec/arm64/dynarec_arm64_functions.c:103: undefined reference tocos' collect2: error: ld returned 1 exit status make[2]: [CMakeFiles/box64.dir/build.make:3839:box64] 错误 1 make[1]: [CMakeFiles/Makefile2:284:CMakeFiles/box64.dir/all] 错误 2 make: *** [Makefile:166:all] 错误 2@

ptitSeb commented 2 years ago

What did you do to have a static build?

fish4terrisa-MSDSM commented 2 years ago

To port box64 to termux. :-) static binaries works well on termux

ptitSeb commented 2 years ago

Not asking why, but how, so I can reproduce on my side.

fish4terrisa-MSDSM commented 2 years ago

l just add these lines after the first line of CMakeLists.txt: set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") set(BUILD_SHARED_LIBS OFF) set(CMAKE_EXE_LINKER_FLAGS "-static") so the first lines of it is

cmake_minimum_required(VERSION 3.4) set(CMAKE_FIND_LIBRARY_SUFFIXES ".a") set(BUILD_SHARED_LIBS OFF) set(CMAKE_EXE_LINKER_FLAGS "-static")

fish4terrisa-MSDSM commented 2 years ago

(there are few lines ,but github just showed it as one line)

ptitSeb commented 2 years ago

Ok, I'll try to get a solution for static build.

fish4terrisa-MSDSM commented 2 years ago

Thank you.

TheRemote commented 2 years ago

I'd also like a static build of this (use as a drop-in replacement for QEMU inside a Docker container but I know you didn't ask).

I kept running across issue #146 when googling if anyone had a static build of this just publicly available. I almost commented on that very old issue before I saw this one from much more recently.

I have had multiple people say box64 is much faster than QEMU for running the Minecraft Bedrock server (only available in x86_64) in comments / issues on some of my projects that run on aarch64. It makes it go from pretty laggy on Raspberry Pi to almost perfect.

At any rate consider this seconded for purposes of embedded devices / multiarch / other useful scenarios that if you spend the time on this will be utilized by downstream projects. Thanks!

Ristovski commented 8 months ago

@ptitSeb Any progress on this? The main use case would be a drop-in replacment for qemu-user-static as @TheRemote already mentioned.

ptitSeb commented 8 months ago

I did nome testing not too long ago about this but without getting good result. I need to use a more drastic approach on this to succeed. Not sure when I'll work on this tho, it's quite a heavy change I have in mind.

fish4terrisa-MSDSM commented 8 months ago

@ptitSeb Any progress on this? The main use case would be a drop-in replacment for qemu-user-static as @TheRemote already mentioned.

And, if it can replace qemu-user-static , it would also be possible to combine box64 with proot.

ptitSeb commented 8 months ago

@ptitSeb Any progress on this? The main use case would be a drop-in replacment for qemu-user-static as @TheRemote already mentioned.

And, if it can replace qemu-user-static , it would also be possible to combine box64 with proot.

Well yeah, but to do what? the static build of box64 will have (very) limited wrapped functionnality. So no wrapped opengl, vulkan or pulse audio. Basicaly, it can be use for headless server stuffs, but not for gaming.

ptitSeb commented 8 months ago

Finaly got a static build of box64. I have just tested the integrated test and they works. Running bash doesn't work because I'm not on a x86_64 chroot. There are some limitation of the static build: mainly: no lib wrapping. It might still work for headless usecases.

shenmo7192 commented 7 months ago

Finaly got a static build of box64. I have just tested the integrated test and they works. Running bash doesn't work because I'm not on a x86_64 chroot. There are some limitation of the static build: mainly: no lib wrapping. It might still work for headless usecases.

In file included from /home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlibbsd.c:42:
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlibbsd_private.h:5:4: error: ‘arc4random’ undeclared here (not in a function); did you mean ‘srandom’?
 GO(arc4random, uFv)
    ^~~~~~~~~~
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlib_init.h:48:30: note: in definition of macro ‘GO’
 #define GO(N, W) {#N, W, 0, &N},
                              ^
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlibbsd_private.h:7:4: error: ‘arc4random_buf’ undeclared here (not in a function); did you mean ‘arc4random_stir’?
 GO(arc4random_buf, vFpL)
    ^~~~~~~~~~~~~~
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlib_init.h:48:30: note: in definition of macro ‘GO’
 #define GO(N, W) {#N, W, 0, &N},
                              ^
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlibbsd_private.h:9:4: error: ‘arc4random_uniform’ undeclared here (not in a function); did you mean ‘arc4random_stir’?
 GO(arc4random_uniform, uFu)
    ^~~~~~~~~~~~~~~~~~
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlib_init.h:48:30: note: in definition of macro ‘GO’
 #define GO(N, W) {#N, W, 0, &N},
                              ^
make[2]: *** [CMakeFiles/box64.di

Failed to build on gcc8 with -D STATICBUILD=1

Should i use a newer compiler?

ptitSeb commented 7 months ago

No, that's libbsd symbols here. tbh, I'm not sure on what I should do with them. I want to exclude them, but recent gcc/glibc (?) seems to consider they are default and later libstdc++ use them.

shenmo7192 commented 7 months ago

No, that's libbsd symbols here. tbh, I'm not sure on what I should do with them. I want to exclude them, but recent gcc/glibc (?) seems to consider they are default and later libstdc++ use them.

Roger

wuzw10 commented 5 months ago

Finaly got a static build of box64. I have just tested the integrated test and they works. Running bash doesn't work because I'm not on a x86_64 chroot. There are some limitation of the static build: mainly: no lib wrapping. It might still work for headless usecases.

In file included from /home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlibbsd.c:42:
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlibbsd_private.h:5:4: error: ‘arc4random’ undeclared here (not in a function); did you mean ‘srandom’?
 GO(arc4random, uFv)
    ^~~~~~~~~~
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlib_init.h:48:30: note: in definition of macro ‘GO’
 #define GO(N, W) {#N, W, 0, &N},
                              ^
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlibbsd_private.h:7:4: error: ‘arc4random_buf’ undeclared here (not in a function); did you mean ‘arc4random_stir’?
 GO(arc4random_buf, vFpL)
    ^~~~~~~~~~~~~~
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlib_init.h:48:30: note: in definition of macro ‘GO’
 #define GO(N, W) {#N, W, 0, &N},
                              ^
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlibbsd_private.h:9:4: error: ‘arc4random_uniform’ undeclared here (not in a function); did you mean ‘arc4random_stir’?
 GO(arc4random_uniform, uFu)
    ^~~~~~~~~~~~~~~~~~
/home/shenmo-ikun/Desktop/box64/src/wrapped/wrappedlib_init.h:48:30: note: in definition of macro ‘GO’
 #define GO(N, W) {#N, W, 0, &N},
                              ^
make[2]: *** [CMakeFiles/box64.di

Failed to build on gcc8 with -D STATICBUILD=1

Should i use a newer compiler?

I have encountered same problem while staticlly building box64 with gcc11.