Bug 232357 - graphics/ImageMagick: run-time failure for convert(1) if built with libOpenCL and beignet / clover are installed
Summary: graphics/ImageMagick: run-time failure for convert(1) if built with libOpenCL...
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Koop Mast
URL:
Keywords:
Depends on: 233495
Blocks:
  Show dependency treegraph
 
Reported: 2018-10-17 14:37 UTC by John Hein
Modified: 2020-04-02 18:18 UTC (History)
2 users (show)

See Also:
bugzilla: maintainer-feedback? (kwm)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Hein 2018-10-17 14:37:07 UTC
If graphics/ImageMagick (currently ImageMagick-6.9.9.28_2,1) is built with the following packages installed:

 devel/opencl
 devel/ocl-icd
 lang/beignet
 lang/clover

... 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>
int
main()
{
    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:

https://github.com/pocl/pocl/issues/474

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

https://bugs.llvm.org/show_bug.cgi?id=30587

and

http://lists.llvm.org/pipermail/llvm-bugs/2016-October/051237.html
Comment 5 Rene Ladan freebsd_committer freebsd_triage 2020-04-02 18:18:31 UTC
FYI, beignet was removed today as it was expired.