joerg-krause / rust-cross-libs

Cross-compile the Rust standard library for custom targets without a full bootstrap build.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to install arm-linux-gcc?

michaelherger opened this issue · comments

I'm trying to follow your instructions in order to build for arm5. You mention using arm-linux-gcc. But how would I install this on eg. Ubuntu 16.04? I do have arm-linux-gnueabi-gcc, but I'd like to use musl instead.

I am using Buildroot to build a musl based toolchain. You can copy the output of the toolchain build to "/usr/local/bin" or create some symlinks. For reference have a look at the manual.

Hmm... copying those files didn't really work. arm-linux-gcc afterwards was looking for arm-linux-gcc.br_real in the wrong place.

So... I changed the export statements for the binaries to point at the output folder. This got me one step further. But now your build script fails lack of compiler-rt submodule:

HEAD ist jetzt bei 1d2a6df384... Auto merge of #43619 - frewsxcv:frewsxcv-thread, r=QuietMisdreavus
error: pathspec 'src/compiler-rt' did not match any file(s) known to git.

Removed that item from the script file. But that was probably a bit naive...

    Updating registry `https://github.com/rust-lang/crates.io-index`
    Updating git repository `https://github.com/rust-lang/cargo`
 Downloading filetime v0.1.10
 Downloading libc v0.2.27
   Compiling gcc v0.3.51
   Compiling libc v0.2.27
   Compiling core v0.0.0 (file:///home/mh/rust-cross-libs/rust-git/src/libcore)
   Compiling libc v0.0.0 (file:///home/mh/rust-cross-libs/rust-git/src/rustc/libc_shim)
   Compiling unwind v0.0.0 (file:///home/mh/rust-cross-libs/rust-git/src/libunwind)
   Compiling filetime v0.1.10
   Compiling compiler_builtins v0.0.0 (file:///home/mh/rust-cross-libs/rust-git/src/rustc/compiler_builtins_shim)
error: couldn't read "/home/mh/rust-cross-libs/rust-git/src/rustc/compiler_builtins_shim/../../libcompiler_builtins/build.rs": No such file or directory (os error 2)

error: Could not compile `compiler_builtins`.
warning: build failed, waiting for other jobs to finish...
error: build failed

I guess I'm lost at this point :-)

I am using symlinks in /usr/local/bin to the Buildroot output directory:

joerg ) ls -l /usr/local/bin/
total 17708
arm-linux-ar -> /home/joerg/buildroot/output/host/usr/bin/arm-linux-ar*
arm-linux-as -> /home/joerg/buildroot/output/host/usr/bin/arm-linux-as*
arm-linux-g++ -> /home/joerg/buildroot/output/host/usr/bin/arm-linux-g++.br_real*
arm-linux-gcc -> /home/joerg/buildroot/output/host/usr/bin/arm-linux-gcc.br_real*
arm-linux-nm -> /home/joerg/buildroot/output/host/usr/bin/arm-linux-nm*
arm-linux-objdump -> /home/joerg/buildroot/output/host/usr/bin/arm-linux-objdump*
arm-linux-readelf -> /home/joerg/buildroot/output/host/usr/bin/arm-linux-readelf*
arm-linux-size -> /home/joerg/buildroot/output/host/usr/bin/arm-linux-size*
arm-linux-strip -> /home/joerg/buildroot/output/host/usr/bin/arm-linux-strip*

I will check if the script still runs...

Rust is porting compiler-rt into Rust and therefore has changed the location of compiler-rt. Commit 81b4605 fixes the issue. The standard library is build now, but I still get linking errors when building hello.

Thanks! Getting further now... but still not working:

   Compiling alloc v0.0.0 (file:///home/mh/rust-cross-libs/rust-git/src/liballoc)
   Compiling alloc_system v0.0.0 (file:///home/mh/rust-cross-libs/rust-git/src/liballoc_system)
   Compiling collections v0.0.0 (file:///home/mh/rust-cross-libs/rust-git/src/libcollections)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-L" "/home/mh/rust-cross-libs/rust/lib/rustlib/armv5te-unknown-linux-musleabi/lib" "/home/mh/rust-cross-libs/rust-git/src/target/armv5te-unknown-linux-musleabi/release/deps/std.0.o" "-o" "/home/mh/rust-cross-libs/rust-git/src/target/armv5te-unknown-linux-musleabi/release/deps/libstd.so" "/home/mh/rust-cross-libs/rust-git/src/target/armv5te-unknown-linux-musleabi/release/deps/std.crate.metadata.o" "/home/mh/rust-cross-libs/rust-git/src/target/armv5te-unknown-linux-musleabi/release/deps/std.crate.allocator.o" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/mh/rust-cross-libs/rust-git/src/target/armv5te-unknown-linux-musleabi/release/deps" "-L" "/home/mh/rust-cross-libs/rust-git/src/target/release/deps" "-L" "/home/mh/rust-cross-libs/rust-git/src/target/armv5te-unknown-linux-musleabi/release/build/compiler_builtins-bde61331e51a7295/out" "-L" "/home/mh/rust-cross-libs/rust/lib/rustlib/armv5te-unknown-linux-musleabi/lib" "-Wl,-Bstatic" "-Wl,--whole-archive" "/tmp/rustc.gTg9Xuj8dESb/libpanic_abort-4cdd35a750c2ac3c.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.gTg9Xuj8dESb/libunwind-a1de818456999d20.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.gTg9Xuj8dESb/librand-581d6275b414ea0c.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.gTg9Xuj8dESb/liballoc_system-507f8c6b1f6a256a.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.gTg9Xuj8dESb/liblibc-62ab0fdf85800f99.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.gTg9Xuj8dESb/liballoc-3033ecb4f421bbb4.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.gTg9Xuj8dESb/libstd_unicode-308f8b4e0fdd739e.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.gTg9Xuj8dESb/libcore-f281291dfb17bc54.rlib" "-Wl,--no-whole-archive" "/tmp/rustc.gTg9Xuj8dESb/libcompiler_builtins-44eb2a0ac190c77d.rlib" "-Wl,-Bdynamic" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread" "-shared"
  = note: /usr/bin/ld: /home/mh/rust-cross-libs/rust-git/src/target/armv5te-unknown-linux-musleabi/release/deps/std.0.o: Relocations in generic ELF (EM: 40)
          /usr/bin/ld: /home/mh/rust-cross-libs/rust-git/src/target/armv5te-unknown-linux-musleabi/release/deps/std.0.o: Relocations in generic ELF (EM: 40)
          /usr/bin/ld: /home/mh/rust-cross-libs/rust-git/src/target/armv5te-unknown-linux-musleabi/release/deps/std.0.o: Relocations in generic ELF (EM: 40)
          /usr/bin/ld: /home/mh/rust-cross-libs/rust-git/src/target/armv5te-unknown-linux-musleabi/release/deps/std.0.o: Relocations in generic ELF (EM: 40)
          /usr/bin/ld: /home/mh/rust-cross-libs/rust-git/src/target/armv5te-unknown-linux-musleabi/release/deps/std.0.o: Relocations in generic ELF (EM: 40)
          /usr/bin/ld: /home/mh/rust-cross-libs/rust-git/src/target/armv5te-unknown-linux-musleabi/release/deps/std.0.o: Relocations in generic ELF (EM: 40)
          /usr/bin/ld: /home/mh/rust-cross-libs/rust-git/src/target/armv5te-unknown-linux-musleabi/release/deps/std.0.o: Relocations in generic ELF (EM: 40)
          /usr/bin/ld: /home/mh/rust-cross-libs/rust-git/src/target/armv5te-unknown-linux-musleabi/release/deps/std.0.o: Relocations in generic ELF (EM: 40)
[...hundreds of these lines...]
          /usr/bin/ld: /home/mh/rust-cross-libs/rust-git/src/target/armv5te-unknown-linux-musleabi/release/deps/std.0.o: Relocations in generic ELF (EM: 40)
          /home/mh/rust-cross-libs/rust-git/src/target/armv5te-unknown-linux-musleabi/release/deps/std.0.o: error adding symbols: File in wrong format
          collect2: error: ld returned 1 exit status
          

error: aborting due to previous error

error: Could not compile `std`.

To learn more, run the command again with --verbose.

I did add --verbose, but this didn't change anything about the result. Would I need to point the build script to arm-linux-ld or something?

You're building with the host linker. Did you run export CC=...? The exports have to be called each time the terminal is opened.

I've pushed another commit cda40d5 which enables the jemalloc feature. This way, I can build the following hello crate:

#![feature(alloc_jemalloc)]
extern crate alloc_jemalloc;

fn main() {
    println!("Hello, world!");
}

I'm away for some days now and will look into this issue later on.

Ok, I think we're getting closer. What I had to do to successfully run your script was to create the .cargo/config file entry and sysroot first. The script then succeeded.

Unfortunately building librespot still fails:

   Compiling librespot v0.1.0 (file:///home/mh/git/librespot)
     Running `rustc --crate-name librespot src/main.rs --crate-type bin --emit=dep-info,link -C opt-level=3 --cfg 'feature="tremor"' --cfg 'feature="with-tremor"' -C metadata=9580186f40a356b6 -C extra-filename=-9580186f40a356b6 --out-dir /home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps --target armv5te-unknown-linux-musleabi -C ar=/usr/local/bin/arm-linux-ar -C linker=/usr/local/bin/arm-unknown-linux-musl-sysroot -L dependency=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps -L dependency=/home/mh/git/librespot/target/release/deps --extern librespot_protocol=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblibrespot_protocol-f84e21ed6630ee45.rlib --extern num_bigint=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libnum_bigint-cd45f088f7d3a338.rlib --extern rand=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/librand-eb7dcc7edb34fe45.rlib --extern serde_json=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libserde_json-8da2f22535a33671.rlib --extern error_chain=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liberror_chain-f855bba8f8999dbf.rlib --extern bit_set=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libbit_set-218f0dd589b86395.rlib --extern protobuf=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libprotobuf-1109ef102abe9912.rlib --extern futures=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libfutures-6cd33d7402659aed.rlib --extern byteorder=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libbyteorder-894c8df8daf0b363.rlib --extern hyper=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libhyper-f27c158a736673f3.rlib --extern mdns=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libmdns-226dc512146c0eb2.rlib --extern log=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblog-3cf4e298ee471219.rlib --extern tempfile=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtempfile-9eb49e65f5eaeab3.rlib --extern env_logger=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libenv_logger-caccdd127e0481c0.rlib --extern linear_map=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblinear_map-b50a94deffd12700.rlib --extern lazy_static=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblazy_static-ba802e28e4b8960a.rlib --extern base64=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libbase64-133939a4cf2fef60.rlib --extern serde_derive=/home/mh/git/librespot/target/release/deps/libserde_derive-e111fa644e03b8e1.so --extern uuid=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libuuid-61a27647e0eca4ec.rlib --extern getopts=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libgetopts-6a2b9910bffd47bd.rlib --extern vorbis=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libvorbis-692d153872d11c66.rlib --extern serde=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libserde-27189a9f4f4ecd49.rlib --extern num_integer=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libnum_integer-384b88c1edb3d048.rlib --extern rpassword=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/librpassword-3ab50e569f3cc076.rlib --extern tokio_core=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtokio_core-529ab5d29ab0769d.rlib --extern tremor=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtremor-d1e8414a75154d66.rlib --extern tokio_signal=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtokio_signal-2fbae690813596fa.rlib --extern tokio_proto=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtokio_proto-4a420acb8204d72f.rlib --extern crypto=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libcrypto-bccd457378813806.rlib --extern num_traits=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libnum_traits-ae2de6548513d5c8.rlib --extern url=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liburl-0630482b0f1be184.rlib --extern shannon=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libshannon-7b50410ce68623ca.rlib --extern librespot=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblibrespot-007b21d8e67244d7.rlib -L native=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/rust-crypto-5030c742ae13b136/out -L native=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/tremor-sys-2ba732d1e9197bf0/out -L native=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/ogg-sys-8642e9f2594fe06c/out -L native=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/vorbis-encoder-451434e56dd76501/out -L native=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/vorbis-sys-7d27ca9652653ff4/out -L native=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/vorbisfile-sys-a5a8e0297d8a5f04/out`
error: linking with `/usr/local/bin/arm-unknown-linux-musl-sysroot` failed: exit code: 1
  |
  = note: "/usr/local/bin/arm-unknown-linux-musl-sysroot" "-L" "/home/mh/git/rust-cross-libs/rust/lib/rustlib/armv5te-unknown-linux-musleabi/lib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/librespot-9580186f40a356b6.0.o" "-o" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/librespot-9580186f40a356b6" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/librespot-9580186f40a356b6.crate.allocator.o" "-Wl,--gc-sections" "-Wl,-O1" "-nodefaultlibs" "-L" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps" "-L" "/home/mh/git/librespot/target/release/deps" "-L" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/rust-crypto-5030c742ae13b136/out" "-L" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/tremor-sys-2ba732d1e9197bf0/out" "-L" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/ogg-sys-8642e9f2594fe06c/out" "-L" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/vorbis-encoder-451434e56dd76501/out" "-L" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/vorbis-sys-7d27ca9652653ff4/out" "-L" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/vorbisfile-sys-a5a8e0297d8a5f04/out" "-L" "/home/mh/git/rust-cross-libs/rust/lib/rustlib/armv5te-unknown-linux-musleabi/lib" "-Wl,-Bstatic" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libenv_logger-caccdd127e0481c0.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtokio_signal-2fbae690813596fa.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libmio_uds-bc81e8012bf054c9.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libregex-d4dca4be613160aa.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libutf8_ranges-73dcda39b40d40fd.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libregex_syntax-7f5f0d9682569172.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libthread_local-c6ff8b4a42f06dcd.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libthread_id-08cbb742174c4bdd.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libaho_corasick-8d0683f2f6470b16.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libmemchr-b136a48c81d3a6e0.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libunreachable-31395280c6f2c1ea.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblibrespot-007b21d8e67244d7.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtremor-d1e8414a75154d66.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtremor_sys-9223ba192159b20c.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libogg_sys-c78ff3931dbbca5b.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblibrespot_protocol-f84e21ed6630ee45.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libuuid-61a27647e0eca4ec.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtempfile-9eb49e65f5eaeab3.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libshannon-7b50410ce68623ca.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/librpassword-3ab50e569f3cc076.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtermios-d885aba9783504eb.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libprotobuf-1109ef102abe9912.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libnum_bigint-cd45f088f7d3a338.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libnum_integer-384b88c1edb3d048.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libmdns-226dc512146c0eb2.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libnix-1449d7ba035f634f.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libvoid-aebacd948e0b1536.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libbitflags-4c542c37938cb5a3.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libmultimap-c83310a2122da1ea.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libdns_parser-c0ed174ce8f2c862.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libquick_error-42e5b0ad3f628d6a.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libbyteorder-3b508cbe72e05cfe.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblinear_map-b50a94deffd12700.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libhyper-f27c158a736673f3.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liburl-0630482b0f1be184.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libidna-0c156d43c5cb4dbb.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libunicode_normalization-c1bc4efb27ce10a3.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libunicode_bidi-129ec38d2d17cc05.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libmatches-d925a273aa2cba35.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libunicase-6880971508ed105b.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtokio_proto-4a420acb8204d72f.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtake-14167b6a7fba60e4.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libsmallvec-21a7ffbfc4d7a277.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtokio_core-529ab5d29ab0769d.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libscoped_tls-1ca741beb5cdb2df.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtokio_io-90c5137fe5704574.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libmio-d0afdb4b888fd58a.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libnet2-c9665e99e222d492.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libcfg_if-dee481c78ed08bae.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblazycell-5f23023108b3ca6f.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libmime-16d56e53e2d18739.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblanguage_tags-b3bee43ac5a198e1.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libhttparse-191105a17849697f.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libfutures_cpupool-52b48c4cab83df27.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libnum_cpus-c6d0660fd30619e2.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libbytes-70ae215f19542c90.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libgetopts-6a2b9910bffd47bd.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libbit_set-218f0dd589b86395.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libbit_vec-9df576f72267d2cd.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libbase64-133939a4cf2fef60.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libserde_json-8da2f22535a33671.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libdtoa-2c2bb90fa808eaac.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libserde-27189a9f4f4ecd49.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libnum_traits-ae2de6548513d5c8.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblog-3cf4e298ee471219.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblazy_static-ba802e28e4b8960a.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liberror_chain-f855bba8f8999dbf.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libitoa-7ccdd8b17762d77a.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libcrypto-bccd457378813806.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtime-8842531faec4e2f3.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/librustc_serialize-94093def06080c1b.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/librand-eb7dcc7edb34fe45.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libiovec-2f1bbbd3bf7e4fd7.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblibc-51257c6f772cd7cc.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libbase64-32e0b56a644068e0.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libbyteorder-894c8df8daf0b363.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libslab-f8463df6aba91be1.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtokio_service-703385ee2a41937f.rlib" "/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libfutures-6cd33d7402659aed.rlib" "/home/mh/git/rust-cross-libs/rust/lib/rustlib/armv5te-unknown-linux-musleabi/lib/libstd.rlib" "/home/mh/git/rust-cross-libs/rust/lib/rustlib/armv5te-unknown-linux-musleabi/lib/libpanic_abort-47695d7ea1b5fd3f.rlib" "/home/mh/git/rust-cross-libs/rust/lib/rustlib/armv5te-unknown-linux-musleabi/lib/libunwind-54eb797aa3d01991.rlib" "/home/mh/git/rust-cross-libs/rust/lib/rustlib/armv5te-unknown-linux-musleabi/lib/liballoc_system-f481f87b8f60754c.rlib" "/home/mh/git/rust-cross-libs/rust/lib/rustlib/armv5te-unknown-linux-musleabi/lib/liblibc-26f26033e675e38f.rlib" "/home/mh/git/rust-cross-libs/rust/lib/rustlib/armv5te-unknown-linux-musleabi/lib/liballoc-a76d7e365cf75933.rlib" "/home/mh/git/rust-cross-libs/rust/lib/rustlib/armv5te-unknown-linux-musleabi/lib/libstd_unicode-ba3a8de78b48e401.rlib" "/home/mh/git/rust-cross-libs/rust/lib/rustlib/armv5te-unknown-linux-musleabi/lib/librand-11c6d5c93ca7d52b.rlib" "/home/mh/git/rust-cross-libs/rust/lib/rustlib/armv5te-unknown-linux-musleabi/lib/libcore-2d8b5f14191b8946.rlib" "/home/mh/git/rust-cross-libs/rust/lib/rustlib/armv5te-unknown-linux-musleabi/lib/libcompiler_builtins-4982dd1ec26532b9.rlib" "-Wl,-Bdynamic" "-l" "c" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "pthread"
  = note: /home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/librespot-9580186f40a356b6.crate.allocator.o: In Funktion `__rust_alloc':
          allocator:(.text.__rust_alloc+0x0): Nicht definierter Verweis auf `__rde_alloc'
          /home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/librespot-9580186f40a356b6.crate.allocator.o: In Funktion `__rust_oom':
          allocator:(.text.__rust_oom+0x0): Nicht definierter Verweis auf `__rde_oom'
          /home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/librespot-9580186f40a356b6.crate.allocator.o: In Funktion `__rust_dealloc':
          allocator:(.text.__rust_dealloc+0x0): Nicht definierter Verweis auf `__rde_dealloc'
          /home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/librespot-9580186f40a356b6.crate.allocator.o: In Funktion `__rust_realloc':
          allocator:(.text.__rust_realloc+0x0): Nicht definierter Verweis auf `__rde_realloc'
          /home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/librespot-9580186f40a356b6.crate.allocator.o: In Funktion `__rust_alloc_zeroed':
          allocator:(.text.__rust_alloc_zeroed+0x0): Nicht definierter Verweis auf `__rde_alloc_zeroed'
          collect2: Fehler: ld gab 1 als Ende-Status zurück
          

error: aborting due to previous error

error: Could not compile `librespot`.

Caused by:
  process didn't exit successfully: `rustc --crate-name librespot src/main.rs --crate-type bin --emit=dep-info,link -C opt-level=3 --cfg feature="tremor" --cfg feature="with-tremor" -C metadata=9580186f40a356b6 -C extra-filename=-9580186f40a356b6 --out-dir /home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps --target armv5te-unknown-linux-musleabi -C ar=/usr/local/bin/arm-linux-ar -C linker=/usr/local/bin/arm-unknown-linux-musl-sysroot -L dependency=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps -L dependency=/home/mh/git/librespot/target/release/deps --extern librespot_protocol=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblibrespot_protocol-f84e21ed6630ee45.rlib --extern num_bigint=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libnum_bigint-cd45f088f7d3a338.rlib --extern rand=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/librand-eb7dcc7edb34fe45.rlib --extern serde_json=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libserde_json-8da2f22535a33671.rlib --extern error_chain=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liberror_chain-f855bba8f8999dbf.rlib --extern bit_set=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libbit_set-218f0dd589b86395.rlib --extern protobuf=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libprotobuf-1109ef102abe9912.rlib --extern futures=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libfutures-6cd33d7402659aed.rlib --extern byteorder=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libbyteorder-894c8df8daf0b363.rlib --extern hyper=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libhyper-f27c158a736673f3.rlib --extern mdns=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libmdns-226dc512146c0eb2.rlib --extern log=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblog-3cf4e298ee471219.rlib --extern tempfile=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtempfile-9eb49e65f5eaeab3.rlib --extern env_logger=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libenv_logger-caccdd127e0481c0.rlib --extern linear_map=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblinear_map-b50a94deffd12700.rlib --extern lazy_static=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblazy_static-ba802e28e4b8960a.rlib --extern base64=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libbase64-133939a4cf2fef60.rlib --extern serde_derive=/home/mh/git/librespot/target/release/deps/libserde_derive-e111fa644e03b8e1.so --extern uuid=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libuuid-61a27647e0eca4ec.rlib --extern getopts=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libgetopts-6a2b9910bffd47bd.rlib --extern vorbis=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libvorbis-692d153872d11c66.rlib --extern serde=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libserde-27189a9f4f4ecd49.rlib --extern num_integer=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libnum_integer-384b88c1edb3d048.rlib --extern rpassword=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/librpassword-3ab50e569f3cc076.rlib --extern tokio_core=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtokio_core-529ab5d29ab0769d.rlib --extern tremor=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtremor-d1e8414a75154d66.rlib --extern tokio_signal=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtokio_signal-2fbae690813596fa.rlib --extern tokio_proto=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libtokio_proto-4a420acb8204d72f.rlib --extern crypto=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libcrypto-bccd457378813806.rlib --extern num_traits=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libnum_traits-ae2de6548513d5c8.rlib --extern url=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liburl-0630482b0f1be184.rlib --extern shannon=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/libshannon-7b50410ce68623ca.rlib --extern librespot=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/deps/liblibrespot-007b21d8e67244d7.rlib -L native=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/rust-crypto-5030c742ae13b136/out -L native=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/tremor-sys-2ba732d1e9197bf0/out -L native=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/ogg-sys-8642e9f2594fe06c/out -L native=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/vorbis-encoder-451434e56dd76501/out -L native=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/vorbis-sys-7d27ca9652653ff4/out -L native=/home/mh/git/librespot/target/armv5te-unknown-linux-musleabi/release/build/vorbisfile-sys-a5a8e0297d8a5f04/out` (exit code: 101)

Thanks a lot for your hand-holding! :-)

This is the same linking error I get. You could try adding the feature macro from the hello example above to the main file of librespot.

I removed the lib-allocation-crate and exe-allocation-crate entries from the config json files. hello builds now without the linking errors.

WOOT! That did it. I started from scratch, following your instructions. Unfortunately the executable doesn't work on the first target platform I tried (a Synology NAS):

Processor : Feroceon 88FR131 rev 1 (v5l)
BogoMIPS : 1589.24
Features : swp half thumb fastmult edsp
CPU implementer : 0x56
CPU architecture: 5TE
CPU variant : 0x2
CPU part : 0x131
CPU revision : 1

The resulting file would report as:
ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-musl-arm.so.1, stripped

Maybe I picked the wrong target when building Buildroot? What ARM architecture would I have to use there?

Oh... it's dynamically linked against musl... how come?!?

Because I am running a musl libc linux system. Therefore, I patch liblibc: https://github.com/joerg-krause/rust-cross-libs/blob/master/patch/liblibc/0001-liblibc-do-not-link-libc-statically-for-ARM-musl.patch

I haven't tried to build a statically linked executable, yet.

Thank you very much for your help. Unfortunately I fear it's too much of a hassle to make this happen... Now the build is complaining about the lack of a static library 'c':

error: could not find native static library `c`, perhaps an -L flag is missing?

error: Could not compile `libc`.
warning: build failed, waiting for other jobs to finish...
error: build failed

I did double-check I configured Buildroot to use must and create static libraries. Alas, I don't get there...

This has nothing to do with Buildroot. Buildroot is used to build the musl-based toolchain. The problem is to tell the Rust build system to link statically. In fact, linking statically is the default for arm and x64 and linking dynamically is the default for mips when using a musl-based toolchain. It can be certainly done. I am busy right now, but I will look into it.

Hi!

I succeeded in building rust apps for a synology DS212 with armv5te and I also succeeded in building spotty and having it play music on the DS212. For me the key was using the toolchain provided by synology.
I document my full steps here. I am pretty sure it answers the question by @michaelherger

My host is Ubuntu 17.04 x86_64 (freshly installed VM in Hyper-V.)

My target is a synology DS212 running DSM 6.1 which according to What_kind_of_CPU_does_my_NAS_have has a Marvell Kirkwood 88F6282 CPU.

Synology provides downloadable toolchains here: synology toolchains

Download the one for DSM 6.1 and 88f62x CPU: 88f62x

Unpack the toolchain to /usr/local:
$ tar Jxvf ~/Downloads/6281-gcc464_glibc215_88f6281-GPL.txz -C /usr/local

Set-up a sysroot.sh file.

$ cat << EOF > /usr/local/arm-marvell-linux-gnueabi/sysroot.sh
#!/bin/bash

SYSROOT=/usr/local/arm-marvell-linux-gnueabi/arm-marvell-linux-gnueabi/libc

/usr/local/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabi-gcc --sysroot=\$SYSROOT \$(echo "\$@" | sed 's/-L \/usr\/lib //g')
EOF

Make the sysroot.sh executable
$ chmod +x /usr/local/arm-marvell-linux-gnueabi/sysroot.sh

Set-up a cargo config file

$ cat << EOF > ~/.cargo/config
[target.armv5te-rcross-linux-gnueabi]
linker = "/usr/local/arm-marvell-linux-gnueabi/sysroot.sh"
ar = "/usr/local/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabi-ar"
EOF

Get the rust source and binaries

$ git clone https://github.com/joerg-krause/rust-cross-libs.git
$ cd rust-cross-libs
$ git clone https://github.com/rust-lang/rust rust-git
$ wget https://static.rust-lang.org/dist/rust-nightly-x86_64-unknown-linux-gnu.tar.gz
$ tar xf rust-nightly-x86_64-unknown-linux-gnu.tar.gz
$ rust-nightly-x86_64-unknown-linux-gnu/install.sh --prefix=$PWD/rust

Define the rust environment

$ export PATH=$PWD/rust/bin:$PATH
$ export LD_LIBRARY_PATH=$PWD/rust/lib
$ export RUST_TARGET_PATH=$PWD/cfg

Define the cross toolchain environment

$ export HOST=x86_64-unknown-linux-gnu
$ export TARGET=armv5te-rcross-linux-gnueabi
$ export CC=/usr/local/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabi-gcc
$ export AR=/usr/local/arm-marvell-linux-gnueabi/bin/arm-marvell-linux-gnueabi-ar
$ export CFLAGS="-Wall -Os -fPIC -D__arm__ -mfloat-abi=soft"

The panic strategy in the armv5te $TARGET.json is abort, so use
$ ./rust-cross-libs.sh --rust-prefix=$PWD/rust --rust-git=$PWD/rust-git --target=$PWD/cfg/$TARGET.json

At this point I created the hello world example and verified it worked on the DS212.

Download the spotty source code
$ git clone https://github.com/michaelherger/spotty

Build spotty with cargo

$ cargo update
$ cargo build --target=$TARGET --release

This failed the first time with a build error in nix 0.8.1 library

I opened the failing file signal.rs in vi
$ vi ~/.cargo/registry/src/github.com-1ecc6299db9ec823/nix-0.8.1/src/sys/signal.rs

and added these line a few lines below “sev.sigev_notify = match sigev_notify”

#[cfg(all(target_os = "linux"))]
SigevNotify::SigevThreadId{..} => libc::SIGEV_THREAD_ID,

I have no idea what this does, I just made sure it builds :-)

Running the cargo build again:
$ cargo build --target=$TARGET --release

this produced a spotty binary :-)

I copied it to the DS212 and verified that it worked there
$ spotty --help

Then I copied it to the LmsRepack plugin location and overwrite the spotty-hf
$ cp spotty /volume1/@appstore/LmsRepack/Cache/InstalledPlugins/Plugins/Spotty/Bin/arm-linux/spotty-hf

I restarted the LMS and entered my spotify username and password in the spotty plugin settings page.
On my squeezebox touch I started the spotty app and I can play music :-)

note: I tried using buildroot at first instead of the synology provided toolchain. With the external Sourcery Codebench ARM 2014.05 toolchain I got a spotty, but it was linked against glibc 2.17 and the DS212 has 2.15 installed, so that didn't work.

@jr01 - Wow... that sounds great! My first attempt failed. But that's most likely to the platform I tried to use because I had it around (Debian Jessie). Downloading Ubuntu right now.

One question: some of the commands obviously need root privileges. Did you run all of this as root, or is it good enough to run do so to extract to /usr/local?

All commands that write to /usr/local need access to that folder, usually that is indeed root. If you are working as a normal user then you need to put sudo in front off those commands.
But it should also be possible to replace /usr/local in everything listed above with a normal users folder, i.e. ~

@michaelherger - it would be great to get this included in the normal spotty plugin release and I can help you if needed. Send me a PM here or on slimforums (same username) if needed ...

@jr01 - the Synology files seem to be 32-bit. I had to add some additional files and support for i386 to make the run

sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386

Didn't you have to do this, too?

@michaelherger - yes I remember now that I had to do something like that. Also I had to apt install git and set the git e-email and name :)

...and with that I finally have my own spotty helper built for those ARMv5 based Synology devices! Thank you both VERY much! I know there will be a bunch of happy users out there.

I'm going to make this available as an optional add-on to the Spotty plugin to those interested, to get some testing. Then include it in the regular plugin distribution. That latter will need some more work for this to work. But that's perfectly fine. Thanks again so much!

@michaelherger - The hack in signal.rs is not needed when env=“gnu” in $PWD/cfg/armv5-rcross-linux-gnueabi.json. The “gnueabi” target was changed to “gnu” in rust.
I have submitted a PR to @joerg-krause

@jr01 Good catch, thanks! Also, thanks for sharing your setup for the Synology. I will later add it to the README.