[libc-commits] [libc] 4abe47c - [libc] Enable 'mktime' for the GPU (#133437)
via libc-commits
libc-commits at lists.llvm.org
Fri Mar 28 09:14:54 PDT 2025
Author: Joseph Huber
Date: 2025-03-28T11:14:51-05:00
New Revision: 4abe47c6fc06e44792bc1b0dc58f3b453ae4fb80
URL: https://github.com/llvm/llvm-project/commit/4abe47c6fc06e44792bc1b0dc58f3b453ae4fb80
DIFF: https://github.com/llvm/llvm-project/commit/4abe47c6fc06e44792bc1b0dc58f3b453ae4fb80.diff
LOG: [libc] Enable 'mktime' for the GPU (#133437)
Summary:
This is a dependency on `strftime` which we provide, so we should have
this.
Added:
Modified:
libc/cmake/modules/LLVMLibCTestRules.cmake
libc/config/gpu/amdgpu/entrypoints.txt
libc/config/gpu/nvptx/entrypoints.txt
libc/test/src/time/CMakeLists.txt
libc/test/src/time/mktime_test.cpp
Removed:
################################################################################
diff --git a/libc/cmake/modules/LLVMLibCTestRules.cmake b/libc/cmake/modules/LLVMLibCTestRules.cmake
index 45a36abd8ce1b..0f0d612d04ba5 100644
--- a/libc/cmake/modules/LLVMLibCTestRules.cmake
+++ b/libc/cmake/modules/LLVMLibCTestRules.cmake
@@ -643,7 +643,7 @@ function(add_libc_hermetic test_name)
cmake_parse_arguments(
"HERMETIC_TEST"
"IS_GPU_BENCHMARK" # Optional arguments
- "SUITE" # Single value arguments
+ "SUITE;CXX_STANDARD" # Single value arguments
"SRCS;HDRS;DEPENDS;ARGS;ENV;COMPILE_OPTIONS;LINK_LIBRARIES;LOADER_ARGS" # Multi-value arguments
${ARGN}
)
@@ -720,10 +720,14 @@ function(add_libc_hermetic test_name)
${HERMETIC_TEST_SRCS}
${HERMETIC_TEST_HDRS}
)
+
+ if(NOT HERMETIC_TEST_CXX_STANDARD)
+ set(HERMETIC_TEST_CXX_STANDARD ${CMAKE_CXX_STANDARD})
+ endif()
set_target_properties(${fq_build_target_name}
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
- #OUTPUT_NAME ${fq_target_name}
+ CXX_STANDARD ${HERMETIC_TEST_CXX_STANDARD}
)
target_include_directories(${fq_build_target_name} SYSTEM PRIVATE ${LIBC_INCLUDE_DIR})
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index a5d32c8eda39f..a5f8f82078f42 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -261,6 +261,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.time.nanosleep
libc.src.time.strftime
libc.src.time.strftime_l
+ libc.src.time.mktime
# wchar.h entrypoints
libc.src.wchar.wcslen
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index f553f7cc2b210..7292ca3d6efca 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -261,6 +261,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.time.nanosleep
libc.src.time.strftime
libc.src.time.strftime_l
+ libc.src.time.mktime
# wchar.h entrypoints
libc.src.wchar.wcslen
diff --git a/libc/test/src/time/CMakeLists.txt b/libc/test/src/time/CMakeLists.txt
index 618812fd8eee5..be7aa6f0f058a 100644
--- a/libc/test/src/time/CMakeLists.txt
+++ b/libc/test/src/time/CMakeLists.txt
@@ -148,7 +148,7 @@ add_libc_unittest(
libc.src.time.time_constants
)
-add_libc_unittest(
+add_libc_test(
mktime_test
SUITE
libc_time_unittests
diff --git a/libc/test/src/time/mktime_test.cpp b/libc/test/src/time/mktime_test.cpp
index fe1116f7dd2ef..1dfdd73de5440 100644
--- a/libc/test/src/time/mktime_test.cpp
+++ b/libc/test/src/time/mktime_test.cpp
@@ -18,6 +18,10 @@ using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Fails;
using LIBC_NAMESPACE::testing::ErrnoSetterMatcher::Succeeds;
using LIBC_NAMESPACE::time_constants::Month;
+#ifndef EOVERFLOW
+#define EOVERFLOW 0
+#endif
+
static inline constexpr int tm_year(int year) {
return year - LIBC_NAMESPACE::time_constants::TIME_YEAR_BASE;
}
More information about the libc-commits
mailing list