-
Notifications
You must be signed in to change notification settings - Fork 796
[SYCL-RTC] Distribute SYCL toolchain header files inside libsycl-jit.so #19924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
aelovikov-intel
merged 15 commits into
intel:sycl
from
aelovikov-intel:sycl-jit-resource
Sep 4, 2025
Merged
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c4c086b
[SYCL-RTC] Use `ToolInvocation` directly instead of via `ClangTool`
aelovikov-intel 800c427
[SYCL-RTC] Distribute SYCL toolchain header files inside libsycl-jit.so
aelovikov-intel 961362b
CMake changes
aelovikov-intel 7ef5c4a
Merge remote-tracking branch 'origin/sycl' into HEAD
aelovikov-intel 51f3828
Another attempt at CMake
aelovikov-intel da51f6b
One more try
aelovikov-intel 8e0c900
Another one
aelovikov-intel 4cb6d54
clang-cl isn't a separate target, use just clang as a dep
aelovikov-intel f2e0e53
add libclc
aelovikov-intel 49255bb
Fix Win path to virtual toolchain root
aelovikov-intel 268c4b4
Debug
aelovikov-intel 422a2ac
Try to fix AMD/NVIDIA targets
aelovikov-intel 7e1ac0a
Merge remote-tracking branch 'origin/sycl' into HEAD
aelovikov-intel c82168c
Binary files can contain NULL
aelovikov-intel 62dc670
More polishing
aelovikov-intel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # We use C23/C++26's `#embed` to implement this resource creation, and "host" | ||
| # CXX compiler might not have support for it. As such, use freshly built | ||
| # `clang++` instead. That, in turn, requires dedicated directory for CMake to | ||
| # allow to override `CMAKE_CXX_COMPILER`. | ||
|
|
||
|
|
||
| set(SYCL_JIT_RESOURCE_CPP "${CMAKE_CURRENT_BINARY_DIR}/resource.cpp") | ||
| add_custom_command( | ||
| OUTPUT ${SYCL_JIT_RESOURCE_CPP} | ||
| COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate.py --toolchain-dir ${CMAKE_BINARY_DIR} --output ${SYCL_JIT_RESOURCE_CPP} --prefix /sycl-jit-toolchain/ | ||
| WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" | ||
| DEPENDS sycl-headers ${CMAKE_CURRENT_SOURCE_DIR}/generate.py | ||
| ) | ||
|
|
||
| set_source_files_properties(${SYCL_JIT_RESOURCE_CPP} PROPERTIES | ||
| COMPILE_FLAGS -Wno-c23-extensions | ||
| ) | ||
|
|
||
| add_llvm_library(sycl-jit-resource | ||
| ${SYCL_JIT_RESOURCE_CPP} | ||
| OBJECT | ||
| DEPENDS | ||
| clang | ||
| # TODO: libdevice | ||
| ) | ||
|
|
||
| set(CMAKE_CXX_COMPILER ${CMAKE_BINARY_DIR}/bin/clang++) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import os | ||
| import argparse | ||
|
|
||
|
|
||
| def main(): | ||
| parser = argparse.ArgumentParser( | ||
| description="Generate SYCL Headers Resource C++ file" | ||
| ) | ||
| parser.add_argument("-o", "--output", type=str, required=True, help="Output file") | ||
| parser.add_argument( | ||
| "-i", | ||
| "--toolchain-dir", | ||
| type=str, | ||
| required=True, | ||
| help="Path to toolchain root directory", | ||
| ) | ||
| parser.add_argument( | ||
| "--prefix", type=str, required=True, help="Prefix for file locations" | ||
| ) | ||
| args = parser.parse_args() | ||
|
|
||
| # abspath also strips trailing "/" | ||
| toolchain_dir = os.path.abspath(args.toolchain_dir) | ||
|
|
||
| with open(args.output, "w") as out: | ||
| out.write( | ||
| """ | ||
| #include <utility> | ||
| #include <string_view> | ||
|
|
||
| namespace jit_compiler { | ||
| extern const std::pair<std::string_view, std::string_view> ToolchainFiles[]; | ||
| const std::pair<std::string_view, std::string_view> ToolchainFiles[] = {""" | ||
| ) | ||
|
|
||
| def process_dir(dir): | ||
| for root, _, files in os.walk(dir): | ||
| for file in files: | ||
| file_path = os.path.join(root, file) | ||
| out.write( | ||
| f""" | ||
| {{ | ||
| {{"{args.prefix}{os.path.relpath(file_path, toolchain_dir)}"}} , | ||
| []() {{ | ||
| static const char data[] = {{ | ||
| #embed "{file_path}" | ||
| , 0}}; | ||
| return std::string_view(data); | ||
| }}() | ||
| }},""" | ||
| ) | ||
|
|
||
| process_dir(os.path.join(args.toolchain_dir, "include/")) | ||
| process_dir(os.path.join(args.toolchain_dir, "lib/clang/")) | ||
|
|
||
| out.write( | ||
| f""" | ||
| }}; | ||
|
|
||
| extern size_t NumToolchainFiles; | ||
| size_t NumToolchainFiles = std::size(ToolchainFiles); | ||
| extern std::string_view ToolchainPrefix; | ||
| std::string_view ToolchainPrefix = "{args.prefix}"; | ||
| }} // namespace jit_compiler | ||
| """ | ||
| ) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not enough (see Win CI failure), but I don't know if we have some precedents to doing something similar. Any pointers would be greatly appreciated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could try random combinations of
PARENT_SCOPECACHEandFORCEThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, maybe try setting the C compiler too because cl is both C and C++?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also doing it this way is unsupported, it seems if we make this a subproject then it will reliably work