mirror of
https://github.com/openembedded/meta-openembedded.git
synced 2025-12-15 14:56:43 +01:00
highway: Fix cmake to detect riscv32
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
parent
582385a1e6
commit
1a5c939eee
|
|
@ -0,0 +1,76 @@
|
|||
From 5d40c0c49f9acde83ba71b6f59094cdbd12e1b78 Mon Sep 17 00:00:00 2001
|
||||
From: Khem Raj <raj.khem@gmail.com>
|
||||
Date: Tue, 17 Sep 2024 18:22:36 +0000
|
||||
Subject: [PATCH] Add cmake check for deducing 32bit or 64bit RISCV
|
||||
|
||||
Currently its only compilable for RV64 when RVV is
|
||||
enabled, this will extend it to build for RV32 with
|
||||
RVV as well
|
||||
|
||||
Upstream-Status: Pending
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
---
|
||||
CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++--
|
||||
1 file changed, 34 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index ea8b330c..cd824787 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -65,6 +65,34 @@ if (NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE RelWithDebInfo)
|
||||
endif()
|
||||
|
||||
+include(CheckCSourceCompiles)
|
||||
+
|
||||
+check_c_source_compiles("
|
||||
+#if __riscv_xlen == 64
|
||||
+int main() { return 0; }
|
||||
+#else
|
||||
+#error Not RISCV-64
|
||||
+#endif
|
||||
+" IS_RISCV_XLEN_64)
|
||||
+
|
||||
+check_c_source_compiles("
|
||||
+#if __riscv_xlen == 32
|
||||
+int main() { return 0; }
|
||||
+#else
|
||||
+#error Not RISCV-32
|
||||
+#endif
|
||||
+" IS_RISCV_XLEN_32)
|
||||
+
|
||||
+if(IS_RISCV_XLEN_32)
|
||||
+ set(RISCV_XLEN 32)
|
||||
+elseif(IS_RISCV_XLEN_64)
|
||||
+ set(RISCV_XLEN 64)
|
||||
+else()
|
||||
+ message(WARNING "Unable to determine RISC-V XLEN")
|
||||
+endif()
|
||||
+
|
||||
+message(STATUS "RISC-V XLEN: ${RISCV_XLEN}")
|
||||
+
|
||||
# The following is only required with GCC < 6.1.0 or CLANG < 16.0
|
||||
set(HWY_CMAKE_ARM7 OFF CACHE BOOL "Set copts for Armv7 with NEON (requires vfpv4)?")
|
||||
|
||||
@@ -72,7 +100,7 @@ set(HWY_CMAKE_ARM7 OFF CACHE BOOL "Set copts for Armv7 with NEON (requires vfpv4
|
||||
# skipped. For GCC 13.1+, you can also build with -fexcess-precision=standard.
|
||||
set(HWY_CMAKE_SSE2 OFF CACHE BOOL "Set SSE2 as baseline for 32-bit x86?")
|
||||
|
||||
-# Currently this will compile the entire codebase with `-march=rv64gcv1p0`:
|
||||
+# Currently this will compile the entire codebase with `-march=rv<XLEN>gcv1p0`:
|
||||
set(HWY_CMAKE_RVV ON CACHE BOOL "Set copts for RISCV with RVV?")
|
||||
|
||||
# Unconditionally adding -Werror risks breaking the build when new warnings
|
||||
@@ -378,7 +406,11 @@ else()
|
||||
# we add the gcv compiler flag, which then requires the CPU (now when using
|
||||
# either compiler) to support V.
|
||||
if(HWY_CMAKE_RVV)
|
||||
- list(APPEND HWY_FLAGS -march=rv64gcv1p0)
|
||||
+ if(RISCV_XLEN EQUAL 64)
|
||||
+ list(APPEND HWY_FLAGS -march=rv64gcv1p0)
|
||||
+ elseif(RISCV_XLEN EQUAL 32)
|
||||
+ list(APPEND HWY_FLAGS -march=rv32gcv1p0)
|
||||
+ endif()
|
||||
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
|
||||
list(APPEND HWY_FLAGS -menable-experimental-extensions)
|
||||
endif()
|
||||
|
|
@ -6,15 +6,16 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=2b42edef8fa55315f34f2370b4715ca9"
|
|||
|
||||
inherit cmake
|
||||
|
||||
SRC_URI = "git://github.com/google/highway.git;protocol=https;branch=master"
|
||||
SRC_URI = "git://github.com/google/highway.git;protocol=https;branch=master \
|
||||
file://0001-Add-cmake-check-for-deducing-32bit-or-64bit-RISCV.patch"
|
||||
|
||||
SRCREV = "457c891775a7397bdb0376bb1031e6e027af1c48"
|
||||
S = "${WORKDIR}/git"
|
||||
|
||||
EXTRA_OECMAKE = "-DBUILD_TESTING=0 -DCMAKE_BUILD_TYPE=Release"
|
||||
# RVV is enabled by default and highway cmake system assumes that RISCV64 = RISCV
|
||||
EXTRA_OECMAKE:append:riscv32 = " -DHWY_CMAKE_RVV=OFF"
|
||||
|
||||
CXXFLAGS:append:arm = " -mfp16-format=ieee"
|
||||
# Option not supported with clang and its default format for __fp16 anyway with clang
|
||||
CXXFLAGS:remove:toolchain-clang = "-mfp16-format=ieee"
|
||||
|
||||
TOOLCHAIN = "gcc"
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user