Dynamic binding: how to ignore version tags?

I want to compile an OpenCL program that uses clAmdFFT, AMDs OpenCL FFT, which is closed.

$ objdump -x libclAmdFft.Runtime.so Dynamic Section: NEEDED libOpenCL.so.1 Version References: required from libOpenCL.so.1: 0x028568b0 0x00 05 OPENCL_1.0 

On one machine, I use the AMD driver, which comes with libOpenCL.so, which includes version information, for example:

 a$ objdump -T /opt/AMDAPP/lib/x86_64/libOpenCL.so 0000000000002610 g DF .text 0000000000000018 OPENCL_1.0 clGetSamplerInfo 00000000000032e0 g DF .text 0000000000000018 OPENCL_1.1 clSetEventCallback 0000000000002350 g DF .text 0000000000000018 OPENCL_1.2 clCreateSubDevices 

Everything is fine on this machine.

On another machine, I use the nVidia driver, which comes with libOpenCL.so, which does not include version information, for example:

 b$ objdump -T /usr/lib/libOpenCL.so # -> /usr/lib/nvidia-current/libOpenCL.so 00000000000021f0 g DF .text 0000000000000018 Base clGetSamplerInfo 0000000000002a40 g DF .text 0000000000000018 Base clSetEventCallback 

Linking the program to -llibOpenCL.so -llibclAmdFft.Runtime.so is not done here, since clAmdFft wants to refer to tagged characters:

 libclAmdFftRuntime.so: undefinded reference to ` clCreateBuffer@OPENCL _1.0` 

The dynamic linker also generates this complaint:

 b$ ldd libclAmdFft.Runtime.so libclAmdFft.Runtime.so: …/libOpenCL.so.1: no version information available … 

Since the nVidia driver implements OpenCL 1.1, and AmdFFT only 1.0, it should work if I can convince it that Base = OPENCL_1.0 . Is it possible?

I cannot force nVidia users to install a different version, since libOpenCL is part of a driver, for example libGL.


Linking with --unresolved-symbols=ignore-in-shared-libs succeeds, but the resulting binary no longer finds the FFT library.


Since OpenCL separates device-specific parts in ICD libraries, this will work if I provided libOpenCL.so from the AMD driver, even on nVidia machines, where it dynamically loads the correct ICD from /etc/OpenCL/vendors/nvidia.icd, but I don’t sure that this is really portable, the directory is hard-coded, for example.

+6
source share

Source: https://habr.com/ru/post/921875/


All Articles