ROCm-OpenCL-Runtime icon indicating copy to clipboard operation
ROCm-OpenCL-Runtime copied to clipboard

Linker complains: multiple definition of ret_val

Open imyxh opened this issue 5 years ago • 1 comments

Hello, I discovered this downstream using the stable AUR version of rocm-opencl-runtime (issue here), but then realized I can reproduce the same error straight from git.

After successfully installing ROCclr, my attempt to build ROCm-OpenCL-Runtime fails with the following errors:

[ 47%] Linking C executable icd_loader_test
/usr/bin/ld: CMakeFiles/icd_loader_test.dir/test_platforms.c.o:(.bss+0x0): multiple definition of `ret_val'; CMakeFiles/icd_loader_test.dir/test_kernel.c.o:(.bss+0x0): first defined here
/usr/bin/ld: CMakeFiles/icd_loader_test.dir/test_program_objects.c.o:(.bss+0x0): multiple definition of `ret_val'; CMakeFiles/icd_loader_test.dir/test_kernel.c.o:(.bss+0x0): first defined here
/usr/bin/ld: CMakeFiles/icd_loader_test.dir/test_sampler_objects.c.o:(.bss+0x0): multiple definition of `ret_val'; CMakeFiles/icd_loader_test.dir/test_kernel.c.o:(.bss+0x0): first defined here
/usr/bin/ld: CMakeFiles/icd_loader_test.dir/test_cl_runtime.c.o:(.bss+0x0): multiple definition of `ret_val'; CMakeFiles/icd_loader_test.dir/test_kernel.c.o:(.bss+0x0): first defined here
/usr/bin/ld: CMakeFiles/icd_loader_test.dir/test_clgl.c.o:(.bss+0x0): multiple definition of `ret_val'; CMakeFiles/icd_loader_test.dir/test_kernel.c.o:(.bss+0x0): first defined here
/usr/bin/ld: CMakeFiles/icd_loader_test.dir/test_image_objects.c.o:(.bss+0x0): multiple definition of `ret_val'; CMakeFiles/icd_loader_test.dir/test_kernel.c.o:(.bss+0x0): first defined here
collect2: error: ld returned 1 exit status
make[2]: *** [khronos/icd/test/loader_test/CMakeFiles/icd_loader_test.dir/build.make:271: khronos/icd/test/loader_test/icd_loader_test] Error 1
make[1]: *** [CMakeFiles/Makefile2:1191: khronos/icd/test/loader_test/CMakeFiles/icd_loader_test.dir/all] Error 2
make: *** [Makefile:150: all] Error 2

It seems test_kernel.c uses a global variable "ret_val" which is the same name as global variables from some other C files (e.g. test_platforms.c) ... can anyone else reproduce this error from Make or am I somehow building things the wrong way?

My build process was entirely based on the README.md files from here and ROCclr. Does anyone have ideas on how I might further debug this?

imyxh avatar May 15 '20 05:05 imyxh

@imyxh, this is a bug in OpenCL ICD Loader tests and looks like this project contains outdated version of them. You can cherry-pick a fix from KhronosGroup/OpenCL-ICD-Loader#101

AlexeySachkov avatar May 15 '20 07:05 AlexeySachkov