Open kkevlar opened 3 years ago
Yeah, this is a known behavior, unfortunately. The problem is that in debug builds, overflow-checks
are enabled. Due to a problem in cargo's build-std
, they are not only enabled for your code, but also for the compiler-builtins
crate. This means, the compiler will insert overflow checks into the intrinsics defined in compiler-builtins
, which in turn reference the panic handler symbol. Now due to the way the Rust standard library works, this is not possible (binary object linking order). That's why you get the errors.
In a non-build-std
build, e.g. with a precompiled libcore
and compiler-builtins
this wouldn't be a problem.
There is a workaround although it isn't really pretty. To quote a previous comment of mine:
that's a known issue: rust-lang/compiler-builtins#347
There is a dirty workaround to add the following to your
Cargo.toml
:[profile.dev.package.compiler_builtins] overflow-checks = false
cargo
will warn about this but it'll still work fine... Alternatively compile in release mode whereoverflow-checks
are always disabled.
One other option would be to disable overflow-checks
entirely in debug mode as well (i.e. also for all other crates including your code), but that of course is a dangerous decision. You'd do this by adding
[profile.dev]
overflow-checks = false
Thank you for your help. I'll use this for now.
Glad I could help! Let's keep this issue open for visibility until the problem is fixed.
Hi all,
Every time I try to build and Arduino Uno project without the --release flag, my project is unable to link with the panic handler.
Is this expected behavior? Thank you so much for your help.