0
votes

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:

[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)
1
This is probably better raised as an issue on the associated project, assuming they allow such things. - tadman

1 Answers

0
votes

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.