How can I pass codegen options to rustc from cargo?

Sorry if it is FAQ.

I want to enable SSE4.2 and saw an article that I must pass target-cpu=native.

I looked at Page Moved but could not find the way.
Could you tell me it or a place of information?

Thanks.

Cargo docs lack the necessary explanations.
I think there are two ways to do what you want, but so far I have found only the first:

cargo rustc --release --bin my_prog_name -- -C target-cpu=native

2 Likes

Thank you!

It seems to work (could compile), but I could not get SSE instructions...

Does anyone know that how to let u64's count method use SSE instruction?

On ARM, to get a nice 2x speedup using NEON instructions in this code snippet, it was necessary to pass:

-C target-feature=+neon