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.
This commit is contained in:
Michael Orlitzky 2024-09-20 22:05:28 -04:00
parent 2765ec9302
commit a407780915

View file

@ -343,6 +343,16 @@ if(MINGW)
add_definitions(-D_WIN32_WINNT=0x600) add_definitions(-D_WIN32_WINNT=0x600)
endif() 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 # extra needed libraries
# we prefer -l<lib> test over `find_library` as sometimes core libraries # we prefer -l<lib> test over `find_library` as sometimes core libraries