How do I build applications natively for CPU?

Hi, I am having a bit of trouble, on Windows 10 I tried to run

RUSTFLAGS="-C target-cpu=native" cargo build --release but this wouldn't even work as RUSTFLAGS does not exist.

I tried to add this in the cargo.toml file:

[build]
rustflags = "-C target-cpu=native"

and when I did run cargo build --release I get this warning message:

warning: unused manifest key: build

So how would I just be able to build an application natively for my CPU for Windows 10?

What's the warning message? Also, FOO="bar" command is a bash syntax to pass environment variables to the command. Which shell are you using? cmd.exe or PowerShell?

I just fixed it, it was poorly formatted for markdown.

I am using cmd.exe

You need the set command to set environment variables on cmd.exe

Or you can specify rustflags = [...] within the cargo config, not in the cargo manifest(Cargo.toml)

3 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.