1

As part of one of my projects, I have to cross-compile a Rust crate from x86_64 to i686 on Linux. I'm currently using Travis CI for this, with a simple Hello World crate (the default binary crate). My Travis CI configuration for the relevant matrix entry is:

# ...

matrix:
  include:
    # ...
    - os: linux
      rust: 1.30.0
      before_script:
        - sudo apt-get update
        - sudo apt-get install -y libc6-dev:i386
      env: TARGET=i686-unknown-linux-gnu
  # ...

script:
  - rustup target install $TARGET
  - cargo build --release --target=$TARGET

Unfortunately, when I push this configuration to Travis CI, I get a build error:

$ cargo build --release --target=$TARGET
   Compiling test-rust-deploy-releases v0.1.0 (/home/travis/build/arnavb/test-rust-deploy-releases)
error: linker `cc` not found
  |
  = note: No such file or directory (os error 2)

error: aborting due to previous error

error: Could not compile `test-rust-deploy-releases`.
To learn more, run the command again with --verbose.
The command "cargo build --release --target=$TARGET" exited with 101.

How do I fix this?

Shepmaster
  • 388,571
  • 95
  • 1,107
  • 1,366
Arnav Borborah
  • 11,357
  • 8
  • 43
  • 88
  • By installing the program `cc`? – Shepmaster Dec 06 '18 at 02:52
  • See also [How do I fix the Rust error “linker 'cc' not found” for Debian on Windows 10?](https://stackoverflow.com/q/52445961/155423) / [Could not exec the linker `cc` error when running “cargo build”](https://stackoverflow.com/q/29023305/155423) – Shepmaster Dec 06 '18 at 02:53

1 Answers1

2

Well, after experimenting and more googling, I changed my apt install command to:

sudo apt-get install -y gcc-4.8 cpp-4.8 gcc-multilib

(The first two are unmet dependencies of the third, which had to be manually installed).

Now the build runs properly.

Arnav Borborah
  • 11,357
  • 8
  • 43
  • 88
  • 1
    I am really rooting for lld. A single linker capable of handling many different architectures right out of the box? That's how you streamline cross-compilation! – Matthieu M. Dec 07 '18 at 08:44