al8n / caches-rs

This is a Rust implementation for popular caches (support no_std).
104 stars 14 forks source link

bare metal support #22

Closed tsatke closed 6 months ago

tsatke commented 6 months ago

According to #20 I understand this should be no_std compatible, but for me it seems like it isn't.

I'm on x86_64-unknown-none (no_std, alloc), and I'm using the dependency as follows. caches = { git = "https://github.com/al8n/caches-rs", default-features = false, features = ["hashbrown"] } (https://github.com/al8n/caches-rs/commit/bd2816c5fafa3ebb8a8078e4c11f827717ebe627). If I don't use the hashbrown feature, I get an error because of extern crate hashbrown.

I tried the latest commit (https://github.com/al8n/caches-rs/commit/bd2816c5fafa3ebb8a8078e4c11f827717ebe627) since I've noticed the new version 0.2.9 which is not published yet, but even with adding libm as dependency (and extern crate libm), I still get:

error[E0432]: unresolved import `libm`
  --> ~/.cargo/git/checkouts/caches-rs-c5090a8b4544925b/bd2816c/src/polyfill.rs:23:13
   |
23 |         use libm;
   |             ^^^^ no external crate `libm`

Is there anything I am missing? Is there anything that can be done so I can use this library with no_std on x86_64-unknown-none?

pantsman0 commented 6 months ago

If you vendor the crate, you need to remove optional = true from the libm dependency. I'll put in a PR in a few minutes.

pantsman0 commented 6 months ago

Nevermind, try the following line for the dependency:

caches = { git = "https://github.com/al8n/caches-rs", default-features = false, features = ["hashbrown", "libm"] }
tsatke commented 6 months ago

I feel like I should have been able to figure this out. Thanks for the help, that works!