librasn / rasn

A Safe #[no_std] ASN.1 Codec Framework
Other
183 stars 43 forks source link

Does not work in no-std environment #262

Open koxu1996 opened 2 weeks ago

koxu1996 commented 2 weeks ago

I am unable to compile my project due to found duplicate lang item panic_impl, which appears to be caused by std library being indirectly included by rasn :fearful:. Even though this library is claimed as no_std its dependencies are not!

Where std gets included?

Latest rasn v0.8.2 depends on custom nom parser with bitvec:

nom-bitvec = { package = "bitvec-nom2", version = "0.2.0" }

This need to be discussed. Why is it custom? Probably because upstream is not supporting bitvec v1 - see https://github.com/rust-bakery/nom-bitvec/issues/1, and relevant PR got stuck. It seems that @XAMPPRocky released fork as renamed package with tag 0.2.0. The different between fork source code and files published in crates.io made my investigation more difficult.

Okay, so let's use crates.io as the source of truth. You can see that bitvec-nom2 depends on bitvec v1:

image

Default features are not disabled, so std gets included:

image

NOTE: I was able to track it down with cargo tree -e features.

koxu1996 commented 2 weeks ago

The second place where std is indirectly included in rasn:

https://github.com/librasn/rasn/blob/1809d7c298ae3ac62da42749692e418f709d7147/Cargo.toml#L49

You can see that snafu's backtraces feature is enabling it:

image

NOTE: snafu 0.8.0 removed this feature

XAMPPRocky commented 2 weeks ago

Thank you for your issue! This is definitely not intentional, we should disable std in my fork and put backtraces behind a feature that is disabled by default.

koxu1996 commented 2 weeks ago

Also JER should be put behind a feature, as jzon is not no-std compatible as well.