-
Notifications
You must be signed in to change notification settings - Fork 294
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #548 from ethereum/cmake_x86-64-v2
cmake: Add option to select micro-arch, use x86-64-v2 by default
- Loading branch information
Showing
4 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
#define STRINGIFY_HELPER(X) #X | ||
#define STRINGIFY(X) STRINGIFY_HELPER(X) | ||
|
||
#if defined(__GNUC__) && __GNUC__ >= 12 | ||
#define CPU_FEATURE "x86-64-v" STRINGIFY(EVMONE_X86_64_ARCH_LEVEL) | ||
#else | ||
// Clang 16 and GCC 11 does not support architecture levels in __builtin_cpu_supports(). | ||
// Use approximations. | ||
#if EVMONE_X86_64_ARCH_LEVEL == 2 | ||
#define CPU_FEATURE "sse4.2" | ||
#endif | ||
#endif | ||
|
||
#ifndef CPU_FEATURE | ||
#error "EVMONE_X86_64_ARCH_LEVEL: Unsupported x86-64 architecture level" | ||
#endif | ||
|
||
#include <cstdio> | ||
#include <cstdlib> | ||
|
||
static bool cpu_check = []() noexcept { | ||
if (!__builtin_cpu_supports(CPU_FEATURE)) | ||
{ | ||
(void)std::fputs("CPU does not support " CPU_FEATURE "\n", stderr); | ||
std::abort(); | ||
} | ||
return false; | ||
}(); |