Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does rustc / cargo have a -march=native equivalent?

I feel like binary portability isn't really a concern, and so something like -march=native may always be the default behavior. I can't find anything saying one way or the other though.

like image 572
Josh Avatar asked Oct 16 '17 22:10

Josh


People also ask

Does Cargo come with Rust?

Cargo is Rust's build system and package manager. With this tool, you'll get a repeatable build because it allows Rust packages to declare their dependencies in the manifest, Cargo. toml . When you install Rust through rustup , Cargo is also installed.

Where does Cargo build output go?

Output Options Defaults to target in the root of the workspace. Copy final artifacts to this directory. This option is unstable and available only on the nightly channel and requires the -Z unstable-options flag to enable.

What is Cargo build -- release?

The Rust Programming Language Cargo has two main profiles: the dev profile Cargo uses when you run cargo build and the release profile Cargo uses when you run cargo build --release . The dev profile is defined with good defaults for development, and the release profile has good defaults for release builds.

What is Cargo in Rust programming?

Cargo is Rust's build system and package manager. Most Rustaceans use this tool to manage their Rust projects because Cargo handles a lot of tasks for you, such as building your code, downloading the libraries your code depends on, and building those libraries. (We call the libraries that your code needs dependencies.)


1 Answers

As mentioned in the comments, pass the -C target-cpu option to rustc:

rustc -C target-cpu=native

For more options:

$ rustc -C help
    ...     
    -C        target-cpu=val -- select target processor (rustc --print target-cpus for details)
    ...

See How to pass rustc flags to cargo? for more methods of passing the option.

I feel like binary portability isn't really a concern

I'm pretty sure that the Firefox developers that rely on Rust would disagree with you, as well as plenty of others.

like image 196
Shepmaster Avatar answered Sep 22 '22 13:09

Shepmaster