From 0525515beedc99e8f1764df0aecd9e7f02bd2f29 Mon Sep 17 00:00:00 2001 From: Quantum Date: Mon, 19 Jul 2021 20:55:20 -0400 Subject: [PATCH] [host] cmake: use -march=x86-64-v2 when it becomes available GCC 11 will support x86_64 micro-architecture feature levels. What we really want to support is nehalem or newer, which is x86-64-v2, and specifying this instead of nehalem means that we are not tuning for nehalem specifically. --- host/CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index b0d4bd35..e047ef2b 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -17,9 +17,14 @@ if(OPTIMIZE_FOR_NATIVE) add_compile_options("-march=native") endif() else() - CHECK_C_COMPILER_FLAG("-march=nehalem" COMPILER_SUPPORTS_MARCH_NEHALEM) - if(COMPILER_SUPPORTS_MARCH_NEHALEM) - add_compile_options("-march=nehalem") + CHECK_C_COMPILER_FLAG("-march=x86-64-v2" COMPILER_SUPPORTS_MARCH_X86_64_V2) + if(COMPILER_SUPPORTS_MARCH_X86_64_V2) + add_compile_options("-march=x86-64-v2") + else() + CHECK_C_COMPILER_FLAG("-march=nehalem" COMPILER_SUPPORTS_MARCH_NEHALEM) + if(COMPILER_SUPPORTS_MARCH_NEHALEM) + add_compile_options("-march=nehalem") + endif() endif() endif()