Along the way, couple of additional things have been done:
- Move ErrnoSetterMatcher.h to test/UnitTest as all other matchers live there now.
- ErrnoSetterMatcher ignores matching errno on GPUs.
Paths
| Differential D151129
[libc] Make ErrnoSetterMatcher handle logging floating point values. ClosedPublic Authored by sivachandra on May 22 2023, 11:29 AM.
Details Summary Along the way, couple of additional things have been done:
Diff Detail
Event TimelineHerald added projects: Restricted Project, Restricted Project. · View Herald TranscriptMay 22 2023, 11:29 AM Comment Actions Applied locally, here's some errors while building, In file included from /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/error_to_string.cpp:10: In file included from /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/platform_errors.h:15: In file included from /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/tables/minimal_platform_errors.h:12: /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/tables/stdc_errors.h:22:16: error: use of undeclared identifier 'EILSEQ' MsgMapping(EILSEQ, "Invalid or incomplete multibyte or wide character"), ^ In file included from /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/error_to_string.cpp:10: In file included from /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/platform_errors.h:15: /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/tables/minimal_platform_errors.h:16:23: error: constexpr variable 'PLATFORM_ERRORS' must be initialized by a constant expression inline constexpr auto PLATFORM_ERRORS = STDC_ERRORS; ^ ~~~~~~~~~~~ /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/tables/minimal_platform_errors.h:16:41: note: initializer of 'STDC_ERRORS' is unknown inline constexpr auto PLATFORM_ERRORS = STDC_ERRORS; ^ /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/tables/minimal_platform_errors.h:16:41: note: in call to 'array(STDC_ERRORS)' /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/tables/stdc_errors.h:18:36: note: declared here inline constexpr const MsgTable<4> STDC_ERRORS = { ^ /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/error_to_string.cpp:36:18: error: constexpr variable 'TOTAL_STR_LEN' must be initialized by a constant expression constexpr size_t TOTAL_STR_LEN = total_str_len(PLATFORM_ERRORS); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/message_mapper.h:35:32: note: initializer of 'PLATFORM_ERRORS' is not a constant expression for (size_t i = 0; i < table.size(); ++i) { ^ /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/error_to_string.cpp:36:34: note: in call to 'total_str_len(PLATFORM_ERRORS)' constexpr size_t TOTAL_STR_LEN = total_str_len(PLATFORM_ERRORS); ^ /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/tables/minimal_platform_errors.h:16:23: note: declared here inline constexpr auto PLATFORM_ERRORS = STDC_ERRORS; ^ /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/error_to_string.cpp:44:18: error: constexpr variable 'ERR_ARRAY_SIZE' must be initialized by a constant expression constexpr size_t ERR_ARRAY_SIZE = max_key_val(PLATFORM_ERRORS) + 1; ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/message_mapper.h:44:32: note: initializer of 'PLATFORM_ERRORS' is not a constant expression for (size_t i = 0; i < table.size(); ++i) { ^ /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/error_to_string.cpp:44:35: note: in call to 'max_key_val(PLATFORM_ERRORS)' constexpr size_t ERR_ARRAY_SIZE = max_key_val(PLATFORM_ERRORS) + 1; ^ /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/tables/minimal_platform_errors.h:16:23: note: declared here inline constexpr auto PLATFORM_ERRORS = STDC_ERRORS; ^ /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/error_to_string.cpp:46:25: error: non-type template argument is not a constant expression constexpr MessageMapper<ERR_ARRAY_SIZE, TOTAL_STR_LEN> ^~~~~~~~~~~~~~ /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/error_to_string.cpp:46:25: note: initializer of 'ERR_ARRAY_SIZE' is not a constant expression /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/error_to_string.cpp:44:18: note: declared here constexpr size_t ERR_ARRAY_SIZE = max_key_val(PLATFORM_ERRORS) + 1; ^ 5 errors generated. Comment Actions New failure due to thread_local /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/error_to_string.cpp:34:1: error: thread-local storage is not supported for the current target thread_local char error_buffer[ERR_BUFFER_SIZE]; ^ Comment Actions I think all of those errors have a single root cause that EILSEQ was missing from the list of generic error numbers. I have added it now. Can you give it another try? Comment Actions
Yes, I think we just need to make the thread_local error buffer a regular integer on platforms without errno. (Same reason we can't support it in the first place). Comment Actions
Few things:
sivachandra retitled this revision from [libc] Make ErrnoSetterMatcher ignore matching errno on GPU. to [libc] Make ErrnoSetterMatcher handle logging floating point values..May 25 2023, 10:50 AM Comment Actions
Okay, this prevented running the existing tests on the GPU so it should at least be worked around for this to land.
That's the simplest solution right now. The GPU does have thread local memory, it comes from the stack. It's very limited but it does exist. The problem is that this stack variable would require each executing kernel on the GPU to initialize the variables. There's basically a few ways to get around this if we really wanted to support it.
I'm not sure, there hasn't exactly been an outcry from the GPU community for errno support. Speaking frankly most users would only *really* care about malloc, free, and `printf. Most everything else can be seen as supplemental. Comment Actions
How is the latest version of this patch?
I will leave it up to you to drive this discussion in the appropriate forums. Even things like, should there be an errno.h in the GPU libc with relevant error macros exposed? For the current work in the libc around this, I only view them as "workarounds" which will help make progress with making more of the libc available on the GPUs while the fundamental questions are being sorted out. Comment Actions Did you update the patch? It's still got the same error: /home/jhuber/Documents/llvm/llvm-project/libc/src/__support/StringUtil/error_to_string.cpp:34:1: error: thread-local storage is not supported for the current target thread_local char error_buffer[ERR_BUFFER_SIZE]; ^ 1 error generated. This revision is now accepted and ready to land.May 25 2023, 1:19 PM Closed by commit rG4f1fe19df385: [libc] Make ErrnoSetterMatcher handle logging floating point values. (authored by sivachandra). · Explain WhyMay 25 2023, 11:25 PM This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 525763 libc/cmake/modules/LLVMLibCTestRules.cmake
libc/include/llvm-libc-macros/generic-error-number-macros.h
libc/test/CMakeLists.txt
libc/test/UnitTest/CMakeLists.txt
libc/test/UnitTest/ErrnoSetterMatcher.h
libc/test/src/fcntl/creat_test.cpp
libc/test/src/fcntl/openat_test.cpp
libc/test/src/sched/affinity_test.cpp
libc/test/src/sched/cpu_count_test.cpp
libc/test/src/signal/kill_test.cpp
libc/test/src/signal/sigaction_test.cpp
libc/test/src/signal/sigaddset_test.cpp
libc/test/src/signal/sigaltstack_test.cpp
libc/test/src/signal/sigdelset_test.cpp
libc/test/src/signal/sigfillset_test.cpp
libc/test/src/signal/signal_test.cpp
libc/test/src/signal/sigprocmask_test.cpp
libc/test/src/stdio/remove_test.cpp
libc/test/src/stdlib/CMakeLists.txt
libc/test/src/stdlib/atof_test.cpp
libc/test/src/stdlib/strtod_test.cpp
libc/test/src/sys/mman/linux/madvise_test.cpp
libc/test/src/sys/mman/linux/mmap_test.cpp
libc/test/src/sys/mman/linux/mprotect_test.cpp
libc/test/src/sys/mman/linux/posix_madvise_test.cpp
libc/test/src/sys/random/linux/getrandom_test.cpp
libc/test/src/sys/resource/getrlimit_setrlimit_test.cpp
libc/test/src/sys/select/select_failure_test.cpp
libc/test/src/sys/sendfile/sendfile_test.cpp
libc/test/src/sys/stat/chmod_test.cpp
libc/test/src/sys/stat/fchmod_test.cpp
libc/test/src/sys/stat/fchmodat_test.cpp
libc/test/src/sys/stat/fstat_test.cpp
libc/test/src/sys/stat/lstat_test.cpp
libc/test/src/sys/stat/mkdirat_test.cpp
libc/test/src/sys/stat/stat_test.cpp
libc/test/src/sys/utsname/uname_test.cpp
libc/test/src/sys/wait/wait4_test.cpp
libc/test/src/sys/wait/waitpid_test.cpp
libc/test/src/termios/termios_test.cpp
libc/test/src/time/difftime_test.cpp
libc/test/src/time/gettimeofday_test.cpp
libc/test/src/time/gmtime_test.cpp
libc/test/src/time/mktime_test.cpp
libc/test/src/time/nanosleep_test.cpp
libc/test/src/unistd/access_test.cpp
libc/test/src/unistd/chdir_test.cpp
libc/test/src/unistd/dup2_test.cpp
libc/test/src/unistd/dup3_test.cpp
libc/test/src/unistd/dup_test.cpp
libc/test/src/unistd/fchdir_test.cpp
libc/test/src/unistd/ftruncate_test.cpp
libc/test/src/unistd/isatty_test.cpp
libc/test/src/unistd/link_test.cpp
libc/test/src/unistd/linkat_test.cpp
libc/test/src/unistd/lseek_test.cpp
libc/test/src/unistd/pread_pwrite_test.cpp
libc/test/src/unistd/read_write_test.cpp
libc/test/src/unistd/readlink_test.cpp
libc/test/src/unistd/readlinkat_test.cpp
libc/test/src/unistd/rmdir_test.cpp
libc/test/src/unistd/symlink_test.cpp
libc/test/src/unistd/symlinkat_test.cpp
libc/test/src/unistd/syscall_test.cpp
libc/test/src/unistd/truncate_test.cpp
libc/test/src/unistd/unlink_test.cpp
libc/test/src/unistd/unlinkat_test.cpp
|