andrewrk / sdl-zig-demo

SDL2 hello world in zig
MIT License
116 stars 20 forks source link

cross compiling to mips (RG350/gcw0) leads to segfault #7

Open asynkayo opened 4 years ago

asynkayo commented 4 years ago

Hi, I've been trying to make this work on my RG350 (which is basically http://www.gcw-zero.com/specifications). I'm using this command to compile the code:

zig build-exe main.zig \
    # --strip \
    --single-threaded \
    --release-safe \
    --libc libc_paths \
    -target mipsel-linux-gnu \
    -L /opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/lib \
    -I /opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/include \
    -L /opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib \
    -I /opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include \
    -lSDL2

This buids fine but when I transfer it to the device and run it, it segfaults. I guess this has something to do with the fact that I'm using this target triple: "mipsel-linux-gnu" and the fact that zig does not ship uClibc... Is there a way to make this work ? Thanks

asynkayo commented 4 years ago

By the way here is the file I use for libc paths:

# The directory that contains `stdlib.h`.
# On POSIX-like systems, include directories be found with: `cc -E -Wp,-v -xc /dev/null`
include_dir=/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include

# The system-specific include directory. May be the same as `include_dir`.
# On Windows it's the directory that includes `vcruntime.h`.
# On POSIX it's the directory that includes `sys/errno.h`.
sys_include_dir=/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include/

# The directory that contains `crt1.o` or `crt2.o`.
# On POSIX, can be found with `cc -print-file-name=crt1.o`.
# Not needed when targeting MacOS.
crt_dir=/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib

# The directory that contains `vcruntime.lib`.
# Only needed when targeting MSVC on Windows.
msvc_lib_dir=

# The directory that contains `kernel32.lib`.
# Only needed when targeting MSVC on Windows.
kernel32_lib_dir=