git: 7e7db577d2a0 - main - lang/halide: update 14.0.0 → 17.0.1

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Tue, 28 May 2024 03:27:52 UTC
The branch main has been updated by yuri:

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

commit 7e7db577d2a02336158b87c7ed3e2d523b4b51d6
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2024-05-28 02:57:39 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2024-05-28 03:27:26 +0000

    lang/halide: update 14.0.0 → 17.0.1
---
 lang/halide/Makefile                               | 17 ++++---
 lang/halide/distinfo                               |  6 +--
 .../files/patch-src_LLVM__Runtime__Linker.cpp      | 53 ++++++++++++++++++++--
 lang/halide/files/patch-src_Target.cpp             |  6 +--
 lang/halide/files/patch-src_runtime_CMakeLists.txt | 10 ++++
 lang/halide/files/patch-src_runtime_fopen__lfs.cpp | 12 +++++
 lang/halide/pkg-plist                              | 15 ++++--
 7 files changed, 97 insertions(+), 22 deletions(-)

diff --git a/lang/halide/Makefile b/lang/halide/Makefile
index 6fc130898c7c..51bfc7637df9 100644
--- a/lang/halide/Makefile
+++ b/lang/halide/Makefile
@@ -1,6 +1,6 @@
 PORTNAME=	halide
 DISTVERSIONPREFIX=	v
-DISTVERSION=	14.0.0
+DISTVERSION=	17.0.1
 PORTEPOCH=	1
 CATEGORIES=	lang
 
@@ -17,25 +17,22 @@ BROKEN_riscv64=		fails to build: /usr/include/c++/v1/__config:1141:6: No thread
 BUILD_DEPENDS=	llvm${LLVM_VERSION}>0:devel/llvm${LLVM_VERSION} # because halide expects LLVMConfig.cmake
 RUN_DEPENDS=	llvm${LLVM_VERSION}>0:devel/llvm${LLVM_VERSION}
 
-USES=		cmake:testing # one test (test_apps_autoscheduler) hangs
+USES=		cmake:testing llvm:${LLVM_VERSION},lib
 USE_LDCONFIG=	yes
 
 USE_GITHUB=	yes
 GH_PROJECT=	Halide
 
-LLVM_VERSION=	14 # last supported llvm
+LLVM_VERSION=	17
 
-# use the same compiler that devel/llvmNN installs
-CC=		clang${LLVM_VERSION}
-CXX=		clang++${LLVM_VERSION}
-CPP=		clang-cpp${LLVM_VERSION}
-
-CMAKE_ARGS=	-DLLVM_DIR=${LOCALBASE}/llvm${LLVM_VERSION}/lib/cmake/llvm
+CMAKE_ARGS=	-DHalide_REQUIRE_LLVM_VERSION=${LLVM_VERSION}
 CMAKE_ON=	LLVM_USE_SHARED_LLVM_LIBRARY HALIDE_SHARED_LIBRARY \
 		Halide_SHARED_LLVM
 CMAKE_OFF=	WITH_PYTHON_BINDINGS WITH_APPS WITH_TUTORIALS WITH_DOCS WITH_TESTS # APPS are demos
 CMAKE_OFF+=	Halide_WITH_INTROSPECTION # missing program_invocation_name variable, see https://github.com/halide/Halide/issues/6945#issuecomment-1217146679
 CMAKE_OFF+=	WITH_WABT # fetches wabt (when www/wabt is available)
+CMAKE_OFF+=	WITH_SERIALIZATION # fetches flatbuffers (unless FLATBUFFERS_USE_FETCHCONTENT=OFF)
+CMAKE_TESTING_ON=	WITH_TESTS
 
 OPTIONS_DEFINE=	NATIVE
 OPTIONS_DEFAULT=
@@ -50,4 +47,6 @@ post-patch-NATIVE-off:
 post-install:
 	${RM} -r ${STAGEDIR}${PREFIX}/share
 
+# tests fail to compile, see https://github.com/halide/Halide/issues/8236
+
 .include <bsd.port.mk>
diff --git a/lang/halide/distinfo b/lang/halide/distinfo
index 94b2c2bf778e..ac8296979940 100644
--- a/lang/halide/distinfo
+++ b/lang/halide/distinfo
@@ -1,3 +1,3 @@
-TIMESTAMP = 1660683499
-SHA256 (halide-Halide-v14.0.0_GH0.tar.gz) = f9fc9765217cbd10e3a3e3883a60fc8f2dbbeaac634b45c789577a8a87999a01
-SIZE (halide-Halide-v14.0.0_GH0.tar.gz) = 31806106
+TIMESTAMP = 1716857358
+SHA256 (halide-Halide-v17.0.1_GH0.tar.gz) = beb18331d9e4b6f69943bcc75fb9d923a250ae689f09f6940a01636243289727
+SIZE (halide-Halide-v17.0.1_GH0.tar.gz) = 33075499
diff --git a/lang/halide/files/patch-src_LLVM__Runtime__Linker.cpp b/lang/halide/files/patch-src_LLVM__Runtime__Linker.cpp
index d7d77fcf3de3..2330fda2ad85 100644
--- a/lang/halide/files/patch-src_LLVM__Runtime__Linker.cpp
+++ b/lang/halide/files/patch-src_LLVM__Runtime__Linker.cpp
@@ -1,11 +1,58 @@
---- src/LLVM_Runtime_Linker.cpp.orig	2022-08-17 05:20:15 UTC
+--- src/LLVM_Runtime_Linker.cpp.orig	2024-02-20 17:13:06 UTC
 +++ src/LLVM_Runtime_Linker.cpp
-@@ -833,7 +833,7 @@ std::unique_ptr<llvm::Module> get_initial_module_for_t
+@@ -432,6 +432,9 @@ llvm::Triple get_triple_for_target(const Target &targe
+         if (target.os == Target::Linux) {
+             triple.setOS(llvm::Triple::Linux);
+             triple.setEnvironment(llvm::Triple::GNU);
++	} else if (target.os == Target::Linux || target.os == Target::FreeBSD) {
++            triple.setOS(llvm::Triple::FreeBSD);
++            triple.setEnvironment(llvm::Triple::GNU);
+         } else if (target.os == Target::OSX) {
+             triple.setVendor(llvm::Triple::Apple);
+             triple.setOS(llvm::Triple::MacOSX);
+@@ -478,6 +481,9 @@ llvm::Triple get_triple_for_target(const Target &targe
+         } else if (target.os == Target::Linux) {
+             triple.setOS(llvm::Triple::Linux);
+             triple.setEnvironment(llvm::Triple::GNUEABIHF);
++        } else if (target.os == Target::FreeBSD) {
++            triple.setOS(llvm::Triple::FreeBSD);
++            triple.setEnvironment(llvm::Triple::GNUEABIHF);
+         } else if (target.os == Target::Windows) {
+             user_assert(target.bits == 64) << "Windows ARM targets must be 64-bit.\n";
+             triple.setVendor(llvm::Triple::PC);
+@@ -539,6 +545,8 @@ llvm::Triple get_triple_for_target(const Target &targe
+ 
+         if (target.os == Target::Linux) {
+             triple.setOS(llvm::Triple::Linux);
++	} else if (target.os == Target::FreeBSD) {
++            triple.setOS(llvm::Triple::FreeBSD);
+         } else if (target.os == Target::Android) {
+             triple.setOS(llvm::Triple::Linux);
+             triple.setEnvironment(llvm::Triple::Android);
+@@ -855,7 +863,7 @@ std::unique_ptr<llvm::Module> get_initial_module_for_t
      if (module_type != ModuleGPU) {
          if (module_type != ModuleJITInlined && module_type != ModuleAOTNoRuntime) {
              // OS-dependent modules
 -            if (t.os == Target::Linux) {
 +            if (t.os == Target::Linux || t.os == Target::FreeBSD) {
+                 add_allocator();
                  modules.push_back(get_initmod_posix_allocator(c, bits_64, debug));
                  modules.push_back(get_initmod_posix_error_handler(c, bits_64, debug));
-                 modules.push_back(get_initmod_posix_print(c, bits_64, debug));
+@@ -1045,7 +1053,7 @@ std::unique_ptr<llvm::Module> get_initial_module_for_t
+             }
+ 
+             // Prefer using fopen_lfs on Linux systems, which calls fopen64() to ensure LFS support.
+-            if (t.os == Target::Linux) {
++            if (t.os == Target::Linux || t.os == Target::FreeBSD) {
+                 modules.push_back(get_initmod_fopen_lfs(c, bits_64, debug));
+             } else {
+                 modules.push_back(get_initmod_fopen(c, bits_64, debug));
+@@ -1209,7 +1217,7 @@ std::unique_ptr<llvm::Module> get_initial_module_for_t
+             if (t.os == Target::Android) {
+                 // Only platform that supports OpenGL Compute for now.
+                 modules.push_back(get_initmod_opengl_egl_context(c, bits_64, debug));
+-            } else if (t.os == Target::Linux) {
++            } else if (t.os == Target::Linux || t.os == Target::FreeBSD) {
+                 if (t.has_feature(Target::EGL)) {
+                     modules.push_back(get_initmod_opengl_egl_context(c, bits_64, debug));
+                 } else {
diff --git a/lang/halide/files/patch-src_Target.cpp b/lang/halide/files/patch-src_Target.cpp
index 08f2121f4f26..72adef4f777c 100644
--- a/lang/halide/files/patch-src_Target.cpp
+++ b/lang/halide/files/patch-src_Target.cpp
@@ -1,6 +1,6 @@
---- src/Target.cpp.orig	2022-08-17 04:41:42 UTC
+--- src/Target.cpp.orig	2024-02-20 17:13:06 UTC
 +++ src/Target.cpp
-@@ -67,6 +67,9 @@ Target calculate_host_target() {
+@@ -148,6 +148,9 @@ Target calculate_host_target() {
  #ifdef __linux__
      os = Target::Linux;
  #endif
@@ -10,7 +10,7 @@
  #ifdef _WIN32
      os = Target::Windows;
  #endif
-@@ -269,6 +272,7 @@ Target::Feature get_host_cuda_capability(Target t) {
+@@ -399,6 +402,7 @@ const std::map<std::string, Target::OS> os_name_map = 
  const std::map<std::string, Target::OS> os_name_map = {
      {"os_unknown", Target::OSUnknown},
      {"linux", Target::Linux},
diff --git a/lang/halide/files/patch-src_runtime_CMakeLists.txt b/lang/halide/files/patch-src_runtime_CMakeLists.txt
new file mode 100644
index 000000000000..9d2262247781
--- /dev/null
+++ b/lang/halide/files/patch-src_runtime_CMakeLists.txt
@@ -0,0 +1,10 @@
+--- src/runtime/CMakeLists.txt.orig	2024-05-28 01:51:11 UTC
++++ src/runtime/CMakeLists.txt
+@@ -150,6 +150,7 @@ set(RUNTIME_CXX_FLAGS
+ # Note: ensure that these flags match the flags in the Makefile.
+ # Note: this always uses Clang-from-LLVM for compilation, so none of these flags should need conditionalization.
+ set(RUNTIME_CXX_FLAGS
++    -Dfopen64=fopen
+     -O3
+     -std=c++17
+     -ffreestanding
diff --git a/lang/halide/files/patch-src_runtime_fopen__lfs.cpp b/lang/halide/files/patch-src_runtime_fopen__lfs.cpp
new file mode 100644
index 000000000000..8a9aa0e6b58f
--- /dev/null
+++ b/lang/halide/files/patch-src_runtime_fopen__lfs.cpp
@@ -0,0 +1,12 @@
+--- src/runtime/fopen_lfs.cpp.orig	2024-05-28 01:22:14 UTC
++++ src/runtime/fopen_lfs.cpp
+@@ -3,5 +3,9 @@ extern "C" WEAK_INLINE void *halide_fopen(const char *
+ extern "C" void *fopen64(const char *, const char *);
+ 
+ extern "C" WEAK_INLINE void *halide_fopen(const char *filename, const char *type) {
++#if !defined(__FreeBSD__)
+     return fopen64(filename, type);
++#else
++    return fopen(filename, type);
++#endif
+ }
diff --git a/lang/halide/pkg-plist b/lang/halide/pkg-plist
index af0093bdbc67..66f3ecba71d9 100644
--- a/lang/halide/pkg-plist
+++ b/lang/halide/pkg-plist
@@ -1,7 +1,9 @@
+bin/adams2019_retrain_cost_model
+bin/adams2019_weightsdir_to_weightsfile
+bin/anderson2021_retrain_cost_model
+bin/anderson2021_weightsdir_to_weightsfile
 bin/featurization_to_sample
 bin/get_host_target
-bin/retrain_cost_model
-bin/weightsdir_to_weightsfile
 include/Halide.h
 include/HalideBuffer.h
 include/HalidePyTorchCudaHelpers.h
@@ -15,20 +17,25 @@ include/HalideRuntimeMetal.h
 include/HalideRuntimeOpenCL.h
 include/HalideRuntimeOpenGLCompute.h
 include/HalideRuntimeQurt.h
+include/HalideRuntimeVulkan.h
+include/HalideRuntimeWebGPU.h
 lib/cmake/Halide/Halide-shared-deps.cmake
 lib/cmake/Halide/Halide-shared-targets-%%CMAKE_BUILD_TYPE%%.cmake
 lib/cmake/Halide/Halide-shared-targets.cmake
 lib/cmake/Halide/HalideConfig.cmake
 lib/cmake/Halide/HalideConfigVersion.cmake
+lib/cmake/HalideHelpers/FindHalide_WebGPU.cmake
 lib/cmake/HalideHelpers/Halide-Interfaces-%%CMAKE_BUILD_TYPE%%.cmake
 lib/cmake/HalideHelpers/Halide-Interfaces.cmake
 lib/cmake/HalideHelpers/HalideGeneratorHelpers.cmake
 lib/cmake/HalideHelpers/HalideHelpersConfig.cmake
 lib/cmake/HalideHelpers/HalideHelpersConfigVersion.cmake
 lib/cmake/HalideHelpers/HalideTargetHelpers.cmake
+lib/cmake/HalideHelpers/TargetExportScript.cmake
 lib/libHalide.so
-lib/libHalide.so.14
-lib/libHalide.so.14.0.0
+lib/libHalide.so.17
+lib/libHalide.so.17.0.1
 lib/libautoschedule_adams2019.so
+lib/libautoschedule_anderson2021.so
 lib/libautoschedule_li2018.so
 lib/libautoschedule_mullapudi2016.so