我尝试在我的计算机上mipsel-unknown-linux-uclibc
交叉编译Rust x86_64-unknown-linux-gnu
并失败:
~ git clone https://github.com/rust-lang/rust && cd rust
# checkout the right commit (rustc -V ---> rustc 1.13.0 (2c6933acc 2016-11-07))
~ git checkout 2c6933acc
~ configure --enable-rustbuild --target=mipsel-unknown-linux-uclibc
~ make
我遇到以下错误:
Documenting stage2 error index (x86_64-unknown-linux-gnu)
Building stage2 std artifacts (x86_64-unknown-linux-gnu -> mipsel-unknown-linux-uclibc)
Compiling core v0.0.0 (file:///mnt/ssd/rust/rust/src/libcore)
Compiling unwind v0.0.0 (file:///mnt/ssd/rust/rust/src/libunwind)
Compiling libc v0.0.0 (file:///mnt/ssd/rust/rust/src/rustc/libc_shim)
Compiling alloc_jemalloc v0.0.0 (file:///mnt/ssd/rust/rust/src/liballoc_jemalloc)
Compiling compiler_builtins v0.0.0 (file:///mnt/ssd/rust/rust/src/libcompiler_builtins)
Compiling std v0.0.0 (file:///mnt/ssd/rust/rust/src/libstd)
Compiling rand v0.0.0 (file:///mnt/ssd/rust/rust/src/librand)
Compiling alloc v0.0.0 (file:///mnt/ssd/rust/rust/src/liballoc)
Compiling rustc_unicode v0.0.0 (file:///mnt/ssd/rust/rust/src/librustc_unicode)
Compiling panic_abort v0.0.0 (file:///mnt/ssd/rust/rust/src/libpanic_abort)
Compiling alloc_system v0.0.0 (file:///mnt/ssd/rust/rust/src/liballoc_system)
Compiling panic_unwind v0.0.0 (file:///mnt/ssd/rust/rust/src/libpanic_unwind)
Compiling collections v0.0.0 (file:///mnt/ssd/rust/rust/src/libcollections)
error: linking with `cc` failed: exit code: 1
|
= note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-L" "/mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/mipsel-unknown-linux-uclibc/lib" "/mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.0.o" "-o" "/mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/libstd-c59cddcd0af2e166.so" "/mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.metadata.o" "-Wl,-O1" "-nodefaultlibs" "-L" "/mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps" "-L" "/mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/build/std-a809d8d8110a0c2c/out/.libs" "-L" "/mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/build/alloc_jemalloc-3fdf800200d00d2b/out/lib" "-L" "/mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/build/compiler_builtins-6f98225e9c197338/out" "-L" "/mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/mipsel-unknown-linux-uclibc/lib" "-Wl,-Bstatic" "-Wl,--whole-archive" "-l" "backtrace" "-Wl,--no-whole-archive" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-Wl,--whole-archive" "/tmp/rustc.Lmi5cZaoYeZ8/libpanic_unwind-7bbc0f7aeca8d97e.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.Lmi5cZaoYeZ8/libcollections-2384fa75982df921.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.Lmi5cZaoYeZ8/liballoc-97c94bbcbb6ce588.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.Lmi5cZaoYeZ8/liballoc_jemalloc-d3ea7757ad00d487.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.Lmi5cZaoYeZ8/librustc_unicode-0f8a4e3472bf9986.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.Lmi5cZaoYeZ8/libunwind-a2900b506cabe0f1.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.Lmi5cZaoYeZ8/liblibc-5e16cc1287996e06.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.Lmi5cZaoYeZ8/librand-9e79fbad0cb1c989.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.Lmi5cZaoYeZ8/libcore-2bfca94c87453f15.rlib" "-Wl,--no-whole-archive" "/tmp/rustc.Lmi5cZaoYeZ8/libcompiler_builtins-66ce650a45b25434.rlib" "-l" "pthread" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "util" "-shared" "-Wl,-rpath,$ORIGIN/../lib"
= note: /usr/bin/ld: /mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.0.o: Relocations in generic ELF (EM: 8)
...
<many more similar lines>
...
/mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage2-std/mipsel-unknown-linux-uclibc/release/deps/std-c59cddcd0af2e166.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.
command did not execute successfully: "/mnt/ssd/rust/rust_build/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "-j" "8" "--target" "mipsel-unknown-linux-uclibc" "--release" "--features" " jemalloc backtrace" "--manifest-path" "/mnt/ssd/rust/rust/src/rustc/std_shim/Cargo.toml"
expected success, got: exit code: 101
Makefile:23: recipe for target 'all' failed
make: *** [all] Error 1
构建系统似乎正在使用cc
链接为MIPS交叉编译的目标文件。我没有找到一种方法来告诉构建系统使用正确的链接器。
rust-cross非常有帮助,但我找不到解决问题的方法。我不知道如何为第2阶段构建传递-C linker=...
标志。我试过了export RUSTFLAGS_STAGE2='-C /path/to/mipsel-unknown-linux-uclibc-gcc'
,但它没有用。
其他信息:
~ rustc --version --verbose
rustc 1.13.0 (2c6933acc 2016-11-07)
binary: rustc
commit-hash: 2c6933acc05c61e041be764cb1331f6281993f3f
commit-date: 2016-11-07
host: x86_64-unknown-linux-gnu
release: 1.13.0
我的~/.cargo/config
:
[target.mipsel-unknown-linux-uclibc]
linker = "/path/to/mipsel-unknown-linux-uclibc-gcc"