dimforge / simba

Set of mathematical traits to facilitate the use of SIMD-based AoSoA (Array of Struct of Array) storage pattern.
Apache License 2.0
290 stars 29 forks source link

Cannot build crate (version 0.7.1, feature libm) #32

Closed AxelMontini closed 2 years ago

AxelMontini commented 2 years ago

I'm currently unable to build nalgebra on an embedded target (thumbv6m-none-eabi) due to simba failing to build.

Dependencies in Cargo.toml:

[dependencies]
simba = { version = "0.7.1", features = ["libm"], default-features = false }

Error:

   Updating crates.io index
  Downloaded approx v0.5.1
  Downloaded nb v1.0.0
  Downloaded void v1.0.2
  Downloaded simba v0.7.1
  Downloaded paste v1.0.7
  Downloaded autocfg v1.1.0
  Downloaded num-complex v0.4.1
  Downloaded num-traits v0.2.15
  Downloaded libm v0.2.2
  Downloaded nb v0.1.3
  Downloaded embedded-hal v0.2.7
  Downloaded 11 crates (342.2 KB) in 0.35s
   Compiling libm v0.2.2
   Compiling autocfg v1.1.0
    Checking nb v1.0.0
    Checking void v1.0.2
   Compiling paste v1.0.7
    Checking nb v0.1.3
    Checking embedded-hal v0.2.7
   Compiling num-traits v0.2.15
    Checking approx v0.5.1
    Checking num-complex v0.4.1
    Checking simba v0.7.1
error[E0034]: multiple applicable items in scope
   --> /home/axel/.cargo/registry/src/github.com-1ecc6299db9ec823/simba-0.7.1/src/scalar/real.rs:82:30
    |
82  |                 $cpysgn_mod::copysign(self, sign)
    |                              ^^^^^^^^ multiple `copysign` found
...
225 | impl_real!(f32, f32, f32, Float; f64, f64, f64, Float);
    | ------------------------------------------------------ in this macro invocation
    |
    = note: candidate #1 is defined in an impl of the trait `Float` for the type `f32`
note: candidate #2 is defined in an impl of the trait `RealField` for the type `f32`
   --> /home/axel/.cargo/registry/src/github.com-1ecc6299db9ec823/simba-0.7.1/src/scalar/real.rs:81:13
    |
81  |             fn copysign(self, sign: Self) -> Self {
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
225 | impl_real!(f32, f32, f32, Float; f64, f64, f64, Float);
    | ------------------------------------------------------ in this macro invocation
    = note: this error originates in the macro `impl_real` (in Nightly builds, run with -Z macro-backtrace for more info)
help: disambiguate the associated function for candidate #1
    |
82  |                 <f32 as Float>::copysign(self, sign)
    |                 ~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
    |
82  |                 <f32 as RealField>::copysign(self, sign)
    |                 ~~~~~~~~~~~~~~~~~~~~

error[E0034]: multiple applicable items in scope
   --> /home/axel/.cargo/registry/src/github.com-1ecc6299db9ec823/simba-0.7.1/src/scalar/real.rs:82:30
    |
82  |                 $cpysgn_mod::copysign(self, sign)
    |                              ^^^^^^^^ multiple `copysign` found
...
225 | impl_real!(f32, f32, f32, Float; f64, f64, f64, Float);
    | ------------------------------------------------------ in this macro invocation
    |
    = note: candidate #1 is defined in an impl of the trait `Float` for the type `f64`
note: candidate #2 is defined in an impl of the trait `RealField` for the type `f64`
   --> /home/axel/.cargo/registry/src/github.com-1ecc6299db9ec823/simba-0.7.1/src/scalar/real.rs:81:13
    |
81  |             fn copysign(self, sign: Self) -> Self {
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
225 | impl_real!(f32, f32, f32, Float; f64, f64, f64, Float);
    | ------------------------------------------------------ in this macro invocation
    = note: this error originates in the macro `impl_real` (in Nightly builds, run with -Z macro-backtrace for more info)
help: disambiguate the associated function for candidate #1
    |
82  |                 <f64 as Float>::copysign(self, sign)
    |                 ~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
    |
82  |                 <f64 as RealField>::copysign(self, sign)
    |                 ~~~~~~~~~~~~~~~~~~~~

For more information about this error, try `rustc --explain E0034`.
error: could not compile `simba` due to 2 previous errors

I can get the crate to build by modifying the impl_real! macro call to use Float as $cpysgn_mod

astraw commented 2 years ago

I was getting this error too (here). I think this is related to num-traits adding num_traits::Float::copysign in 0.2.15. I can work around this issue by pinning the num-traits crate to 0.2.14 (from the current 0.2.15) with this in my Cargo.toml:

num-traits = {version="=0.2.14", default-features=false}

So far I cannot reproduce the build failure with just simba nor can I fix it.

AxelMontini commented 2 years ago

I forgot to close this, #34 got merged which fixed the problem.