Skip to content
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

[libc] Support for scanf on baremetal #131043

Merged
merged 7 commits into from
Mar 20, 2025
Merged

Conversation

petrhosek
Copy link
Member

This uses the templatized scanf Reader interface introduced in #131037.

@llvmbot
Copy link
Member

llvmbot commented Mar 12, 2025

@llvm/pr-subscribers-libc

Author: Petr Hosek (petrhosek)

Changes

This uses the templatized scanf Reader interface introduced in #131037.


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

13 Files Affected:

  • (modified) libc/config/baremetal/aarch64/entrypoints.txt (+4-2)
  • (modified) libc/config/baremetal/arm/entrypoints.txt (+4-2)
  • (modified) libc/config/baremetal/riscv/entrypoints.txt (+4-2)
  • (modified) libc/src/stdio/CMakeLists.txt (+4-54)
  • (modified) libc/src/stdio/baremetal/CMakeLists.txt (+26)
  • (removed) libc/src/stdio/fscanf.cpp (-36)
  • (modified) libc/src/stdio/generic/CMakeLists.txt (+54)
  • (removed) libc/src/stdio/scanf.cpp (-41)
  • (modified) libc/src/stdio/scanf_core/CMakeLists.txt (+2-7)
  • (modified) libc/src/stdio/sscanf.cpp (+2-2)
  • (removed) libc/src/stdio/vfscanf.cpp (-34)
  • (removed) libc/src/stdio/vscanf.cpp (-40)
  • (modified) libc/src/stdio/vsscanf.cpp (+3-3)
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 2c226ef176c08..ffe7e622279a0 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -128,13 +128,15 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.stdio.putchar
     libc.src.stdio.puts
     libc.src.stdio.remove
+    libc.src.stdio.scanf
     libc.src.stdio.snprintf
     libc.src.stdio.sprintf
-    libc.src.stdio.asprintf
+    libc.src.stdio.sscanf
     libc.src.stdio.vprintf
+    libc.src.stdio.vscanf
     libc.src.stdio.vsnprintf
     libc.src.stdio.vsprintf
-    libc.src.stdio.vasprintf
+    libc.src.stdio.vsscanf
 
     # stdbit.h entrypoints
     libc.src.stdbit.stdc_bit_ceil_uc
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index d7a01bdf90b3f..a6628d1c56219 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -128,13 +128,15 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.stdio.putchar
     libc.src.stdio.puts
     libc.src.stdio.remove
+    libc.src.stdio.scanf
     libc.src.stdio.snprintf
     libc.src.stdio.sprintf
-    libc.src.stdio.asprintf
+    libc.src.stdio.sscanf
     libc.src.stdio.vprintf
+    libc.src.stdio.vscanf
     libc.src.stdio.vsnprintf
     libc.src.stdio.vsprintf
-    libc.src.stdio.vasprintf
+    libc.src.stdio.vsscanf
 
     # stdbit.h entrypoints
     libc.src.stdbit.stdc_bit_ceil_uc
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index ae00803dd0def..ccbcb85a216a8 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -124,13 +124,15 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.stdio.putchar
     libc.src.stdio.puts
     libc.src.stdio.remove
+    libc.src.stdio.scanf
     libc.src.stdio.snprintf
     libc.src.stdio.sprintf
-    libc.src.stdio.asprintf
+    libc.src.stdio.sscanf
     libc.src.stdio.vprintf
+    libc.src.stdio.vscanf
     libc.src.stdio.vsnprintf
     libc.src.stdio.vsprintf
-    libc.src.stdio.vasprintf
+    libc.src.stdio.vsscanf
 
     # stdbit.h entrypoints
     libc.src.stdbit.stdc_bit_ceil_uc
diff --git a/libc/src/stdio/CMakeLists.txt b/libc/src/stdio/CMakeLists.txt
index b9bc904471df9..23c103c1d6465 100644
--- a/libc/src/stdio/CMakeLists.txt
+++ b/libc/src/stdio/CMakeLists.txt
@@ -95,20 +95,6 @@ add_entrypoint_object(
     libc.src.__support.File.platform_file
 )
 
-list(APPEND scanf_deps
-      libc.src.__support.arg_list
-      libc.src.stdio.scanf_core.vfscanf_internal
-      libc.hdr.types.FILE
-)
-
-if(LLVM_LIBC_FULL_BUILD AND NOT LIBC_TARGET_OS_IS_GPU)
-  list(APPEND scanf_deps
-      libc.src.__support.File.file
-      libc.src.__support.File.platform_file
-      libc.src.__support.File.platform_stdin
-  )
-endif()
-
 add_entrypoint_object(
   sscanf
   SRCS
@@ -133,46 +119,6 @@ add_entrypoint_object(
     libc.src.stdio.scanf_core.scanf_main
 )
 
-add_entrypoint_object(
-  fscanf
-  SRCS
-    fscanf.cpp
-  HDRS
-    fscanf.h
-  DEPENDS
-    ${scanf_deps}
-)
-
-add_entrypoint_object(
-  vfscanf
-  SRCS
-    vfscanf.cpp
-  HDRS
-    vfscanf.h
-  DEPENDS
-    ${scanf_deps}
-)
-
-add_entrypoint_object(
-  scanf
-  SRCS
-    scanf.cpp
-  HDRS
-    scanf.h
-  DEPENDS
-    ${scanf_deps}
-)
-
-add_entrypoint_object(
-  vscanf
-  SRCS
-    vscanf.cpp
-  HDRS
-    vscanf.h
-  DEPENDS
-    ${scanf_deps}
-)
-
 add_entrypoint_object(
   sprintf
   SRCS
@@ -295,8 +241,12 @@ add_stdio_entrypoint_object(getchar)
 add_stdio_entrypoint_object(getchar_unlocked)
 add_stdio_entrypoint_object(fgets)
 add_stdio_entrypoint_object(ungetc)
+add_stdio_entrypoint_object(scanf)
+add_stdio_entrypoint_object(fscanf)
 add_stdio_entrypoint_object(stdin)
 add_stdio_entrypoint_object(stdout)
 add_stdio_entrypoint_object(stderr)
 add_stdio_entrypoint_object(vprintf)
 add_stdio_entrypoint_object(vfprintf)
+add_stdio_entrypoint_object(vscanf)
+add_stdio_entrypoint_object(vfscanf)
diff --git a/libc/src/stdio/baremetal/CMakeLists.txt b/libc/src/stdio/baremetal/CMakeLists.txt
index c5cf4a8e0e5b5..4abe8bc66b25b 100644
--- a/libc/src/stdio/baremetal/CMakeLists.txt
+++ b/libc/src/stdio/baremetal/CMakeLists.txt
@@ -55,6 +55,19 @@ add_entrypoint_object(
     libc.src.__support.CPP.string_view
 )
 
+add_entrypoint_object(
+  scanf
+  SRCS
+    scanf.cpp
+  HDRS
+    ../scanf.h
+  DEPENDS
+    libc.src.stdio.scanf_core.scanf_main
+    libc.src.stdio.scanf_core.reader
+    libc.src.__support.arg_list
+    libc.src.__support.OSUtil.osutil
+)
+
 add_entrypoint_object(
   vprintf
   SRCS
@@ -67,3 +80,16 @@ add_entrypoint_object(
     libc.src.__support.arg_list
     libc.src.__support.OSUtil.osutil
 )
+
+add_entrypoint_object(
+  vscanf
+  SRCS
+    vscanf.cpp
+  HDRS
+    ../vscanf.h
+  DEPENDS
+    libc.src.stdio.scanf_core.scanf_main
+    libc.src.stdio.scanf_core.reader
+    libc.src.__support.arg_list
+    libc.src.__support.OSUtil.osutil
+)
diff --git a/libc/src/stdio/fscanf.cpp b/libc/src/stdio/fscanf.cpp
deleted file mode 100644
index 94b843978749e..0000000000000
--- a/libc/src/stdio/fscanf.cpp
+++ /dev/null
@@ -1,36 +0,0 @@
-//===-- Implementation of fscanf --------------------------------*- 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/stdio/fscanf.h"
-
-#include "src/__support/File/file.h"
-#include "src/__support/arg_list.h"
-#include "src/__support/macros/config.h"
-#include "src/stdio/scanf_core/vfscanf_internal.h"
-
-#include "hdr/types/FILE.h"
-#include <stdarg.h>
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(int, fscanf,
-                   (::FILE *__restrict stream, const char *__restrict format,
-                    ...)) {
-  va_list vlist;
-  va_start(vlist, format);
-  internal::ArgList args(vlist); // This holder class allows for easier copying
-                                 // and pointer semantics, as well as handling
-                                 // destruction automatically.
-  va_end(vlist);
-  int ret_val = scanf_core::vfscanf_internal(stream, format, args);
-  // This is done to avoid including stdio.h in the internals. On most systems
-  // EOF is -1, so this will be transformed into just "return ret_val".
-  return (ret_val == -1) ? EOF : ret_val;
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdio/generic/CMakeLists.txt b/libc/src/stdio/generic/CMakeLists.txt
index bf301a6b0cb3c..9f568c5ab8d3a 100644
--- a/libc/src/stdio/generic/CMakeLists.txt
+++ b/libc/src/stdio/generic/CMakeLists.txt
@@ -425,6 +425,60 @@ add_entrypoint_object(
     ${fprintf_deps}
 )
 
+list(APPEND scanf_deps
+      libc.src.__support.arg_list
+      libc.src.stdio.scanf_core.vfscanf_internal
+      libc.hdr.types.FILE
+)
+
+if(LLVM_LIBC_FULL_BUILD AND NOT LIBC_TARGET_OS_IS_GPU)
+  list(APPEND scanf_deps
+      libc.src.__support.File.file
+      libc.src.__support.File.platform_file
+      libc.src.__support.File.platform_stdin
+  )
+endif()
+
+add_entrypoint_object(
+  fscanf
+  SRCS
+    fscanf.cpp
+  HDRS
+    ../fscanf.h
+  DEPENDS
+    ${scanf_deps}
+)
+
+add_entrypoint_object(
+  vfscanf
+  SRCS
+    vfscanf.cpp
+  HDRS
+    ../vfscanf.h
+  DEPENDS
+    ${scanf_deps}
+)
+
+add_entrypoint_object(
+  scanf
+  SRCS
+    scanf.cpp
+  HDRS
+    ../scanf.h
+  DEPENDS
+    ${scanf_deps}
+)
+
+add_entrypoint_object(
+  vscanf
+  SRCS
+    vscanf.cpp
+  HDRS
+    ../vscanf.h
+  DEPENDS
+    ${scanf_deps}
+)
+
 add_entrypoint_object(
   fgets
   SRCS
diff --git a/libc/src/stdio/scanf.cpp b/libc/src/stdio/scanf.cpp
deleted file mode 100644
index 86a8851df2886..0000000000000
--- a/libc/src/stdio/scanf.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-//===-- Implementation of scanf ---------------------------------*- 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/stdio/scanf.h"
-
-#include "src/__support/File/file.h"
-#include "src/__support/arg_list.h"
-#include "src/__support/macros/config.h"
-#include "src/stdio/scanf_core/vfscanf_internal.h"
-
-#include "hdr/types/FILE.h"
-#include <stdarg.h>
-
-#ifndef LIBC_COPT_STDIO_USE_SYSTEM_FILE
-#define SCANF_STDIN LIBC_NAMESPACE::stdin
-#else // LIBC_COPT_STDIO_USE_SYSTEM_FILE
-#define SCANF_STDIN ::stdin
-#endif // LIBC_COPT_STDIO_USE_SYSTEM_FILE
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(int, scanf, (const char *__restrict format, ...)) {
-  va_list vlist;
-  va_start(vlist, format);
-  internal::ArgList args(vlist); // This holder class allows for easier copying
-                                 // and pointer semantics, as well as handling
-                                 // destruction automatically.
-  va_end(vlist);
-  int ret_val = scanf_core::vfscanf_internal(
-      reinterpret_cast<::FILE *>(SCANF_STDIN), format, args);
-  // This is done to avoid including stdio.h in the internals. On most systems
-  // EOF is -1, so this will be transformed into just "return ret_val".
-  return (ret_val == -1) ? EOF : ret_val;
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdio/scanf_core/CMakeLists.txt b/libc/src/stdio/scanf_core/CMakeLists.txt
index 014413ccaa8da..714b174892504 100644
--- a/libc/src/stdio/scanf_core/CMakeLists.txt
+++ b/libc/src/stdio/scanf_core/CMakeLists.txt
@@ -16,6 +16,8 @@ if(LIBC_TARGET_OS_IS_GPU)
     libc.src.stdio.ungetc
     libc.src.stdio.ferror
   )
+elseif(LIBC_TARGET_OS_IS_BAREMETAL)
+  # There's no FILE* for baremetal.
 elseif(LLVM_LIBC_FULL_BUILD)
   list(APPEND file_deps
     libc.src.__support.File.file
@@ -54,13 +56,6 @@ add_header_library(
     libc.src.__support.CPP.string_view
 )
 
-if(NOT(TARGET libc.src.__support.File.file) AND LLVM_LIBC_FULL_BUILD AND
-  (NOT LIBC_TARGET_OS_IS_GPU))
-  # Not all platforms have a file implementation. If file is unvailable, and a
-  # full build is requested, then we must skip all file based scanf sections.
-  return()
-endif()
-
 add_object_library(
   scanf_main
   SRCS
diff --git a/libc/src/stdio/sscanf.cpp b/libc/src/stdio/sscanf.cpp
index 82de8a29f6ad1..ec4e10caf6cb5 100644
--- a/libc/src/stdio/sscanf.cpp
+++ b/libc/src/stdio/sscanf.cpp
@@ -29,8 +29,8 @@ LLVM_LIBC_FUNCTION(int, sscanf,
                                  // and pointer semantics, as well as handling
                                  // destruction automatically.
   va_end(vlist);
-  scanf_core::ReadBuffer rb{buffer, cpp::numeric_limits<size_t>::max()};
-  scanf_core::Reader reader(&rb);
+  scanf_core::StringBuffer rb(buffer, cpp::numeric_limits<size_t>::max());
+  scanf_core::Reader<scanf_core::StringBuffer> reader(&rb);
   int ret_val = scanf_core::scanf_main(&reader, format, args);
   // This is done to avoid including stdio.h in the internals. On most systems
   // EOF is -1, so this will be transformed into just "return ret_val".
diff --git a/libc/src/stdio/vfscanf.cpp b/libc/src/stdio/vfscanf.cpp
deleted file mode 100644
index 220576522d0fd..0000000000000
--- a/libc/src/stdio/vfscanf.cpp
+++ /dev/null
@@ -1,34 +0,0 @@
-//===-- Implementation of vfscanf -------------------------------*- 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/stdio/vfscanf.h"
-
-#include "src/__support/File/file.h"
-#include "src/__support/arg_list.h"
-#include "src/__support/macros/config.h"
-#include "src/stdio/scanf_core/vfscanf_internal.h"
-
-#include "hdr/types/FILE.h"
-#include <stdarg.h>
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(int, vfscanf,
-                   (::FILE *__restrict stream, const char *__restrict format,
-                    va_list vlist)) {
-  internal::ArgList args(vlist); // This holder class allows for easier copying
-                                 // and pointer semantics, as well as handling
-                                 // destruction automatically.
-  va_end(vlist);
-  int ret_val = scanf_core::vfscanf_internal(stream, format, args);
-  // This is done to avoid including stdio.h in the internals. On most systems
-  // EOF is -1, so this will be transformed into just "return ret_val".
-  return (ret_val == -1) ? EOF : ret_val;
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdio/vscanf.cpp b/libc/src/stdio/vscanf.cpp
deleted file mode 100644
index 64f5cc1d6962a..0000000000000
--- a/libc/src/stdio/vscanf.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-//===-- Implementation of vscanf --------------------------------*- 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/stdio/vscanf.h"
-
-#include "src/__support/File/file.h"
-#include "src/__support/arg_list.h"
-#include "src/__support/macros/config.h"
-#include "src/stdio/scanf_core/vfscanf_internal.h"
-
-#include "hdr/types/FILE.h"
-#include <stdarg.h>
-
-#ifndef LIBC_COPT_STDIO_USE_SYSTEM_FILE
-#define SCANF_STDIN LIBC_NAMESPACE::stdin
-#else // LIBC_COPT_STDIO_USE_SYSTEM_FILE
-#define SCANF_STDIN ::stdin
-#endif // LIBC_COPT_STDIO_USE_SYSTEM_FILE
-
-namespace LIBC_NAMESPACE_DECL {
-
-LLVM_LIBC_FUNCTION(int, vscanf,
-                   (const char *__restrict format, va_list vlist)) {
-  internal::ArgList args(vlist); // This holder class allows for easier copying
-                                 // and pointer semantics, as well as handling
-                                 // destruction automatically.
-  va_end(vlist);
-  int ret_val = scanf_core::vfscanf_internal(
-      reinterpret_cast<::FILE *>(SCANF_STDIN), format, args);
-  // This is done to avoid including stdio.h in the internals. On most systems
-  // EOF is -1, so this will be transformed into just "return ret_val".
-  return (ret_val == -1) ? EOF : ret_val;
-}
-
-} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdio/vsscanf.cpp b/libc/src/stdio/vsscanf.cpp
index f3f56bce64292..e3e2fe34c32ec 100644
--- a/libc/src/stdio/vsscanf.cpp
+++ b/libc/src/stdio/vsscanf.cpp
@@ -21,9 +21,9 @@ namespace LIBC_NAMESPACE_DECL {
 LLVM_LIBC_FUNCTION(int, vsscanf,
                    (const char *buffer, const char *format, va_list vlist)) {
   internal::ArgList args(vlist);
-  scanf_core::ReadBuffer rb{const_cast<char *>(buffer),
-                            cpp::numeric_limits<size_t>::max()};
-  scanf_core::Reader reader(&rb);
+  scanf_core::StringBuffer rb{const_cast<char *>(buffer),
+                              cpp::numeric_limits<size_t>::max()};
+  scanf_core::Reader<scanf_core::StringBuffer> reader(&rb);
   int ret_val = scanf_core::scanf_main(&reader, format, args);
   // This is done to avoid including stdio.h in the internals. On most systems
   // EOF is -1, so this will be transformed into just "return ret_val".

This uses the templatized scanf Reader interface introduced in llvm#131037.
@petrhosek
Copy link
Member Author

@michaelrj-google This is ready for review now.

libc.hdr.types.FILE
)

if(LLVM_LIBC_FULL_BUILD AND NOT LIBC_TARGET_OS_IS_GPU)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this not needed anymore?

Copy link
Member Author

Choose a reason for hiding this comment

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

It was moved to libc/src/stdio/generic/CMakeLists.txt.

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.

overall LGTM with some organizational comments


namespace {

struct StreamReader : scanf_core::Reader<StreamReader> {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: this should be named BaremetalReader or something other than StreamReader to keep it clear which is which.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, I went with StdinReader.

Comment on lines 24 to 33
struct StreamReader : scanf_core::Reader<StreamReader> {
LIBC_INLINE char getc() {
char buf[1];
auto result = read_from_stdin(buf, sizeof(buf));
if (result <= 0)
return EOF;
return buf[0];
}
LIBC_INLINE void ungetc(int) {}
};
Copy link
Contributor

Choose a reason for hiding this comment

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

would it make sense to have a shared header that defines this? Similar to fvscanf_internal.h

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, I moved the implementation to scanf_internal.h.

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.

did you forget to add scanf_internal.h to your commit?

@petrhosek
Copy link
Member Author

did you forget to add scanf_internal.h to your commit?

I did, it should be included now.

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

@petrhosek petrhosek merged commit afae7c9 into llvm:main Mar 20, 2025
16 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 20, 2025

LLVM Buildbot has detected a new failure on builder openmp-offload-amdgpu-runtime-2 running on rocm-worker-hw-02 while building libc at step 5 "compile-openmp".

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

Here is the relevant piece of the build log for the reference
Step 5 (compile-openmp) failure: build (failure)
...
Call Stack (most recent call first):
  /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/libc/cmake/modules/LLVMLibCLibraryRules.cmake:106 (get_all_object_file_deps)
  /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/libc/lib/CMakeLists.txt:43 (add_bitcode_entrypoint_library)


-- check-runtimes does nothing.
-- Configuring incomplete, errors occurred!
See also "/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-amdgcn-amd-amdhsa-bins/CMakeFiles/CMakeOutput.log".
See also "/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-amdgcn-amd-amdhsa-bins/CMakeFiles/CMakeError.log".
34.999 [11/2/4547] Creating library symlink lib/libclang-cpp.so
FAILED: runtimes/runtimes-amdgcn-amd-amdhsa-stamps/runtimes-amdgcn-amd-amdhsa-configure /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-amdgcn-amd-amdhsa-stamps/runtimes-amdgcn-amd-amdhsa-configure 
cd /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-amdgcn-amd-amdhsa-bins && /usr/bin/cmake --no-warn-unused-cli -DCMAKE_C_COMPILER=/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/clang -DCMAKE_CXX_COMPILER=/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/clang++ -DCMAKE_ASM_COMPILER=/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/clang -DCMAKE_LINKER=/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/ld.lld -DCMAKE_AR=/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/llvm-ar -DCMAKE_RANLIB=/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/llvm-ranlib -DCMAKE_NM=/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/llvm-nm -DCMAKE_OBJDUMP=/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/llvm-objdump -DCMAKE_OBJCOPY=/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/llvm-objcopy -DCMAKE_STRIP=/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/llvm-strip -DCMAKE_READELF=/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/./bin/llvm-readelf -DCMAKE_C_COMPILER_TARGET=amdgcn-amd-amdhsa -DCMAKE_CXX_COMPILER_TARGET=amdgcn-amd-amdhsa -DCMAKE_Fortran_COMPILER_TARGET=amdgcn-amd-amdhsa -DCMAKE_ASM_COMPILER_TARGET=amdgcn-amd-amdhsa -DCMAKE_INSTALL_PREFIX=/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.inst -DLLVM_BINARY_DIR=/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build -DLLVM_CONFIG_PATH=/home/botworker/builds/openmp-offload-amdgpu-runtime-2/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 64 --time-tests --timeout 100" -DLLVM_SOURCE_PREFIX= -DPACKAGE_VERSION=21.0.0git -DCMAKE_BUILD_TYPE=Release -DCMAKE_MAKE_PROGRAM=/usr/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_Fortran_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/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/bin/amdhsa-loader "-DLLVM_ENABLE_RUNTIMES=libcxxabi;libunwind;offload;openmp;compiler-rt;libcxx" -DLLVM_USE_LINKER= -DLIBC_GPU_TEST_JOBS=4 -DLLVM_ENABLE_RUNTIMES=libc -DLIBC_GPU_LOADER_EXECUTABLE=/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/bin/amdhsa-loader -GNinja -C/home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/projects/runtimes-amdgcn-amd-amdhsa/tmp/runtimes-amdgcn-amd-amdhsa-cache-Release.cmake /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.src/llvm/runtimes/../../runtimes && /usr/bin/cmake -E touch /home/botworker/builds/openmp-offload-amdgpu-runtime-2/llvm.build/runtimes/runtimes-amdgcn-amd-amdhsa-stamps//runtimes-amdgcn-amd-amdhsa-configure
ninja: build stopped: subcommand failed.

michaelrj-google added a commit to michaelrj-google/llvm-project that referenced this pull request Mar 20, 2025
The scanf and fscanf implementations were moved into /generic, update
the bazel targets.
michaelrj-google added a commit that referenced this pull request Mar 21, 2025
The scanf and fscanf implementations were moved into /generic, update
the bazel targets.
@jplehr
Copy link
Contributor

jplehr commented Mar 21, 2025

This broke the libc on AMDGPU bot https://lab.llvm.org/buildbot/#/builders/10/builds/1791
@jhuber6 can you take a look at it, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants