[libc-commits] [libc] [libc] Enable 'mktime' for the GPU (PR #133437)
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Fri Mar 28 09:08:41 PDT 2025
https://github.com/jhuber6 updated https://github.com/llvm/llvm-project/pull/133437
>From 5ce70b91c8bab36f5b530f6b2a5705ac8029e322 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Fri, 28 Mar 2025 07:35:36 -0500
Subject: [PATCH] [libc] Enable 'mktime' for the GPU
Summary:
This is a dependency on `strftime` which we provide, so we should have
this.
---
libc/cmake/modules/LLVMLibCTestRules.cmake | 8 ++++++--
libc/config/gpu/amdgpu/entrypoints.txt | 1 +
libc/config/gpu/nvptx/entrypoints.txt | 1 +
libc/test/src/time/CMakeLists.txt | 2 +-
libc/test/src/time/mktime_test.cpp | 4 ++++
5 files changed, 13 insertions(+), 3 deletions(-)
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