I was trying to compile a simple OpenCL source with clang:
extern int foo(int, int);
I got an error msg:
clang.exe : tmp.cl:1:1: error: OpenCL does not support the ‘extern’ storage class specifier
OpenCL spec 1.2 says:
The typedef
, extern
, and static
storage-class specifiers are supported.
Is this a bug? Or did I miss anything? Thanks.
Sam
You need to set the cl-std value to 1.2. By default its 1.1.
-Tanya
It’d be useful to mention this in the diagnostic. How about
‘extern’ storage class specifier is an OpenCL 1.2 extension
… and downgrading this from an Error to an ExtWarn?
Thanks. I got it.
For those who are curious, the command line is like
clang -cc1 -cl-std=CL1.2 tmp.cl
Sam
It’d be useful to mention this in the diagnostic. How about
‘extern’ storage class specifier is an OpenCL 1.2 extension
Sure. I can change this.
… and downgrading this from an Error to an ExtWarn?
I wouldn’t mind this being a warning instead. Technically the CL spec says its not supported, but I don’t think it says it MUST be an error.
-Tanya
Thanks. I got it.
For those who are curious, the command line is like
clang -cc1 -cl-std=CL1.2 tmp.cl
Sam
It seems it isn’t, but why not -std? We already use this to refer to both the C and C++ standards.
Jordan
I totally agree with you, but I did not write the OpenCL Spec and I have no idea why they decided they needed another std option.
Its not a high priority to me to change it to be a driver level option, but someone else might complain (and they can fix it).
-Tanya
I’m not familiar with the OpenCL part of the compiler, but I’m pretty sure you’re not supposed to invoke -cc1 mode directly, just like the C compiler. The right way to do this is with the usual -std option:
clang -std=cl1.2 tmp.cl
This ensures that all the other driver-specified options get handled appropriately.
I agree that you shouldn’t use -cc1, but -cl-std= should be a driver level option. If not, then it should be fixed.
It seems it isn’t, but why not -std? We already use this to refer to both the C and C++ standards.
I totally agree with you, but I did not write the OpenCL Spec and I have no idea why they decided they needed another std option.
Ah, I didn’t realize the command-line interface was specified by the standard. My bad.
Its not a high priority to me to change it to be a driver level option, but someone else might complain (and they can fix it).
Since we are unlikely to have a separate openclc driver tool anytime soon, this does seem like the right way to go.
Thanks for the explanation,
Jordan