Skip to content

SYCL_EXTERNAL definition is inconsistent. #20541

@bader

Description

@bader

Describe the bug

Here is an example of the code to demonstrate the inconsistency:

$ 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions