Skip to content

Compilation for Chrome OS devices #229

Description

@JLIT0

Would it be possible to make a compilation target for ARM-based Chromebooks running the included Linux runtime?

Activity

  1. ptitSeb commented on Oct 13, 2020

    @ptitSeb
    Owner

    Yes, sure. What would be the CFLAGS parameters tu use (and LDFLAGS also maybe?)

  2. JLIT0 commented on Oct 13, 2020

    @JLIT0
    Author

    About half of the Chrome OS ARM devices are using the Rockchip RK3399, which has the following cflags:

    CFLAGS="--target=aarch64-unknown-linux-gnu -O3 -pipe -march=armv8-a+crc+simd+crypto -mcpu=cortex-a72+crc+simd+crypto"

    Roughly the other half uses the MediaTek MT8173C, which I don't know the cflags for.

  3. ptitSeb commented on Oct 13, 2020

    @ptitSeb
    Owner

    ok, but don't forget box86 is a 32bits apps, and need a 32bits chroot/multiarch/whetever to run on aarch64 linux. That may change at least the --target no?

  4. JLIT0 commented on Oct 13, 2020

    @JLIT0
    Author

    Yep, so we can substitute aarch64 for armhf

    I've just quickly tested, and the Crostini runtime does allow you to add the armhf architecture and run packages within 64-bit Chrome OS on an RK3399, so it shouldn't be an issue.

  5. ptitSeb commented on Dec 31, 2020

    @ptitSeb
    Owner

    I have added support for RK3399 in the CMakeList now. Does the support is enough for this ticket to be closed?

  6. Maccraft123 commented on Dec 31, 2020

    @Maccraft123
  7. kaosushijin commented on Dec 8, 2021

    @kaosushijin

    I'm failing to build with the MT8183. The RK3399 build appears to succeed, but the resulting binary is non-operable.

  8. ptitSeb commented on Dec 8, 2021

    @ptitSeb
    Owner

    MT8183 seems to be Cortex-A73/-A53. How the RK3399 is non-operable? What kind of error do you get?

  9. kaosushijin commented on Dec 8, 2021

    @kaosushijin
    jinx@penguin:~/box86/build$ sudo make install
    Consolidate compiler generated dependencies of target dynarec_arm
    [  3%] Built target dynarec_arm
    [  3%] Built target WRAPPERS
    Consolidate compiler generated dependencies of target arm_pass0
    [ 11%] Built target arm_pass0
    Consolidate compiler generated dependencies of target arm_pass1
    [ 19%] Built target arm_pass1
    Consolidate compiler generated dependencies of target arm_pass2
    [ 27%] Built target arm_pass2
    Consolidate compiler generated dependencies of target arm_pass3
    [ 35%] Built target arm_pass3
    [ 36%] Built target dynarec
    [ 36%] Built target PRINTER
    Consolidate compiler generated dependencies of target box86
    [100%] Built target box86
    Install the project...
    -- Install configuration: "RelWithDebInfo"
    -- Installing: /usr/local/bin/box86
    -- Installing: /etc/binfmt.d/box86.conf
    -- Installing: /usr/lib/i386-linux-gnu/libstdc++.so.6
    -- Installing: /usr/lib/i386-linux-gnu/libstdc++.so.5
    -- Installing: /usr/lib/i386-linux-gnu/libgcc_s.so.1
    jinx@penguin:~/box86/build$ cd
    jinx@penguin:~$ sudo systemctl restart systemd-binfmt
    Job for systemd-binfmt.service failed because the control process exited with error code.
    See "systemctl status systemd-binfmt.service" and "journalctl -xeu systemd-binfmt.service" for details.
    jinx@penguin:~$ box86 -v
    -bash: /usr/local/bin/box86: No such file or directory
    jinx@penguin:~$ box86 --help
    -bash: /usr/local/bin/box86: No such file or directory
    jinx@penguin:~$ 
    
  10. ptitSeb commented on Dec 8, 2021

    @ptitSeb
    Owner

    Ah ok. You are missing the "armhf" multiarch. If you are on debian/armbian/ubuntu, use "sudo dpk --add-architeture armhf && sudo apt update && sudo apt install libc6:armhf" at least to have box86 running. On other OS, you need to use chroot or something similar...

  11. kaosushijin commented on Dec 8, 2021

    @kaosushijin

    Success! Something about the compile instructions gave me the impression that multiarch wouldn't be necessary. Now to fiddle with i386 wine to see if I can get Avernum going. It would be a huge add to this Chromebook. Thanks!

  12. ptitSeb commented on Dec 8, 2021

    @ptitSeb
    Owner

    Good :)

    You will need a few more armhf libs for wine, like x11 and many other. Unfortunatly, I don't have the list.

  13. nhobson99 commented on Jun 12, 2022

    @nhobson99

    I followed similar instructions to build, but used the Snapdragon 845 target since my Chromebook uses a Snapdragon 7C (which I assume is close enough, it's all ARM64). I did indeed have to enable the armhf architecture.

    However, for some reason it doesn't seem to have proper binfmt support.

    pirouette@penguin:~/box86/build$ sudo update-binfmts --display
    box86.conf (disabled):
         package = box86
            type = magic
          offset = 0
           magic = \x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff
            mask = 
     interpreter = /usr/local/bin/box86
        detector = 
    python3.10 (enabled):
         package = python3.10
            type = magic
          offset = 0
           magic = \x6f\x0d\x0d\x0a
            mask = 
     interpreter = /usr/bin/python3.10
        detector = 
    

    This is after manually copying the box86.conf file into /usr/share/binfmts/box86.conf as per #419 , accounting for the differing format since I'm using a Ubuntu 22.04 container on Chrome OS (the default container they give you is Debian Bullseye).

    I also had to manually enable mounting namespaces in Chrome OS, which I had to search for as well. OP can be found here, but the necessary component is:

    1. vmc start termina
    2. From a separate shell-  vmc container termina giraffe --privileged true
    

    Now, if I try to enable binfmt support, I'm shown the following:

    pirouette@penguin:~/box86/build$ sudo update-binfmts --enable
    update-binfmts: warning: unable to close /proc/sys/fs/binfmt_misc/register: Invalid argument
    update-binfmts: exiting due to previous errors
    

    Unfortunately I'm stuck here. Without binfmt support, anything that fork/execs doesn't want to work. Is there something I'm missing?

  14. nhobson99 commented on Jun 14, 2022

    @nhobson99

    I was able to partially fix this issue by doing a few additional things:

    From Crosh

    • Enter termina (vmc launch termina)
    • Inside termina:
      • lxc config set security.nesting true
      • lxc config set security.virtualization true
    • Exit termina, reboot Chrome OS

    After modifying lxc configs, it takes a little longer for the virtual machine to start up. Wait a few minutes to finish updating (it should give you a notification that the virtual machine is being updated), then launch Terminal as usual.

    Now, back in Terminal, update /usr/share/binfmts/box86.conf to read as follows:

    package box86
    interpreter /usr/local/bin/box86
    magic \x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00
    mask \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff
    

    Then sudo update-binfmts --import box86.conf and sudo update-binfmts --enable should just work. Finally after all that work, I receive the following:

    pirouette@penguin:~$ sudo update-binfmts --display
    box86.conf (enabled):
         package = box86
            type = magic
          offset = 0
           magic = \x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00
            mask = \xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff
     interpreter = /usr/local/bin/box86
        detector = 
    

    However, trying to actually run anything just results in box86 not working. Example:

    pirouette@penguin:~$ sudo apt install hello:i386
    pirouette@penguin:~$ hello
    -bash: /usr/bin/hello: No such file or directory
    

    Trying to run Box86 without binfmt does not seem to work either:

    pirouette@penguin:~$ box86 /usr/bin/hello 
    -bash: /usr/local/bin/box86: No such file or directory
    

    I'll keep digging through GitHub and Chrome OS issues to see if I can find anything, but I'm definitely running out of ideas.

    ...

    Additional (important) information: I gave up on Ubuntu 22.04 for the sole reason that it doesn't natively support side-by-side multiarch, meaning I couldn't install libc6:i386 alongside libc6:arm64. I'm now running a custom container with Debian Bookworm (arm64) installed, which is basically just a more up to date version of the default Bullseye container that Terminal sets up by default. If you want to follow along with Ubuntu, you'll need a chroot or proot setup. I'm no expert at that, but there are guides that are relatively easy to follow. You'll still need nesting and virtualization enabled for this to work, as far as I can tell.

    (For those curious, I wanted a variable sized virtual machine, so I had to build the container myself anyway, and I figured I might as well update to Bookworm while I was at it.)

  15. nhobson99 commented on Jun 14, 2022

    @nhobson99

    Ok, partial success after looking at #465 . I completely forgot to install the armhf version of libc6, which as I understand is the interpreter responsible for loading and running 32 bit arm executables (even on arm64).

    I feel very close now to getting this fully working on Crostini. I can run simple text based programs now, still yet to run graphical programs. I'm surely only missing one small piece of the puzzle now.

    Sorry for the... triple post at this point, but I think documenting my experience is worthwhile, and I can make a full writeup when I'm successful in my end goal of launching Steam.

  16. nhobson99 commented on Jun 14, 2022

    @nhobson99

    image

    After some trial and error installing various armhf graphics drivers, I've finally gotten some OpenGL apps to run, including the Linux (Steam) version of VVVVVV! It runs flawlessly, too. I just had to go through steamcmd to download it, but I knew it was one of the few Steam games I own that doesn't actively use the DRM. Others may work by installing a Steam emulator like Goldberg. Will update shortly.

    UPDATE: Goldberg didn't fix games with broken symbols unfortunately.

    Also, I still haven't managed to get to the Steam UI at all, it crashes in the terminal, complaining about Can't find 'steam-runtime-check-requirements', continuing anyway and libstdc++.so.6 Global Symbol __libc_single_threaded. I'll put the full terminal output at the end of this comment for posterity.

    I'm fairly certain I've installed all the necessary libraries for Steam at this point, with an unhealthy mix of arm64, armhf, i386 and amd64 libs, half of which are probably unnecessary, since box86/64 mostly use native armhf libraries. I think the Global Symbol that's missing is the culprit, but not sure how to go about fixing it.

    I also tried installing Steam through Wine (sudo apt install wine64:amd64 wine:i386), which fails with the following output:

    Using native(wrapped) libc.so.6
    Using native(wrapped) ld-linux-x86-64.so.2
    Using native(wrapped) libpthread.so.0
    Using native(wrapped) librt.so.1
    Error loading needed lib /usr/lib/x86_64-linux-gnu/wine/../libwine.so.1
    Warning: Cannot dlopen("/usr/lib/x86_64-linux-gnu/wine/../libwine.so.1"/0xa2d80190, 2)
    Using emulated /usr/lib/x86_64-linux-gnu/wine/libwine.so.1
    Error loading needed lib /usr/lib/x86_64-linux-gnu/wine/kernel32.so
    Warning: Cannot dlopen("/usr/lib/x86_64-linux-gnu/wine/kernel32.so"/0xa2e14960, 2)
    Error loading needed lib /usr/lib/x86_64-linux-gnu/wine/kernelbase.so
    Warning: Cannot dlopen("/usr/lib/x86_64-linux-gnu/wine/kernelbase.so"/0xa2e29300, 2)
    Box86 with Dynarec v0.2.7 4a2ff61f built on Jun 13 2022 21:07:54
    

    I know that Wine at least partially works because I was able to successfully open notepad.exe and cmd.exe. Would installing Winetricks or PlayOnLinux (or any other Wine helper tool) help at all?

    Something interesting I noticed is that running glxgears (i386 using box86 or amd64 using box64) runs much faster with the environment variable LIBGL_ALWAYS_SOFTWARE=1, which is odd. This behavior is not unique to box86/64, however, the armhf and arm64 versions also exhibit this weird behavior.

    ...

    Full steam output:

    pirouette@penguin:~$ steam
    /home/pirouette/.local/share/Steam/steam.sh: line 124: VERSION_ID: unbound variable
    /home/pirouette/.local/share/Steam/steam.sh: line 124: VERSION_ID: unbound variable
    steam.sh[12861]: Running Steam on debian  64-bit
    steam.sh[12861]: STEAM_RUNTIME is enabled by the user
    setup.sh[12923]: Steam runtime environment up-to-date!
    steam.sh[12861]: Can't find 'steam-runtime-check-requirements', continuing anyway
    Box86 with Dynarec v0.2.7 4a2ff61f built on Jun 13 2022 21:07:54
    Error: Global Symbol __libc_single_threaded not found, cannot apply R_386_GLOB_DAT @0xf0b9f914 ((nil)) in /lib/i386-linux-gnu/libstdc++.so.6
    

    EDIT: Clarified on Goldberg Steam emulator, it doesn't fix games with broken Global Symbols

  17. ptitSeb commented on Oct 11, 2022

    @ptitSeb
    Owner

    I'm migrating this ticket to Discussion, that seems more appropriate.

  18. Repository owner locked and limited conversation to collaborators on Oct 11, 2022
  19. converted this issue into a discussion #691 on Oct 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions