[cfe-dev] Problem with standard headers in single source programming models
Gainullin, Artur via cfe-dev
cfe-dev at lists.llvm.org
Thu Apr 18 14:31:34 PDT 2019
In single source programming models (like CUDA, OpenMP) there are both "host" and "device" code in the same source file/translation unit. This causes some issues with system headers and standard library headers when compilation is performed for device target. Reason is that even when compiling for the device, host code must be semantically analyzable.
For example, in case of compilation to 'spir' target with -std=gnu++11 flag we will get an error:
error: __float128 is not supported on this target
Also, in headers there could be other things like inline asm, intrinsics not lowerable in device.
Since the problem is not new, my question is about the possible solutions of this problem.
I tried to look into the approach currently implemented in clang for single source programming models.
As far as I understood:
1. Host headers are used for device compilation.
2. -aux-triple for host device and triple for target device are used to enable defines and builtins for both targets unconditionally.
3. Deferred diagnostics approach is used to emit diagnostics only when we know that something unsupported is used on device.
4. For unsupported types we still emit these types by emit errors only for operations with such types.
Is this an approach which is used in clang to solve the problem with headers in single source programming languages?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev