diff mbox series

[v6,06/10] package/fp16: new package

Message ID 20230316083440.3466725-6-james.hilliard1@gmail.com
State New
Headers show
Series [v6,01/10] package/cpuinfo: new package | expand

Commit Message

James Hilliard March 16, 2023, 8:34 a.m. UTC
This package is required by tensorflow-lite.

We need to add a patch to remove the c++ requirement.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
Changes v5 -> v6:
  - add patch fixing build without c++
Changes v4 -> v5:
  - add comment indicating library is header only
---
 DEVELOPERS                                    |  1 +
 package/Config.in                             |  1 +
 ...le-CXX-unless-building-tests-benchma.patch | 48 +++++++++++++++++++
 package/fp16/Config.in                        |  8 ++++
 package/fp16/fp16.hash                        |  4 ++
 package/fp16/fp16.mk                          | 20 ++++++++
 6 files changed, 82 insertions(+)
 create mode 100644 package/fp16/0001-CMake-don-t-enable-CXX-unless-building-tests-benchma.patch
 create mode 100644 package/fp16/Config.in
 create mode 100644 package/fp16/fp16.hash
 create mode 100644 package/fp16/fp16.mk
diff mbox series

Patch

diff --git a/DEVELOPERS b/DEVELOPERS
index 24c571544d..12b33c5fbc 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -2687,6 +2687,7 @@  F:	package/ti-gfx/
 
 N:	Stefan Hager <stefan.hager@ginzinger.com>
 F:	package/cpuinfo/
+F:	package/fp16/
 F:	package/gemmlowp/
 F:	package/psimd/
 F:	package/pthreadpool/
diff --git a/package/Config.in b/package/Config.in
index ac9241f18b..4878e8ba2f 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -2036,6 +2036,7 @@  menu "Other"
 	source "package/flann/Config.in"
 	source "package/flatbuffers/Config.in"
 	source "package/flatcc/Config.in"
+	source "package/fp16/Config.in"
 	source "package/fxdiv/Config.in"
 	source "package/gconf/Config.in"
 	source "package/gdal/Config.in"
diff --git a/package/fp16/0001-CMake-don-t-enable-CXX-unless-building-tests-benchma.patch b/package/fp16/0001-CMake-don-t-enable-CXX-unless-building-tests-benchma.patch
new file mode 100644
index 0000000000..b3c5219d59
--- /dev/null
+++ b/package/fp16/0001-CMake-don-t-enable-CXX-unless-building-tests-benchma.patch
@@ -0,0 +1,48 @@ 
+From eba14b5277ed8f155eb333f4bbe9f99366e3dece Mon Sep 17 00:00:00 2001
+From: James Hilliard <james.hilliard1@gmail.com>
+Date: Sun, 29 Jan 2023 21:43:50 -0700
+Subject: [PATCH] CMake: don't enable CXX unless building tests/benchmarks
+
+We only need CXX support when building tests/benchmarks.
+
+Fixes:
+CMake Error at CMakeLists.txt:6 (PROJECT):
+  No CMAKE_CXX_COMPILER could be found.
+
+  Tell CMake where to find the compiler by setting either the environment
+  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
+  to the compiler, or to the compiler name if it is in the PATH.
+
+Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
+[Upstream status:
+https://github.com/Maratyszcza/FP16/pull/22]
+---
+ CMakeLists.txt | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 5e7d127..8028c07 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -3,13 +3,17 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR)
+ INCLUDE(GNUInstallDirs)
+ 
+ # ---[ Project
+-PROJECT(FP16 C CXX)
++PROJECT(FP16 C)
+ 
+ # ---[ Options.
+ OPTION(FP16_BUILD_TESTS "Build FP16 unit tests" ON)
+ OPTION(FP16_BUILD_BENCHMARKS "Build FP16 micro-benchmarks" ON)
+ 
+ # ---[ CMake options
++IF(FP16_BUILD_TESTS OR FP16_BUILD_BENCHMARKS)
++  ENABLE_LANGUAGE(CXX)
++ENDIF()
++
+ IF(FP16_BUILD_TESTS)
+   ENABLE_TESTING()
+ ENDIF()
+-- 
+2.34.1
+
diff --git a/package/fp16/Config.in b/package/fp16/Config.in
new file mode 100644
index 0000000000..e07c6ebb8a
--- /dev/null
+++ b/package/fp16/Config.in
@@ -0,0 +1,8 @@ 
+config BR2_PACKAGE_FP16
+	bool "fp16"
+	select BR2_PACKAGE_PSIMD
+	help
+	  Header-only library for conversion to/from half-precision
+	  floating point formats.
+
+	  https://github.com/Maratyszcza/FP16
diff --git a/package/fp16/fp16.hash b/package/fp16/fp16.hash
new file mode 100644
index 0000000000..63634eb2cf
--- /dev/null
+++ b/package/fp16/fp16.hash
@@ -0,0 +1,4 @@ 
+# Locally calculated
+sha256  a91f4770ff9c39f4d72e339c379f566b3bbb359fa66122d85fc0bae3dde7abc7  fp16-0a92994d729ff76a58f692d3028ca1b64b145d91.tar.gz
+# License files, locally calculated
+sha256  17e4f539024be2749ee729d1e2f01d24cef12ece8c9bf18e91a4349be29c80bf  LICENSE
diff --git a/package/fp16/fp16.mk b/package/fp16/fp16.mk
new file mode 100644
index 0000000000..80710523fb
--- /dev/null
+++ b/package/fp16/fp16.mk
@@ -0,0 +1,20 @@ 
+################################################################################
+#
+# fp16
+#
+################################################################################
+
+FP16_VERSION = 0a92994d729ff76a58f692d3028ca1b64b145d91
+FP16_SITE = $(call github,Maratyszcza,FP16,$(FP16_VERSION))
+FP16_LICENSE = MIT
+FP16_LICENSE_FILES = LICENSE
+FP16_INSTALL_STAGING = YES
+# Only installs a header
+FP16_INSTALL_TARGET = NO
+FP16_DEPENDENCIES = psimd
+FP16_CONF_OPTS = \
+	-DFP16_BUILD_TESTS=OFF \
+	-DFP16_BUILD_BENCHMARKS=OFF \
+	-DPSIMD_SOURCE_DIR="$(PSIMD_DIR)"
+
+$(eval $(cmake-package))