Due to homebrew was failing to cross compile from M1 OSX to RPi4

Hey,

I have been trying to cross compile from an M1 OSX to a Raspberry Pi 4 running aarch64. I have rustup add-ed the targets:

$ rustup show
Default host: aarch64-apple-darwin
rustup home:  /Users/daniel/.rustup

installed targets for active toolchain
--------------------------------------

aarch64-apple-darwin
aarch64-unknown-linux-gnu
aarch64-unknown-linux-musl
aarch64-unknown-none
wasm32-wasi

active toolchain
----------------

stable-aarch64-apple-darwin (default)
rustc 1.64.0 (a55dd71d5 2022-09-19)

I have brew-installed the aarch64-elf-binutils. And have set up the cargo config:

$ cat ~/.cargo/config
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-elf-ld"
ar = "aarch64-elf-ar"

I yet when I try to build ripgrep I get:

$ cargo build --target=aarch64-unknown-linux-gnu
   Compiling cfg-if v1.0.0
   Compiling lazy_static v1.4.0
   Compiling regex-automata v0.1.10
   Compiling regex-syntax v0.6.25
   Compiling same-file v1.0.6
   Compiling once_cell v1.10.0
   Compiling fnv v1.0.7
   Compiling ryu v1.0.9
error[E0463]: can't find crate for `core`
  |
  = note: the `aarch64-unknown-linux-gnu` target may not be installed
  = help: consider downloading the target with `rustup target add aarch64-unknown-linux-gnu`

error[E0463]: can't find crate for `compiler_builtins`
etc.....

As I was writing this post I figured out the problem and just thought I may as well post it here so it doesn't get lost to the next person who stumbles on this problem.

If you have a "system" cargo installed and a rustup one at the same time, they can conflict. Removing my brew installed rust/cargo solved my problem.

1 Like

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.