Set custom CC #107

Closed
daschl opened this Issue Jan 2, 2017 · 1 comment

Projects

None yet

1 participant

@daschl
daschl commented Jan 2, 2017

Hi,

when building/linking the classical way for mips_unknown_linux_uclibc I set this before make which works:

export CC_mips_unknown_linux_uclibc=mips-openwrt-linux-gcc

I tried to export the same but it is seemingly ignored by xargo. What is the recommended way to set it when using xargo?

For reference, here is what I'm seeing

vagrant@vagrant-ubuntu-trusty-64:~/src/hello$ xargo build --target=mips-unknown-linux-uclibc --release
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling core v0.0.0 (file:///home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcore)
   Compiling gcc v0.3.41
   Compiling compiler_builtins v0.0.0 (file:///home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcompiler_builtins)
warning: ../compiler-rt/lib/builtins/divdc3.c:21:1: warning: conflicting types for built-in function '__divdc3' [enabled by default]
warning:  __divdc3(double __a, double __b, double __c, double __d)
warning:  ^
warning: ../compiler-rt/lib/builtins/divsc3.c:21:1: warning: conflicting types for built-in function '__divsc3' [enabled by default]
warning:  __divsc3(float __a, float __b, float __c, float __d)
warning:  ^
warning: ../compiler-rt/lib/builtins/muldc3.c:21:1: warning: conflicting types for built-in function '__muldc3' [enabled by default]
warning:  __muldc3(double __a, double __b, double __c, double __d)
warning:  ^
warning: ../compiler-rt/lib/builtins/mulsc3.c:21:1: warning: conflicting types for built-in function '__mulsc3' [enabled by default]
warning:  __mulsc3(float __a, float __b, float __c, float __d)
warning:  ^
   Compiling unwind v0.0.0 (file:///home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libunwind)
   Compiling libc v0.0.0 (file:///home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/rustc/libc_shim)
   Compiling build_helper v0.1.0 (file:///home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/build_helper)
   Compiling std v0.0.0 (file:///home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd)
   Compiling alloc v0.0.0 (file:///home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc)
   Compiling rand v0.0.0 (file:///home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/librand)
   Compiling panic_abort v0.0.0 (file:///home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libpanic_abort)
   Compiling std_unicode v0.0.0 (file:///home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libstd_unicode)
   Compiling collections v0.0.0 (file:///home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/libcollections)
   Compiling alloc_system v0.0.0 (file:///home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/src/liballoc_system)
error: linking with `cc` failed: exit code: 1
  |
  = note: "cc" "-Wl,--as-needed" "-Wl,-z,noexecstack" "-L" "/home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/mips-unknown-linux-uclibc/lib" "/tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/release/deps/std.0.o" "-o" "/tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/release/deps/libstd.so" "/tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/release/deps/std.metadata.o" "-Wl,-O1" "-nodefaultlibs" "-L" "/tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/release/deps" "-L" "/tmp/xargo.WjqVkbnlf05J/target/release/deps" "-L" "/tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/release/build/compiler_builtins-602d2a73d968cfcf/out" "-L" "/home/vagrant/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/mips-unknown-linux-uclibc/lib" "-Wl,-Bstatic" "-Wl,-Bdynamic" "-l" "dl" "-l" "rt" "-l" "pthread" "-Wl,--whole-archive" "/tmp/rustc.uBrQwNoTOp9l/libunwind-ac1a1fec30c001ac.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.uBrQwNoTOp9l/libpanic_abort-495326e155feac8c.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.uBrQwNoTOp9l/libcollections-0b376f0b906e9745.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.uBrQwNoTOp9l/liballoc-7cc5c532539ab224.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.uBrQwNoTOp9l/liballoc_system-49b4d62dc6af0961.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.uBrQwNoTOp9l/liblibc-eebf1c3e8ec2ca3b.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.uBrQwNoTOp9l/libstd_unicode-e51b80b032b4a388.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.uBrQwNoTOp9l/librand-f0387718c4599978.rlib" "-Wl,--no-whole-archive" "-Wl,--whole-archive" "/tmp/rustc.uBrQwNoTOp9l/libcore-659fd2c27cdd9fae.rlib" "-Wl,--no-whole-archive" "/tmp/rustc.uBrQwNoTOp9l/libcompiler_builtins-e4b20475efed79fa.rlib" "-l" "gcc_s" "-l" "c" "-l" "m" "-l" "rt" "-l" "util" "-shared"
  = note: /usr/bin/ld: /tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/release/deps/std.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/release/deps/std.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/release/deps/std.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/release/deps/std.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/release/deps/std.0.o: Relocations in generic ELF (EM: 8)

**snip, many more of those**

/usr/bin/ld: /tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/release/deps/std.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/release/deps/std.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/release/deps/std.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/release/deps/std.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/release/deps/std.0.o: Relocations in generic ELF (EM: 8)
/usr/bin/ld: /tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/release/deps/std.0.o: Relocations in generic ELF (EM: 8)
/tmp/xargo.WjqVkbnlf05J/target/mips-unknown-linux-uclibc/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.
error: `"cargo" "build" "--release" "--manifest-path" "/tmp/xargo.WjqVkbnlf05J/Cargo.toml" "--target" "mips-unknown-linux-uclibc" "-p" "std"` failed with exit code: Some(101)
note: run with `RUST_BACKTRACE=1` for a backtrace
@daschl
daschl commented Jan 2, 2017

I think I got it working, closing - keeping it for reference so if anyone else runs into it:

The trick is to set it in the .cargo/config in your project folder:

$ cat .cargo/config 
[build]
target = "mips-unknown-linux-uclibc"

[target.mips-unknown-linux-uclibc]
linker = "mips-openwrt-linux-gcc"
@daschl daschl closed this Jan 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment