SYCL_EXTERNAL definition is inconsistent.
- Dominant language
- LLVM
- Stars
- 1.5k
- Forks
- 854
- Avg merge
- 3d 17h
- Merged PRs (30d)
- 137
Description
### Describe the bug
Here is an example of the code to demonstrate the inconsistency:
```console
$ cat example.cpp
SYCL_EXTERNAL int mul(int x) {
return x * 42;
}
$ clang++ -fsycl-device-only example.cpp
$ clang++ -fsycl-host-only example.cpp
example.cpp:1:1: error: unknown type name 'SYCL_EXTERNAL'
1 | SYCL_EXTERNAL int mul(int x) {
| ^
1 error generated.
$ clang++ -fsycl example.cpp
example.cpp:1:1: error: unknown type name 'SYCL_EXTERNAL'
1 | SYCL_EXTERNAL int mul(int x) {
| ^
1 error generated.
```
Device compiler defines `SYCL_EXTERNAL` macro, whereas host compiler does not.
To define the macro on the host, `defines_elementary.hpp` header must be included. https://github.com/intel/llvm/blob/sycl/sycl/include/sycl/detail/defines_elementary.hpp#L39
I found this issue while trying to create a simple library of C++ functions available from the SYCL kernels. My library code does not use any SYCL data structures or any symbols. It uses only `SYCL_EXTERNAL` macro.
I think the implementation should define this macro consistently either using the compiler or using the library, but not both.
@gmlueck, @tahonermann, @Fznamznon, what do you think?
My personal preference is to use the compiler to define `SYCL_EXTERNAL`.
### To reproduce
_No response_
### Environment
_No response_
### Additional context
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.