introduce the concept of conflicting CPU features
Extracted from #12220.
$ stage3/bin/zig build-exe empty.zig -target x86_64-freestanding-none -mcpu=x86_64+soft_float
thread 427475 panic: Illegal instruction at address 0x5c6d154
As pointed out in https://github.com/llvm/llvm-project/issues/56351#issuecomment-1173063759, +x87 and +soft_float is a pair of contradictory options. However, Zig currently has no way to denote such contradictions, meaning that a user might easily run into that problem above, and not realize that they could do this:
$ stage3/bin/zig build-exe empty.zig -target x86_64-freestanding-none -mcpu=x86_64+soft_float-x87-sse2-sse
$
This issue is to introduce a field to std.Target.Cpu.Feature for storing conflicts with other features, and then do one of two things:
- introduce a new compile error that occurs when conflicting features are activated
- update the handling of CPU feature sets to automatically remove conflicting features. For example, when
+soft_floatis encountered, zig would infer to automatically do-x87-sse-sse2.
Perhaps we should do both? If a feature conflicts with a default feature, then we know to disable the default feature. If two explicitly-provided features are passed, then we throw an error, since we can't know which feature the user actually intends.