From a407780915469a7352b2ca8b0b6d698b0d82bd3f Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Fri, 20 Sep 2024 22:05:28 -0400 Subject: [PATCH] CMakeLists.txt: check /proc/cpuinfo for an SV39 MMU If the host has an SV39 MMU, the usual aligned hinting strategy will not work despite the system being 64-bit. On RISC-V linux systems, the type of MMU can be read from /proc/cpuinfo. If we find one, a constant is defined that will allow us to skip the aligned hinting when the time comes. --- CMakeLists.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index bcfe91d8..20b22c09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -343,6 +343,16 @@ if(MINGW) add_definitions(-D_WIN32_WINNT=0x600) endif() +# Check /proc/cpuinfo for an SV39 MMU and define a constant if one is +# found. We will want to skip the aligned hinting in that case. +if (EXISTS /proc/cpuinfo) + file(STRINGS /proc/cpuinfo mi_sv39_mmu REGEX "^mmu[ \t]+:[ \t]+sv39$") + if (mi_sv39_mmu) + MESSAGE( STATUS "SV39 MMU detected" ) + list(APPEND mi_defines MI_SV39_MMU=1) + endif() +endif() + # extra needed libraries # we prefer -l test over `find_library` as sometimes core libraries