I started a conversation on Reddit:
but I believe a forum is a better medium for this, as I'm likely to have ongoing doubts about this...
So I'm trying to build stuff for a RG-300 handheld console. It runs Linux and, for instance, comes with a wolf3d port:
$ file wolf3d/wolf3d
wolf3d/wolf3d: ELF 32-bit LSB executable, MIPS, MIPS32 version 1 (SYSV), dynamically linked, interpreter /lib/ld-uClibc.so.0, not stripped
I've been able to cross-compile mipsel-gnu binaries, but they don't seem to work. I don't think I have a good way to troubleshoot that, so I'm trying to cross-compile mipsel-musl binaries... while that's not uclibc like what the system runs, I suppose that could work?
I'm trying to write games, so the example I'm trying to compile is a rust-sdl2 example (actually, the "demo" example). I'm trying out various stuff, but the most promising one so far is:
$ CMAKE_C_COMPILER=mipsel-linux-gnu-gcc cargo build --release --example demo --target mipsel-unknown-linux-musl --features bundled
Compiling sdl2-sys v0.32.6 (/home/alex/git/rust-sdl2/sdl2-sys)
Compiling sdl2 v0.32.2 (/home/alex/git/rust-sdl2)
error: linking with `/usr/bin/mipsel-linux-gnu-gcc` failed: exit code: 1
|
= note: "/usr/bin/mipsel-linux-gnu-gcc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-Wl,--eh-frame-hdr" "-L" "/home/alex/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.demo.efjj4cfb-cgu.0.rcgu.o" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.demo.efjj4cfb-cgu.1.rcgu.o" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.demo.efjj4cfb-cgu.10.rcgu.o" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.demo.efjj4cfb-cgu.11.rcgu.o" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.demo.efjj4cfb-cgu.12.rcgu.o" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.demo.efjj4cfb-cgu.13.rcgu.o" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.demo.efjj4cfb-cgu.14.rcgu.o" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.demo.efjj4cfb-cgu.15.rcgu.o" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.demo.efjj4cfb-cgu.2.rcgu.o" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.demo.efjj4cfb-cgu.3.rcgu.o" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.demo.efjj4cfb-cgu.4.rcgu.o" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.demo.efjj4cfb-cgu.5.rcgu.o" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.demo.efjj4cfb-cgu.6.rcgu.o" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.demo.efjj4cfb-cgu.7.rcgu.o" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.demo.efjj4cfb-cgu.8.rcgu.o" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.demo.efjj4cfb-cgu.9.rcgu.o" "-o" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/examples/demo-cd3dc7739d2262b7.53ka2isznhz5ijg9.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/deps" "-L" "/home/alex/git/rust-sdl2/target/release/deps" "-L" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/build/sdl2-sys-e7b69d6b74505090/out/lib" "-L" "/home/alex/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib" "-Wl,-Bstatic" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/deps/libsdl2-24fc8a218d815f7a.rlib" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/deps/libsdl2_sys-6322dfb6db2ec021.rlib" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/deps/libbitflags-cf0b9a229f903dd1.rlib" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/deps/liblazy_static-5ca797e4c59098f8.rlib" "/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/deps/liblibc-6c67bcfab9b7336f.rlib" "-Wl,--start-group" "/home/alex/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/libstd-b6414ae168385702.rlib" "/home/alex/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/libpanic_unwind-efbc2c947951b8cc.rlib" "/home/alex/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/libhashbrown-b177382d9a04ffbe.rlib" "/home/alex/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/librustc_std_workspace_alloc-ba7d2244d33447d5.rlib" "/home/alex/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/libbacktrace-39569dc87e4ea301.rlib" "/home/alex/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/libbacktrace_sys-cd9e255bd82ddb5c.rlib" "/home/alex/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/librustc_demangle-f83165e777dccb8d.rlib" "/tmp/rustcuPwFMj/libunwind-10b085de263b1750.rlib" "/home/alex/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/libcfg_if-9a4a22edf44da957.rlib" "/tmp/rustcuPwFMj/liblibc-68fabc677efa98de.rlib" "/home/alex/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/liballoc-026dc0061b48e8b6.rlib" "/home/alex/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/librustc_std_workspace_core-7bf75bb619341145.rlib" "/home/alex/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/libcore-ef54709e300503ed.rlib" "-Wl,--end-group" "/home/alex/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/libcompiler_builtins-4ed27d8420cb4abc.rlib" "-Wl,-Bdynamic" "-lSDL2" "-lgcc_s" "-lc"
= note: /usr/lib/gcc-cross/mipsel-linux-gnu/8/../../../../mipsel-linux-gnu/bin/ld: skipping incompatible /home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/build/sdl2-sys-e7b69d6b74505090/out/lib/libSDL2.so when searching for -lSDL2
/usr/lib/gcc-cross/mipsel-linux-gnu/8/../../../../mipsel-linux-gnu/bin/ld: /home/alex/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/mipsel-unknown-linux-musl/lib/libstd-b6414ae168385702.rlib(std-b6414ae168385702.std.2w1w7wxd-cgu.0.rcgu.o): undefined reference to symbol 'dlsym@@GLIBC_2.0'
/usr/lib/gcc-cross/mipsel-linux-gnu/8/../../../../mipsel-linux-gnu/bin/ld: //lib/mipsel-linux-gnu/libdl.so.2: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
error: aborting due to previous error
error: could not compile `sdl2`.
To learn more, run the command again with --verbose.
I believe cmake (run through build.rs using the cmake crate) is ignoring the CMAKE_* env var and creating an x86-64 binary:
$ ls -l /home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/build/sdl2-sys-e7b69d6b74505090/out/lib/libSDL2.so
lrwxrwxrwx 1 alex alex 14 Jan 9 21:15 /home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/build/sdl2-sys-e7b69d6b74505090/out/lib/libSDL2.so -> libSDL2-2.0.so
alex@molly:~/git/rust-sdl2$ ls -l /home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/build/sdl2-sys-e7b69d6b74505090/out/lib/libSDL2-2.0.so
lrwxrwxrwx 1 alex alex 16 Jan 9 21:15 /home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/build/sdl2-sys-e7b69d6b74505090/out/lib/libSDL2-2.0.so -> libSDL2-2.0.so.0
alex@molly:~/git/rust-sdl2$ ls -l /home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/build/sdl2-sys-e7b69d6b74505090/out/lib/libSDL2-2.0.so.0
lrwxrwxrwx 1 alex alex 21 Jan 9 21:15 /home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/build/sdl2-sys-e7b69d6b74505090/out/lib/libSDL2-2.0.so.0 -> libSDL2-2.0.so.0.10.0
alex@molly:~/git/rust-sdl2$ file /home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/build/sdl2-sys-e7b69d6b74505090/out/lib/libSDL2-2.0.so.0.10.0
/home/alex/git/rust-sdl2/target/mipsel-unknown-linux-musl/release/build/sdl2-sys-e7b69d6b74505090/out/lib/libSDL2-2.0.so.0.10.0: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=ee49ab77f8244d1db6123568a0f77fdd142cf7a4, not stripped
Any suggestions? The console comes with a buildroot system, but using an old version which doesn't seem to have Rust support...