Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when building OpenCL ICD Loader using MinGW #11

Closed
sirzooro opened this issue Jan 30, 2017 · 9 comments · Fixed by #64 or #197
Closed

Error when building OpenCL ICD Loader using MinGW #11

sirzooro opened this issue Jan 30, 2017 · 9 comments · Fixed by #64 or #197
Assignees

Comments

@sirzooro
Copy link

sirzooro commented Jan 30, 2017

Compilation of OpenCL ICD Loader using MinGW gcc fails. Compiler complains about missing InitOnceExecuteOnce function, then linker complains about missing dl lib. More details about this problem and workaround needed to get libOpenCL.a are in this thread on StackOverflow. Please fix this.

BTW, please also add some option to easily get static lib instead of shared one. I am going to link this lib with app used for computations on one of BOINC projects. It is easier to link everything statically and distribute single binary than having to provide additional libs.

@kepatil
Copy link
Contributor

kepatil commented Apr 27, 2017

Thanks for the link and description of the MinGW issue. Will you be able to create a pull request with a fix?

There is an existing pull request that adds an option to compile a static library. I will consider merging it.

@hydra3333
Copy link

hydra3333 commented May 6, 2017

Unsure if this is related, however seems worth mentioning.
Using a newbie's build script based on rdp's windows_build_helpers, the x64 mingw based build for ICD works, however the x32 build for ICD does not.
Logs attached below.
Suggestions welcomed.

successful x64 build log:

# log from a MINGW x64 based successful build of the OpenCL ICD leader
+ cd OpenCL-ICD-Loader
+ apply_patch https://raw.githubusercontent.com/hydra3333/ffmpeg-windows-build-helpers-withOpenCL/master/patches/0001-OpenCL-git-prefix.patch -p1
+ local url=https://raw.githubusercontent.com/hydra3333/ffmpeg-windows-build-helpers-withOpenCL/master/patches/0001-OpenCL-git-prefix.patch
+ local patch_type=-p1
+ [[ -z -p1 ]]
++ basename https://raw.githubusercontent.com/hydra3333/ffmpeg-windows-build-helpers-withOpenCL/master/patches/0001-OpenCL-git-prefix.patch
+ local patch_name=0001-OpenCL-git-prefix.patch
+ local patch_done_name=0001-OpenCL-git-prefix.patch.done
+ [[ ! -e 0001-OpenCL-git-prefix.patch.done ]]
+ [[ -f 0001-OpenCL-git-prefix.patch ]]
+ curl -4 -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'Cache-Control: max-age=0' --retry 5 https://raw.githubusercontent.com/hydra3333/ffmpeg-windows-build-helpers-withOpenCL/master/patches/0001-OpenCL-git-prefix.patch -O --fail
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   634  100   634    0     0   1251      0 --:--:-- --:--:-- --:--:--  1250
100   634  100   634    0     0   1250      0 --:--:-- --:--:-- --:--:--  1250
+ echo 'applying patch 0001-OpenCL-git-prefix.patch'
applying patch 0001-OpenCL-git-prefix.patch
+ patch -p1
patching file CMakeLists.txt
+ touch 0001-OpenCL-git-prefix.patch.done
+ rm -f 'already_ran*'
+ echo 'PATCH finished 0001-OpenCL-git-prefix.patch -p1'
PATCH finished 0001-OpenCL-git-prefix.patch -p1
+ set -x
+ rm -f libOpenCL.dll.a
+ cmake –G”Unix Makefiles” . -DENABLE_STATIC_RUNTIME=1 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RANLIB=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32-ranlib -DCMAKE_C_COMPILER=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++ -DCMAKE_RC_COMPILER=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32-windres -DCMAKE_INSTALL_PREFIX=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32 -DBUILD_SHARED_LIBS=OFF -DCMAKE_FIND_ROOT_PATH=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32-gcc
-- Check for working C compiler: /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++
-- Check for working CXX compiler: /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-x86_64/bin/x86_64-w64-mingw32-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    ENABLE_STATIC_RUNTIME


-- Build files have been written to: /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/x86_64/OpenCL-ICD-Loader
+ make clean
+ make -j 2
Scanning dependencies of target IcdLog
Scanning dependencies of target OpenCL
[  8%] Building C object CMakeFiles/OpenCL.dir/icd.c.obj
[  8%] Building C object test/platform/CMakeFiles/IcdLog.dir/icd_test_log.c.obj
[ 12%] Linking C shared library ../../bin/libIcdLog.dll
[ 12%] Built target IcdLog
Scanning dependencies of target OpenCLDriverStub
[ 16%] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/cl.c.obj
[ 20%] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/cl_ext.c.obj
[ 25%] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/cl_gl.c.obj
[ 29%] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/icd.c.obj
[ 33%] Linking C shared library ../../bin/libOpenCLDriverStub.dll
[ 33%] Built target OpenCLDriverStub
[ 37%] Building C object CMakeFiles/OpenCL.dir/icd_dispatch.c.obj
[ 41%] Building C object CMakeFiles/OpenCL.dir/icd_windows.c.obj
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/x86_64/OpenCL-ICD-Loader/icd_dispatch.c: In function 'clGetExtensionFunctionAddressForPlatform':
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/x86_64/OpenCL-ICD-Loader/icd_dispatch.c:1415:5: warning: 'clGetKernelSubGroupInfoKHR' is deprecated [-Wdeprecated-declarations]
     CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetKernelSubGroupInfoKHR);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/x86_64/OpenCL-ICD-Loader/icd_dispatch.h:72:0,
                 from /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/x86_64/OpenCL-ICD-Loader/icd_dispatch.c:38:
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-x86_64/include/CL/cl_ext.h:379:1: note: declared here
 clGetKernelSubGroupInfoKHR(cl_kernel /* in_kernel */,
 ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/x86_64/OpenCL-ICD-Loader/icd_dispatch.c: In function 'clGetExtensionFunctionAddress':
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/x86_64/OpenCL-ICD-Loader/icd_dispatch.c:1621:5: warning: 'clGetKernelSubGroupInfoKHR' is deprecated [-Wdeprecated-declarations]
     CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetKernelSubGroupInfoKHR);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/x86_64/OpenCL-ICD-Loader/icd_dispatch.h:72:0,
                 from /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/x86_64/OpenCL-ICD-Loader/icd_dispatch.c:38:
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-x86_64/include/CL/cl_ext.h:379:1: note: declared here
 clGetKernelSubGroupInfoKHR(cl_kernel /* in_kernel */,
 ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/x86_64/OpenCL-ICD-Loader/icd_windows.c: In function 'khrIcdOsVendorsEnumerateOnce':
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/x86_64/OpenCL-ICD-Loader/icd_windows.c:129:5: warning: implicit declaration of function 'InitOnceExecuteOnce' [-Wimplicit-function-declaration]
     InitOnceExecuteOnce(&initialized, khrIcdOsVendorsEnumerate, NULL, NULL);
     ^~~~~~~~~~~~~~~~~~~
[ 45%] Linking C shared library bin/OpenCL.dll
[ 45%] Built target OpenCL
Scanning dependencies of target icd_loader_test
[ 54%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_kernel.c.obj
[ 54%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/main.c.obj
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/x86_64/OpenCL-ICD-Loader/test/loader_test/main.c: In function 'main':
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/x86_64/OpenCL-ICD-Loader/test/loader_test/main.c:36:5: warning: implicit declaration of function 'test_release_calls' [-Wimplicit-function-declaration]
     test_release_calls();
     ^~~~~~~~~~~~~~~~~~
[ 58%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_platforms.c.obj
[ 62%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/icd_test_match.c.obj
[ 66%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_program_objects.c.obj
[ 70%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_sampler_objects.c.obj
[ 75%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_buffer_object.c.obj
[ 79%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_cl_runtime.c.obj
[ 83%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/callbacks.c.obj
[ 87%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_create_calls.c.obj
[ 91%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_clgl.c.obj
[ 95%] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_image_objects.c.obj
[100%] Linking C executable ../../bin/icd_loader_test.exe
[100%] Built target icd_loader_test
+ cp -vf libOpenCL.dll.a /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/lib/libOpenCL.dll.a
'libOpenCL.dll.a' -> '/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-x86_64/x86_64-w64-mingw32/lib/libOpenCL.dll.a'

unsuccessful x32 build log:

+ cd OpenCL-ICD-Loader
+ apply_patch https://raw.githubusercontent.com/hydra3333/ffmpeg-windows-build-helpers-withOpenCL/master/patches/0001-OpenCL-git-prefix.patch -p1
+ local url=https://raw.githubusercontent.com/hydra3333/ffmpeg-windows-build-helpers-withOpenCL/master/patches/0001-OpenCL-git-prefix.patch
+ local patch_type=-p1
+ [[ -z -p1 ]]
++ basename https://raw.githubusercontent.com/hydra3333/ffmpeg-windows-build-helpers-withOpenCL/master/patches/0001-OpenCL-git-prefix.patch
+ local patch_name=0001-OpenCL-git-prefix.patch
+ local patch_done_name=0001-OpenCL-git-prefix.patch.done
+ [[ ! -e 0001-OpenCL-git-prefix.patch.done ]]
+ [[ -f 0001-OpenCL-git-prefix.patch ]]
+ curl -4 -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'Cache-Control: max-age=0' --retry 5 https://raw.githubusercontent.com/hydra3333/ffmpeg-windows-build-helpers-withOpenCL/master/patches/0001-OpenCL-git-prefix.patch -O --fail
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100   634  100   634    0     0   1174      0 --:--:-- --:--:-- --:--:--  1176


+ echo 'applying patch 0001-OpenCL-git-prefix.patch'
applying patch 0001-OpenCL-git-prefix.patch
+ patch -p1
patching file CMakeLists.txt
+ touch 0001-OpenCL-git-prefix.patch.done
+ rm -f 'already_ran*'
+ echo 'PATCH finished 0001-OpenCL-git-prefix.patch -p1'
PATCH finished 0001-OpenCL-git-prefix.patch -p1
+ set -x
+ rm -f libOpenCL.dll.a
+ cmake –G”Unix Makefiles” . -DENABLE_STATIC_RUNTIME=1 -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_RANLIB=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-ranlib -DCMAKE_C_COMPILER=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-g++ -DCMAKE_RC_COMPILER=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-windres -DCMAKE_INSTALL_PREFIX=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32 -DBUILD_SHARED_LIBS=OFF -DCMAKE_FIND_ROOT_PATH=/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/i686-w64-mingw32
-- The C compiler identification is GNU 6.3.0
-- The CXX compiler identification is GNU 6.3.0
-- Check for working C compiler: /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-gcc
-- Check for working C compiler: /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-g++
-- Check for working CXX compiler: /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/bin/i686-w64-mingw32-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
CMake Warning:
  Manually-specified variables were not used by the project:

    ENABLE_STATIC_RUNTIME


-- Build files have been written to: /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader
+ make clean
+ make -j 2
Scanning dependencies of target IcdLog
Scanning dependencies of target OpenCL
[  4%] Building C object test/platform/CMakeFiles/IcdLog.dir/icd_test_log.c.obj
[  8%] Building C object CMakeFiles/OpenCL.dir/icd.c.obj
[ 12%] Linking C shared library ../../bin/libIcdLog.dll
[ 12%] Built target IcdLog
Scanning dependencies of target OpenCLDriverStub
[ 16%] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/cl.c.obj
[ 20%] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/cl_ext.c.obj
[ 25%] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/cl_gl.c.obj
[ 29%] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/icd.c.obj
[ 33%] Linking C shared library ../../bin/libOpenCLDriverStub.dll
Warning: resolving _clGetExtensionFunctionAddress by linking to _clGetExtensionFunctionAddress@4
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving _clIcdGetPlatformIDsKHR by linking to _clIcdGetPlatformIDsKHR@12
[ 33%] Built target OpenCLDriverStub
[ 37%] Building C object CMakeFiles/OpenCL.dir/icd_dispatch.c.obj
[ 41%] Building C object CMakeFiles/OpenCL.dir/icd_windows.c.obj
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_dispatch.c: In function 'clGetExtensionFunctionAddressForPlatform':
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_dispatch.c:1415:5: warning: 'clGetKernelSubGroupInfoKHR' is deprecated [-Wdeprecated-declarations]
     CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetKernelSubGroupInfoKHR);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_dispatch.h:72:0,
                 from /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_dispatch.c:38:
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/include/CL/cl_ext.h:379:1: note: declared here
 clGetKernelSubGroupInfoKHR(cl_kernel /* in_kernel */,
 ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_dispatch.c: In function 'clGetExtensionFunctionAddress':
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_dispatch.c:1621:5: warning: 'clGetKernelSubGroupInfoKHR' is deprecated [-Wdeprecated-declarations]
     CL_COMMON_EXTENSION_ENTRYPOINT_ADD(clGetKernelSubGroupInfoKHR);
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_dispatch.h:72:0,
                 from /home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_dispatch.c:38:
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/cross_compilers/mingw-w64-i686/include/CL/cl_ext.h:379:1: note: declared here
 clGetKernelSubGroupInfoKHR(cl_kernel /* in_kernel */,
 ^~~~~~~~~~~~~~~~~~~~~~~~~~
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_windows.c: In function 'khrIcdOsVendorsEnumerateOnce':
/home/u/Desktop/ffmpeg-windows-build-helpers-withOpenCL-master/sandbox/win32/OpenCL-ICD-Loader/icd_windows.c:129:5: warning: implicit declaration of function 'InitOnceExecuteOnce' [-Wimplicit-function-declaration]
     InitOnceExecuteOnce(&initialized, khrIcdOsVendorsEnumerate, NULL, NULL);
     ^~~~~~~~~~~~~~~~~~~
[ 45%] Linking C shared library bin/OpenCL.dll
Warning: resolving _clBuildProgram by linking to _clBuildProgram@24
Use --enable-stdcall-fixup to disable these warnings
Use --disable-stdcall-fixup to disable these fixups
Warning: resolving _clCloneKernel by linking to _clCloneKernel@8
Warning: resolving _clCompileProgram by linking to _clCompileProgram@36
Warning: resolving _clCreateBuffer by linking to _clCreateBuffer@24
Warning: resolving _clCreateCommandQueue by linking to _clCreateCommandQueue@20
Warning: resolving _clCreateCommandQueueWithProperties by linking to _clCreateCommandQueueWithProperties@16
Warning: resolving _clCreateContext by linking to _clCreateContext@24
Warning: resolving _clCreateContextFromType by linking to _clCreateContextFromType@24
Warning: resolving _clCreateFromGLBuffer by linking to _clCreateFromGLBuffer@20
Warning: resolving _clCreateFromGLRenderbuffer by linking to _clCreateFromGLRenderbuffer@20
Warning: resolving _clCreateFromGLTexture by linking to _clCreateFromGLTexture@28
Warning: resolving _clCreateFromGLTexture2D by linking to _clCreateFromGLTexture2D@28
Warning: resolving _clCreateFromGLTexture3D by linking to _clCreateFromGLTexture3D@28
Warning: resolving _clCreateImage by linking to _clCreateImage@28
Warning: resolving _clCreateImage2D by linking to _clCreateImage2D@36
Warning: resolving _clCreateImage3D by linking to _clCreateImage3D@44
Warning: resolving _clCreateKernel by linking to _clCreateKernel@12
Warning: resolving _clCreateKernelsInProgram by linking to _clCreateKernelsInProgram@16
Warning: resolving _clCreatePipe by linking to _clCreatePipe@28
Warning: resolving _clCreateProgramWithBinary by linking to _clCreateProgramWithBinary@28
Warning: resolving _clCreateProgramWithBuiltInKernels by linking to _clCreateProgramWithBuiltInKernels@20
Warning: resolving _clCreateProgramWithIL by linking to _clCreateProgramWithIL@16
Warning: resolving _clCreateProgramWithSource by linking to _clCreateProgramWithSource@20
Warning: resolving _clCreateSampler by linking to _clCreateSampler@20
Warning: resolving _clCreateSamplerWithProperties by linking to _clCreateSamplerWithProperties@12
Warning: resolving _clCreateSubBuffer by linking to _clCreateSubBuffer@24
Warning: resolving _clCreateSubDevices by linking to _clCreateSubDevices@20
Warning: resolving _clCreateUserEvent by linking to _clCreateUserEvent@8
Warning: resolving _clEnqueueAcquireGLObjects by linking to _clEnqueueAcquireGLObjects@24
Warning: resolving _clEnqueueBarrier by linking to _clEnqueueBarrier@4
Warning: resolving _clEnqueueBarrierWithWaitList by linking to _clEnqueueBarrierWithWaitList@16
Warning: resolving _clEnqueueCopyBuffer by linking to _clEnqueueCopyBuffer@36
Warning: resolving _clEnqueueCopyBufferRect by linking to _clEnqueueCopyBufferRect@52
Warning: resolving _clEnqueueCopyBufferToImage by linking to _clEnqueueCopyBufferToImage@36
Warning: resolving _clEnqueueCopyImage by linking to _clEnqueueCopyImage@36
Warning: resolving _clEnqueueCopyImageToBuffer by linking to _clEnqueueCopyImageToBuffer@36
Warning: resolving _clEnqueueFillBuffer by linking to _clEnqueueFillBuffer@36
Warning: resolving _clEnqueueFillImage by linking to _clEnqueueFillImage@32
Warning: resolving _clEnqueueMapBuffer by linking to _clEnqueueMapBuffer@44
Warning: resolving _clEnqueueMapImage by linking to _clEnqueueMapImage@52
Warning: resolving _clEnqueueMarker by linking to _clEnqueueMarker@8
Warning: resolving _clEnqueueMarkerWithWaitList by linking to _clEnqueueMarkerWithWaitList@16
Warning: resolving _clEnqueueMigrateMemObjects by linking to _clEnqueueMigrateMemObjects@32
Warning: resolving _clEnqueueNDRangeKernel by linking to _clEnqueueNDRangeKernel@36
Warning: resolving _clEnqueueNativeKernel by linking to _clEnqueueNativeKernel@40
Warning: resolving _clEnqueueReadBuffer by linking to _clEnqueueReadBuffer@36
Warning: resolving _clEnqueueReadBufferRect by linking to _clEnqueueReadBufferRect@56
Warning: resolving _clEnqueueReadImage by linking to _clEnqueueReadImage@44
Warning: resolving _clEnqueueReleaseGLObjects by linking to _clEnqueueReleaseGLObjects@24
Warning: resolving _clEnqueueSVMFree by linking to _clEnqueueSVMFree@32
Warning: resolving _clEnqueueSVMMap by linking to _clEnqueueSVMMap@36
Warning: resolving _clEnqueueSVMMemFill by linking to _clEnqueueSVMMemFill@32
Warning: resolving _clEnqueueSVMMemcpy by linking to _clEnqueueSVMMemcpy@32
Warning: resolving _clEnqueueSVMMigrateMem by linking to _clEnqueueSVMMigrateMem@36
Warning: resolving _clEnqueueSVMUnmap by linking to _clEnqueueSVMUnmap@20
Warning: resolving _clEnqueueTask by linking to _clEnqueueTask@20
Warning: resolving _clEnqueueUnmapMemObject by linking to _clEnqueueUnmapMemObject@24
Warning: resolving _clEnqueueWaitForEvents by linking to _clEnqueueWaitForEvents@12
Warning: resolving _clEnqueueWriteBuffer by linking to _clEnqueueWriteBuffer@36
Warning: resolving _clEnqueueWriteBufferRect by linking to _clEnqueueWriteBufferRect@56
Warning: resolving _clEnqueueWriteImage by linking to _clEnqueueWriteImage@44
Warning: resolving _clFinish by linking to _clFinish@4
Warning: resolving _clFlush by linking to _clFlush@4
Warning: resolving _clGetCommandQueueInfo by linking to _clGetCommandQueueInfo@20
Warning: resolving _clGetContextInfo by linking to _clGetContextInfo@20
Warning: resolving _clGetDeviceAndHostTimer by linking to _clGetDeviceAndHostTimer@12
Warning: resolving _clGetDeviceIDs by linking to _clGetDeviceIDs@24
Warning: resolving _clGetDeviceInfo by linking to _clGetDeviceInfo@20
Warning: resolving _clGetEventInfo by linking to _clGetEventInfo@20
Warning: resolving _clGetEventProfilingInfo by linking to _clGetEventProfilingInfo@20
Warning: resolving _clGetExtensionFunctionAddress by linking to _clGetExtensionFunctionAddress@4
Warning: resolving _clGetExtensionFunctionAddressForPlatform by linking to _clGetExtensionFunctionAddressForPlatform@8
Warning: resolving _clGetGLObjectInfo by linking to _clGetGLObjectInfo@12
Warning: resolving _clGetGLTextureInfo by linking to _clGetGLTextureInfo@20
Warning: resolving _clGetHostTimer by linking to _clGetHostTimer@8
Warning: resolving _clGetImageInfo by linking to _clGetImageInfo@20
Warning: resolving _clGetKernelArgInfo by linking to _clGetKernelArgInfo@24
Warning: resolving _clGetKernelInfo by linking to _clGetKernelInfo@20
Warning: resolving _clGetKernelSubGroupInfo by linking to _clGetKernelSubGroupInfo@32
Warning: resolving _clGetKernelWorkGroupInfo by linking to _clGetKernelWorkGroupInfo@24
Warning: resolving _clGetMemObjectInfo by linking to _clGetMemObjectInfo@20
Warning: resolving _clGetPipeInfo by linking to _clGetPipeInfo@20
Warning: resolving _clGetPlatformIDs by linking to _clGetPlatformIDs@12
Warning: resolving _clGetPlatformInfo by linking to _clGetPlatformInfo@20
Warning: resolving _clGetProgramBuildInfo by linking to _clGetProgramBuildInfo@24
Warning: resolving _clGetProgramInfo by linking to _clGetProgramInfo@20
Warning: resolving _clGetSamplerInfo by linking to _clGetSamplerInfo@20
Warning: resolving _clGetSupportedImageFormats by linking to _clGetSupportedImageFormats@28
Warning: resolving _clLinkProgram by linking to _clLinkProgram@36
Warning: resolving _clReleaseCommandQueue by linking to _clReleaseCommandQueue@4
Warning: resolving _clReleaseContext by linking to _clReleaseContext@4
Warning: resolving _clReleaseDevice by linking to _clReleaseDevice@4
Warning: resolving _clReleaseEvent by linking to _clReleaseEvent@4
Warning: resolving _clReleaseKernel by linking to _clReleaseKernel@4
Warning: resolving _clReleaseMemObject by linking to _clReleaseMemObject@4
Warning: resolving _clReleaseProgram by linking to _clReleaseProgram@4
Warning: resolving _clReleaseSampler by linking to _clReleaseSampler@4
Warning: resolving _clRetainCommandQueue by linking to _clRetainCommandQueue@4
Warning: resolving _clRetainContext by linking to _clRetainContext@4
Warning: resolving _clRetainDevice by linking to _clRetainDevice@4
Warning: resolving _clRetainEvent by linking to _clRetainEvent@4
Warning: resolving _clRetainKernel by linking to _clRetainKernel@4
Warning: resolving _clRetainMemObject by linking to _clRetainMemObject@4
Warning: resolving _clRetainProgram by linking to _clRetainProgram@4
Warning: resolving _clRetainSampler by linking to _clRetainSampler@4
Warning: resolving _clSVMAlloc by linking to _clSVMAlloc@20
Warning: resolving _clSVMFree by linking to _clSVMFree@8
Warning: resolving _clSetCommandQueueProperty by linking to _clSetCommandQueueProperty@20
Warning: resolving _clSetDefaultDeviceCommandQueue by linking to _clSetDefaultDeviceCommandQueue@12
Warning: resolving _clSetEventCallback by linking to _clSetEventCallback@16
Warning: resolving _clSetKernelArg by linking to _clSetKernelArg@16
Warning: resolving _clSetKernelArgSVMPointer by linking to _clSetKernelArgSVMPointer@12
Warning: resolving _clSetKernelExecInfo by linking to _clSetKernelExecInfo@16
Warning: resolving _clSetMemObjectDestructorCallback by linking to _clSetMemObjectDestructorCallback@12
Warning: resolving _clSetUserEventStatus by linking to _clSetUserEventStatus@8
Warning: resolving _clUnloadCompiler by linking to _clUnloadCompiler@0
Warning: resolving _clUnloadPlatformCompiler by linking to _clUnloadPlatformCompiler@4
Warning: resolving _clWaitForEvents by linking to _clWaitForEvents@8
CMakeFiles/OpenCL.dir/objects.a(icd_windows.c.obj):icd_windows.c:(.text+0x143): undefined reference to `InitOnceExecuteOnce'
collect2: error: ld returned 1 exit status
CMakeFiles/OpenCL.dir/build.make:152: recipe for target 'bin/OpenCL.dll' failed
make[2]: *** [bin/OpenCL.dll] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/OpenCL.dir/all' failed
make[1]: *** [CMakeFiles/OpenCL.dir/all] Error 2
Makefile:94: recipe for target 'all' failed
make: *** [all] Error 2

@hydra3333
Copy link

@kepatil
Copy link
Contributor

kepatil commented Feb 27, 2018

I am not sure what fix is needed here. I haven't had the bandwidth yet to install MinGW and try building with it. I am happy to take patches from someone who knows what's going on with the build.

Marking this as enhancement for now.

Ruyk added a commit to Ruyk/OpenCL-ICD-Loader that referenced this issue Oct 5, 2018
@mmha
Copy link
Contributor

mmha commented May 3, 2019

I recently added w64-MinGW SEH gcc 4.9 to 8 to the AppVeyor CI matrix of my Conan package. For anyone interested in building for MinGW by themselves, there is a patch series that fixes compilation to x86_64-w64-mingw32 from both native hosts and Linux hosts (since the link above is broken).

For others who "just want the ICD loader": The compiled binaries are being pushed to Bintray. Either check the CI logs for the hash of the config that you are interested in or just download it via the Conan client.

In short, this is (mostly) an upstream MinGW problem. There are declarations missing in the headers. There was a minor problem wrt. cross builds from Linux in that Devpkey.h should have been named devpkey.h because of case sensitivity. As for the 32 bit builds failing to link, I believe this is because one of the MinGW 32 .def files got wrong ordinal numbers, but I can't verify this right now because I don't have access to a Windows machine.

I'm therefore unsure whether we should add those patches here. I'd rather fix MinGW upstream, but in the meantime this is obviously less than ideal for people depending on upstream ICD to work on MinGW.

@sirzooro
Copy link
Author

sirzooro commented May 8, 2019

@mmha is there is any MinGW issue for this? It would be nice if they could fix it, and start delivering compiled OpenCL ICD loader.

@bashbaug
Copy link
Contributor

bashbaug commented May 8, 2019

This issue was automatically closed when #64 was merged. Reopening.

@alucryd
Copy link

alucryd commented Jan 9, 2021

Also getting this, but interestingly it only affects the i686 build, x86_64 is fine.

ninja: Entering directory `build'
[1/33] Building RC object CMakeFiles/OpenCL.dir/loader/windows/OpenCL.rc.res
[2/33] Building C object test/log/CMakeFiles/IcdLog.dir/icd_test_log.c.obj
[3/33] Linking C static library test/log/libIcdLog.a
[4/33] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/cl_ext.c.obj
[5/33] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/cl_gl.c.obj
[6/33] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/cl.c.obj
[7/33] Building C object test/driver_stub/CMakeFiles/OpenCLDriverStub.dir/icd.c.obj
[8/33] Linking C static library test/driver_stub/libOpenCLDriverStub.a
[9/33] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/main.c.obj
[10/33] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_platforms.c.obj
[11/33] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_kernel.c.obj
[12/33] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/icd_test_match.c.obj
[13/33] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_program_objects.c.obj
[14/33] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_sampler_objects.c.obj
[15/33] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_cl_runtime.c.obj
[16/33] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_buffer_object.c.obj
[17/33] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/callbacks.c.obj
[18/33] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_clgl.c.obj
[19/33] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_create_calls.c.obj
[20/33] Building C object test/loader_test/CMakeFiles/icd_loader_test.dir/test_image_objects.c.obj
[21/33] Building C object CMakeFiles/OpenCL.dir/loader/icd.c.obj
[22/33] Building C object CMakeFiles/OpenCL.dir/loader/windows/icd_windows_hkr.c.obj
[23/33] Building C object CMakeFiles/OpenCL.dir/loader/windows/icd_windows_envvars.c.obj
[24/33] Building C object CMakeFiles/OpenCL.dir/loader/windows/icd_windows_dxgk.c.obj
[25/33] Building C object CMakeFiles/OpenCL.dir/loader/icd_dispatch.c.obj
[26/33] Building C object CMakeFiles/OpenCL.dir/loader/windows/icd_windows.c.obj
../loader/windows/icd_windows.c: In function ‘khrIcdOsVendorsEnumerate’:
../loader/windows/icd_windows.c:196:64: warning: passing argument 2 of ‘pCreateDXGIFactory’ from incompatible pointer type [-Wincompatible-pointer-types]
  196 |             HRESULT hr = pCreateDXGIFactory(&IID_IDXGIFactory, &pFactory);
      |                                                                ^~~~~~~~~
      |                                                                |
      |                                                                IDXGIFactory **
../loader/windows/icd_windows.c:196:64: note: expected ‘void **’ but argument is of type ‘IDXGIFactory **’
../loader/windows/icd_windows.c: In function ‘khrIcdOsVendorsEnumerateOnce’:
../loader/windows/icd_windows.c:251:5: warning: implicit declaration of function ‘InitOnceExecuteOnce’ [-Wimplicit-function-declaration]
  251 |     InitOnceExecuteOnce(&initialized, khrIcdOsVendorsEnumerate, NULL, NULL);
      |     ^~~~~~~~~~~~~~~~~~~
[27/33] Building CXX object CMakeFiles/OpenCL.dir/loader/windows/icd_windows_apppackage.cpp.obj
[28/33] Building C object test/layer/CMakeFiles/PrintLayer.dir/icd_print_layer.c.obj
[29/33] Building C object CMakeFiles/OpenCL.dir/loader/icd_dispatch_generated.c.obj
[30/33] Linking CXX static library libOpenCL.a
[31/33] Linking CXX executable test/loader_test/icd_loader_test.exe
FAILED: test/loader_test/icd_loader_test.exe 
: && /usr/bin/i686-w64-mingw32-g++ --sysroot=/usr/i686-w64-mingw32 -I/home/embybuilder/Buildbot/x86_windows/staging/include -O2 -g -pipe -Wall -fexceptions --param=ssp-buffer-size=4 -DWINVER=0x0601 -I/home/embybuilder/Buildbot/x86_windows/staging/include -O3 -DNDEBUG -static-libstdc++ -static-libgcc -static -L/home/embybuilder/Buildbot/x86_windows/staging/lib -Wl,-rpath-link=/home/embybuilder/Buildbot/x86_windows/staging/lib   -static-libstdc++ -static-libgcc -static test/loader_test/CMakeFiles/icd_loader_test.dir/test_kernel.c.obj test/loader_test/CMakeFiles/icd_loader_test.dir/main.c.obj test/loader_test/CMakeFiles/icd_loader_test.dir/test_platforms.c.obj test/loader_test/CMakeFiles/icd_loader_test.dir/icd_test_match.c.obj test/loader_test/CMakeFiles/icd_loader_test.dir/test_program_objects.c.obj test/loader_test/CMakeFiles/icd_loader_test.dir/test_sampler_objects.c.obj test/loader_test/CMakeFiles/icd_loader_test.dir/test_buffer_object.c.obj test/loader_test/CMakeFiles/icd_loader_test.dir/test_cl_runtime.c.obj test/loader_test/CMakeFiles/icd_loader_test.dir/callbacks.c.obj test/loader_test/CMakeFiles/icd_loader_test.dir/test_create_calls.c.obj test/loader_test/CMakeFiles/icd_loader_test.dir/test_clgl.c.obj test/loader_test/CMakeFiles/icd_loader_test.dir/test_image_objects.c.obj -o test/loader_test/icd_loader_test.exe -Wl,--out-implib,test/loader_test/libicd_loader_test.dll.a -Wl,--major-image-version,0,--minor-image-version,0  libOpenCL.a  test/log/libIcdLog.a  -lcfgmgr32  -lruntimeobject  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 && :
/usr/lib/gcc/i686-w64-mingw32/10.2.0/../../../../i686-w64-mingw32/bin/ld: libOpenCL.a(icd_windows.c.obj): in function `khrIcdOsVendorsEnumerateOnce':
/home/embybuilder/Buildbot/x86_windows/libopencl_icd_loader-x86_windows/build/OpenCL-ICD-Loader-2020.12.18/build/../loader/windows/icd_windows.c:251: undefined reference to `InitOnceExecuteOnce'
collect2: error: ld returned 1 exit status
[32/33] Building C object test/layer/CMakeFiles/PrintLayer.dir/icd_print_layer_generated.c.obj
ninja: build stopped: subcommand failed.

Any idea why?

@bashbaug
Copy link
Contributor

bashbaug commented Oct 8, 2022

Hello, just FYI we've been making a lot of progress getting the OpenCL ICD loader building on MinGW, please follow the discussion here: KhronosGroup/OpenCL-SDK#58

PR #186 has the latest changes and appears to build correctly for both 64-bit and 32- bit builds (with OpenCLon12 disabled) but I'm still getting some linker warnings. I've yet to determine if these are something that needs to be fixed or not.

Hopefully we're getting close to fixing this (very old) issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants