From e1fba7a7b4418e58e8c595619106d7a3df6b4db4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josep=20Maria=20Antol=C3=ADn=20Segura?= Date: Sat, 22 Jun 2024 03:20:49 +0200 Subject: [PATCH] Fixes to build under arm32 ( raspberry pi on 32bit debian). (#261) --- CMakeLists.txt | 9 +++++++-- cmake/arch-detect.cmake | 9 ++++++++- src/codegen/codegen.cmake | 16 +++++++--------- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c42c6415..7cce6c1d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,8 +15,13 @@ if(${PCEM_CPU_TYPE} STREQUAL "i386") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -msse2") endif() -set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fomit-frame-pointer -mstackrealign -fno-strict-aliasing") -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -mstackrealign -fno-strict-aliasing") +if(${PCEM_CPU_TYPE} MATCHES "arm.*") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fomit-frame-pointer -fno-strict-aliasing") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -fno-strict-aliasing") +else() + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -fomit-frame-pointer -mstackrealign -fno-strict-aliasing") + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -mstackrealign -fno-strict-aliasing") +endif() if (UNIX) add_definitions(-D_FILE_OFFSET_BITS=64) diff --git a/cmake/arch-detect.cmake b/cmake/arch-detect.cmake index a43026a2..753d22c3 100644 --- a/cmake/arch-detect.cmake +++ b/cmake/arch-detect.cmake @@ -1,9 +1,15 @@ set(archdetect_c_code " #if defined(__arm__) || defined(__TARGET_ARCH_ARM) - #if defined(__ARM_ARCH_7__) \\ + #if defined(__ARM_ARCH_8__) \\ + || defined(__ARM_ARCH_8A__) \\ + || (defined(__ARM_ARCH) && __ARM_ARCH >= 8) \\ + || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 8) + #error cmake_ARCH armv8 + #elif defined(__ARM_ARCH_7__) \\ || defined(__ARM_ARCH_7A__) \\ || defined(__ARM_ARCH_7R__) \\ || defined(__ARM_ARCH_7M__) \\ + || (defined(__ARM_ARCH) && __ARM_ARCH >= 7) \\ || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7) #error cmake_ARCH armv7 #elif defined(__ARM_ARCH_6__) \\ @@ -13,6 +19,7 @@ set(archdetect_c_code " || defined(__ARM_ARCH_6K__) \\ || defined(__ARM_ARCH_6ZK__) \\ || defined(__ARM_ARCH_6M__) \\ + || (defined(__ARM_ARCH) && __ARM_ARCH >= 6) \\ || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6) #error cmake_ARCH armv6 #elif defined(__ARM_ARCH_5TEJ__) \\ diff --git a/src/codegen/codegen.cmake b/src/codegen/codegen.cmake index c164f938..204f6321 100644 --- a/src/codegen/codegen.cmake +++ b/src/codegen/codegen.cmake @@ -106,14 +106,6 @@ if(${PCEM_CPU_TYPE} STREQUAL "i386") ) endif() -if(${PCEM_CPU_TYPE} STREQUAL "arm") - set(PCEM_SRC ${PCEM_SRC} - codegen/arm32/codegen_backend_arm.c - codegen/arm32/codegen_backend_arm_ops.c - codegen/arm32/codegen_backend_arm_uops.c - ) -endif() - if(${PCEM_CPU_TYPE} STREQUAL "arm64") set(PCEM_SRC ${PCEM_SRC} codegen/arm64/codegen_backend_arm64.c @@ -121,4 +113,10 @@ if(${PCEM_CPU_TYPE} STREQUAL "arm64") codegen/arm64/codegen_backend_arm64_ops.c codegen/arm64/codegen_backend_arm64_uops.c ) -endif() \ No newline at end of file +elseif(${PCEM_CPU_TYPE} MATCHES "armv.*") + set(PCEM_SRC ${PCEM_SRC} + codegen/arm32/codegen_backend_arm.c + codegen/arm32/codegen_backend_arm_ops.c + codegen/arm32/codegen_backend_arm_uops.c + ) +endif()