Skip to content

[libc][windows] start time API implementation #117775

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
merged 14 commits into from
Dec 5, 2024

Conversation

SchrodingerZhu
Copy link
Contributor

@SchrodingerZhu SchrodingerZhu commented Nov 26, 2024

Add a clock_gettime emulation layer and use it to implement the time entrypoint.

For windows, the monotonic clock is emulated using QPC.
The realtime clock is emulated using GetSystemTimePreciseAsFileTime.

@llvmbot llvmbot added libc bazel "Peripheral" support tier build system: utils/bazel labels Nov 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Nov 26, 2024

@llvm/pr-subscribers-libc

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/117775.diff

20 Files Affected:

  • (modified) libc/config/windows/entrypoints.txt (+3)
  • (modified) libc/hdr/types/clockid_t.h (+1-1)
  • (added) libc/include/llvm-libc-macros/windows/CMakeLists.txt (+6)
  • (added) libc/include/llvm-libc-macros/windows/time-macros-ext.h (+15)
  • (modified) libc/src/CMakeLists.txt (+1-1)
  • (modified) libc/src/__support/time/CMakeLists.txt (+7)
  • (renamed) libc/src/__support/time/clock_gettime.h (+3-7)
  • (modified) libc/src/__support/time/linux/CMakeLists.txt (+1-1)
  • (modified) libc/src/__support/time/linux/clock_conversion.h (+1-1)
  • (modified) libc/src/__support/time/linux/clock_gettime.cpp (+1-1)
  • (added) libc/src/__support/time/windows/CMakeLists.txt (+16)
  • (added) libc/src/__support/time/windows/clock_gettime.cpp (+89)
  • (modified) libc/src/time/CMakeLists.txt (+8-2)
  • (modified) libc/src/time/linux/CMakeLists.txt (+3-16)
  • (modified) libc/src/time/linux/clock.cpp (+1-1)
  • (modified) libc/src/time/linux/clock_gettime.cpp (+1-1)
  • (modified) libc/src/time/linux/gettimeofday.cpp (+1-1)
  • (renamed) libc/src/time/time.cpp (+6-3)
  • (modified) libc/test/src/__support/threads/linux/raw_mutex_test.cpp (+1-1)
  • (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+1-1)
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 8f0b50bcc83ea2..d0796b85aec2af 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -95,6 +95,9 @@ set(TARGET_LIBC_ENTRYPOINTS
 
     # errno.h entrypoints
     libc.src.errno.errno
+
+    # time.h entrypoints
+    libc.src.time.time
 )
 
 set(TARGET_LIBM_ENTRYPOINTS
diff --git a/libc/hdr/types/clockid_t.h b/libc/hdr/types/clockid_t.h
index 333342072a2ff2..06fafc5b150612 100644
--- a/libc/hdr/types/clockid_t.h
+++ b/libc/hdr/types/clockid_t.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_HDR_TYPES_CLOCKID_T_H
 #define LLVM_LIBC_HDR_TYPES_CLOCKID_T_H
 
-#ifdef LIBC_FULL_BUILD
+#if defined(LIBC_FULL_BUILD) || defined(_MSC_VER)
 
 #include "include/llvm-libc-types/clockid_t.h"
 
diff --git a/libc/include/llvm-libc-macros/windows/CMakeLists.txt b/libc/include/llvm-libc-macros/windows/CMakeLists.txt
new file mode 100644
index 00000000000000..48afc795178a0d
--- /dev/null
+++ b/libc/include/llvm-libc-macros/windows/CMakeLists.txt
@@ -0,0 +1,6 @@
+add_header(
+  time_macros_ext
+  HDR
+    time-macros-ext.h
+)
+
diff --git a/libc/include/llvm-libc-macros/windows/time-macros-ext.h b/libc/include/llvm-libc-macros/windows/time-macros-ext.h
new file mode 100644
index 00000000000000..e629a92f371c4a
--- /dev/null
+++ b/libc/include/llvm-libc-macros/windows/time-macros-ext.h
@@ -0,0 +1,15 @@
+//===-- Windows Time Macros Extension -------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_MACROS_WINDOWS_TIME_MACROS_EXT_H
+#define LLVM_LIBC_MACROS_WINDOWS_TIME_MACROS_EXT_H
+
+#define CLOCK_MONOTONIC 0
+#define CLOCK_REALTIME 1
+
+#endif // LLVM_LIBC_MACROS_WINDOWS_TIME_MACROS_EXT_H
diff --git a/libc/src/CMakeLists.txt b/libc/src/CMakeLists.txt
index 02c193e635362e..dd3b51886edfea 100644
--- a/libc/src/CMakeLists.txt
+++ b/libc/src/CMakeLists.txt
@@ -13,6 +13,7 @@ add_subdirectory(stdio)
 add_subdirectory(stdlib)
 add_subdirectory(string)
 add_subdirectory(wchar)
+add_subdirectory(time)
 
 if(${LIBC_TARGET_OS} STREQUAL "linux")
   add_subdirectory(dirent)
@@ -40,5 +41,4 @@ add_subdirectory(setjmp)
 add_subdirectory(signal)
 add_subdirectory(spawn)
 add_subdirectory(threads)
-add_subdirectory(time)
 add_subdirectory(locale)
diff --git a/libc/src/__support/time/CMakeLists.txt b/libc/src/__support/time/CMakeLists.txt
index 89ddffb099388b..e73f2744b15a0e 100644
--- a/libc/src/__support/time/CMakeLists.txt
+++ b/libc/src/__support/time/CMakeLists.txt
@@ -2,6 +2,13 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
   add_subdirectory(${LIBC_TARGET_OS})
 endif()
 
+add_object_library(
+  clock_gettime
+  ALIAS
+  DEPENDS
+    libc.src.__support.time.${LIBC_TARGET_OS}.clock_gettime
+)
+
 add_header_library(
   units
   HDRS
diff --git a/libc/src/__support/time/linux/clock_gettime.h b/libc/src/__support/time/clock_gettime.h
similarity index 72%
rename from libc/src/__support/time/linux/clock_gettime.h
rename to libc/src/__support/time/clock_gettime.h
index f7f996ce7c1975..584bf546cd60cd 100644
--- a/libc/src/__support/time/linux/clock_gettime.h
+++ b/libc/src/__support/time/clock_gettime.h
@@ -6,21 +6,17 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
-#define LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
+#ifndef LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H
+#define LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H
 
 #include "hdr/types/clockid_t.h"
 #include "hdr/types/struct_timespec.h"
 #include "src/__support/error_or.h"
 
-#if defined(SYS_clock_gettime64)
-#include <linux/time_types.h>
-#endif
-
 namespace LIBC_NAMESPACE_DECL {
 namespace internal {
 ErrorOr<int> clock_gettime(clockid_t clockid, timespec *ts);
 } // namespace internal
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_GETTIME_H
+#endif // LLVM_LIBC_SRC___SUPPORT_TIME_CLOCK_GETTIME_H
diff --git a/libc/src/__support/time/linux/CMakeLists.txt b/libc/src/__support/time/linux/CMakeLists.txt
index 94ed09e6521524..6fec7eeba99add 100644
--- a/libc/src/__support/time/linux/CMakeLists.txt
+++ b/libc/src/__support/time/linux/CMakeLists.txt
@@ -1,7 +1,7 @@
 add_object_library(
   clock_gettime
   HDRS
-    clock_gettime.h
+    ../clock_gettime.h
   SRCS
     clock_gettime.cpp
   DEPENDS
diff --git a/libc/src/__support/time/linux/clock_conversion.h b/libc/src/__support/time/linux/clock_conversion.h
index 7a52873263a14c..ac5357d308d7c5 100644
--- a/libc/src/__support/time/linux/clock_conversion.h
+++ b/libc/src/__support/time/linux/clock_conversion.h
@@ -10,7 +10,7 @@
 #define LLVM_LIBC_SRC___SUPPORT_TIME_LINUX_CLOCK_CONVERSION_H
 
 #include "src/__support/macros/config.h"
-#include "src/__support/time/linux/clock_gettime.h"
+#include "src/__support/time/clock_gettime.h"
 #include "src/__support/time/units.h"
 
 namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/__support/time/linux/clock_gettime.cpp b/libc/src/__support/time/linux/clock_gettime.cpp
index 3a0eca417724ac..944fc0a2b80fe7 100644
--- a/libc/src/__support/time/linux/clock_gettime.cpp
+++ b/libc/src/__support/time/linux/clock_gettime.cpp
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "src/__support/time/linux/clock_gettime.h"
+#include "src/__support/time/clock_gettime.h"
 #include "hdr/types/clockid_t.h"
 #include "hdr/types/struct_timespec.h"
 #include "src/__support/OSUtil/linux/vdso.h"
diff --git a/libc/src/__support/time/windows/CMakeLists.txt b/libc/src/__support/time/windows/CMakeLists.txt
new file mode 100644
index 00000000000000..24b5fa7e086265
--- /dev/null
+++ b/libc/src/__support/time/windows/CMakeLists.txt
@@ -0,0 +1,16 @@
+add_object_library(
+  clock_gettime
+  HDRS
+    ../clock_gettime.h
+  SRCS
+    clock_gettime.cpp
+  DEPENDS
+    libc.hdr.types.struct_timespec
+    libc.hdr.types.clockid_t
+    libc.hdr.errno_macros
+    libc.include.llvm-libc-macros.windows.time_macros_ext
+    libc.src.__support.common
+    libc.src.__support.error_or
+    libc.src.__support.OSUtil.osutil
+    libc.src.__support.CPP.atomic
+)
diff --git a/libc/src/__support/time/windows/clock_gettime.cpp b/libc/src/__support/time/windows/clock_gettime.cpp
new file mode 100644
index 00000000000000..6e0b7e028c9789
--- /dev/null
+++ b/libc/src/__support/time/windows/clock_gettime.cpp
@@ -0,0 +1,89 @@
+//===--- clock_gettime windows implementation -------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/time/clock_gettime.h"
+#include "include/llvm-libc-macros/windows/time-macros-ext.h"
+#include "src/__support/CPP/atomic.h"
+#include "src/__support/CPP/bit.h"
+#include "src/__support/time/units.h"
+#include <Windows.h>
+
+#ifdef __clang__
+#define UNINITIALIZED [[clang::uninitialized]]
+#else
+#define UNINITIALIZED
+#endif
+
+namespace LIBC_NAMESPACE_DECL {
+
+static long long get_ticks_per_second() {
+  static cpp::Atomic<long long> frequency = 0;
+  if (!frequency) {
+    UNINITIALIZED LARGE_INTEGER buffer;
+    // On systems that run Windows XP or later, the function will always
+    // succeed and will thus never return zero.
+    ::QueryPerformanceFrequency(&buffer);
+    frequency = buffer.QuadPart;
+    return buffer.QuadPart;
+  }
+  return frequency.load(cpp::MemoryOrder::RELAXED);
+}
+
+ErrorOr<int> clock_gettime(clockid_t clockid, timespec *ts) {
+  using namespace time_units;
+  ErrorOr<int> ret = 0;
+  __try {
+    switch (clockid) {
+    default:
+      ret = cpp::unexpected(EINVAL);
+      break;
+
+    case CLOCK_MONOTONIC: {
+      // see
+      // https://learn.microsoft.com/en-us/windows/win32/sysinfo/acquiring-high-resolution-time-stamps
+      // Is the performance counter monotonic (non-decreasing)?
+      // Yes. QPC does not go backward.
+      UNINITIALIZED LARGE_INTEGER buffer;
+      // On systems that run Windows XP or later, the function will always
+      // succeed and will thus never return zero.
+      ::QueryPerformanceCounter(&buffer);
+      long long freq = get_ticks_per_second();
+      long long ticks = buffer.QuadPart;
+      long long tv_sec = ticks / freq;
+      long long tv_nsec = (ticks % freq) * 1_s_ns / freq;
+      ts->tv_sec = static_cast<decltype(ts->tv_sec)>(tv_sec);
+      ts->tv_nsec = static_cast<decltype(ts->tv_nsec)>(tv_nsec);
+      break;
+    }
+    case CLOCK_REALTIME: {
+      // https://learn.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime
+      // GetSystemTimePreciseAsFileTime
+      // This function is best suited for high-resolution time-of-day
+      // measurements, or time stamps that are synchronized to UTC
+      UNINITIALIZED FILETIME file_time;
+      UNINITIALIZED ULARGE_INTEGER time;
+      ::GetSystemTimePreciseAsFileTime(&file_time);
+      time.LowPart = file_time.dwLowDateTime;
+      time.HighPart = file_time.dwHighDateTime;
+
+      // adjust to POSIX epoch (from Jan 1, 1601 to Jan 1, 1970)
+      constexpr unsigned long long HNS_PER_SEC = 1_s_ns / 100ULL;
+      time.QuadPart -= (11644473600ULL * HNS_PER_SEC);
+      unsigned long long tv_sec = time.QuadPart / HNS_PER_SEC;
+      unsigned long long tv_nsec = (time.QuadPart % HNS_PER_SEC) * 100ULL;
+      ts->tv_sec = static_cast<decltype(ts->tv_sec)>(tv_sec);
+      ts->tv_nsec = static_cast<decltype(ts->tv_nsec)>(tv_nsec);
+      break;
+    }
+    }
+  } __except (EXCEPTION_EXECUTE_HANDLER) {
+    ret = cpp::unexpected(EFAULT);
+  }
+  return ret;
+}
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/time/CMakeLists.txt b/libc/src/time/CMakeLists.txt
index b3318e7ca87fa5..bc7a2e1c113fc6 100644
--- a/libc/src/time/CMakeLists.txt
+++ b/libc/src/time/CMakeLists.txt
@@ -106,9 +106,15 @@ add_entrypoint_object(
 
 add_entrypoint_object(
   time
-  ALIAS
+  SRCS
+    time.cpp
+  HDRS
+    time_func.h
   DEPENDS
-    .${LIBC_TARGET_OS}.time
+    libc.hdr.time_macros
+    libc.hdr.types.time_t
+    libc.src.__support.time.clock_gettime
+    libc.src.errno.errno
 )
 
 add_entrypoint_object(
diff --git a/libc/src/time/linux/CMakeLists.txt b/libc/src/time/linux/CMakeLists.txt
index c15fb44ad5d123..3e1a943843be85 100644
--- a/libc/src/time/linux/CMakeLists.txt
+++ b/libc/src/time/linux/CMakeLists.txt
@@ -1,16 +1,3 @@
-add_entrypoint_object(
-  time
-  SRCS
-    time.cpp
-  HDRS
-    ../time_func.h
-  DEPENDS
-    libc.hdr.time_macros
-    libc.hdr.types.time_t
-    libc.src.__support.time.linux.clock_gettime
-    libc.src.errno.errno
-)
-
 add_entrypoint_object(
   clock
   SRCS
@@ -21,7 +8,7 @@ add_entrypoint_object(
     libc.hdr.time_macros
     libc.hdr.types.clock_t
     libc.src.__support.time.units
-    libc.src.__support.time.linux.clock_gettime
+    libc.src.__support.time.clock_gettime
     libc.src.__support.CPP.limits
     libc.src.errno.errno
 )
@@ -49,7 +36,7 @@ add_entrypoint_object(
   DEPENDS
     libc.hdr.types.clockid_t
     libc.hdr.types.struct_timespec
-    libc.src.__support.time.linux.clock_gettime
+    libc.src.__support.time.clock_gettime
     libc.src.errno.errno
 )
 
@@ -62,7 +49,7 @@ add_entrypoint_object(
   DEPENDS
     libc.hdr.time_macros
     libc.hdr.types.suseconds_t
-    libc.src.__support.time.linux.clock_gettime
+    libc.src.__support.time.clock_gettime
     libc.src.__support.time.units
     libc.src.errno.errno
 )
diff --git a/libc/src/time/linux/clock.cpp b/libc/src/time/linux/clock.cpp
index f43e1bcad6a3a1..ee4fa82b4f8944 100644
--- a/libc/src/time/linux/clock.cpp
+++ b/libc/src/time/linux/clock.cpp
@@ -11,7 +11,7 @@
 #include "src/__support/CPP/limits.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
-#include "src/__support/time/linux/clock_gettime.h"
+#include "src/__support/time/clock_gettime.h"
 #include "src/__support/time/units.h"
 #include "src/errno/libc_errno.h"
 
diff --git a/libc/src/time/linux/clock_gettime.cpp b/libc/src/time/linux/clock_gettime.cpp
index a2b20a6dbc9879..743c644d65d024 100644
--- a/libc/src/time/linux/clock_gettime.cpp
+++ b/libc/src/time/linux/clock_gettime.cpp
@@ -9,7 +9,7 @@
 #include "src/time/clock_gettime.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
-#include "src/__support/time/linux/clock_gettime.h"
+#include "src/__support/time/clock_gettime.h"
 #include "src/errno/libc_errno.h"
 
 namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/time/linux/gettimeofday.cpp b/libc/src/time/linux/gettimeofday.cpp
index 19d9988ae73a6e..e8ddf482fc9840 100644
--- a/libc/src/time/linux/gettimeofday.cpp
+++ b/libc/src/time/linux/gettimeofday.cpp
@@ -11,7 +11,7 @@
 #include "hdr/types/suseconds_t.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
-#include "src/__support/time/linux/clock_gettime.h"
+#include "src/__support/time/clock_gettime.h"
 #include "src/__support/time/units.h"
 #include "src/errno/libc_errno.h"
 
diff --git a/libc/src/time/linux/time.cpp b/libc/src/time/time.cpp
similarity index 82%
rename from libc/src/time/linux/time.cpp
rename to libc/src/time/time.cpp
index 20fb86e8e29dbb..e3615d995116b8 100644
--- a/libc/src/time/linux/time.cpp
+++ b/libc/src/time/time.cpp
@@ -9,14 +9,17 @@
 #include "hdr/time_macros.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
-#include "src/__support/time/linux/clock_gettime.h"
+#include "src/__support/time/clock_gettime.h"
 #include "src/errno/libc_errno.h"
 #include "src/time/time_func.h"
 
+#ifdef _MSC_VER
+#include "include/llvm-libc-macros/windows/time-macros-ext.h"
+#endif
+
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(time_t, time, (time_t * tp)) {
-  // TODO: Use the Linux VDSO to fetch the time and avoid the syscall.
+LLVM_LIBC_FUNCTION(time_t, time, (time_t *tp)) {
   struct timespec ts;
   auto result = internal::clock_gettime(CLOCK_REALTIME, &ts);
   if (!result.has_value()) {
diff --git a/libc/test/src/__support/threads/linux/raw_mutex_test.cpp b/libc/test/src/__support/threads/linux/raw_mutex_test.cpp
index 918f5d35c94f42..dadc706421d06e 100644
--- a/libc/test/src/__support/threads/linux/raw_mutex_test.cpp
+++ b/libc/test/src/__support/threads/linux/raw_mutex_test.cpp
@@ -12,7 +12,7 @@
 #include "src/__support/OSUtil/syscall.h"
 #include "src/__support/threads/linux/raw_mutex.h"
 #include "src/__support/threads/sleep.h"
-#include "src/__support/time/linux/clock_gettime.h"
+#include "src/__support/time/clock_gettime.h"
 #include "src/stdlib/exit.h"
 #include "src/sys/mman/mmap.h"
 #include "src/sys/mman/munmap.h"
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 2573788658d59b..5f730f2eacb2d7 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -1475,7 +1475,7 @@ libc_support_library(
 
 libc_support_library(
     name = "__support_time_linux_clock_gettime",
-    hdrs = ["src/__support/time/linux/clock_gettime.h"],
+    hdrs = ["src/__support/time/clock_gettime.h"],
     target_compatible_with = select({
         "@platforms//os:linux": [],
         "//conditions:default": ["@platforms//:incompatible"],

Copy link

github-actions bot commented Nov 26, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good start, thanks for adding the links to the microsoft docs

@SchrodingerZhu
Copy link
Contributor Author

Rebase to address conflicts.

Copy link
Member

@Lancern Lancern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation LGTM

Copy link
Contributor

@michaelrj-google michaelrj-google left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a few small changes

@SchrodingerZhu
Copy link
Contributor Author

All fixed!

@SchrodingerZhu SchrodingerZhu merged commit 0adff0a into llvm:main Dec 5, 2024
5 of 6 checks passed
@SchrodingerZhu SchrodingerZhu deleted the libc/win/time branch December 5, 2024 19:08
@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 5, 2024

LLVM Buildbot has detected a new failure on builder openmp-offload-libc-amdgpu-runtime running on omp-vega20-1 while building libc,utils at step 5 "compile-openmp".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/73/builds/9687

Here is the relevant piece of the build log for the reference
Step 5 (compile-openmp) failure: build (failure)
...
  /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/libc/cmake/modules/LLVMLibCFlagRules.cmake:251 (expand_flags_for_target)
  /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/libc/cmake/modules/LLVMLibCObjectRules.cmake:107 (add_target_with_flags)
  /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/libc/src/__support/time/CMakeLists.txt:5 (add_object_library)


-- Found the ROCm device library. Implementations falling back to the vendor libraries will be resolved statically.
-- check-runtimes does nothing.
-- Configuring incomplete, errors occurred!
See also "/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-amdgcn-amd-amdhsa-bins/CMakeFiles/CMakeOutput.log".
See also "/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-amdgcn-amd-amdhsa-bins/CMakeFiles/CMakeError.log".
FAILED: runtimes/runtimes-amdgcn-amd-amdhsa-stamps/runtimes-amdgcn-amd-amdhsa-configure /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-amdgcn-amd-amdhsa-stamps/runtimes-amdgcn-amd-amdhsa-configure 
cd /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-amdgcn-amd-amdhsa-bins && /usr/local/cmake/bin/cmake --no-warn-unused-cli -DCMAKE_C_COMPILER=/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang -DCMAKE_CXX_COMPILER=/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang++ -DCMAKE_ASM_COMPILER=/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang -DCMAKE_LINKER=/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/ld.lld -DCMAKE_AR=/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/llvm-ar -DCMAKE_RANLIB=/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/llvm-ranlib -DCMAKE_NM=/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/llvm-nm -DCMAKE_OBJDUMP=/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/llvm-objdump -DCMAKE_OBJCOPY=/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/llvm-objcopy -DCMAKE_STRIP=/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/llvm-strip -DCMAKE_READELF=/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/llvm-readelf -DCMAKE_C_COMPILER_TARGET=amdgcn-amd-amdhsa -DCMAKE_CXX_COMPILER_TARGET=amdgcn-amd-amdhsa -DCMAKE_ASM_COMPILER_TARGET=amdgcn-amd-amdhsa -DCMAKE_INSTALL_PREFIX=/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.inst -DLLVM_BINARY_DIR=/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build -DLLVM_CONFIG_PATH=/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/bin/llvm-config -DLLVM_ENABLE_WERROR=OFF -DLLVM_HOST_TRIPLE=x86_64-unknown-linux-gnu -DLLVM_HAVE_LINK_VERSION_SCRIPT=1 -DLLVM_USE_RELATIVE_PATHS_IN_DEBUG_INFO=OFF -DLLVM_USE_RELATIVE_PATHS_IN_FILES=OFF "-DLLVM_LIT_ARGS=-vv --show-unsupported --show-xfail -j 32" -DLLVM_SOURCE_PREFIX= -DPACKAGE_VERSION=20.0.0git -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/usr/local/bin/ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DCOMPILER_RT_BUILD_BUILTINS=OFF -DLLVM_INCLUDE_TESTS=ON -DLLVM_ENABLE_PROJECTS_USED=ON -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON -DCMAKE_C_COMPILER_WORKS=ON -DCMAKE_CXX_COMPILER_WORKS=ON -DCMAKE_ASM_COMPILER_WORKS=ON -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON -DLLVM_RUNTIMES_TARGET=amdgcn-amd-amdhsa -DHAVE_LLVM_LIT=ON -DCLANG_RESOURCE_DIR= -DLLVM_DEFAULT_TARGET_TRIPLE=amdgcn-amd-amdhsa -DLLVM_LIBC_GPU_BUILD=ON -DRUNTIMES_amdgcn-amd-amdhsa_LIBC_GPU_LOADER_EXECUTABLE=/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/bin/amdhsa-loader -DRUNTIMES_amdgcn-amd-amdhsa_LLVM_LIBC_FULL_BUILD=ON "-DLLVM_ENABLE_RUNTIMES=offload;openmp;compiler-rt" -DLLVM_USE_LINKER= -DLIBC_GPU_TEST_ARCHITECTURE=gfx906 -DLLVM_ENABLE_RUNTIMES=libc -DLIBC_GPU_LOADER_EXECUTABLE=/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/bin/amdhsa-loader -DLLVM_LIBC_FULL_BUILD=ON -GNinja -C/home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/projects/runtimes-amdgcn-amd-amdhsa/tmp/runtimes-amdgcn-amd-amdhsa-cache-Release.cmake /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.src/llvm/runtimes/../../runtimes && /usr/local/cmake/bin/cmake -E touch /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/runtimes/runtimes-amdgcn-amd-amdhsa-stamps//runtimes-amdgcn-amd-amdhsa-configure
ninja: build stopped: subcommand failed.

jhuber6 added a commit that referenced this pull request Dec 5, 2024
SchrodingerZhu added a commit to SchrodingerZhu/llvm-project that referenced this pull request Dec 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bazel "Peripheral" support tier build system: utils/bazel libc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants