-
Notifications
You must be signed in to change notification settings - Fork 798
[SYCL RTC] Use in-memory libcxx/libc headers for SPIR-V targets #20502
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
base: sycl
Are you sure you want to change the base?
Changes from 4 commits
ea115c6
d7a20b3
02fca66
dab7317
0821704
ed22872
4b85687
649561a
99affbb
f7a3ed5
da5ee80
6a6770c
fab3b51
d76c4df
3729836
5f88bca
1067a08
4e0b4ba
8a39ac6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -825,6 +825,8 @@ foreach(target IN LISTS all_install_header_targets) | |
| endforeach() | ||
|
|
||
| if(LLVM_LIBC_FULL_BUILD) | ||
| add_custom_target(generate-libc-headers | ||
| DEPENDS libc-headers) | ||
|
Comment on lines
+862
to
+863
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's commit libc and libcxx changes to https://github.com/llvm/llvm-project/ as well. It would be ideal if we merge them to https://github.com/llvm/llvm-project/ before merging this PR to gather the feedback from the LLVM's libc and libcxx communities.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have an in-tree use-case to make upstream PR.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Could you please check with libc/libcxx maintainers if such use case is required?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't feel comfortable asking to contribute something that I myself believe shouldn't go upstream. For bugfixes I intended to do so, only to find later that those were fixed in the trunk, so it's not that I refuse to work with them.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bader , ping
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
@aelovikov-intel, do you have a question for me?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, I have an answer to your previous question. I don't think those changes can/should be upstreamed. If it's your stance that somebody has to go to community and get either an approval or rejection there before moving this PR forward, then we need to find another owner for this task. |
||
| add_custom_target(install-libc-headers | ||
| DEPENDS libc-headers | ||
| COMMAND "${CMAKE_COMMAND}" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -246,7 +246,7 @@ functions: | |
| - type: const wchar_t **__restrict | ||
| - type: size_t | ||
| - type: size_t | ||
| - type: mbstate_t | ||
| - type: mbstate_t *__restrict | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This and the one below are part of the upstream llvm/llvm-project#164666. |
||
| - name: wcsrtombs | ||
| standards: | ||
| - stdc | ||
|
|
@@ -255,7 +255,7 @@ functions: | |
| - type: char *__restrict | ||
| - type: const wchar_t **__restrict | ||
| - type: size_t | ||
| - type: mbstate_t | ||
| - type: mbstate_t *__restrict | ||
| - name: wcrtomb | ||
| standards: | ||
| - stdc | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| if(EXISTS "${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/${LIBC_TARGET_ARCHITECTURE}/entrypoints.txt") | ||
| include("${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/${LIBC_TARGET_ARCHITECTURE}/entrypoints.txt") | ||
| else() | ||
| include("${LIBC_SOURCE_DIR}/config/${LIBC_TARGET_OS}/entrypoints.txt") | ||
| endif() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| include("${LIBC_SOURCE_DIR}/config/linux/x86_64/headers.txt") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| _LIBCPP_BEGIN_NAMESPACE_STD | ||
|
|
||
| using __libcpp_timespec_t = int; | ||
|
|
||
| // | ||
| // Mutex | ||
| // | ||
| using __libcpp_mutex_t = int; | ||
| #define _LIBCPP_MUTEX_INITIALIZER 0 | ||
|
|
||
| using __libcpp_recursive_mutex_t = int; | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have a feeling I asked this before on another PR but are these files basically to support stuff not supported by LLVM's libc/cxx?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The short answer something didn't work when I used libcxx in (default) mode that uses pthreads to implement |
||
| int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t*); | ||
| _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t*); | ||
| _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t*); | ||
| _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t*); | ||
| int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t*); | ||
|
|
||
| _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_lock(__libcpp_mutex_t*); | ||
| _LIBCPP_NO_THREAD_SAFETY_ANALYSIS bool __libcpp_mutex_trylock(__libcpp_mutex_t*); | ||
| _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_mutex_unlock(__libcpp_mutex_t*); | ||
| int __libcpp_mutex_destroy(__libcpp_mutex_t*); | ||
|
|
||
| // | ||
| // Condition Variable | ||
| // | ||
| using __libcpp_condvar_t = int; | ||
| #define _LIBCPP_CONDVAR_INITIALIZER 0 | ||
|
|
||
| int __libcpp_condvar_signal(__libcpp_condvar_t*); | ||
| int __libcpp_condvar_broadcast(__libcpp_condvar_t*); | ||
| _LIBCPP_NO_THREAD_SAFETY_ANALYSIS int __libcpp_condvar_wait(__libcpp_condvar_t*, __libcpp_mutex_t*); | ||
| _LIBCPP_NO_THREAD_SAFETY_ANALYSIS | ||
| int __libcpp_condvar_timedwait(__libcpp_condvar_t*, __libcpp_mutex_t*, __libcpp_timespec_t*); | ||
| int __libcpp_condvar_destroy(__libcpp_condvar_t*); | ||
|
|
||
| // | ||
| // Execute once | ||
| // | ||
| using __libcpp_exec_once_flag = int; | ||
| #define _LIBCPP_EXEC_ONCE_INITIALIZER 0 | ||
|
|
||
| int __libcpp_execute_once(__libcpp_exec_once_flag*, void (*__init_routine)()); | ||
|
|
||
| // | ||
| // Thread id | ||
| // | ||
| using __libcpp_thread_id = int; | ||
|
|
||
| bool __libcpp_thread_id_equal(__libcpp_thread_id, __libcpp_thread_id); | ||
| bool __libcpp_thread_id_less(__libcpp_thread_id, __libcpp_thread_id); | ||
|
|
||
| // | ||
| // Thread | ||
| // | ||
| #define _LIBCPP_NULL_THREAD 0 | ||
| using __libcpp_thread_t = int; | ||
|
|
||
| bool __libcpp_thread_isnull(const __libcpp_thread_t*); | ||
| int __libcpp_thread_create(__libcpp_thread_t*, void* (*__func)(void*), void* __arg); | ||
| __libcpp_thread_id __libcpp_thread_get_current_id(); | ||
| __libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t*); | ||
| int __libcpp_thread_join(__libcpp_thread_t*); | ||
| int __libcpp_thread_detach(__libcpp_thread_t*); | ||
| void __libcpp_thread_yield(); | ||
| void __libcpp_thread_sleep_for(const chrono::nanoseconds&); | ||
|
|
||
| // | ||
| // Thread local storage | ||
| // | ||
| #define _LIBCPP_TLS_DESTRUCTOR_CC 0 | ||
| using __libcpp_tls_key = int; | ||
|
|
||
| int __libcpp_tls_create(__libcpp_tls_key*, void (*__at_exit)(void*)); | ||
| void* __libcpp_tls_get(__libcpp_tls_key); | ||
| int __libcpp_tls_set(__libcpp_tls_key, void*); | ||
|
|
||
| _LIBCPP_END_NAMESPACE_STD | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,11 +32,11 @@ def main(): | |
| const resource_file ToolchainFiles[] = {""" | ||
| ) | ||
|
|
||
| def process_file(file_path): | ||
| def process_file(file_path, relative_to): | ||
| out.write( | ||
| f""" | ||
| {{ | ||
| {{"{args.prefix}{os.path.relpath(file_path, toolchain_dir).replace(os.sep, "/")}"}} , | ||
| {{"{args.prefix}{os.path.relpath(file_path, relative_to).replace(os.sep, "/")}"}} , | ||
| []() {{ | ||
| static const char data[] = {{ | ||
| #embed "{file_path}" if_empty(0) | ||
|
|
@@ -50,9 +50,17 @@ def process_dir(dir): | |
| for root, _, files in os.walk(dir): | ||
| for file in files: | ||
| file_path = os.path.join(root, file) | ||
| process_file(file_path) | ||
| process_file(file_path, dir) | ||
|
|
||
| process_dir(args.toolchain_dir) | ||
| process_dir( | ||
| os.path.realpath( | ||
| os.path.join( | ||
| os.path.dirname(os.path.realpath(__file__)), | ||
| "../lib/resource-includes/", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do we get from using the relative path
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think
so my recollection is probably correct here. |
||
| ) | ||
| ) | ||
| ) | ||
|
|
||
| out.write( | ||
| f""" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.