rust-embedded / cortex-m-quickstart

Template to develop bare metal applications for Cortex-M microcontrollers
809 stars 167 forks source link

'eh_personality' not found when building from another directory #67

Closed hug-dev closed 5 years ago

hug-dev commented 5 years ago

Problem

When a cortex-m-quickstart project is built from another directory using cargo build --manifest-path=oof-test/Cargo.toml command it fails with the following output:

[hug-dev@machine tmp]$ cargo build --manifest-path=oof-test/Cargo.toml
   Compiling semver-parser v0.7.0
   Compiling proc-macro2 v0.4.26
   Compiling unicode-xid v0.1.0
   Compiling rand_core v0.4.0
   Compiling vcell v0.1.0
   Compiling cortex-m v0.5.8
   Compiling aligned v0.2.0
   Compiling cortex-m-semihosting v0.3.2
   Compiling cortex-m-rt v0.6.7
   Compiling r0 v0.2.2
   Compiling oof-test v0.1.0 (/tmp/oof-test)
   Compiling panic-halt v0.2.0
   Compiling volatile-register v0.2.0
   Compiling rand_core v0.3.1
   Compiling rand v0.5.6
   Compiling semver v0.9.0
   Compiling rustc_version v0.2.3
   Compiling bare-metal v0.2.4
   Compiling quote v0.6.11
   Compiling syn v0.15.26
   Compiling cortex-m-rt-macros v0.1.5
error: language item required, but not found: `eh_personality`

error: aborting due to previous error

error: Could not compile `oof-test`.

To learn more, run the command again with --verbose.

How to reproduce

Why is it a problem?

I would like to create a Rust workspace with multiple cortex-m-quickstart projects, but because of that I can not. The workaround I did is to have a script that pushd into the Cargo projects and cargo build from there. Could be nice to have that working!

japaric commented 5 years ago

'eh_personality' not found

You get this error when you compile cortex-m crates for the host. To cross compile you need cargo build --target thumbv7m-none-eabi for example. You don't need the --target to cross compile within the quickstart directory because .cargo/config sets the default compilation target to thumbv7m-none-eabi (for example).

hug-dev commented 5 years ago

Oh yes that is because I was outside of the project directory that cargo did not pick the target information from .cargo/config. Adding --target works!