# cleanup CPU model & feature detection · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/49817c6adde3e9e98282dcecd017ab076faa1d85)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 49817c6adde3e9e98282dcecd017ab076faa1d85

Requested commit: 49817c6adde3e9e98282dcecd017ab076faa1d85

Commit: 49817c6adde3e9e98282dcecd017ab076faa1d85

Tree: e4a9863a9cf0c8d3fbdb1e1745573e7e5b499587

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
cleanup CPU model & feature detection

Add std.Target.Cpu.Model.generic which is even more empty than baseline.
CPU model and feature detection uses this rather than baseline.

Rename cpu_detected to cpu_detection_unimplemented and flip the logic.
It can be relied on by stage2.zig to decide whether the LLVM workaround
is needed without also checking the CrossTarget.

Move the CPU detection to after the OS detection, and use the detected
OS for the CPU detection. This is relevant because operating systems
sometimes emulate certain CPU features, so knowing the OS and version is
relevant for determining CPU features.

Prepare for #4592 by passing the CPU arch to the detection code, instead
of having it rely on Target.current.

The CPU model & feature detection logic is modified. Before:

 * Detect actual features
 * Use as hint when detecting CPU model
 * Populate dependencies of CPU model features
 * Merge that into the actual features set

After:

 * Detect actual features
 * Use as hint when detecting CPU model
 * Add known CPU model features to actual features
 * Detect actual features again, overriding known CPU model features
 * Populate dependencies

```

## Parents

- [f19918256746ccc81b6ff11d17e98665b4853400](https://git.cafe/gitcafe/zig/commit/f19918256746ccc81b6ff11d17e98665b4853400?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/49817c6adde3e9e98282dcecd017ab076faa1d85?format=markdown)
