Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Rust: problems installing Inari library

I am new to Rust, so this could be a stupid mistake, but I can’t figure out how to fix it.

The problem

I tried to install Inari (a Rust implementation of interval arithmetic, https://crates.io/crates/inari). But when I try to compile the project, I get some errors:

   Compiling inari v1.0.0
error: RUSTFLAGS='-Ctarget-cpu=haswell' or later is required. See https://doc.rust-lang.org/rustc/codegen-options/#target-cpu
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/inari-1.0.0/src/simd/x86_64.rs:174:9
    |
174 | ...   compile_error!("RUSTFLAGS='-Ctarget-cpu=haswell' or later is required. See https://doc.rust-lang.org/rustc/codegen-options/#target-cpu...
    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0425]: cannot find function `add_ru` in this scope
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/inari-1.0.0/src/arith.rs:25:21
   |
25 |         Self { rep: add_ru(x, y) }
   |                     ^^^^^^ help: a function with a similar name exists: `add_rn`
   |

...

The error says something about using Haswell, so I tried to add the following lines to Cargo.toml:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

[build]
rustflags = ["-Ctarget-cpu=haswell"]
rustdocflags = ["-Ctarget-cpu=haswell"]

but it didn’t change anything.

Steps to reproduce

Create a new project with cargo new project-name. Add inari as a dependancy cargo add inari. Run the project with cargo run.

Environment

  • cargo 1.62.1 (a748cf5a3 2022-06-08)
  • rustc 1.62.1 (e092d0b6b 2022-07-16)
  • Ubuntu 20.04.3 LTS (in WSL)

>Solution :

You need to put that in .cargo/config.toml, not in Cargo.toml. Alternatively, set the environment variable RUSTFLAGS before running Cargo.

See Configuration – build.rustflags – The Cargo Book.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading