Suggest -microarch:native if popcnt instruction is missing.

Fixes #4453.
This commit is contained in:
Jeroen van Rijn
2024-11-07 12:56:49 +01:00
parent fd442b8678
commit 925d8749e0
4 changed files with 49 additions and 21 deletions

View File

@@ -3321,6 +3321,19 @@ int main(int arg_count, char const **arg_ptr) {
}
}
#if defined(GB_CPU_X86)
// We've detected that the CPU doesn't support popcnt, or another reason to use `-microarch:native`,
// and that no custom microarch was chosen.
if (should_use_march_native() && march == get_default_microarchitecture()) {
if (command == "run" || command == "test") {
gb_printf_err("Error: Try using '-microarch:native' as Odin defaults to %.*s (close to Nehalem) by default and your CPU seems to be a much older CPU.\n", LIT(march));
gb_exit(1);
} else if (command == "build") {
gb_printf("Suggestion: Try using '-microarch:native' as Odin defaults to %.*s (close to Nehalem) by default and your CPU seems to be a much older CPU.\n", LIT(march));
}
}
#endif
if (build_context.target_features_string.len != 0) {
String_Iterator target_it = {build_context.target_features_string, 0};
for (;;) {