Open JayFoxRox opened 1 year ago
Did you try the main branch or the release?
I'm on the main branch. The current main branch revision also still contains the problematic code linked above.
It does have the unused code, but I believe https://github.com/pocl/pocl/pull/1252 fixes the issue that you are running into.
OCL_ICD_LIBRARIES
OCL_ICD_LIBDIR
).In my case OpenCL ICD Loader is found, so both of these variables are valid, but they don't get used correctly.
These variables get used to set OPENCL_LIBRARIES
(= OCL_ICD_LIBRARIES
) and OPENCL_LIBDIR
and (= OCL_ICD_LIBDIR
) then.
Example: OPENCL_LIBS=Threads::Threads;OpenCL
OPENCL_LIBDIR=/opt/homebrew/Cellar/opencl-icd-loader/2023.04.17/lib
; both valid.
However, from that point onwards, only OPENCL_LIBRARIES
is used. OPENCL_LIBDIR
is used for some things, but the linker never gets told about it.
This means the linker links against -lOpenCL
(from OPENCL_LIBRARIES
) but it never adds the path where that lib can be found (should be from OPENCL_LIBDIR
). So essentially missing -L${OPENCL_LIBDIR}
.
A redesign with import targets would make this error impossible, as the library name, library path (and other potentially important things like flags) are part of the same "object".
A redesign with import targets would make this error impossible
Indeed, most of the CMake code is old and doesn't use targets. However any redesign must also keep in mind that PoCL should also support other ICD loaders (Khronos), and also builds without ICD.
The current CMake setup is rather outdated and doesn't use the recommended way of integrating the OpenCL-ICD-Loader (which uses import targets now). Instead a couple of variables get created here:
https://github.com/pocl/pocl/blob/5a99e12d0bb78427ad948ac368589135507f1b59/CMakeLists.txt#L1022-L1023
However,
OPENCL_LIBDIR
is never actually used to control the linker, so if the OpenCL library is not part of the system library path, the build-script will fail to find it.I think the build-system needs major redesign in this area.
To combat this, I'm currently using this patch: