summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKhem Raj <raj.khem@gmail.com>2024-09-17 18:27:24 +0000
committerKhem Raj <raj.khem@gmail.com>2024-09-17 13:58:13 -0700
commit1a5c939eeed75d26226e0e5afb3445740e358a7d (patch)
tree2759c7ddef15fba10dd60603ce54ac771e70cb45
parent582385a1e6ce9bedb0fa1652087bf8898e5397fe (diff)
downloadmeta-openembedded-1a5c939eeed75d26226e0e5afb3445740e358a7d.tar.gz
highway: Fix cmake to detect riscv32
Signed-off-by: Khem Raj <raj.khem@gmail.com>
-rw-r--r--meta-oe/recipes-extended/highway/highway/0001-Add-cmake-check-for-deducing-32bit-or-64bit-RISCV.patch76
-rw-r--r--meta-oe/recipes-extended/highway/highway_1.2.0.bb7
2 files changed, 80 insertions, 3 deletions
diff --git a/meta-oe/recipes-extended/highway/highway/0001-Add-cmake-check-for-deducing-32bit-or-64bit-RISCV.patch b/meta-oe/recipes-extended/highway/highway/0001-Add-cmake-check-for-deducing-32bit-or-64bit-RISCV.patch
new file mode 100644
index 0000000000..bafe218f0d
--- /dev/null
+++ b/meta-oe/recipes-extended/highway/highway/0001-Add-cmake-check-for-deducing-32bit-or-64bit-RISCV.patch
@@ -0,0 +1,76 @@
1From 5d40c0c49f9acde83ba71b6f59094cdbd12e1b78 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Tue, 17 Sep 2024 18:22:36 +0000
4Subject: [PATCH] Add cmake check for deducing 32bit or 64bit RISCV
5
6Currently its only compilable for RV64 when RVV is
7enabled, this will extend it to build for RV32 with
8RVV as well
9
10Upstream-Status: Pending
11Signed-off-by: Khem Raj <raj.khem@gmail.com>
12---
13 CMakeLists.txt | 36 ++++++++++++++++++++++++++++++++++--
14 1 file changed, 34 insertions(+), 2 deletions(-)
15
16diff --git a/CMakeLists.txt b/CMakeLists.txt
17index ea8b330c..cd824787 100644
18--- a/CMakeLists.txt
19+++ b/CMakeLists.txt
20@@ -65,6 +65,34 @@ if (NOT CMAKE_BUILD_TYPE)
21 set(CMAKE_BUILD_TYPE RelWithDebInfo)
22 endif()
23
24+include(CheckCSourceCompiles)
25+
26+check_c_source_compiles("
27+#if __riscv_xlen == 64
28+int main() { return 0; }
29+#else
30+#error Not RISCV-64
31+#endif
32+" IS_RISCV_XLEN_64)
33+
34+check_c_source_compiles("
35+#if __riscv_xlen == 32
36+int main() { return 0; }
37+#else
38+#error Not RISCV-32
39+#endif
40+" IS_RISCV_XLEN_32)
41+
42+if(IS_RISCV_XLEN_32)
43+ set(RISCV_XLEN 32)
44+elseif(IS_RISCV_XLEN_64)
45+ set(RISCV_XLEN 64)
46+else()
47+ message(WARNING "Unable to determine RISC-V XLEN")
48+endif()
49+
50+message(STATUS "RISC-V XLEN: ${RISCV_XLEN}")
51+
52 # The following is only required with GCC < 6.1.0 or CLANG < 16.0
53 set(HWY_CMAKE_ARM7 OFF CACHE BOOL "Set copts for Armv7 with NEON (requires vfpv4)?")
54
55@@ -72,7 +100,7 @@ set(HWY_CMAKE_ARM7 OFF CACHE BOOL "Set copts for Armv7 with NEON (requires vfpv4
56 # skipped. For GCC 13.1+, you can also build with -fexcess-precision=standard.
57 set(HWY_CMAKE_SSE2 OFF CACHE BOOL "Set SSE2 as baseline for 32-bit x86?")
58
59-# Currently this will compile the entire codebase with `-march=rv64gcv1p0`:
60+# Currently this will compile the entire codebase with `-march=rv<XLEN>gcv1p0`:
61 set(HWY_CMAKE_RVV ON CACHE BOOL "Set copts for RISCV with RVV?")
62
63 # Unconditionally adding -Werror risks breaking the build when new warnings
64@@ -378,7 +406,11 @@ else()
65 # we add the gcv compiler flag, which then requires the CPU (now when using
66 # either compiler) to support V.
67 if(HWY_CMAKE_RVV)
68- list(APPEND HWY_FLAGS -march=rv64gcv1p0)
69+ if(RISCV_XLEN EQUAL 64)
70+ list(APPEND HWY_FLAGS -march=rv64gcv1p0)
71+ elseif(RISCV_XLEN EQUAL 32)
72+ list(APPEND HWY_FLAGS -march=rv32gcv1p0)
73+ endif()
74 if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
75 list(APPEND HWY_FLAGS -menable-experimental-extensions)
76 endif()
diff --git a/meta-oe/recipes-extended/highway/highway_1.2.0.bb b/meta-oe/recipes-extended/highway/highway_1.2.0.bb
index 020116d864..d226cd82ce 100644
--- a/meta-oe/recipes-extended/highway/highway_1.2.0.bb
+++ b/meta-oe/recipes-extended/highway/highway_1.2.0.bb
@@ -6,15 +6,16 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=2b42edef8fa55315f34f2370b4715ca9"
6 6
7inherit cmake 7inherit cmake
8 8
9SRC_URI = "git://github.com/google/highway.git;protocol=https;branch=master" 9SRC_URI = "git://github.com/google/highway.git;protocol=https;branch=master \
10 file://0001-Add-cmake-check-for-deducing-32bit-or-64bit-RISCV.patch"
10 11
11SRCREV = "457c891775a7397bdb0376bb1031e6e027af1c48" 12SRCREV = "457c891775a7397bdb0376bb1031e6e027af1c48"
12S = "${WORKDIR}/git" 13S = "${WORKDIR}/git"
13 14
14EXTRA_OECMAKE = "-DBUILD_TESTING=0 -DCMAKE_BUILD_TYPE=Release" 15EXTRA_OECMAKE = "-DBUILD_TESTING=0 -DCMAKE_BUILD_TYPE=Release"
15# RVV is enabled by default and highway cmake system assumes that RISCV64 = RISCV
16EXTRA_OECMAKE:append:riscv32 = " -DHWY_CMAKE_RVV=OFF"
17 16
18CXXFLAGS:append:arm = " -mfp16-format=ieee" 17CXXFLAGS:append:arm = " -mfp16-format=ieee"
19# Option not supported with clang and its default format for __fp16 anyway with clang 18# Option not supported with clang and its default format for __fp16 anyway with clang
20CXXFLAGS:remove:toolchain-clang = "-mfp16-format=ieee" 19CXXFLAGS:remove:toolchain-clang = "-mfp16-format=ieee"
20
21TOOLCHAIN = "gcc"