public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/erlang-cl] rawhide: Switch to declarative build system (f44+)
@ 2026-12-01 20:05 Peter Lemenkov
0 siblings, 0 replies; only message in thread
From: Peter Lemenkov @ 2026-12-01 20:05 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/erlang-cl
Branch : rawhide
Commit : ad0c6f6915c769c80323c6c40fcf164d6fc87dc4
Author : Peter Lemenkov <lemenkov@gmail.com>
Date : 2026-12-01T20:45:06+01:00
Stats : +517/-282 in 10 file(s)
URL : https://src.fedoraproject.org/rpms/erlang-cl/c/ad0c6f6915c769c80323c6c40fcf164d6fc87dc4?branch=rawhide
Log:
Switch to declarative build system (f44+)
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
---
diff --git a/.gitignore b/.gitignore
index e4a32b8..706957c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1 @@
-/cl-1.2.1.tar.gz
-/cl-1.2.3.tar.gz
-/cl-1.2.4.tar.gz
+/cl-*.tar.gz
diff --git a/erlang-cl-0001-Build-the-NIF-with-the-rebar3-port-compiler-plugin.patch b/erlang-cl-0001-Build-the-NIF-with-the-rebar3-port-compiler-plugin.patch
new file mode 100644
index 0000000..4b09b1a
--- /dev/null
+++ b/erlang-cl-0001-Build-the-NIF-with-the-rebar3-port-compiler-plugin.patch
@@ -0,0 +1,59 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Lemenkov <lemenkov@gmail.com>
+Date: Tue, 1 Dec 2026 19:26:00 +0100
+Subject: [PATCH] Build the NIF with the rebar3 port compiler plugin
+
+The port_specs entry had no sources: it only stopped old rebar from
+building a default cl_drv.so while c_src/Makefile, called from the
+pre_hooks, did the actual build. The rebar3 port compiler plugin (pc)
+therefore built nothing.
+
+Load pc, run it on compile and clean, give it the sources of the NIF and
+link it with OpenCL, and drop the make hooks, which would build it a
+second time. c_src/Makefile stays for building by hand.
+
+Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+---
+ rebar.config | 20 +++++++++-----------
+ 1 file changed, 9 insertions(+), 11 deletions(-)
+
+diff --git a/rebar.config b/rebar.config
+index a2ab498..533e9e8 100644
+--- a/rebar.config
++++ b/rebar.config
+@@ -1,14 +1,12 @@
+ %% -*- erlang -*-
+ %% Config file for cl-application
+ {deps, []}.
++{plugins, [pc]}.
+ {erl_opts, [debug_info, fail_on_warning]}.
+
+-{provider_hooks, [{post, [{ct, edoc}, {ct, dialyzer}]}]}.
+-
+-{pre_hooks,
+- [{"(linux|darwin|solaris|win32)", compile, "make -C c_src"},
+- {"(freebsd)", compile, "gmake -C c_src"}
+- ]}.
++{provider_hooks, [{pre, [{compile, {pc, compile}},
++ {clean, {pc, clean}}]},
++ {post, [{ct, edoc}, {ct, dialyzer}]}]}.
+
+ %% Assumes bash (even on windows)
+ {post_hooks,
+@@ -21,10 +19,10 @@
+ {"", clean, "rm -f test/*.beam"},
+ {"", clean, "rm -rf logs"},
+ {"", clean, "rm -rf doc/*.html"},
+- {"", clean, "rm -rf ebin/*"},
+- {"(linux|darwin|solaris|win32)", clean, "make -C c_src clean"},
+- {"(freebsd)", clean, "gmake -C c_src clean"}
++ {"", clean, "rm -rf ebin/*"}
+ ]}.
+
+-%% Make old-rebar avoid building cl_drv.so
+-{port_specs, [{"priv/cl_nif.so", []}]}.
++%% The NIF is built by the port compiler plugin (pc)
++{port_specs, [{"priv/cl_nif.so", ["c_src/*.c"]}]}.
++{port_env, [{"(linux|freebsd|solaris)", "LDFLAGS", "$LDFLAGS -lOpenCL"},
++ {"darwin", "LDFLAGS", "$LDFLAGS -framework OpenCL"}]}.
diff --git a/erlang-cl-0001-Remove-handmade-makefile.patch b/erlang-cl-0001-Remove-handmade-makefile.patch
deleted file mode 100644
index 62afd94..0000000
--- a/erlang-cl-0001-Remove-handmade-makefile.patch
+++ /dev/null
@@ -1,255 +0,0 @@
-From: Peter Lemenkov <lemenkov@gmail.com>
-Date: Tue, 6 Mar 2018 13:32:05 +0300
-Subject: [PATCH] Remove handmade makefile
-
-Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
-
-diff --git a/c_src/Makefile b/c_src/Makefile
-deleted file mode 100644
-index 0cdf469..0000000
---- a/c_src/Makefile
-+++ /dev/null
-@@ -1,194 +0,0 @@
--#
--# Copyright (C) 2016, Rogvall Invest AB, <tony@rogvall.se>
--#
--# This software is licensed as described in the file COPYRIGHT, which
--# you should have received as part of this distribution. The terms
--# are also available at http://www.rogvall.se/docs/copyright.txt.
--#
--# You may opt to use, copy, modify, merge, publish, distribute and/or sell
--# copies of the Software, and permit persons to whom the Software is
--# furnished to do so, under the terms of the COPYRIGHT file.
--#
--# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
--# KIND, either express or implied.
--#
--
--## us NOCL=true make to force build with gcc on windows
--
--OSNAME := $(shell uname -s)
--MACHINE := $(shell uname -m)
--OUT_C = -o
--OUT_L = -o
--OBJ = o
--
--
--MAC_OS_X = No
--WIN32_GCC = No
--WIN32_CL = No
--LINUX = No
--
--
--ERL = erl
--EXT = so
--PRIVDIR=../priv
--
--
--ifneq (, $(findstring MINGW,$(OSNAME)))
--MINGW = Yes
--ERL = erl.exe
--endif
--
--ifeq ($(WSLcross), true)
--# cross building from Windows WSL linux to native windows
--ERL = erl.exe
--endif
--
--WORDSIZE = $(shell $(ERL) -noshell -eval "io:format([126,119,126,110],[erlang:system_info(wordsize)*8])" -s erlang halt)
--
--ifeq ($(OSNAME)$(WSLcross), Linux)
--LINUX = Yes
--CFLAGS += -I/usr/include/nvidia-current
--CFLAGS += -I/opt/AMDAPP/include
--ifeq ($(WORDSIZE), 32)
--CFLAGS += -O3 -fPIC -m32
--endif
--ifeq ($(WORDSIZE), 64)
--CFLAGS += -O3 -fPIC -m64
--endif
--LD_SHARED := $(CC) -shared
--LDFLAGS += -lOpenCL
--endif
--
--ifeq ($(OSNAME), Darwin)
--MAC_OS_X = Yes
--ifeq ($(WORDSIZE), 32)
--CFLAGS += -O3 -fPIC -m32 -DDARWIN -no-cpp-precomp
--LD_SHARED := $(CC) -m32 -bundle -flat_namespace -undefined suppress
--endif
--ifeq ($(WORDSIZE), 64)
--CFLAGS += -O3 -fPIC -m64 -DDARWIN -no-cpp-precomp
--LD_SHARED := $(CC) -m64 -bundle -flat_namespace -undefined suppress
--endif
--LDFLAGS += -framework OpenCL
--endif
--
--ERLDIR := $(shell $(ERL) -noshell -eval "io:format([126,115,126,110],[code:root_dir()])" -s erlang halt)
--ERL_C_INCLUDE_DIR := "$(ERLDIR)/usr/include"
--
--ifeq ($(TYPE), debug)
--CFLAGS += -Ddebug -DDEBUG -g -Wall -Wextra -Wswitch-default -Wswitch-enum -D_THREAD_SAFE
--CFLAGS += -D_REENTRANT -fno-common -I$(ERL_C_INCLUDE_DIR)
--WIN_DEBUG = -Ddebug -DDEBUG
--endif
--
--ifeq ($(TYPE), release)
--CFLAGS += -Wall -Wextra -Wswitch-default -Wswitch-enum -D_THREAD_SAFE -D_REENTRANT -fno-common
--CFLAGS += -Wno-deprecated-declarations -Wno-missing-field-initializers -I$(ERL_C_INCLUDE_DIR)
--endif
--
--############### WINDOWS
--
--ifeq ($(MINGW), Yes)
-- EXT = dll
-- ifeq ($(NOCL), true)
-- WIN32_GCC=Yes
-- else
-- ifneq ($(findstring Microsoft,$(shell cl.exe 2>&1)), )
-- WIN32_CL=Yes
-- MS2C = MSYS2_ARG_CONV_EXCL=*
-- else
-- WIN32_GCC=Yes
-- endif
-- endif
--endif
--
--ifeq ($(WSLcross), true)
-- # Only support MCL for WSLcross for now
-- WIN32_CL=Yes
-- EXT = dll
--endif
--
--ifeq ($(WIN32_CL), Yes)
--## Use Microsoft CL
-- CC=cl.exe
-- MS2C = MSYS2_ARG_CONV_EXCL=*
-- OUT_C = /Fo
-- ifeq ($(OPENCL_DIR), )
-- OPENCL_DIR = c:/msys64/opt/local/
-- endif
-- CFLAGS = /FS /Zi /nologo /W1 -DWIN32 -D__WIN32__ $(WIN_DEBUG)
-- CFLAGS += /I$(OPENCL_DIR)/include /I$(ERL_C_INCLUDE_DIR)
-- LD_SHARED=link.exe /DLL
-- OUT_L=/OUT:
-- ifeq ($(WORDSIZE), 32)
-- LDFLAGS += /NOLOGO $(OPENCL_DIR)/lib/x86/OpenCL.lib
-- else
-- CFLAGS += -DWIN_X64
-- LDFLAGS += /NOLOGO $(OPENCL_DIR)/lib/x64/OpenCL.lib
-- endif
--endif
--
--ifeq ($(WIN32_GCC), Yes)
-- #CC=gcc
-- CFLAGS += -D__WIN32__ $(WIN_DEBUG)
-- ifeq ($(OPENCL_DIR), )
-- OPENCL_DIR = /opt/local/
-- endif
--
-- ifeq ($(WORDSIZE), 32)
-- CFLAGS += -shared -I$(OPENCL_DIR)/include -m32 -DWIN32
-- LDFLAGS += -L$(OPENCL_DIR)/lib/x86 -lOpenCL
-- endif
-- ifeq ($(WORDSIZE), 64)
-- CFLAGS += -shared -I$(OPENCL_DIR)/include -m64 -DWIN32
-- CFLAGS += -DWIN_X64
-- LDFLAGS += -L$(OPENCL_DIR)/lib/x64 -lOpenCL
-- endif
--
-- LD_SHARED := $(CC) -shared
--## Optimizations is broken on mingw 4.4.0 (it crashes with it on)
-- GCC_VERSION = $(shell gcc -dumpversion)
-- ifneq ($(GCC_VERSION), 4.4.0)
-- CFLAGS += -O3
-- endif
--endif
--############### WINDOWS end
--
--CL_NIF = $(PRIVDIR)/cl_nif.$(EXT)
--
--CL_NIF_OBJS = \
-- cl_nif.$(OBJ) \
-- cl_hash.$(OBJ)
--
--CL_NIF_SRC = \
-- cl_nif.c \
-- cl_hash.c
--
--all:
-- $(MAKE) nif TYPE=release
--
--debug:
-- $(MAKE) nif TYPE=debug
--
--clean:
-- rm -f $(CL_NIF_OBJS)
-- rm -f $(CL_NIF)
--
--release:
-- $(MAKE) nif TYPE=release
--
--nif: $(CL_NIF)
--
--cl_nif.$(OBJ): cl_hash.h
--
--clean_internal:
-- -rm -f *.$(OBJ)
-- -rm -f $(PRIVDIR)/*.$(EXT)
--
--%.$(OBJ): %.c
-- $(MS2C) $(CC) -c $(OUT_C)$@ $(CFLAGS) $<
--
--$(CL_NIF): $(OCL_LIB) $(CL_NIF_OBJS)
-- @mkdir -p $(PRIVDIR)
-- $(MS2C) $(LD_SHARED) $(OUT_L)$@ $(CL_NIF_OBJS) $(LDFLAGS)
--
-diff --git a/ebin/.gitignore b/ebin/.gitignore
-deleted file mode 100644
-index 120fe3a..0000000
---- a/ebin/.gitignore
-+++ /dev/null
-@@ -1,2 +0,0 @@
--*.beam
--*.app
-diff --git a/rebar.config b/rebar.config
-index a2ab498..a9c2790 100644
---- a/rebar.config
-+++ b/rebar.config
-@@ -5,26 +5,14 @@
-
- {provider_hooks, [{post, [{ct, edoc}, {ct, dialyzer}]}]}.
-
--{pre_hooks,
-- [{"(linux|darwin|solaris|win32)", compile, "make -C c_src"},
-- {"(freebsd)", compile, "gmake -C c_src"}
-- ]}.
-+{port_specs, [
-+ {"priv/cl_nif.so", [
-+ "c_src/*.c"
-+ ]}
-+]}.
-
--%% Assumes bash (even on windows)
--{post_hooks,
-- [%% Temporary hack for equal usage on rebar and rebar3
-- {"(linux|darwin|solaris|freebsd)", compile,
-- "cp _build/default/lib/cl/ebin/* ebin 2> /dev/null | :"},
-- {"win32", compile,
-- "xcopy _build\\default\\lib\\cl\\ebin\\*.* ebin\\ /c /q /i /y | echo ok"},
-- %%
-- {"", clean, "rm -f test/*.beam"},
-- {"", clean, "rm -rf logs"},
-- {"", clean, "rm -rf doc/*.html"},
-- {"", clean, "rm -rf ebin/*"},
-- {"(linux|darwin|solaris|win32)", clean, "make -C c_src clean"},
-- {"(freebsd)", clean, "gmake -C c_src clean"}
-- ]}.
--
--%% Make old-rebar avoid building cl_drv.so
--{port_specs, [{"priv/cl_nif.so", []}]}.
-+{port_envs, [
-+ {"CFLAGS", "$CFLAGS -fPIC"},
-+ {"DRV_CFLAGS", "$DRV_CFLAGS"},
-+ {"DRV_LDFLAGS", "$DRV_LDFLAGS -lOpenCL"}
-+ ]}.
diff --git a/erlang-cl-0002-Remove-handmade-makefile.patch b/erlang-cl-0002-Remove-handmade-makefile.patch
new file mode 100644
index 0000000..4f9e16e
--- /dev/null
+++ b/erlang-cl-0002-Remove-handmade-makefile.patch
@@ -0,0 +1,214 @@
+From: Peter Lemenkov <lemenkov@gmail.com>
+Date: Tue, 6 Mar 2018 13:32:05 +0300
+Subject: [PATCH] Remove handmade makefile
+
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/c_src/Makefile b/c_src/Makefile
+deleted file mode 100644
+index 0cdf469..0000000
+--- a/c_src/Makefile
++++ /dev/null
+@@ -1,194 +0,0 @@
+-#
+-# Copyright (C) 2016, Rogvall Invest AB, <tony@rogvall.se>
+-#
+-# This software is licensed as described in the file COPYRIGHT, which
+-# you should have received as part of this distribution. The terms
+-# are also available at http://www.rogvall.se/docs/copyright.txt.
+-#
+-# You may opt to use, copy, modify, merge, publish, distribute and/or sell
+-# copies of the Software, and permit persons to whom the Software is
+-# furnished to do so, under the terms of the COPYRIGHT file.
+-#
+-# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+-# KIND, either express or implied.
+-#
+-
+-## us NOCL=true make to force build with gcc on windows
+-
+-OSNAME := $(shell uname -s)
+-MACHINE := $(shell uname -m)
+-OUT_C = -o
+-OUT_L = -o
+-OBJ = o
+-
+-
+-MAC_OS_X = No
+-WIN32_GCC = No
+-WIN32_CL = No
+-LINUX = No
+-
+-
+-ERL = erl
+-EXT = so
+-PRIVDIR=../priv
+-
+-
+-ifneq (, $(findstring MINGW,$(OSNAME)))
+-MINGW = Yes
+-ERL = erl.exe
+-endif
+-
+-ifeq ($(WSLcross), true)
+-# cross building from Windows WSL linux to native windows
+-ERL = erl.exe
+-endif
+-
+-WORDSIZE = $(shell $(ERL) -noshell -eval "io:format([126,119,126,110],[erlang:system_info(wordsize)*8])" -s erlang halt)
+-
+-ifeq ($(OSNAME)$(WSLcross), Linux)
+-LINUX = Yes
+-CFLAGS += -I/usr/include/nvidia-current
+-CFLAGS += -I/opt/AMDAPP/include
+-ifeq ($(WORDSIZE), 32)
+-CFLAGS += -O3 -fPIC -m32
+-endif
+-ifeq ($(WORDSIZE), 64)
+-CFLAGS += -O3 -fPIC -m64
+-endif
+-LD_SHARED := $(CC) -shared
+-LDFLAGS += -lOpenCL
+-endif
+-
+-ifeq ($(OSNAME), Darwin)
+-MAC_OS_X = Yes
+-ifeq ($(WORDSIZE), 32)
+-CFLAGS += -O3 -fPIC -m32 -DDARWIN -no-cpp-precomp
+-LD_SHARED := $(CC) -m32 -bundle -flat_namespace -undefined suppress
+-endif
+-ifeq ($(WORDSIZE), 64)
+-CFLAGS += -O3 -fPIC -m64 -DDARWIN -no-cpp-precomp
+-LD_SHARED := $(CC) -m64 -bundle -flat_namespace -undefined suppress
+-endif
+-LDFLAGS += -framework OpenCL
+-endif
+-
+-ERLDIR := $(shell $(ERL) -noshell -eval "io:format([126,115,126,110],[code:root_dir()])" -s erlang halt)
+-ERL_C_INCLUDE_DIR := "$(ERLDIR)/usr/include"
+-
+-ifeq ($(TYPE), debug)
+-CFLAGS += -Ddebug -DDEBUG -g -Wall -Wextra -Wswitch-default -Wswitch-enum -D_THREAD_SAFE
+-CFLAGS += -D_REENTRANT -fno-common -I$(ERL_C_INCLUDE_DIR)
+-WIN_DEBUG = -Ddebug -DDEBUG
+-endif
+-
+-ifeq ($(TYPE), release)
+-CFLAGS += -Wall -Wextra -Wswitch-default -Wswitch-enum -D_THREAD_SAFE -D_REENTRANT -fno-common
+-CFLAGS += -Wno-deprecated-declarations -Wno-missing-field-initializers -I$(ERL_C_INCLUDE_DIR)
+-endif
+-
+-############### WINDOWS
+-
+-ifeq ($(MINGW), Yes)
+- EXT = dll
+- ifeq ($(NOCL), true)
+- WIN32_GCC=Yes
+- else
+- ifneq ($(findstring Microsoft,$(shell cl.exe 2>&1)), )
+- WIN32_CL=Yes
+- MS2C = MSYS2_ARG_CONV_EXCL=*
+- else
+- WIN32_GCC=Yes
+- endif
+- endif
+-endif
+-
+-ifeq ($(WSLcross), true)
+- # Only support MCL for WSLcross for now
+- WIN32_CL=Yes
+- EXT = dll
+-endif
+-
+-ifeq ($(WIN32_CL), Yes)
+-## Use Microsoft CL
+- CC=cl.exe
+- MS2C = MSYS2_ARG_CONV_EXCL=*
+- OUT_C = /Fo
+- ifeq ($(OPENCL_DIR), )
+- OPENCL_DIR = c:/msys64/opt/local/
+- endif
+- CFLAGS = /FS /Zi /nologo /W1 -DWIN32 -D__WIN32__ $(WIN_DEBUG)
+- CFLAGS += /I$(OPENCL_DIR)/include /I$(ERL_C_INCLUDE_DIR)
+- LD_SHARED=link.exe /DLL
+- OUT_L=/OUT:
+- ifeq ($(WORDSIZE), 32)
+- LDFLAGS += /NOLOGO $(OPENCL_DIR)/lib/x86/OpenCL.lib
+- else
+- CFLAGS += -DWIN_X64
+- LDFLAGS += /NOLOGO $(OPENCL_DIR)/lib/x64/OpenCL.lib
+- endif
+-endif
+-
+-ifeq ($(WIN32_GCC), Yes)
+- #CC=gcc
+- CFLAGS += -D__WIN32__ $(WIN_DEBUG)
+- ifeq ($(OPENCL_DIR), )
+- OPENCL_DIR = /opt/local/
+- endif
+-
+- ifeq ($(WORDSIZE), 32)
+- CFLAGS += -shared -I$(OPENCL_DIR)/include -m32 -DWIN32
+- LDFLAGS += -L$(OPENCL_DIR)/lib/x86 -lOpenCL
+- endif
+- ifeq ($(WORDSIZE), 64)
+- CFLAGS += -shared -I$(OPENCL_DIR)/include -m64 -DWIN32
+- CFLAGS += -DWIN_X64
+- LDFLAGS += -L$(OPENCL_DIR)/lib/x64 -lOpenCL
+- endif
+-
+- LD_SHARED := $(CC) -shared
+-## Optimizations is broken on mingw 4.4.0 (it crashes with it on)
+- GCC_VERSION = $(shell gcc -dumpversion)
+- ifneq ($(GCC_VERSION), 4.4.0)
+- CFLAGS += -O3
+- endif
+-endif
+-############### WINDOWS end
+-
+-CL_NIF = $(PRIVDIR)/cl_nif.$(EXT)
+-
+-CL_NIF_OBJS = \
+- cl_nif.$(OBJ) \
+- cl_hash.$(OBJ)
+-
+-CL_NIF_SRC = \
+- cl_nif.c \
+- cl_hash.c
+-
+-all:
+- $(MAKE) nif TYPE=release
+-
+-debug:
+- $(MAKE) nif TYPE=debug
+-
+-clean:
+- rm -f $(CL_NIF_OBJS)
+- rm -f $(CL_NIF)
+-
+-release:
+- $(MAKE) nif TYPE=release
+-
+-nif: $(CL_NIF)
+-
+-cl_nif.$(OBJ): cl_hash.h
+-
+-clean_internal:
+- -rm -f *.$(OBJ)
+- -rm -f $(PRIVDIR)/*.$(EXT)
+-
+-%.$(OBJ): %.c
+- $(MS2C) $(CC) -c $(OUT_C)$@ $(CFLAGS) $<
+-
+-$(CL_NIF): $(OCL_LIB) $(CL_NIF_OBJS)
+- @mkdir -p $(PRIVDIR)
+- $(MS2C) $(LD_SHARED) $(OUT_L)$@ $(CL_NIF_OBJS) $(LDFLAGS)
+-
+diff --git a/ebin/.gitignore b/ebin/.gitignore
+deleted file mode 100644
+index 120fe3a..0000000
+--- a/ebin/.gitignore
++++ /dev/null
+@@ -1,2 +0,0 @@
+-*.beam
+-*.app
diff --git a/erlang-cl-0003-Report-CL_MISALIGNED_SUB_BUFFER_OFFSET-as-an-error-a.patch b/erlang-cl-0003-Report-CL_MISALIGNED_SUB_BUFFER_OFFSET-as-an-error-a.patch
new file mode 100644
index 0000000..9bfae60
--- /dev/null
+++ b/erlang-cl-0003-Report-CL_MISALIGNED_SUB_BUFFER_OFFSET-as-an-error-a.patch
@@ -0,0 +1,77 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Lemenkov <lemenkov@gmail.com>
+Date: Tue, 1 Dec 2026 19:36:59 +0100
+Subject: [PATCH] Report CL_MISALIGNED_SUB_BUFFER_OFFSET as an error atom
+
+clCreateSubBuffer fails with CL_MISALIGNED_SUB_BUFFER_OFFSET when the
+origin isn't a multiple of CL_DEVICE_MEM_BASE_ADDR_ALIGN, but the NIF
+had no atom for it and returned {error,unknown}.
+
+Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+---
+ c_src/cl_nif.c | 9 +++++++++
+ include/cl.hrl | 2 ++
+ 2 files changed, 11 insertions(+)
+
+diff --git a/c_src/cl_nif.c b/c_src/cl_nif.c
+index c3bbf07..9bd3ba3 100644
+--- a/c_src/cl_nif.c
++++ b/c_src/cl_nif.c
+@@ -1024,6 +1024,7 @@ DECL_ATOM(image_format_mismatch);
+ DECL_ATOM(image_format_not_supported);
+ DECL_ATOM(build_program_failure);
+ DECL_ATOM(map_failure);
++DECL_ATOM(misaligned_sub_buffer_offset);
+ DECL_ATOM(invalid_value);
+ DECL_ATOM(invalid_device_type);
+ DECL_ATOM(invalid_platform);
+@@ -1427,6 +1428,9 @@ ecl_kv_t kv_execution_status[] = { // enum
+ { &ATOM(image_format_not_supported), CL_IMAGE_FORMAT_NOT_SUPPORTED },
+ { &ATOM(build_program_failure), CL_BUILD_PROGRAM_FAILURE },
+ { &ATOM(map_failure), CL_MAP_FAILURE },
++#ifdef CL_MISALIGNED_SUB_BUFFER_OFFSET
++ { &ATOM(misaligned_sub_buffer_offset), CL_MISALIGNED_SUB_BUFFER_OFFSET },
++#endif
+ { &ATOM(invalid_value), CL_INVALID_VALUE },
+ { &ATOM(invalid_device_type), CL_INVALID_DEVICE_TYPE },
+ { &ATOM(invalid_platform), CL_INVALID_PLATFORM },
+@@ -2000,6 +2004,10 @@ ERL_NIF_TERM ecl_error(cl_int err)
+ return ATOM(build_program_failure);
+ case CL_MAP_FAILURE:
+ return ATOM(map_failure);
++#ifdef CL_MISALIGNED_SUB_BUFFER_OFFSET
++ case CL_MISALIGNED_SUB_BUFFER_OFFSET:
++ return ATOM(misaligned_sub_buffer_offset);
++#endif
+ case CL_INVALID_VALUE:
+ return ATOM(invalid_value);
+ case CL_INVALID_DEVICE_TYPE:
+@@ -7374,6 +7382,7 @@ static int ecl_load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info)
+ LOAD_ATOM(image_format_not_supported);
+ LOAD_ATOM(build_program_failure);
+ LOAD_ATOM(map_failure);
++ LOAD_ATOM(misaligned_sub_buffer_offset);
+ LOAD_ATOM(invalid_value);
+ LOAD_ATOM(invalid_device_type);
+ LOAD_ATOM(invalid_platform);
+diff --git a/include/cl.hrl b/include/cl.hrl
+index e353a87..7b71679 100644
+--- a/include/cl.hrl
++++ b/include/cl.hrl
+@@ -232,6 +232,7 @@
+ %% 'image_format_not_supported' |
+ %% 'build_program_failure' |
+ %% 'map_failure' |
++%% 'misaligned_sub_buffer_offset' |
+ %% 'invalid_value' |
+ %% 'invalid_device type' |
+ %% 'invalid_platform' |
+@@ -280,6 +281,7 @@
+ 'image_format_not_supported' |
+ 'build_program_failure' |
+ 'map_failure' |
++ 'misaligned_sub_buffer_offset' |
+ 'invalid_value' |
+ 'invalid_device type' |
+ 'invalid_platform' |
diff --git a/erlang-cl-0004-Use-normalized-coordinates-with-the-repeat-sampler-i.patch b/erlang-cl-0004-Use-normalized-coordinates-with-the-repeat-sampler-i.patch
new file mode 100644
index 0000000..fa5cfe9
--- /dev/null
+++ b/erlang-cl-0004-Use-normalized-coordinates-with-the-repeat-sampler-i.patch
@@ -0,0 +1,31 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Lemenkov <lemenkov@gmail.com>
+Date: Tue, 1 Dec 2026 19:37:05 +0100
+Subject: [PATCH] Use normalized coordinates with the repeat sampler in
+ cl_basic
+
+The OpenCL specification allows the repeat and mirrored repeat
+addressing modes only with normalized coordinates, so clCreateSampler
+with unnormalized coordinates and CL_ADDRESS_REPEAT fails with
+CL_INVALID_VALUE on implementations which check it, such as pocl.
+
+Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+---
+ test/cl_basic.erl | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/test/cl_basic.erl b/test/cl_basic.erl
+index 778c898..8423e10 100644
+--- a/test/cl_basic.erl
++++ b/test/cl_basic.erl
+@@ -272,7 +272,8 @@ test_sampler(E, Device) ->
+ cl:release_sampler(Sampler1),
+
+ %% Sampler2
+- {ok,Sampler2} = cl:create_sampler(E#cl.context,false,repeat,linear),
++ %% Repeat addressing is only defined for normalized coordinates
++ {ok,Sampler2} = cl:create_sampler(E#cl.context,true,repeat,linear),
+ io:format("Sampler2: ~p\n", [Sampler2]),
+ {ok,Sampler2Info} = cl:get_sampler_info(Sampler2),
+ io:format("Sampler2Info: ~p\n", [Sampler2Info]),
diff --git a/erlang-cl-0005-Align-the-sub-buffer-in-cl_buffer-sub-to-the-device.patch b/erlang-cl-0005-Align-the-sub-buffer-in-cl_buffer-sub-to-the-device.patch
new file mode 100644
index 0000000..7faf876
--- /dev/null
+++ b/erlang-cl-0005-Align-the-sub-buffer-in-cl_buffer-sub-to-the-device.patch
@@ -0,0 +1,55 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Lemenkov <lemenkov@gmail.com>
+Date: Tue, 1 Dec 2026 19:38:03 +0100
+Subject: [PATCH] Align the sub buffer in cl_buffer:sub to the device
+
+The origin of a sub buffer must be a multiple of
+CL_DEVICE_MEM_BASE_ADDR_ALIGN, and pocl, for one, rejects origin 18 with
+CL_MISALIGNED_SUB_BUFFER_OFFSET. Create the sub buffer at the alignment
+of the device and write the data so that the same bytes start there.
+
+The test also compared the result with =:=, whose value Common Test
+ignores, so it passed whatever it read; match it instead.
+
+Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+---
+ test/cl_buffer.erl | 13 +++++++++----
+ 1 file changed, 9 insertions(+), 4 deletions(-)
+
+diff --git a/test/cl_buffer.erl b/test/cl_buffer.erl
+index 6a4b9ff..b7dee33 100644
+--- a/test/cl_buffer.erl
++++ b/test/cl_buffer.erl
+@@ -122,7 +122,11 @@ sub(Config) ->
+ C = clu:setup(proplists:get_value(type, Config, gpu)),
+ true = lists:member({1,1},cl:versions()),
+ {ok,Q} = cl:create_queue(clu:context(C),clu:device(C),[]),
+- {ok,Buf1} = cl:create_buffer(clu:context(C),[read_write], 8*8),
++ %% The origin of a sub buffer must be aligned to mem_base_addr_align
++ %% (in bits), so put the data where the sub buffer starts at that origin
++ {ok,AlignBits} = cl:get_device_info(clu:device(C),mem_base_addr_align),
++ Origin = AlignBits div 8,
++ {ok,Buf1} = cl:create_buffer(clu:context(C),[read_write], Origin+8*8),
+ Data1 = <<0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ 0,0,1,2,3,4,0,0,
+@@ -131,14 +135,15 @@ sub(Config) ->
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ 0, 0,0,0,0,0,0,0>>,
+- {ok,E1} = cl:enqueue_write_buffer(Q, Buf1, 0, 64, Data1, []),
+- {ok,Buf2} = cl:create_sub_buffer(Buf1,[read_write],region,[18,14]),
++ {ok,E1} = cl:enqueue_write_buffer(Q, Buf1, Origin-18, 64, Data1, []),
++ {ok,Buf2} = cl:create_sub_buffer(Buf1,[read_write],region,[Origin,14]),
+ {ok,E2} = cl:enqueue_read_buffer(Q, Buf2, 0, 12, [E1]),
+ cl:flush(Q),
+ cl:wait_for_events([E1]),
+ {ok,Data2} = cl:wait(E2),
+ clu:teardown(C),
+- Data2 =:= <<1,2,3,4,0,0,0,0,5,6,7,8>>.
++ <<1,2,3,4,0,0,0,0,5,6,7,8>> = Data2,
++ ok.
+
+
+ %% fill buffer, require version 1.2
diff --git a/erlang-cl-0006-Don-t-call-erlang-get_stacktrace-0-in-cl_SUITE.patch b/erlang-cl-0006-Don-t-call-erlang-get_stacktrace-0-in-cl_SUITE.patch
new file mode 100644
index 0000000..6305918
--- /dev/null
+++ b/erlang-cl-0006-Don-t-call-erlang-get_stacktrace-0-in-cl_SUITE.patch
@@ -0,0 +1,31 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Lemenkov <lemenkov@gmail.com>
+Date: Tue, 1 Dec 2026 19:38:12 +0100
+Subject: [PATCH] Don't call erlang:get_stacktrace/0 in cl_SUITE
+
+It was removed in Erlang/OTP 23, so when no OpenCL device can be set up,
+init_per_suite crashed in its catch clause instead of skipping the
+suite. Take the stacktrace from the catch pattern instead.
+
+Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+---
+ test/cl_SUITE.erl | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/test/cl_SUITE.erl b/test/cl_SUITE.erl
+index 107ae4c..2e90cdc 100644
+--- a/test/cl_SUITE.erl
++++ b/test/cl_SUITE.erl
+@@ -22,9 +22,9 @@ init_per_suite(Config) ->
+ {ok, [Type|_]} = cl:get_device_info(clu:device(CLU), type),
+ clu:teardown(CLU),
+ [{type, Type}|Config]
+- catch _:Reason ->
++ catch _:Reason:Stacktrace ->
+ io:format("Skipping test case failed to figure out cl device~n"),
+- io:format("~p: ~p~n",[Reason, erlang:get_stacktrace()]),
++ io:format("~p: ~p~n",[Reason, Stacktrace]),
+ {skip, "Can not find cl type"}
+ end.
+
diff --git a/erlang-cl-0007-Don-t-run-edoc-and-dialyzer-after-the-tests.patch b/erlang-cl-0007-Don-t-run-edoc-and-dialyzer-after-the-tests.patch
new file mode 100644
index 0000000..a981ac6
--- /dev/null
+++ b/erlang-cl-0007-Don-t-run-edoc-and-dialyzer-after-the-tests.patch
@@ -0,0 +1,30 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Lemenkov <lemenkov@gmail.com>
+Date: Tue, 1 Dec 2026 19:39:25 +0100
+Subject: [PATCH] Don't run edoc and dialyzer after the tests
+
+rebar3 ct ran edoc and dialyzer as post hooks, so the tests failed
+whenever dialyzer reported a warning, even when every test passed, and
+every test run waited for a dialyzer analysis. Both remain available as
+rebar3 edoc and rebar3 dialyzer.
+
+Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+---
+ rebar.config | 3 +--
+ 1 file changed, 1 insertion(+), 2 deletions(-)
+
+diff --git a/rebar.config b/rebar.config
+index 533e9e8..017a975 100644
+--- a/rebar.config
++++ b/rebar.config
+@@ -5,8 +5,7 @@
+ {erl_opts, [debug_info, fail_on_warning]}.
+
+ {provider_hooks, [{pre, [{compile, {pc, compile}},
+- {clean, {pc, clean}}]},
+- {post, [{ct, edoc}, {ct, dialyzer}]}]}.
++ {clean, {pc, clean}}]}]}.
+
+ %% Assumes bash (even on windows)
+ {post_hooks,
diff --git a/erlang-cl.spec b/erlang-cl.spec
index 7bdc274..60564ac 100644
--- a/erlang-cl.spec
+++ b/erlang-cl.spec
@@ -7,39 +7,34 @@ Summary: OpenCL binding for Erlang
License: MIT
URL: https://github.com/tonyrog/%{realname}
VCS: git:%{url}.git
-Source0: %{url}/archive/cl-%{version}/%{realname}-%{version}.tar.gz
-Patch1: erlang-cl-0001-Remove-handmade-makefile.patch
+Source: %{url}/archive/cl-%{version}/%{realname}-%{version}.tar.gz
+Patch: erlang-cl-0001-Build-the-NIF-with-the-rebar3-port-compiler-plugin.patch
+Patch: erlang-cl-0002-Remove-handmade-makefile.patch
+Patch: erlang-cl-0003-Report-CL_MISALIGNED_SUB_BUFFER_OFFSET-as-an-error-a.patch
+Patch: erlang-cl-0004-Use-normalized-coordinates-with-the-repeat-sampler-i.patch
+Patch: erlang-cl-0005-Align-the-sub-buffer-in-cl_buffer-sub-to-the-device.patch
+Patch: erlang-cl-0006-Don-t-call-erlang-get_stacktrace-0-in-cl_SUITE.patch
+Patch: erlang-cl-0007-Don-t-run-edoc-and-dialyzer-after-the-tests.patch
BuildRequires: erlang-edown
-BuildRequires: erlang-rebar3
+BuildRequires: erlang-rebar3-pc
BuildRequires: gcc
BuildRequires: ocl-icd-devel
BuildRequires: opencl-headers
-# We have only one OpenCL runtime for tests. Unfortunately tests fails to pass
-# with this one.
-# BuildRequires: pocl
-# BuildRequires: opencl-filesystem
+# The tests run on the CPU with pocl, which isn't available for %%{ix86}
+# and doesn't work on s390x: clCreateProgramWithBinary crashes there, and
+# upstream doesn't support big-endian (https://github.com/pocl/pocl/issues/2129)
+%ifnarch %{ix86} s390x
+BuildRequires: pocl
+%endif
+BuildSystem: rebar3
%description
%{summary}.
-%prep
-%autosetup -p1 -n %{realname}-cl-%{version}
-
-%build
-%{erlang3_compile}
-
-# FIXME we don't have a port compiler plugin for rebar3 yet
-mkdir -p ./priv
-gcc c_src/cl_hash.c $CFLAGS -fPIC -c -I%{_libdir}/erlang/usr/include -o c_src/cl_hash.o
-gcc c_src/cl_nif.c $CFLAGS -fPIC -c -I%{_libdir}/erlang/usr/include -o c_src/cl_nif.o
-gcc c_src/cl_hash.o c_src/cl_nif.o $LDFLAGS -shared -L%{_libdir}/erlang/usr/lib -lei -lOpenCL -o priv/cl_nif.so
-
-%install
-%{erlang3_install}
-
%check
-# Can't pass autotests for now due to limited OpenCL support in Fedora (?)
-#%%{erlang3_test}
+%ifnarch %{ix86} s390x
+%{erlang3_test}
+%endif
%files
%license COPYRIGHT
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-12-01 20:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-01 20:05 [rpms/erlang-cl] rawhide: Switch to declarative build system (f44+) Peter Lemenkov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox