Skip to content

Portable definition of set_precision()? #144214

@he32

Description

@he32

I am trying to build pydantic-core, and as part of that, the lexical-parse-float-1.0.5 rust crate on NetBSD/i386 using the i586-unknown-netbsd rust target. This fails with:

error[E0308]: mismatched types
  --> /usr/pkgsrc/devel/py-pydantic-core/work/vendor/lexical-parse-float-1.0.5/src/number.rs:77:23
   |
77 |         let _cw: () = set_precision::<F>();
   |                  --   ^^^^^^^^^^^^^^^^^^^^ expected `()`, found `FPUControlWord`
   |                  |
   |                  expected due to this

For more information about this error, try `rustc --explain E0308`.
error: could not compile `lexical-parse-float` (lib) due to 1 previous error

I expected this to build.

This possibly goes back to the set_precision() function not having a consistent type depending on whether "sse2" is in the target feature set (which it isn't in this case, ref. i586).

In ${PREFIX}/lib/rustlib/src/rust/library/core/src/num/dec2flt/fpu.rs I find:

#[cfg(all(target_arch = "x86", not(target_feature = "sse2")))]
mod fpu_precision {
...
    pub(crate) fn set_precision<T>() -> FPUControlWord {
...
#[cfg(any(not(target_arch = "x86"), target_feature = "sse2"))]
mod fpu_precision {
    pub(crate) fn set_precision<T>() {}
}

Even though my familiarity with rust is sub-par, those two function signatures surely are not the same, and hence, code which expects one but gets the other bombs out as above.

What's the appropriate fix or workaround?

Meta

rustc --version --verbose:

$ rustc --version --verbose
rustc 1.88.0 (6b00bc388 2025-06-23) (built from a source tarball)
binary: rustc
commit-hash: 6b00bc3880198600130e1cf62b8f8a93494488cc
commit-date: 2025-06-23
host: i586-unknown-netbsd
release: 1.88.0
LLVM version: 20.1.5
$ 

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-discussionCategory: Discussion or questions that doesn't represent real issues.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions