rust-cross / rust-musl-cross

Docker images for compiling static Rust binaries using musl-cross
MIT License
620 stars 68 forks source link

Cross-compilation libudev-sys #13

Closed xoac closed 5 years ago

xoac commented 6 years ago

Hi, I have a problem with cross-compile example tokio-serial. I described the problem on tokio-serial issue - but I think here should be more people that can manage this problem.

messense commented 6 years ago

Try it with apt-get update && apt-get install -y pkg-config && YOUR_COMMAND

xoac commented 6 years ago

Hi, thx for quick response. Here is the result:

error: linking with `armv7-unknown-linux-musleabihf-gcc` failed: exit code: 1
  |
  = note: "armv7-unknown-linux-musleabihf-gcc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-nostdlib" "-Wl,--eh-frame-hdr" "-Wl,-(" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib/crt1.o" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib/crti.o" "-L" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/mtcp_tokio_test-586b127ba98e05b6.1y16o1qfye96o7m0.rcgu.o" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/mtcp_tokio_test-586b127ba98e05b6.3rngp6bm2u2q5z0y.rcgu.o" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/mtcp_tokio_test-586b127ba98e05b6.4tya8504jph8aqpv.rcgu.o" "-o" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/mtcp_tokio_test-586b127ba98e05b6" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/mtcp_tokio_test-586b127ba98e05b6.crate.allocator.rcgu.o" "-Wl,--gc-sections" "-no-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "-L" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps" "-L" "/home/rust/src/target/debug/deps" "-L" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/build/backtrace-sys-d2d149ec40f93565/out" "-L" "/usr/lib/x86_64-linux-gnu" "-L" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib" "-Wl,-Bstatic" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib/liballoc_jemalloc-f68d8e8245e507c6.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib/libtest-ba7fd7d6fe5b5d5e.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib/libterm-11634d939d68f20a.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib/libgetopts-abaed018c96e2d07.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libtokio_serial-f600eca6920dfb53.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libmio_serial-7ab9438e1f56a6c2.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libserialport-b1879f39129d9792.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libbitflags-a287bb825bb54d4f.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libnix-bf56b91a1fca1bcf.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libvoid-c3207025e914684a.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/liblibudev-26b5f3a51b49dd29.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/liblibudev_sys-f6bf3368f2693f6d.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libtokio-ab9ce1d3007097f7.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libtokio_udp-2b3089ae1dbe21c6.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libtokio_tcp-001b6b81f85fa040.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libtokio_timer-7c6f0f58c29c99b2.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libtokio_reactor-b9dae11afb9f0b89.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libtokio_fs-c6f994ef6bf5db6a.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libtokio_threadpool-96c7f86577d45c8e.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/librand-5f180f3e2ebb8495.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libnum_cpus-a346406cbe9d9bd1.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libcrossbeam_deque-63037901456e94a2.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libcrossbeam_epoch-9e2e55aad4687481.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libscopeguard-e608ef0ffdcaad27.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libmemoffset-149f6ed9f605cd7b.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/liblazy_static-7c819e3daef53e0c.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libcrossbeam_utils-6451544d5a00087d.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libarrayvec-bc3c520652462091.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libnodrop-be36956243b6d79f.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libtokio_executor-61230ec28dd0a7ad.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libmio-0d077f612b9390e5.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libslab-4cf90430dd41c37b.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libnet2-1ccae07ae1cd8146.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/liblazycell-f8f7e8d9a0de6c32.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libmtcp_rs-4ddc6bcbe2133a86.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libtokio_io-5c8a4e747adf57a8.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libfutures-5b956a4db5559ac0.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/liblog-9631fe6d33431cb3.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libcrc16-09ce0c9eb5f78fa3.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libbytes-059e7c7778130e24.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libiovec-de33f2349d037c05.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libbyteorder-884110d3e2495e9d.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libfailure-dc27a13c66dbb83c.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libbacktrace-c765c089b24f4701.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libbacktrace_sys-184696af594ea763.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/librustc_demangle-09133b4445568f8b.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libcfg_if-74c642e6707421e7.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/liblibc-743abe886a843383.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libstatic_assertions-45b21aa07558f341.rlib" "/home/rust/src/target/armv7-unknown-linux-musleabihf/debug/deps/libbitflags-d18cb012f8fef78f.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib/libstd-8d847bbe97fc9dc5.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib/libpanic_unwind-008c42aad548e7dd.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib/libunwind-0fe53371ec419e32.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib/liballoc_system-9dec1cbd51097ce1.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib/liblibc-6a4fb915dd86d140.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib/liballoc-7ebba6af2d3cc324.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib/libstd_unicode-7a26f8b3cf380464.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib/libcore-b0c2d164a9741309.rlib" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib/libcompiler_builtins-66d072e25a9acee3.rlib" "-Wl,-Bdynamic" "-l" "udev" "-static" "/root/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/armv7-unknown-linux-musleabihf/lib/crtn.o" "-Wl,-)"
  = note: /usr/lib/x86_64-linux-gnu/libudev.so: file not recognized: File format not recognized
          collect2: error: ld returned 1 exit status

error: aborting due to previous error

error: Could not compile `mtcp-tokio-test`.

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

So the problem is that I don't have libudev library for armv7. (what is more linked statically).

root@bbc455924b54:/usr/local/musl/lib# ls
gcc  libcc1.la  libcc1.so  libcc1.so.0  libcc1.so.0.0.0
root@bbc455924b54:/usr/local/musl/lib# cd gcc/armv7-unknown-linux-musleabihf/7.2.0/
root@bbc455924b54:/usr/local/musl/lib/gcc/armv7-unknown-linux-musleabihf/7.2.0# ls
crtbegin.o  crtbeginS.o  crtbeginT.o  crtend.o  crtendS.o  crtfastmath.o  include  include-fixed  install-tools  libgcc.a  libgcc_eh.a  libgcov.a  plugin
root@bbc455924b54:/usr/local/musl/lib/gcc/armv7-unknown-linux-musleabihf/7.2.0# 

Look here. Maybe I should ask this question there..

xoac commented 6 years ago

I added here a wrong output (form my crate). But I go one step ahead if u are interested see here

theronic commented 5 years ago

@xoac did you manage to solve this? I'm having the same problem trying to cross-compile a project using serialport crate.

xoac commented 5 years ago

@theronic Yes. You have a links above. It go to crate that was responsible for that:

See: https://github.com/berkowski/tokio-serial/issues/13#issuecomment-427592411

if u wanna use serialport crate in version 2 u can use my PR: https://github.com/xoac/tokio-serial/tree/serialport_rs_2_3_1