From dff058f3048815b8deb61e336ff656151a5e8618 Mon Sep 17 00:00:00 2001 From: Marius Meyer Date: Fri, 23 Aug 2024 10:43:10 +0200 Subject: [PATCH] Add OpenCL ICD v2.3.2 (#9270) Co-authored-by: Tim Besard --- O/ocl_icd/build_tarballs.jl | 60 +++++++++++++++++++ .../bundled/patches/ocl-icd-2.3.2-1.src.patch | 43 +++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 O/ocl_icd/build_tarballs.jl create mode 100644 O/ocl_icd/bundled/patches/ocl-icd-2.3.2-1.src.patch diff --git a/O/ocl_icd/build_tarballs.jl b/O/ocl_icd/build_tarballs.jl new file mode 100644 index 00000000000..43649deff9f --- /dev/null +++ b/O/ocl_icd/build_tarballs.jl @@ -0,0 +1,60 @@ +# Note that this script can accept some limited command-line arguments, run +# `julia build_tarballs.jl --help` to see a usage message +using BinaryBuilder + +name = "ocl_icd" +version = v"2.3.2" + +# Collection of sources required to complete build +sources = [ + GitSource("https://github.com/OCL-dev/ocl-icd.git", + "fdde6677b21329432db8b481e2637cd10f7d3cb2"), + DirectorySource("./bundled") +] + +# Bash recipe for building across all platforms +script = raw""" +apk add ruby + +cd ${WORKSPACE}/srcdir/ocl-icd +install_license COPYING + +# Fix build for Windows based on +# https://cygwin.com/cgit/cygwin-packages/ocl-icd/tree/ocl-icd-2.3.2-1.src.patch +if [[ "${target}" == *-w64-* ]]; then + atomic_patch -p2 ../patches/ocl-icd-2.3.2-1.src.patch +fi + +./bootstrap + +# Fix rpl_malloc for musl +if [[ "${target}" == *-musl* ]] || [[ "${target}" == *-apple-* ]]; then + sed -i '/AC_FUNC_MALLOC/d' ./configure.ac + sed -i '/AC_FUNC_REALLOC/d' ./configure.ac +fi + +./configure --prefix=${prefix} --build=${MACHTYPE} --host=${target} + +make -j${nproc} all +make install +""" + +# These are the platforms we will build for by default, unless further +# platforms are passed in on the command line +platforms = supported_platforms() +filter!(p -> !(Sys.iswindows(p) && arch(p) == "i686"), platforms) + +# The products that we will ensure are always built +products = [ + LibraryProduct(["libOpenCL", "OpenCL"], :libocl_icd), + FileProduct("include/ocl_icd.h", :ocl_icd_h) +] + +# Dependencies that must be installed before this package can be built +dependencies = [ + Dependency("dlfcn_win32_jll", platforms=filter(Sys.iswindows, platforms)) +] + +# Build the tarballs, and possibly a `build.jl` as well. +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; + julia_compat="1.6") diff --git a/O/ocl_icd/bundled/patches/ocl-icd-2.3.2-1.src.patch b/O/ocl_icd/bundled/patches/ocl-icd-2.3.2-1.src.patch new file mode 100644 index 00000000000..a8b944cefba --- /dev/null +++ b/O/ocl_icd/bundled/patches/ocl-icd-2.3.2-1.src.patch @@ -0,0 +1,43 @@ +--- origsrc/ocl-icd-2.3.2/Makefile.am 2023-09-10 19:42:53.360404200 +0900 ++++ src/ocl-icd-2.3.2/Makefile.am 2023-09-10 19:54:18.819354400 +0900 +@@ -48,7 +48,7 @@ libOpenCL_la_CFLAGS= $(NO_DEPRECATED_DEC + + libOpenCL_la_SOURCES = ocl_icd_loader.c ocl_icd_loader.h ocl_icd_debug.h + nodist_libOpenCL_la_SOURCES = ocl_icd_loader_gen.c ocl_icd.h +-libOpenCL_la_LDFLAGS = -version-info 1:0:0 $(PTHREAD_CFLAGS) ++libOpenCL_la_LDFLAGS = -no-undefined -version-info 1:0:0 $(PTHREAD_CFLAGS) + libOpenCL_la_LIBADD = $(PTHREAD_LIBS) + if USE_MAP + libOpenCL_la_LDFLAGS += -Wl,--version-script,ocl_icd_loader_gen.map +@@ -103,25 +103,23 @@ stamp-generator-dummy: icd_generator.rb + $(RUBY) $< --mode generate --database $(srcdir)/ocl_interface.yaml + echo "timestamp" > $@ + +-# noinst_LTLIBRARIES would be the correct thing but then libtool +-# only built non shared version :-( So, declaring the libs as +-# pkglib_LTLIBRARIES and using an install hook to remove them. +-pkglib_LTLIBRARIES = libdummycl.la libdummycl2.la libdummycl-noext.la libdummylayer.la +-install-exec-hook:: +- $(RM) -r $(DESTDIR)$(pkglibdir) ++noinst_LTLIBRARIES = libdummycl.la libdummycl2.la libdummycl-noext.la + libdummycl_la_SOURCES = libdummy_icd.c libdummy_icd.h + nodist_libdummycl_la_SOURCES = libdummy_icd_gen.c libdummy_icd_gen.h + libdummycl_la_LDFLAGS = -module ++libdummycl_la_LDFLAGS += -rpath `pwd` -no-undefined -avoid-version + libdummycl_noext_la_SOURCES = $(libdummycl_la_SOURCES) + nodist_libdummycl_noext_la_SOURCES = $(nodist_libdummycl_la_SOURCES) + libdummycl_noext_la_LDFLAGS = -module ++libdummycl_noext_la_LDFLAGS += -rpath `pwd` -no-undefined -avoid-version + libdummycl_noext_la_CPPFLAGS = $(AM_CPPFLAGS) -DICD_WITHOUT_EXTENSION + libdummycl2_la_SOURCES = $(libdummycl_la_SOURCES) + nodist_libdummycl2_la_SOURCES = $(nodist_libdummycl_la_SOURCES) + libdummycl2_la_LDFLAGS = -module ++libdummycl2_la_LDFLAGS += -rpath `pwd` -no-undefined -avoid-version + libdummycl2_la_CPPFLAGS = $(AM_CPPFLAGS) -DICD_SUFFIX=\"2\" +-nodist_libdummylayer_la_SOURCES = dummy_icd_layer_gen.c +-libdummylayer_la_LDFLAGS = -module ++#nodist_libdummylayer_la_SOURCES = dummy_icd_layer_gen.c ++#libdummylayer_la_LDFLAGS = -module + + noinst_PROGRAMS=run_dummy_icd_through_our_ICDL + run_dummy_icd_through_our_ICDL_SOURCES = run_dummy_icd.c