On 2018-03-08 11:58:41 -0800, Andres Freund wrote:
> I think we can easily fix this by behaving like clang, which uses
> llvm::sys::getHostCPUFeatures(HostFeatures) to built the feature list:
>
> // If -march=native, autodetect the feature list.
> if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
> if (StringRef(A->getValue()) == "native") {
> llvm::StringMap<bool> HostFeatures;
> if (llvm::sys::getHostCPUFeatures(HostFeatures))
> for (auto &F : HostFeatures)
> Features.push_back(
> Args.MakeArgString((F.second ? "+" : "-") + F.first()));
> }
> }
>
> which seems easy enough.
Or even in core LLVM, which has this nice comment:
// If user asked for the 'native' CPU, we need to autodetect features.
// This is necessary for x86 where the CPU might not support all the
// features the autodetected CPU name lists in the target. For example,
// not all Sandybridge processors support AVX.
if (MCPU == "native") {
which pretty much describes the issue you're apparently hitting.
I've pushed an attempted fix (needs a comment, but works here).
Greetings,
Andres Freund