KhronosGroup / KhronosGroup/OpenCL-Headers
Error when compiling for MinGW from Cygwin with gcc 7.4.0
- Dominant language
- C
- Stars
- 766
- Forks
- 273
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 3
Description
I tried to compile some code with latest headers (from HEAD) using x86_64-w64-mingw32-g++ 7.4.0 crosscompiler shipped with Cygwin. I got following errors:
```
In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/intrin.h:41:0,
from ./CL/cl_platform.h:380,
from ./CL/cl.h:35,
from ./CL/opencl.h:47,
from CL/cl.hpp:170,
from RakeSearchOpenCL.h:6,
from main.cpp:19:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/psdk_inc/intrin-impl.h:1848:42: error: macro "__cpuid" requires 5 arguments, but only 2 given
void __cpuid(int CPUInfo[4], int InfoType);
^
/usr/x86_64-w64-mingw32/sys-root/mingw/include/psdk_inc/intrin-impl.h:1851:42: error: macro "__cpuid" requires 5 arguments, but only 2 given
void __cpuid(int CPUInfo[4], int InfoType) {
^
In file included from ./CL/cl_platform.h:380:0,
from ./CL/cl.h:35,
from ./CL/opencl.h:47,
from CL/cl.hpp:170,
from RakeSearchOpenCL.h:6,
from main.cpp:19:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/intrin.h:1117:44: error: macro "__cpuid" requires 5 arguments, but only 2 given
__MACHINEI(void __cpuid(int a[4],int b))
^
In file included from /usr/x86_64-w64-mingw32/sys-root/mingw/include/intrin.h:41:0,
from ./CL/cl_platform.h:380,
from ./CL/cl.h:35,
from ./CL/opencl.h:47,
from CL/cl.hpp:170,
from RakeSearchOpenCL.h:6,
from main.cpp:19:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/psdk_inc/intrin-impl.h:1848:6: error: variable or field ‘__cpuid’ declared void
void __cpuid(int CPUInfo[4], int InfoType);
^~~~~~~
/usr/x86_64-w64-mingw32/sys-root/mingw/include/psdk_inc/intrin-impl.h:1851:6: error: variable or field ‘__cpuid’ declared void
void __cpuid(int CPUInfo[4], int InfoType) {
^~~~~~~
/usr/x86_64-w64-mingw32/sys-root/mingw/include/psdk_inc/intrin-impl.h:1852:4: error: expected primary-expression before ‘__asm__’
__asm__ __volatile__ (
^~~~~~~
/usr/x86_64-w64-mingw32/sys-root/mingw/include/psdk_inc/intrin-impl.h:1852:4: error: expected ‘}’ before ‘__asm__’
In file included from ./CL/cl_platform.h:380:0,
from ./CL/cl.h:35,
from ./CL/opencl.h:47,
from CL/cl.hpp:170,
from RakeSearchOpenCL.h:6,
from main.cpp:19:
/usr/x86_64-w64-mingw32/sys-root/mingw/include/intrin.h:1117:5: error: variable or field ‘__cpuid’ declared void
__MACHINEI(void __cpuid(int a[4],int b))
^
In file included from CL/cl.hpp:170:0,
from RakeSearchOpenCL.h:6,
from main.cpp:19:
./CL/opencl.h:55:1: error: expected declaration before ‘}’ token
}
```
Problem is caused by following part of code in cl_platform.h
```c
#if defined( __MINGW64__ )
#include
#else
#include
#endif
```
There are 3 similar code clocks there. When I commented out parts for `__MINGW64__ `, code compiled without errors.
I use SSE/AVX intrinsics for more than 2 years, and during that time I always included headers as suggested in Intel Intrinsics Guide. Looks that MinGW shipped with Cygwin has correct headers and does not need any workarounds. If you need them for some other reason, some extra checks will be needed here.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in CL/cl_platform.h at the three __MINGW64__ conditional blocks that include intrin.h, and reproduce the failure with the x86_64-w64-mingw32-g++ 7.4.0 Cygwin cross-compiler. Compare the behavior after removing those inclusions and verify that the headers compile without the __cpuid macro errors while retaining the required SSE/AVX support.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100