NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.9k stars 13.95k forks source link

box64: Missing libgcc_s.so.1 when running a x86_64 executable #345301

Open Vcele opened 3 weeks ago

Vcele commented 3 weeks ago

Describe the bug

Box64 is missing "libgcc_s.so.1" when running.

Steps To Reproduce

Steps to reproduce the behavior:

  1. install newest version of box86 from nixpkgs-unstable
  2. run a x86_64 executable
  3. Using native(wrapped) libm.so.6
    Using native(wrapped) librt.so.1
    Using native(wrapped) libdl.so.2
    Using native(wrapped) libpthread.so.0
    Error loading needed lib libgcc_s.so.1
    Using native(wrapped) libc.so.6
    Using native(wrapped) ld-linux-x86-64.so.2
    Using native(wrapped) libutil.so.1
    Using native(wrapped) libbsd.so.0
    Error loading one of needed lib

Expected behavior

Should execute binary.

Additional context

The binary I tried to run was the terraria-server from nixpkgs.

Notify maintainers

@gador @OPNA2608

Metadata

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"aarch64-linux"`
 - host os: `Linux 6.6.52, NixOS, 24.05 (Uakari), 24.05.20240923.babc25a`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.20.3`
 - channels(root): `"nixos-23.11"`
 - nixpkgs: `/nix/store/yn5s22qkqjgj2ibq5glzyh1ngch6rjd0-source`

Add a :+1: reaction to issues you find important.

OPNA2608 commented 6 days ago

@Vcele Could you elaborate on how you got the terraria-server package & how you were trying to run it? This works for me:

↪ nix-build --no-out-link '<nixpkgs>' -A box64
/nix/store/00jw10j4m28521v4scxzkg6wrmj2p654-box64-0.3.0

↪ env NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link '<nixpkgs>' -A terraria-server --argstr crossSystem x86_64-linux
these 2 derivations will be built:
  /nix/store/zg9yhisj2r82cgvkg4gryqlsm07cprv0-terraria-server-1449.zip.drv
  /nix/store/47qv4gas2jbvgnb66hn2rbpwsyiwar7b-terraria-server-1.4.4.9.drv
[...]
/nix/store/17pch1fcwryp6hyyzvdi0byc1z4flm1p-terraria-server-x86_64-unknown-linux-gnu-1.4.4.9

↪ BOX64_NOBANNER=0 BOX64_LOG=1 /nix/store/00jw10j4m28521v4scxzkg6wrmj2p654-box64-0.3.0/bin/box64 /nix/store/17pch1fcwryp6hyyzvdi0byc1z4flm1p-terraria-server-x86_64-unknown-linux-gnu-1.4.4.9/bin/TerrariaServer
Debug level is 1
Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL SHA1 SHA2 PageSize:4096 Running on Unknown CPU with 6 Cores
Will use Hardware counter measured at 24.0 MHz emulating 3.0 GHz
Params database has 14 entries
Box64 with Dynarec v0.3.0 nogit built on Jan  1 1980 00:00:00
BOX64: Detected 48bits at least of address space
Counted 68 Env var
BOX64 LIB PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/
BOX64 BIN PATH: ./:bin/:/run/wrappers/bin/:/home/puna/.nix-profile/bin/:/nix/profile/bin/:/home/puna/.local/state/nix/profile/bin/:/etc/profiles/per-user/puna/bin/:/nix/var/nix/profiles/default/bin/:/run/current-system/sw/bin/
Looking for /nix/store/17pch1fcwryp6hyyzvdi0byc1z4flm1p-terraria-server-x86_64-unknown-linux-gnu-1.4.4.9/bin/TerrariaServer
Rename process to "TerrariaServer.bin.x86_64"
Using native(wrapped) libm.so.6
Using native(wrapped) librt.so.1
Using native(wrapped) libdl.so.2
Using native(wrapped) libpthread.so.0
Using emulated /nix/store/w2rnb23sdrr601ikczaj41x2mpfzvm3g-libgcc-x86_64-unknown-linux-gnu-13.3.0/lib/libgcc_s.so.1
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) libutil.so.1
Using native(wrapped) libbsd.so.0
[...]
Terraria Server v1.4.4.9

n       New World
d <number>  Delete World

Choose World: 

If you built terraria-server on an x86_64-linux system and copied over the binary, or only fetched that package from the cache and none of its dependencies, then you're likely just missing the libgcc_s.so.1 that the binary is linked against. You need to copy over the whole closure (nix-copy-closure).

I tried adding stdenv.cc.cc.libgcc to the LD_LIBRARY_PATH before running box64, but it uses the emulated libgcc_s.so.1 nonetheless. Seems like you can't replace it with a native wrapped one, so the x86_64-linux one needs to be present on your system.

Vcele commented 6 days ago

@Vcele Could you elaborate on how you got the terraria-server package & how you were trying to run it? This works for me:

↪ nix-build --no-out-link '<nixpkgs>' -A box64
/nix/store/00jw10j4m28521v4scxzkg6wrmj2p654-box64-0.3.0

↪ env NIXPKGS_ALLOW_UNFREE=1 nix-build --no-out-link '<nixpkgs>' -A terraria-server --argstr crossSystem x86_64-linux
these 2 derivations will be built:
  /nix/store/zg9yhisj2r82cgvkg4gryqlsm07cprv0-terraria-server-1449.zip.drv
  /nix/store/47qv4gas2jbvgnb66hn2rbpwsyiwar7b-terraria-server-1.4.4.9.drv
[...]
/nix/store/17pch1fcwryp6hyyzvdi0byc1z4flm1p-terraria-server-x86_64-unknown-linux-gnu-1.4.4.9

↪ BOX64_NOBANNER=0 BOX64_LOG=1 /nix/store/00jw10j4m28521v4scxzkg6wrmj2p654-box64-0.3.0/bin/box64 /nix/store/17pch1fcwryp6hyyzvdi0byc1z4flm1p-terraria-server-x86_64-unknown-linux-gnu-1.4.4.9/bin/TerrariaServer
Debug level is 1
Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL SHA1 SHA2 PageSize:4096 Running on Unknown CPU with 6 Cores
Will use Hardware counter measured at 24.0 MHz emulating 3.0 GHz
Params database has 14 entries
Box64 with Dynarec v0.3.0 nogit built on Jan  1 1980 00:00:00
BOX64: Detected 48bits at least of address space
Counted 68 Env var
BOX64 LIB PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/
BOX64 BIN PATH: ./:bin/:/run/wrappers/bin/:/home/puna/.nix-profile/bin/:/nix/profile/bin/:/home/puna/.local/state/nix/profile/bin/:/etc/profiles/per-user/puna/bin/:/nix/var/nix/profiles/default/bin/:/run/current-system/sw/bin/
Looking for /nix/store/17pch1fcwryp6hyyzvdi0byc1z4flm1p-terraria-server-x86_64-unknown-linux-gnu-1.4.4.9/bin/TerrariaServer
Rename process to "TerrariaServer.bin.x86_64"
Using native(wrapped) libm.so.6
Using native(wrapped) librt.so.1
Using native(wrapped) libdl.so.2
Using native(wrapped) libpthread.so.0
Using emulated /nix/store/w2rnb23sdrr601ikczaj41x2mpfzvm3g-libgcc-x86_64-unknown-linux-gnu-13.3.0/lib/libgcc_s.so.1
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) libutil.so.1
Using native(wrapped) libbsd.so.0
[...]
Terraria Server v1.4.4.9

n     New World
d <number>    Delete World

Choose World: 

If you built terraria-server on an x86_64-linux system and copied over the binary, or only fetched that package from the cache and none of its dependencies, then you're likely just missing the libgcc_s.so.1 that the binary is linked against. You need to copy over the whole closure (nix-copy-closure).

I tried adding stdenv.cc.cc.libgcc to the LD_LIBRARY_PATH before running box64, but it uses the emulated libgcc_s.so.1 nonetheless. Seems like you can't replace it with a native wrapped one, so the x86_64-linux one needs to be present on your system.

Last week I found a solution to my problem later I can elaborate more 👍

Vcele commented 6 days ago

I also used the binary from the nix-store. I managed to fix the issue by setting "LD_LIBRARY_PATH" to:

    systemd.services.terraria = {
      serviceConfig = {
        Environment = "LD_LIBRARY_PATH=${pkgsCross.libgcc}/lib";
      };
    };
Vcele commented 6 days ago

Maybe it has something to do with the fact that I used nix options for enabling the server.

OPNA2608 commented 6 days ago

That would've been nice to know for reproducing the issue yeah. And how did you get the service to run the binary through box64? Do you maybe have the entire config / the relevant snippet of it uploaded somewhere?