Hi,
I'm trying to figure out how to cross compile 32 bit binaries for a CLI tool I have made from a 64 bit Ubuntu 14.04 OS. The package is very simple, e.g I do:
cargo new example
rustup target install i686-unknown-linux-gnu
cargo build --target=i686-unknown-linux-gnu
This is the huge error message I get:
Compiling example v0.1.0 (/home/ubuntu/workspace/example)
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-m32" "-L" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-unknown-linux-gnu/lib" "/home/ubuntu/workspace/example/target/i686-unknown-linux-gnu/debug/deps/example-5a8227dde3b9ec8d.2oejpczlljnfyixd.rcgu.o" "/home/ubuntu/workspace/example/target/i686-unknown-linux-gnu/debug/deps/example-5a8227dde3b9ec8d.35afubvs36dabc2e.rcgu.o" "/home/ubuntu/workspace/example/target/i686-unknown-linux-gnu/debug/deps/example-5a8227dde3b9ec8d.37eu5qjafrxd0cfa.rcgu.o" "/home/ubuntu/workspace/example/target/i686-unknown-linux-gnu/debug/deps/example-5a8227dde3b9ec8d.3fm91tgzksovsnwp.rcgu.o" "/home/ubuntu/workspace/example/target/i686-unknown-linux-gnu/debug/deps/example-5a8227dde3b9ec8d.3r4kd2wxy8fo5i4j.rcgu.o" "/home/ubuntu/workspace/example/target/i686-unknown-linux-gnu/debug/deps/example-5a8227dde3b9ec8d.jjcklmj2bmjetod.rcgu.o" "-o" "/home/ubuntu/workspace/example/target/i686-unknown-linux-gnu/debug/deps/example-5a8227dde3b9ec8d" "/home/ubuntu/workspace/example/target/i686-unknown-linux-gnu/debug/deps/example-5a8227dde3b9ec8d.2ma3alsuow31b39v.rcgu.o" "-Wl,--gc-sections" "-pie" "-Wl,-zrelro" "-Wl,-znow" "-nodefaultlibs" "-L" "/home/ubuntu/workspace/example/target/i686-unknown-linux-gnu/debug/deps" "-L" "/home/ubuntu/workspace/example/target/debug/deps" "-L" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-unknown-linux-gnu/lib" "-Wl,--start-group" "-Wl,-Bstatic" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-unknown-linux-gnu/lib/libstd-909f0af19a48c085.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-unknown-linux-gnu/lib/libpanic_unwind-16c132140238f57b.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-unknown-linux-gnu/lib/liballoc_jemalloc-5c4aa6b252d07726.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-unknown-linux-gnu/lib/libunwind-4375cc96ac904b39.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-unknown-linux-gnu/lib/liballoc_system-7b876e3945087ab6.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-unknown-linux-gnu/lib/liblibc-f9c86d7cc296b8ef.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-unknown-linux-gnu/lib/liballoc-041f482c2dcfe112.rlib" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-unknown-linux-gnu/lib/libcore-b474d61928d6a0a3.rlib" "-Wl,--end-group" "/home/ubuntu/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/i686-unknown-linux-gnu/lib/libcompiler_builtins-e7a2a8f558042407.rlib" "-Wl,-Bdynamic" "-ldl" "-lrt" "-lpthread" "-lpthread" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-lutil" "-lutil"
= note: /usr/bin/ld: cannot find Scrt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status
error: aborting due to previous error
error: Could not compile `example`.
To learn more, run the command again with --verbose.
As evident, apparently the linker cannot find some important files for 32 bit (Scrt1.o
, crti.o
) binaries. Normal builds for x86_64 work exactly as expected. I searched up this issue on Google and cannot find any info related to Rust for this (not GCC in general). If it helps, here is my system info:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.5 LTS
Release: 14.04
Codename: trusty