dub icon indicating copy to clipboard operation
dub copied to clipboard

Dub does not work inside amd64 docker containers running on M1 processors

Open gedaiu opened this issue 3 years ago • 3 comments
trafficstars

System information

  • DUB version 1.27.0, built on Jan 13 2022
  • Linux b2af8da24c0a 5.10.76-linuxkit #1 SMP PREEMPT Mon Nov 8 11:22:26 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
  • any compiler

Bug Description

Dub does not work inside docker containers running on M1 processors

How to reproduce?

On a mac M1 start a docker container with:

docker run -it  --platform linux/amd64 --volume `pwd`:/app fedora:latest

install any ldc2 or dmd and try to build a project with dub:

root@b2af8da24c0a:/app# dub 
Failed to invoke the compiler /usr/local/bin/ldc2 to determine the build platform: 

Expected Behavior

to build the app

Logs

root@b2af8da24c0a:/app# dub --vverbose
Using dub registry url 'https://code.dlang.org/'
Refreshing local packages (refresh existing: true)...
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /root/.dub/packages/local-packages.json
Looking for local package map at /app/.dub/packages/local-packages.json
iterating dir /root/.dub/packages/
iterating dir /root/.dub/packages/ entry trial-0.7.10
'git --git-dir=/app/.git describe --long --tags' failed with exit code -11: 
'git --git-dir=/app/.git rev-parse --abbrev-ref HEAD' failed with exit code -11: 
Note: Failed to determine version of package app at .. Assuming ~master.
Failed to invoke the compiler /usr/local/bin/ldc2 to determine the build platform: 
Full exception: object.Exception@source/dub/compilers/compiler.d(134): Failed to invoke the compiler /usr/local/bin/ldc2 to determine the build platform: 
----------------
??:? [0x40002bf875]
??:? [0x40002c1306]
??:? [0x40002a29bf]
??:? [0x4000052617]
??:? [0x40001c1e82]
??:? [0x40001c188f]
??:? [0x40001c4949]
??:? [0x4000238965]
??:? [0x400023851b]
??:? [0x4000239415]
??:? [0x400023a8fd]
??:? [0x40001d05de]
??:? [0x40002a26a7]
??:? [0x40002a25a4]
??:? [0x40002a23fd]
??:? __libc_start_main [0x4001de3564]
??:? [0x4000047db9]
root@b2af8da24c0a:/app# 

gedaiu avatar Feb 09 '22 10:02 gedaiu

Looks like dub is the least of your concerns here. Running git is resulting in a segfault. Have a look into that first and fix it, then try the compiler (does /usr/local/bin/ldc2 exist? Is it segfaulting as well?), then dub.

ibuclaw avatar Feb 09 '22 12:02 ibuclaw

Running git outside of dub works well. This might be some kind of issue about how dub is starting the new process.

root@2724d7f59b87:/app# dub --vverbose
Using dub registry url 'https://code.dlang.org/'
Refreshing local packages (refresh existing: true)...
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /root/.dub/packages/local-packages.json
Looking for local package map at /app/.dub/packages/local-packages.json
iterating dir /root/.dub/packages/
iterating dir /root/.dub/packages/ entry trial-0.7.10
'git --git-dir=/app/.git describe --long --tags' failed with exit code -11: 
'git --git-dir=/app/.git rev-parse --abbrev-ref HEAD' failed with exit code -11: 
Note: Failed to determine version of package app at .. Assuming ~master.
Failed to invoke the compiler /usr/local/bin/ldc2 to determine the build platform: 
Full exception: object.Exception@source/dub/compilers/compiler.d(134): Failed to invoke the compiler /usr/local/bin/ldc2 to determine the build platform: 
----------------
??:? [0x40002bf875]
??:? [0x40002c1306]
??:? [0x40002a29bf]
??:? [0x4000052617]
??:? [0x40001c1e82]
??:? [0x40001c188f]
??:? [0x40001c4949]
??:? [0x4000238965]
??:? [0x400023851b]
??:? [0x4000239415]
??:? [0x400023a8fd]
??:? [0x40001d05de]
??:? [0x40002a26a7]
??:? [0x40002a25a4]
??:? [0x40002a23fd]
??:? __libc_start_main [0x4001de3564]
??:? [0x4000047db9]
root@2724d7f59b87:/app# git --git-dir=/app/.git describe --long --tags
v1.19.2-0-g6cacb86
root@2724d7f59b87:/app# git --git-dir=/app/.git rev-parse --abbrev-ref HEAD
master
root@2724d7f59b87:/app# /usr/local/bin/ldc2 --version
LDC - the LLVM D compiler (1.28.1):
  based on DMD v2.098.1 and LLVM 12.0.1
  built with LDC - the LLVM D compiler (1.28.1)
  Default target: x86_64-unknown-linux-gnu
  Host CPU: k8-sse3
  http://dlang.org - http://wiki.dlang.org/LDC

  Registered Targets:
    aarch64    - AArch64 (little endian)
    aarch64_32 - AArch64 (little endian ILP32)
    aarch64_be - AArch64 (big endian)
    amdgcn     - AMD GCN GPUs
    arm        - ARM
    arm64      - ARM64 (little endian)
    arm64_32   - ARM64 (little endian ILP32)
    armeb      - ARM (big endian)
    avr        - Atmel AVR Microcontroller
    mips       - MIPS (32-bit big endian)
    mips64     - MIPS (64-bit big endian)
    mips64el   - MIPS (64-bit little endian)
    mipsel     - MIPS (32-bit little endian)
    msp430     - MSP430 [experimental]
    nvptx      - NVIDIA PTX 32-bit
    nvptx64    - NVIDIA PTX 64-bit
    ppc32      - PowerPC 32
    ppc32le    - PowerPC 32 LE
    ppc64      - PowerPC 64
    ppc64le    - PowerPC 64 LE
    r600       - AMD GPUs HD2XXX-HD6XXX
    riscv32    - 32-bit RISC-V
    riscv64    - 64-bit RISC-V
    thumb      - Thumb
    thumbeb    - Thumb (big endian)
    wasm32     - WebAssembly 32-bit
    wasm64     - WebAssembly 64-bit
    x86        - 32-bit X86: Pentium-Pro and above
    x86-64     - 64-bit X86: EM64T and AMD64
root@2724d7f59b87:/app# 


gedaiu avatar Feb 09 '22 15:02 gedaiu

I debugged the issue a little bit on my mac, and it looks like the execute function from std.process has always a -11 status code. Not sure why, but I'll also try it on my linux machine to see if this happens there too. Could this issue be related to the linuxkit kernel used by the container?

Anyway, this is not a dub issue and it's more like a phobos one....

gedaiu avatar Feb 11 '22 16:02 gedaiu

possibly this issue? https://issues.dlang.org/show_bug.cgi?id=23684

WebFreak001 avatar Feb 13 '23 13:02 WebFreak001

what does ulimit -a print inside the docker container?

WebFreak001 avatar Feb 13 '23 13:02 WebFreak001