# Running the cross-compiler?

**URL:** <https://internals.rust-lang.org/t/running-the-cross-compiler/11910>\
**Category:** compiler\
**Created:** [February 28, 2020, 12:37am UTC](https://internals.rust-lang.org/t/running-the-cross-compiler/11910 "2020-02-28T00:37:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michele](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@Michele](https://internals.rust-lang.org/u/Michele)\
**Post date:** [February 28, 2020, 12:37am UTC](https://internals.rust-lang.org/t/running-the-cross-compiler/11910/1 "2020-02-28T00:37:47Z")

</div>

I successfully built (I think) a cross-compiler for Solaris SPARC in x64 Ubuntu: michele@michele-VirtualBox:~/rust$ ./x.py build --target sparcv9-solaris2.11 michele@michele-VirtualBox:~/rust$ sudo ./x.py install ... Dist std stage2 (x86\_64-unknown-linux-gnu -\> sparcv9-sun-solaris) finished in 15.907 Install std stage2 (Some("sparcv9-sun-solaris")) install: creating uninstall script at /usr/local/lib/rustlib/uninstall.sh install: installing component 'rust-std-sparcv9-sun-solaris'

```
std is standing at the ready.

```

Dist rustc stage2 (x86\_64-unknown-linux-gnu) finished in 134.709 Install rustc stage2 (Some("x86\_64-unknown-linux-gnu")) install: creating uninstall script at /usr/local/lib/rustlib/uninstall.sh install: installing component 'rustc'

```
Rust is ready to roll.

```

Build completed successfully in 1:35:32

This may be a dumb question, but where is it? I see a new rustc has appeared in /usr/local/bin but I don't know if that's the right thing. And when I ran /usr/local/bin/rustc hello.rs, it created an x64 executable, not a SPARC executable.

And when I ran michele@michele-VirtualBox:~$ /usr/local/bin/rustc --target sparcv9-sun-solaris hello.rs error: linking with `cc` failed: exit code: 1

My .cargo/config has this: [source.crates-io] replace-with = "vendored-sources"

```
[source.vendored-sources]
directory = "vendor"

[target.sparcv9-sun-solaris]
linker = "/usr/sparcv9-solaris/solaris/cross/bin/sparcv9-solaris2.11-gcc"

```

**UPDATE** After some more searching I found this page: https://github.com/japaric/rust-cross Apparently you have to say $ cargo new --bin hello first. I did that and then in fact got an executable that ran on my Sun. It's still not clear why I can't just invoke rustc to get the same result.

---

<div class="post-metadata">

**Author:** ![mbrubeck](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/mbrubeck/32/174_2.png) [@mbrubeck](https://internals.rust-lang.org/u/mbrubeck)\
**Post date:** [February 28, 2020, 3:06am UTC](https://internals.rust-lang.org/t/running-the-cross-compiler/11910/2 "2020-02-28T03:06:36Z")

</div>

rustc doesn't read options from `.cargo/config`, so you'll need to pass them on the command line instead. In your Cargo project, you can run `cargo build -v` to see how your configuration translates into rustc options.

---

<div class="post-metadata">

**Author:** ![Michele](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@Michele](https://internals.rust-lang.org/u/Michele)\
**Post date:** [February 28, 2020, 6:56pm UTC](https://internals.rust-lang.org/t/running-the-cross-compiler/11910/3 "2020-02-28T18:56:37Z")

</div>

Thanks for the tip. I found that I can get a cross-compiled executable by saying:

`$ /usr/local/bin/rustc --target=sparcv9-sun-solaris -C linker=/usr/sparcv9-solaris/solaris/cross/bin/sparcv9-solaris2.11-gcc hello.rs`

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [May 28, 2020, 6:56pm UTC](https://internals.rust-lang.org/t/running-the-cross-compiler/11910/4 "2020-05-28T18:56:42Z")

</div>

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