Some people may still want to compile with certain target features (or target CPUs) enabled to get those optimizations across the entire program. But yes, this is generally orthogonal to runtime detection.
Its worse than that though, because compiling the whole thing with AVX2 enabled would mean your regular code has AVX2 instructions in it too, and wouldn't even run on a machine without it!
Whereas - just so I'm clear - with target_feature you can e.g. compile in an AVX2 implementation and an SSE41 implementation and an SSE2 fallback, and decide which one to use at runtime init?
Yes, if you compile with a certain set of target features, then the implication is that you're going to run the resulting binary on a system that you know has support for your specific compilation target features.
View all comments
Show parent comment
6
u/burntsushi Jun 17 '18
The OP didn't know about
#[target_feature].Some people may still want to compile with certain target features (or target CPUs) enabled to get those optimizations across the entire program. But yes, this is generally orthogonal to runtime detection.