metrics-rs / quanta

high-speed timing library in Rust
MIT License
302 stars 31 forks source link

Fails to build on x86 without SSE2 #69

Closed jbeich closed 2 years ago

jbeich commented 2 years ago

FreeBSD, NetBSD, OpenBSD still support pre-SSE2 CPUs, so downstream rust package for 32-bit x86 (aka i386) targets real i686 (aka pentiumpro) or i586 (aka pentium). To reproduce on Linux (via rustup) pass --target i586-unknown-linux-gnu or similar.

$ cargo build
[...]
   Compiling quanta v0.10.0 (/tmp/quanta)
error[E0599]: no function or associated item named `new` found for struct `CpuId` in the current scope
   --> src/lib.rs:558:24
    |
558 |     let cpuid = CpuId::new();
    |                        ^^^ function or associated item not found in `CpuId`

error[E0599]: no function or associated item named `new` found for struct `CpuId` in the current scope
   --> src/lib.rs:566:24
    |
566 |     let cpuid = CpuId::new();
    |                        ^^^ function or associated item not found in `CpuId`

For more information about this error, try `rustc --explain E0599`.
error: could not compile `quanta` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
tobz commented 2 years ago

Trying to build quanta via cargo build --target i586-unknown-linux-gnu doesn't seem to actually manage to even build the dependencies, namely once_cell.

I pushed a change to main to consolidate the usage of CpuId to an area where know we at least are on x86_64 with SSE2 support. Do you mind testing that out locally?

jbeich commented 2 years ago

Thanks, builds fine now:

$ cargo build
[...]
   Compiling quanta v0.10.0 (/tmp/quanta)
warning: unused import: `raw_cpuid::CpuId`
   --> src/lib.rs:149:5
    |
149 | use raw_cpuid::CpuId;
    |     ^^^^^^^^^^^^^^^^
    |
    = note: `#[warn(unused_imports)]` on by default

warning: `quanta` (lib) generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.86s