Building x64 cross-compiler, ld error

While attempting to build a cross compiler in x64 Ubuntu for a Solaris 11.4 SPARC target, I got this:

  ...
 Compiling rustc-main v0.0.0 (/home/michele/rust/src/rustc)
error: linking with `/usr/sparcv9-solaris/solaris/cross/bin/sparcv9-solaris2.11-gcc` failed: exit code: 1
  |
  = note: "/usr/sparcv9-solaris/solaris/cross/bin/sparcv9-solaris2.11-gcc" "-m64" "-L" "/home/michele/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/sparcv9-sun-solaris/lib" "/home/michele/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/sparcv9-sun-solaris/release/deps/rustc_binary-3d46a0faefb690a4.rustc_binary.5tik5m7y-cgu.0.rcgu.o" "/home/michele/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/sparcv9-sun-solaris/release/deps/rustc_binary-3d46a0faefb690a4.rustc_binary.5tik5m7y-cgu.1.rcgu.o" "-o" "/home/michele/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/sparcv9-sun-solaris/release/deps/rustc_binary-3d46a0faefb690a4" "-Wl,-zignore" "-nodefaultlibs" "-L" "/home/michele/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/sparcv9-sun-solaris/release/deps" "-L" "/home/michele/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/release/deps" "-L" "/home/michele/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/sparcv9-sun-solaris/release/build/backtrace-sys-45e87700b56249f2/out" "-L" "/home/michele/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/sparcv9-sun-solaris/release/build/rustc_llvm-6077ec6336d80f41/out" "-L" "/home/michele/rust/build/sparcv9-sun-solaris/llvm/build/lib" "-L" "/home/michele/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/sparcv9-sun-solaris/lib" "-L" "/home/michele/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/sparcv9-sun-solaris/release/deps" "-lrustc_driver-7de6df8a8556e642" "-L" "/home/michele/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/sparcv9-sun-solaris/lib" "-ltest-3c6e93d786083d7e" "-Wl,--start-group" "-L" "/home/michele/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/sparcv9-sun-solaris/lib" "-lstd-10e2604344b426f1" "-Wl,--end-group" "-Wl,-Bstatic" "/home/michele/rust/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/sparcv9-sun-solaris/lib/libcompiler_builtins-42a37272c4e84dc8.rlib" "-Wl,-Bdynamic" "-lstdc++" "-lsocket" "-lposix4" "-lpthread" "-lresolv" "-lgcc_s" "-lc" "-lm" "-lrt" "-lpthread" "-Wl,-rpath,$ORIGIN/../lib"
  = note: /usr/sparcv9-solaris/solaris/cross/lib/gcc/sparcv9-solaris2.11/7.3.0/../../../../sparcv9-solaris2.11/bin/ld: warning: -z ignore ignored
          /usr/sparcv9-solaris/solaris/cross/lib/gcc/sparcv9-solaris2.11/7.3.0/../../../../sparcv9-solaris2.11/bin/ld: /home/michele/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/sparcv9-sun-solaris/release/deps/librustc_driver-7de6df8a8556e642.so: fabs: invalid version 7 (max 0)
          /usr/sparcv9-solaris/solaris/cross/lib/gcc/sparcv9-solaris2.11/7.3.0/../../../../sparcv9-solaris2.11/bin/ld: /home/michele/rust/build/x86_64-unknown-linux-gnu/stage1-rustc/sparcv9-sun-solaris/release/deps/librustc_driver-7de6df8a8556e642.so: error adding symbols: bad value
          collect2: error: ld returned 1 exit status
          
error: aborting due to previous error

I have nothing set in this section of my config.toml:

    # Linker to be used to link Rust code. Note that the
    # default value is platform specific, and if not specified it may also depend on
    # what platform is crossing to what platform.
    #linker = "cc"

and I suspect that is possibly the problem, but I don't know what to put there.

Or maybe these lines need some sort of fixing?

#build = "x86_64-unknown-linux-gnu"    # defaults to your host platform
host = ['sparcv9-sun-solaris']
#target = ["x86_64-unknown-linux-gnu"] # defaults to just the build triple

UPDATE

Turns out that by setting target = ["sparcv9-sun-solaris"] and unsetting #host = ["sparcv9-sun-solaris"]

in config.toml, I was able to get a successful build:

...
   Compiling test v0.0.0 (/home/michele/rust/src/libtest)
    Finished release [optimized] target(s) in 1m 11s
Copying stage2 std from stage2 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu / sparcv9-sun-solaris)
Build completed successfully in 0:01:17

I haven't tried actually using it yet.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.