Bug 232357

Summary: graphics/ImageMagick: run-time failure for convert(1) if built with libOpenCL and beignet / clover are installed
Product: Ports & Packages Reporter: John Hein <jcfyecrayz>
Component: Individual Port(s)Assignee: Koop Mast <kwm>
Status: New ---    
Severity: Affects Some People CC: ohartmann, rene
Priority: --- Flags: bugzilla: maintainer-feedback? (kwm)
Version: Latest   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223879
Bug Depends on: 233495    
Bug Blocks:    

Description John Hein 2018-10-17 14:37:07 UTC
If graphics/ImageMagick (currently ImageMagick-,1) is built with the following packages installed:


... then running convert(1) (from ImageMagick) with certain parameters will fail:

% convert foo.png -colorspace Gray foo2.png
Device open failed, aborting...
: CommandLine Error: Option 'enable-value-profiling' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
Nothing to output !

This was first noticed when building x11-wm/awesome on a system (amd64) with lang/beignet & lang/clover installed.  You can reproduce it by installing devel/ocl-icd, devel/opencl, lang/beignet and lang/clover packages (maybe just lang/beignet??), then trying 'make build' in x11-wm/awesome.

The configure stage for ImageMagick detects the opencl include files & libraries and will link with libOpenCL if detected.  Then if the lang/beignet and lang/clover ports are installed then convert will use them at run-time.  That triggers the error.  I have not yet done any in depth digging into ImageMagick to see more details about this.

Workaround: configure ImageMagick with --disable-opencl
Comment 1 John Hein 2018-11-16 12:42:47 UTC
Simple test case:

#include <CL/opencl.h>
#include <stdio.h>
    unsigned int uu;
    printf("rc: %d\n", clGetPlatformIDs(0, 0, &uu));
    printf("uu: %u\n", uu);
    return 0;

% cc -Wall -I/usr/local/include -L/usr/local/lib -lOpenCL cl.c -o cl
% ./cl
X server found. dri2 connection failed!
Device open failed, aborting...
: CommandLine Error: Option 'enable-value-profiling' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
Nothing to output !

clGetPlatformIDs() apparently is calling exit when it detectes what it thinks is an error (a very impolite think for a library to be doing).  convert is calling clGetPlatformIDs under the covers.  If you move away /usr/local/lib/beignet/libbeignet.so, clGetPlatformIDs returns a 0 and uu in the above STC is 2.

Unknown yet why libOpenCL has this behavior.  That seems to be the crux of this bug, but it has infected ImageMagick, and perhaps a workaround may be useful (OPENCL option? default off? for now?).
Comment 2 John Hein 2018-11-24 18:21:30 UTC
Other bugs with similar failures:

bug 223879
bug 224584
bug 231226
Comment 3 John Hein 2018-11-25 00:54:52 UTC
See also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=852746
Comment 4 O. Hartmann 2018-11-25 09:48:20 UTC
See Bug 233495 . I tried to gather issues and direct the issue to the root of the problem. It seems, that developers of POCL are aware of the problem, see for this here:


As refered in Bug 233495, the issue seems to root here:



Comment 5 Rene Ladan freebsd_committer 2020-04-02 18:18:31 UTC
FYI, beignet was removed today as it was expired.