Bug 222757

Summary: Some problems in mesa ports related to OpenCL
Product: Ports & Packages Reporter: shamaz.mazum
Component: Individual Port(s)Assignee: freebsd-x11 (Nobody) <x11>
Status: Open ---    
Severity: Affects Only Me CC: arrowd
Priority: --- Flags: bugzilla: maintainer-feedback? (x11)
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Gallium pipe-loader patch none

Description shamaz.mazum 2017-10-03 16:27:49 UTC
Created attachment 186882 [details]
Gallium pipe-loader patch

Hello. I've tried OpenCL using lang/clover provider and encountered some problems in mesa ports (can be fixed patching graphics/mesa-dri). I use FreeBSD 11.1 and have the port tree updated with portsnap and packages updated with portupgrade

1) OpenCL applications do not work in X11 environment. I have exactly the same problem as described here: bug #214204 (*) The fix is still the same, maybe this is a regression. I attach patch which is combined from an old patch in graphics/mesa-dri/files and the fix. I still do not know how to link -lxcb to opencl targets. Autoconf is very complicated for me, so I do not know what to do.

2) When I call clReleaseContext() from my program, it finishes OK, but program crashes with segmantation fault when calls atexit handlers, having very strange backtrace:

(gdb) bt
#0  0x0000000808534500 in ?? ()
#1  0x0000000800b754d5 in __cxa_finalize (dso=0x0) at /usr/src/lib/libc/stdlib/atexit.c:237
#2  0x0000000800b063d1 in exit (status=0) at /usr/src/lib/libc/stdlib/exit.c:72
#3  0x0000000000400da6 in _start ()
#4  0x0000000800625000 in ?? ()
#5  0x0000000000000000 in ?? ()

clinfo has the same behaviour. I do not know the solution. Any suggestions?

(*) https://lists.freebsd.org/pipermail/freebsd-x11/2016-November/018240.html
Comment 1 Gleb Popov freebsd_committer 2020-04-25 13:23:08 UTC
There was a lot of changes in mesa, and clover also had many updates. Shamaz, can you check if the problem is still relevant, please?
Comment 2 shamaz.mazum 2020-04-25 14:17:24 UTC
(In reply to Gleb Popov from comment #1)

I do not use xorg anymore (I use wayland), so I cannot help you with 1). 2) is still there. For some reason control is passed to nowhere rather than to an exit handler (a function which is registered with atexit(3)).

My personal solution is to use functions with __constructor__ and __destructor__ attributes rather than exit handlers.
Comment 3 Gleb Popov freebsd_committer 2020-04-25 14:27:11 UTC
(In reply to shamaz.mazum from comment #2)

For problem 2), can you provide a testcase, that can be compiled & executed?
Comment 4 shamaz.mazum 2020-04-25 14:31:53 UTC
(In reply to Gleb Popov from comment #3)

Just launch devel/clinfo (provided you have a videocard supported by radeonkms or amdgpu).