[cfe-dev] [RFC] New file extension for compiling C++ for OpenCL sources

Andrzej Warzynski via cfe-dev cfe-dev at lists.llvm.org
Thu Feb 18 04:28:19 PST 2021


I think that there are two things. First, the file extensions on their 
own. I think that it's fine to introduce e.g. .clcxx/.clcpp and make 
them map to e.g. TY_CL. This won't change much from the perspective of 
the driver, but end-users could start using and getting used to it. And 
adoption in IDEs/CMake could start as well.

The other thing is internal representation in clangDriver. Do we need to 
introduce TY_CLXX on top of TY_CL? I get the impression that TY_CL 
should be fine for now. There is TY_C and TY_CXX and you will find many 
places in the driver where the input type (e.g. TY_C vs TY_CXX vs 
TY_Fortran) affects the logic (e.g. which headers/libs/search-paths to 
include).

For Fortran, extensions are used to differentiate between:
   * fixed-form, free-form
   * pre-processed, not-pre-processed
   * various language standards
(personally I find this very confusing). So the extensions matters a lot 
and affects various stages of the compilation (e.g. preprocessing, 
parsing & sema). Some of the resulting logic lives in clangDriver, some 
of it in the new Flang frontend driver. Do you think that we will need 
such logic to differentiate between C and C++ OpenCL source files?

I get the impression that in order to support what's currently required, 
we don't need TY_CLXX just yet. But I'm also an OpenCL outsider and I 
might be missing something here :)

-Andrzej


On 18/02/2021 11:40, Anastasia Stulova via cfe-dev wrote:
> Good point - another similar example would be the syntax highlight
> in the IDEs or editors that frequently use the file extensions too.
> 
> ------------------------------------------------------------------------
> *From:* cfe-dev <cfe-dev-bounces at lists.llvm.org> on behalf of Stephen 
> Kelly via cfe-dev <cfe-dev at lists.llvm.org>
> *Sent:* 17 February 2021 22:12
> *To:* cfe-dev at lists.llvm.org <cfe-dev at lists.llvm.org>
> *Subject:* Re: [cfe-dev] [RFC] New file extension for compiling C++ for 
> OpenCL sources
> 
> On 17/02/2021 16:36, Arthur O'Dwyer via cfe-dev wrote:
>> FWIW, as a complete outsider, as a complete non-user of OpenCL (but a 
>> heavy user of C++), I don't see why a new filename extension is a good 
>> thing. 
> 
> 
> I'm also an opencl outsider.
> 
> However, if opencl files are to be detected by a buildsystem like (but
> not limited to) cmake, then a file extension is a good thing. Consider
> this cmake code:
> 
> cmake_minimum_required(VERSION 3.10)
> 
> project(testproj C CXX OBJCXX OBJC)
> 
> add_library(test
>  ���� test.cpp
>  ���� test.c
>  ���� test.m
>  ���� test.mm
> )
> 
> 
> CMake detects the source-language of each source file and uses the
> appropriate driver and language compile option for each one.
> 
> With a file extension for opencl, CMake could use the appropriate
> driver/option for that language too. Without a distinct file extension
> for it, the user would have to tell cmake what the language is, which is
> inconvenient for the user.
> 
> Thanks,
> 
> Stephen.
> 
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev 
> <https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev>
> 
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
> 


More information about the cfe-dev mailing list