From 925d8749e030c9dec49a5e27080000a4f950d625 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Thu, 7 Nov 2024 12:56:49 +0100 Subject: Suggest `-microarch:native` if `popcnt` instruction is missing. Fixes #4453. --- src/main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index b04ee90f1..e65f866a1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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 (;;) { -- cgit v1.2.3 From deb562613f5229e2e3881bd92b7a58e13813ea86 Mon Sep 17 00:00:00 2001 From: Jeroen van Rijn Date: Thu, 7 Nov 2024 13:13:58 +0100 Subject: Phrasing! --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index e65f866a1..92d03b47a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3326,10 +3326,10 @@ int main(int arg_count, char const **arg_ptr) { // 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_printf_err("Error: Try using '-microarch:native' as Odin defaults to %.*s (close to Nehalem), and your CPU seems to be older.\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)); + gb_printf("Suggestion: Try using '-microarch:native' as Odin defaults to %.*s (close to Nehalem), and your CPU seems to be older.\n", LIT(march)); } } #endif -- cgit v1.2.3