ptitSeb / box64

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

/usr/bin/cc - broken when cmake -DRPI4ARM64=1 #357

Open entewurzelauskuh opened 2 years ago

entewurzelauskuh commented 2 years ago

Hi! I was following this tutorial: https://www.reddit.com/r/valheim/comments/s1os21/create_your_own_free_dedicated_server/

Like written in the post, I'm running a Linux instance1 5.15.0-1013-oracle #17-Ubuntu SMP Fri Jun 24 10:14:16 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux from the Free Tier subscription of Oracle Cloud.

I had no problems with box86, but when I tried cmake .. -DRPI4ARM64=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo with box64, I got this error from cmake:

-- Found Python3: /usr/bin/python3.10 (found version "3.10.4") found components: Interpreter
-- The C compiler identification is unknown
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc - broken
CMake Error at /usr/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "/usr/bin/cc"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/fred/box64/build/CMakeFiles/CMakeTmp

    Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_ae2bb/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_ae2bb.dir/build.make CMakeFiles/cmTC_ae2bb.dir/build
    gmake[1]: Entering directory '/home/fred/box64/build/CMakeFiles/CMakeTmp'
    Building C object CMakeFiles/cmTC_ae2bb.dir/testCCompiler.c.o
    /usr/bin/cc    -o CMakeFiles/cmTC_ae2bb.dir/testCCompiler.c.o -c /home/fred/box64/build/CMakeFiles/CMakeTmp/testCCompiler.c
    Assembler messages:
    Error: unrecognized option -mabi=lp64
    gmake[1]: *** [CMakeFiles/cmTC_ae2bb.dir/build.make:78: CMakeFiles/cmTC_ae2bb.dir/testCCompiler.c.o] Error 1
    gmake[1]: Leaving directory '/home/fred/box64/build/CMakeFiles/CMakeTmp'
    gmake: *** [Makefile:127: cmTC_ae2bb/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:75 (project)

-- Configuring incomplete, errors occurred!
See also "/home/fred/box64/build/CMakeFiles/CMakeOutput.log".
See also "/home/fred/box64/build/CMakeFiles/CMakeError.log".

If others are able to run it in the oracle cloud using the free and their aarch64, why am I not? Is that a bug or am I just stupid?

entewurzelauskuh commented 2 years ago

I tried suppressing the test program with cmake -D CMAKE_C_COMPILER_WORKS=1 .. -DRPI4ARM64=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo but then I ran into make -j$(nproc):

Scanning dependencies of target dynarec_native
[  0%] Built target WRAPPERS
[  1%] Building C object CMakeFiles/dynarec_native.dir/src/dynarec/dynablock.c.o
[  1%] Building C object CMakeFiles/dynarec_native.dir/src/dynarec/dynarec_native.c.o
[  1%] Building C object CMakeFiles/dynarec_native.dir/src/dynarec/arm64/dynarec_arm64_functions.c.o
Assembler messages:
Scanning dependencies of target native_pass0
Error: unrecognized option -mabi=lp64
Assembler messages:
Error: unrecognized option -mabi=lp64
Assembler messages:
Error: unrecognized option -mabi=lp64
make[2]: *** [CMakeFiles/dynarec_native.dir/build.make:88: CMakeFiles/dynarec_native.dir/src/dynarec/dynarec_native.c.o] Error 2
make[2]: *** Waiting for unfinished jobs....
Scanning dependencies of target native_pass1
[  1%] Building C object CMakeFiles/native_pass0.dir/src/dynarec/arm64/dynarec_arm64_helper.c.o
make[2]: *** [CMakeFiles/dynarec_native.dir/build.make:75: CMakeFiles/dynarec_native.dir/src/dynarec/dynablock.c.o] Error 2
[  2%] Building C object CMakeFiles/native_pass0.dir/src/dynarec/arm64/dynarec_arm64_emit_tests.c.o
Assembler messages:
Error: unrecognized option -mabi=lp64
make[2]: *** [CMakeFiles/dynarec_native.dir/build.make:101: CMakeFiles/dynarec_native.dir/src/dynarec/arm64/dynarec_arm64_functions.c.o] Error 2
make[1]: *** [CMakeFiles/Makefile2:123: CMakeFiles/dynarec_native.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Assembler messages:
Error: unrecognized option -mabi=lp64
[  2%] Building C object CMakeFiles/native_pass1.dir/src/dynarec/arm64/dynarec_arm64_helper.c.o
[  3%] Building C object CMakeFiles/native_pass1.dir/src/dynarec/arm64/dynarec_arm64_emit_tests.c.o
Assembler messages:
Error: unrecognized option -mabi=lp64
Assembler messages:
Error: unrecognized option -mabi=lp64
make[2]: *** [CMakeFiles/native_pass0.dir/build.make:88: CMakeFiles/native_pass0.dir/src/dynarec/arm64/dynarec_arm64_emit_tests.c.o] Error 2
make[2]: *** Waiting for unfinished jobs....
make[2]: *** [CMakeFiles/native_pass0.dir/build.make:75: CMakeFiles/native_pass0.dir/src/dynarec/arm64/dynarec_arm64_helper.c.o] Error 2
make[1]: *** [CMakeFiles/Makefile2:149: CMakeFiles/native_pass0.dir/all] Error 2
[  3%] Building C object CMakeFiles/native_pass1.dir/src/dynarec/arm64/dynarec_arm64_emit_math.c.o
[  3%] Building C object CMakeFiles/native_pass1.dir/src/dynarec/arm64/dynarec_arm64_emit_logic.c.o
make[2]: *** [CMakeFiles/native_pass1.dir/build.make:88: CMakeFiles/native_pass1.dir/src/dynarec/arm64/dynarec_arm64_emit_tests.c.o] Error 2
make[2]: *** Waiting for unfinished jobs....
Assembler messages:
Error: unrecognized option -mabi=lp64
Assembler messages:
Error: unrecognized option -mabi=lp64
make[2]: *** [CMakeFiles/native_pass1.dir/build.make:75: CMakeFiles/native_pass1.dir/src/dynarec/arm64/dynarec_arm64_helper.c.o] Error 2
make[2]: *** [CMakeFiles/native_pass1.dir/build.make:114: CMakeFiles/native_pass1.dir/src/dynarec/arm64/dynarec_arm64_emit_logic.c.o] Error 2
make[2]: *** [CMakeFiles/native_pass1.dir/build.make:101: CMakeFiles/native_pass1.dir/src/dynarec/arm64/dynarec_arm64_emit_math.c.o] Error 2
make[1]: *** [CMakeFiles/Makefile2:175: CMakeFiles/native_pass1.dir/all] Error 2
make: *** [Makefile:166: all] Error 2
ptitSeb commented 2 years ago

I don't know what happens, but your cmake configuration seems completly broken. delete the build forlder and start over. There is no -mab=lp64 in box64 CMakeList.txt

Jai-JAP commented 2 years ago

Try reinstalling build-essentials On debian or ubuntu thats sudo apt install --reinstall -y build-essential

entewurzelauskuh commented 2 years ago

Done both, sudo apt install --reinstall gcc build-essential gcc-arm-linux-gnueabihf libc6:armhf libncurses5:armhf libstdc++6:armhf and deleted build folder, ran cmake .. -DRPI4ARM64=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo, same issue. I'm sorry if I'm too novice in that, if you need any output please let me know

Jai-JAP commented 2 years ago

Try deleting box64 folder and reclone Also what os do use

entewurzelauskuh commented 2 years ago

Tried deleting and recloned, unfortunately same issue still uname -a Linux instance1 5.15.0-1013-oracle #17-Ubuntu SMP Fri Jun 24 10:14:16 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux cat /etc/lsb_release cat: /etc/lsb_release: No such file or directory

entewurzelauskuh commented 2 years ago

Yea, it's a free VPS from Oracle: https://www.oracle.com/cloud/free/, Arm-based Ampere A1 cores I was wondering why it seemed to work for everyone else from the reddit thread with Oracle's Ampere VPS, but not for me

Jai-JAP commented 2 years ago

Post the output of ls -l /usr/bin/cc

entewurzelauskuh commented 2 years ago

ls -l /usr/bin/cc lrwxrwxrwx 1 root root 20 Jul 22 21:26 /usr/bin/cc -> /etc/alternatives/cc

Jai-JAP commented 2 years ago

update-alternatives --query cc

entewurzelauskuh commented 2 years ago

update-alternatives --query cc

Name: cc
Link: /usr/bin/cc
Slaves:
 cc.1.gz /usr/share/man/man1/cc.1.gz
Status: auto
Best: /usr/bin/gcc
Value: /usr/bin/gcc

Alternative: /usr/bin/gcc
Priority: 20
Slaves:
 cc.1.gz /usr/share/man/man1/gcc.1.gz
Jai-JAP commented 2 years ago

Oops typo update-alternatives --query gcc

entewurzelauskuh commented 2 years ago

ls -l /usr/bin/gcc lrwxrwxrwx 1 root root 6 Aug 5 2021 /usr/bin/gcc -> gcc-11 update-alternatives --query gcc update-alternatives: error: no alternatives for gcc

Jai-JAP commented 2 years ago

ls -l /usr/bin/gcc-11

entewurzelauskuh commented 2 years ago

ls -l /usr/bin/gcc-11 lrwxrwxrwx 1 root root 24 Mar 24 14:22 /usr/bin/gcc-11 -> aarch64-linux-gnu-gcc-11

Jai-JAP commented 2 years ago

That should be good Can't tell what the error is based on this info

entewurzelauskuh commented 2 years ago

No problem, thanks for your time mate! Maybe somebody else has another idea

PeterStrick commented 2 years ago

No problem, thanks for your time mate! Maybe somebody else has another idea.

I build box64 successfully on an Ampere ARM instance running Ubuntu 22.04 with the following script:

#!/bin/sh
rm -rf box64
git clone https://github.com/ptitSeb/box64
cd box64
mkdir build; cd build; cmake .. -DARM_DYNAREC=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo
make -j$(nproc)
sudo make install
sudo systemctl restart systemd-binfmt

You´ll need the following dependencies

sudo apt install make cmake build-essential git
PeterStrick commented 2 years ago

Alternatively you could also just use daily pre-compiled binaries https://github.com/ptitSeb/box64/blob/main/docs/COMPILE.md#debian-based-linux

entewurzelauskuh commented 2 years ago

I executed sudo apt install make cmake build-essential git, all of that was already present but to be sure I added --reinstall. I then tried cmake .. -DARM_DYNAREC=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo but I still got the same error. Dang, no idea what's wrong with my machine. I added the repo and installing the binary from there seemed to work, thanks for the tip!

PeterStrick commented 2 years ago

I executed sudo apt install make cmake build-essential git, all of that was already present but to be sure I added --reinstall. I then tried cmake .. -DARM_DYNAREC=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo but I still got the same error. Dang, no idea what's wrong with my machine. I added the repo and installing the binary from there seemed to work, thanks for the tip!

No problem, just a hint the box64 binary only updates from the repo if you run sudo apt upgrade

jserv commented 1 month ago

Is this issue still valid?