git: be729ef9da64 - main - lang/pocl: Update to POCL 3.1

From: Fernando Apesteguía <fernape_at_FreeBSD.org>
Date: Wed, 03 May 2023 08:06:32 UTC
The branch main has been updated by fernape:

URL: https://cgit.FreeBSD.org/ports/commit/?id=be729ef9da645eb8edea50e3239ef8538306a757

commit be729ef9da645eb8edea50e3239ef8538306a757
Author:     O. Hartmann <ohartmann@walstatt.org>
AuthorDate: 2023-05-02 10:37:07 +0000
Commit:     Fernando Apesteguía <fernape@FreeBSD.org>
CommitDate: 2023-05-03 08:01:44 +0000

    lang/pocl: Update to POCL 3.1
    
    PR:             271159
    Reported by:    ohartmann@walstatt.org (maintainer)
---
 lang/pocl/Makefile                             | 26 ++++++++++++--------------
 lang/pocl/distinfo                             |  6 +++---
 lang/pocl/files/patch-CMakeLists.txt           | 10 +++++-----
 lang/pocl/files/patch-config.h.in.cmake        |  4 ++--
 lang/pocl/files/patch-lib_CL_devices_cpuinfo.c | 16 ++++++++--------
 lang/pocl/files/patch-lib_CL_pocl__timing.c    | 13 +++++++++++++
 lang/pocl/pkg-descr                            | 21 ++++++++++++++++-----
 lang/pocl/pkg-message                          | 18 ++++++++++++++++++
 lang/pocl/pkg-plist                            |  3 +--
 9 files changed, 78 insertions(+), 39 deletions(-)

diff --git a/lang/pocl/Makefile b/lang/pocl/Makefile
index 4b7f2dc2a34f..682871ce64be 100644
--- a/lang/pocl/Makefile
+++ b/lang/pocl/Makefile
@@ -1,11 +1,11 @@
 PORTNAME=	pocl
-PORTVERSION=	1.8
-DISTVERSIONPREFIX=v
+DISTVERSIONPREFIX=	v
+DISTVERSION=	3.1
 CATEGORIES=	lang
 
-MAINTAINER=	ohartmann@freebsd-de.org
+MAINTAINER=	ohartmann@walstatt.org
 COMMENT=	POrtable Computing Language (POCL)
-WWW=		http://portablecl.org/
+WWW=	http://portablecl.org/
 
 LICENSE=	MIT
 LICENSE_FILE=	${WRKSRC}/LICENSE
@@ -14,16 +14,15 @@ ONLY_FOR_ARCHS=	aarch64 amd64 i386 powerpc64 powerpc64le
 ONLY_FOR_ARCHS_REASON=	only tested on ${ONLY_FOR_ARCHS:tW:S/ /, /g}
 BROKEN_i386=	Unable to access file /wrkdirs/usr/ports/lang/pocl/work/stage/usr/local/share/pocl/kernel-i386-portbld-freebsd13.0-avx.bc:No such file or directory
 
-BUILD_DEPENDS=	llvm${LLVM_VERSION}>=10:devel/llvm${LLVM_VERSION} \
-		opencl>=2.2:devel/opencl
+BUILD_DEPENDS=	llvm${LLVM_VERSION}>=14:devel/llvm${LLVM_VERSION} \
+		opencl>=3:devel/opencl
 LIB_DEPENDS=	libhwloc.so:devel/hwloc2 libOpenCL.so:devel/ocl-icd
-RUN_DEPENDS=	${BUILD_DEPENDS}
 
 USES=		cmake localbase:ldflags ncurses pkgconfig
 USE_GITHUB=	yes
 USE_LDCONFIG=	yes
 
-LLVM_VERSION=	${MESA_LLVM_VER:U13}
+LLVM_VERSION=	${MESA_LLVM_VER:U15}
 CMAKE_ARGS=	-DWITH_LLVM_CONFIG="${LOCALBASE}/llvm${LLVM_VERSION}/bin/llvm-config" \
 		-DPOCL_INSTALL_PKGCONFIG_DIR="${PREFIX}/libdata/pkgconfig" \
 		-DSINGLE_LLVM_LIB=ON \
@@ -38,21 +37,21 @@ PLIST_SUB=	CONFIGURE_TARGET=${CONFIGURE_TARGET:S/amd64/x86_64/}
 
 OPTIONS_DEFINE=	DOCS
 
-DOCS_DESC=	Build documentation (needs sphinx)
-DOCS_CMAKE_OFF=	-DENABLE_DOCS=OFF
+DOCS_DESC=	Build documentation (needs textproc/py-sphinx)
 DOCS_CMAKE_ON=	-DENABLE_DOCS=ON
+DOCS_CMAKE_OFF=	-DENABLE_DOCS=OFF
 DOCS_USES=	python:3.6+
-DOCS_BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}sphinx>=0,1:textproc/py-sphinx@${PY_FLAVOR}
+DOCS_BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}sphinx>=0:textproc/py-sphinx@${PY_FLAVOR}
 
 .include <bsd.port.options.mk>
 
 .if ${ARCH} == aarch64
-PLIST_SUB+=     AARCH64=""
+PLIST_SUB+=	AARCH64=""
 PLIST_SUB+=	PPC64="@comment "
 PLIST_SUB+=	PPC64LE="@comment "
 PLIST_SUB+=	X86="@comment "
 .elif ${ARCH} == amd64 || ${ARCH} == i386
-PLIST_SUB+=     AARCH64="@comment "
+PLIST_SUB+=	AARCH64="@comment "
 PLIST_SUB+=	PPC64="@comment "
 PLIST_SUB+=	PPC64LE="@comment "
 PLIST_SUB+=	X86=""
@@ -67,6 +66,5 @@ PLIST_SUB+=	PPC64="@comment "
 PLIST_SUB+=	PPC64LE=""
 PLIST_SUB+=	X86="@comment "
 .endif
-PLIST_SUB+=	CONFIGURE_TARGET=${CONFIGURE_TARGET:S/amd64/x86_64/}
 
 .include <bsd.port.mk>
diff --git a/lang/pocl/distinfo b/lang/pocl/distinfo
index 5b95d2ff1d4f..a60086168896 100644
--- a/lang/pocl/distinfo
+++ b/lang/pocl/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1634367852
-SHA256 (pocl-pocl-v1.8_GH0.tar.gz) = 0f63377ae1826e16e90038fc8e7f65029be4ff6f9b059f6907174b5c0d1f8ab2
-SIZE (pocl-pocl-v1.8_GH0.tar.gz) = 1614545
+TIMESTAMP = 1670346593
+SHA256 (pocl-pocl-v3.1_GH0.tar.gz) = 82314362552e050aff417318dd623b18cf0f1d0f84f92d10a7e3750dd12d3a9a
+SIZE (pocl-pocl-v3.1_GH0.tar.gz) = 1928607
diff --git a/lang/pocl/files/patch-CMakeLists.txt b/lang/pocl/files/patch-CMakeLists.txt
index f5e41ee6b99e..ac4253d87ac6 100644
--- a/lang/pocl/files/patch-CMakeLists.txt
+++ b/lang/pocl/files/patch-CMakeLists.txt
@@ -1,12 +1,12 @@
---- CMakeLists.txt.orig	2020-12-16 13:02:13 UTC
+--- CMakeLists.txt.orig	2022-06-10 10:09:05 UTC
 +++ CMakeLists.txt
-@@ -398,6 +398,9 @@ endif()
- 
- 
+@@ -394,6 +394,9 @@ find_package(Hwloc)
+       set(ENABLE_HWLOC ON CACHE BOOL "Hwloc" FORCE)
+   endif()
  
 +include(CheckIncludeFiles)
 +check_include_files("sys/types.h;sys/sysctl.h" HAVE_SYSCTL_H)
 +
  
- ######################################################################################
+ include(sanitizers)
  
diff --git a/lang/pocl/files/patch-config.h.in.cmake b/lang/pocl/files/patch-config.h.in.cmake
index d252edbc8c5f..6f507f989de8 100644
--- a/lang/pocl/files/patch-config.h.in.cmake
+++ b/lang/pocl/files/patch-config.h.in.cmake
@@ -1,6 +1,6 @@
---- config.h.in.cmake.orig	2020-12-16 13:02:13 UTC
+--- config.h.in.cmake.orig	2022-06-10 10:09:05 UTC
 +++ config.h.in.cmake
-@@ -39,6 +39,8 @@
+@@ -57,6 +57,8 @@
  
  #cmakedefine HAVE_VFORK
  
diff --git a/lang/pocl/files/patch-lib_CL_devices_cpuinfo.c b/lang/pocl/files/patch-lib_CL_devices_cpuinfo.c
index ddc39b56f3a0..ce0187187300 100644
--- a/lang/pocl/files/patch-lib_CL_devices_cpuinfo.c
+++ b/lang/pocl/files/patch-lib_CL_devices_cpuinfo.c
@@ -1,5 +1,5 @@
---- lib/CL/devices/cpuinfo.c.orig	2021-10-12 16:33:15.000000000 +0200
-+++ lib/CL/devices/cpuinfo.c	2021-10-16 09:29:13.414668000 +0200
+--- lib/CL/devices/cpuinfo.c.orig	2022-06-10 10:09:05 UTC
++++ lib/CL/devices/cpuinfo.c
 @@ -34,6 +34,12 @@
  #include "config.h"
  #include "cpuinfo.h"
@@ -13,7 +13,7 @@
  static const char* cpuinfo = "/proc/cpuinfo";
  #define MAX_CPUINFO_SIZE 64*1024
  //#define DEBUG_POCL_CPUINFO
-@@ -41,9 +47,6 @@
+@@ -41,9 +47,6 @@ static const char* cpufreq_file="/sys/devices/system/c
  //Linux' cpufrec interface
  static const char* cpufreq_file="/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq";
  
@@ -23,7 +23,7 @@
  /* Strings to parse in /proc/cpuinfo. Else branch is for x86, x86_64 */
  #if   defined  __powerpc__
   #define FREQSTRING "clock"
-@@ -156,8 +159,51 @@
+@@ -156,8 +159,51 @@ pocl_cpuinfo_detect_max_clock_frequency()
      } 
    return -1;  
  }
@@ -75,7 +75,7 @@
  /**
   * Detects the number of parallel hardware threads supported by
   * the CPU by parsing the cpuinfo.
-@@ -235,6 +281,19 @@
+@@ -235,6 +281,19 @@ pocl_cpuinfo_detect_compute_unit_count()
      } 
    return -1;  
  }
@@ -95,7 +95,7 @@
  
  #if __arm__ || __aarch64__
  enum
-@@ -302,6 +361,7 @@
+@@ -302,6 +361,7 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_device_id devi
     * short_name is in the .data anyways.*/
    device->long_name = device->short_name;
  
@@ -103,7 +103,7 @@
    /* default vendor and vendor_id, in case it cannot be found by other means */
    device->vendor = cpuvendor_default;
    if (device->vendor_id == 0)
-@@ -404,7 +464,26 @@
+@@ -404,7 +464,26 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_device_id devi
    char *new_name = (char*)malloc (len);
    snprintf (new_name, len, "%s-%s", device->short_name, start);
    device->long_name = new_name;
@@ -130,7 +130,7 @@
    /* If the vendor_id field is still empty, we should get the PCI ID associated
     * with the CPU vendor (if there is one), to be ready for the (currently
     * provisional) OpenCL 3.0 specification that has finally clarified the
-@@ -415,13 +494,23 @@
+@@ -415,13 +494,23 @@ pocl_cpuinfo_get_cpu_name_and_vendor(cl_device_id devi
     */
    if (!device->vendor_id)
      {
diff --git a/lang/pocl/files/patch-lib_CL_pocl__timing.c b/lang/pocl/files/patch-lib_CL_pocl__timing.c
new file mode 100644
index 000000000000..5450f1b75652
--- /dev/null
+++ b/lang/pocl/files/patch-lib_CL_pocl__timing.c
@@ -0,0 +1,13 @@
+--- lib/CL/pocl_timing.c.orig	2022-06-10 10:09:05 UTC
++++ lib/CL/pocl_timing.c
+@@ -69,8 +69,8 @@ uint64_t pocl_gettimemono_ns() {
+   struct timespec timespec;
+ # ifdef CLOCK_MONOTONIC_RAW /* Linux */
+   clock_gettime(CLOCK_MONOTONIC_RAW, &timespec);
+-# elif defined(CLOCK_UPTIME_FAST) /* FreeBSD, DragonFlyBSD, etc */
+-  clock_gettime(CLOCK_UPTIME_FAST, &timespec);
++# elif defined(CLOCK_MONOTONIC_FAST) /* FreeBSD, DragonFlyBSD, etc */
++  clock_gettime(CLOCK_MONOTONIC_FAST, &timespec);
+ # elif defined(CLOCK_MONOTONIC) /* POSIX 2008, NetBSD, etc */
+   clock_gettime(CLOCK_MONOTONIC, &timespec);
+ # else /* older POSIX didn't define CLOCK_MONOTONIC */
diff --git a/lang/pocl/pkg-descr b/lang/pocl/pkg-descr
index df8597fc68dc..8c09ff01267d 100644
--- a/lang/pocl/pkg-descr
+++ b/lang/pocl/pkg-descr
@@ -1,17 +1,28 @@
-Portable OpenCL aims to be an efficient open source (MIT-licensed)
-implementation of the OpenCL 1.2 standard.
+[
+{	type: install
+	message: <<EOM
+Portable OpenCL (pocl)
+----------------------
+
+Portable OpenCL (>= 3.0) aims to be an efficient open source
+(MIT-licensed) implementation of the OpenCL 2.X standard with
+adaptions of OpenCL 3.0.
 
 In addition to producing an easily portable open source OpenCL
 implementation, another major goal of the project is improving
 performance portability of OpenCL programs with compiler
 optimizations, reducing the need for target-dependent manual
-optimizations. At the core of POCL is a set of LLVM passes used
-to statically parallelize multiple work-items with the kernel
+optimizations. At the core of pocl is a set of LLVM passes
+used to statically parallelize multiple work-items with the kernel
 compiler, even in the presence of work-group barriers. This enables
 parallelization of the fine-grained static concurrency in the work
-groups in multiple ways (SIMD, VLIW, superscalar, ...).
+groups in multiple ways (SIMD, VLIW, superscalar,...).
 
 The code base is modularized to allow easy adding of new "device drivers"
 in the host-device layer. A generic multithreaded "target driver" is
 included. It allows running OpenCL applications on a host that supports
 the pthread library with multithreading at the work group granularity.
+
+EOM
+}
+]
diff --git a/lang/pocl/pkg-message b/lang/pocl/pkg-message
new file mode 100644
index 000000000000..802c2dee25b1
--- /dev/null
+++ b/lang/pocl/pkg-message
@@ -0,0 +1,18 @@
+[
+{ 	type:	install
+	message: <<EOM
+
+Deadlocks (freezes) on FreeBSD:
+
+OpenCL applications using pocl on FreeBSD must be compiled with 
+options CFLAGS+=-pthread or CXXFLAGS+=-pthread, otherwise someone risk
+that a library may not initialize the threading on BSD independently, 
+even if an ICD loader is used.
+
+See: 
+	http://www.freebsd.org/cgi/query-pr.cgi?pr=163512
+
+(Source: http://portablecl.org/docs/html/faq.html?highlight=freebsd)
+EOM
+}
+]
diff --git a/lang/pocl/pkg-plist b/lang/pocl/pkg-plist
index 20639933c7bc..3544359ccbea 100644
--- a/lang/pocl/pkg-plist
+++ b/lang/pocl/pkg-plist
@@ -2,8 +2,7 @@ bin/poclcc
 etc/OpenCL/vendors/pocl.icd
 lib/libpocl.so
 lib/libpocl.so.2
-lib/libpocl.so.2.8.0
-lib/pocl/libllvmopencl.so
+lib/libpocl.so.2.10.0
 lib/pocl/libpocl-devices-basic.so
 lib/pocl/libpocl-devices-pthread.so
 libdata/pkgconfig/pocl.pc