Make codegen use a compatible target-cpu, but tune for a modern one

As an occasionally packager coming from gcc and clang, I find the ability to specify separate -march and -mtune options in these compilers a nice thing. These switches tell the compiler to generate code that work for a wide range of CPUs, but schedule the code such that it works better with the microarchitectual details of some CPU that may be newer and more popular. At least in theory, it's a nice thing for people.

I checked the codegen documentation, and it seems that the only place that accepts a model or whatever llvm's designator is target-cpu, which does basically -march only. I could do what I want by manually removing features, but that would be really tedious.

When clang implemented -mtune, they left a tune-cpu attribute in the LLVM codegen thing for people to use. Can Rust expose that thing somehow?

(tune-cpu is only checked by the x86 target, because when clang did it GCC was only giving -mtune to x86. Now GCC is giving that to every arch, so I think a separate LLVM discussion is in order. ARM already put it in their fork.)

1 Like

I think this is best discussed on

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.