Skip to content

[libc] Breakup freelist_malloc into separate files #98784

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 7 commits into from
Dec 12, 2024

Conversation

petrhosek
Copy link
Member

This better matches the structure we use for the rest of libc.

This better matches the structure we use for the rest of libc.
@llvmbot
Copy link
Member

llvmbot commented Jul 14, 2024

@llvm/pr-subscribers-libc

Author: Petr Hosek (petrhosek)

Changes

This better matches the structure we use for the rest of libc.


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

11 Files Affected:

  • (modified) libc/config/baremetal/arm/entrypoints.txt (-1)
  • (modified) libc/config/baremetal/riscv/entrypoints.txt (-1)
  • (modified) libc/src/__support/CMakeLists.txt (+6-1)
  • (renamed) libc/src/__support/freelist_heap.cpp (+1-24)
  • (modified) libc/src/stdlib/CMakeLists.txt (+84-92)
  • (modified) libc/src/stdlib/baremetal/CMakeLists.txt (+50)
  • (added) libc/src/stdlib/baremetal/aligned_alloc.cpp (+21)
  • (added) libc/src/stdlib/baremetal/calloc.cpp (+21)
  • (added) libc/src/stdlib/baremetal/free.cpp (+19)
  • (added) libc/src/stdlib/baremetal/malloc.cpp (+21)
  • (added) libc/src/stdlib/baremetal/realloc.cpp (+21)
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 90a4dab2decba..9734ed09b9039 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -180,7 +180,6 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.stdlib.div
     libc.src.stdlib.exit
     libc.src.stdlib.free
-    libc.src.stdlib.freelist_malloc
     libc.src.stdlib.labs
     libc.src.stdlib.ldiv
     libc.src.stdlib.llabs
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index e735dd157c6b2..3ce9c01e24d5e 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -176,7 +176,6 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.stdlib.div
     libc.src.stdlib.exit
     libc.src.stdlib.free
-    libc.src.stdlib.freelist_malloc
     libc.src.stdlib.labs
     libc.src.stdlib.ldiv
     libc.src.stdlib.llabs
diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt
index d8a192f1ffa57..27ed7fb47b99c 100644
--- a/libc/src/__support/CMakeLists.txt
+++ b/libc/src/__support/CMakeLists.txt
@@ -26,8 +26,10 @@ add_header_library(
     libc.src.__support.CPP.span
 )
 
-add_header_library(
+add_object_library(
   freelist_heap
+  SRCS
+    freelist_heap.cpp
   HDRS
     freelist_heap.h
   DEPENDS
@@ -40,6 +42,9 @@ add_header_library(
     libc.src.__support.libc_assert
     libc.src.string.memory_utils.inline_memcpy
     libc.src.string.memory_utils.inline_memset
+  COMPILE_OPTIONS
+    -DLIBC_FREELIST_MALLOC_SIZE=${LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE}
+
 )
 
 add_header_library(
diff --git a/libc/src/stdlib/freelist_malloc.cpp b/libc/src/__support/freelist_heap.cpp
similarity index 53%
rename from libc/src/stdlib/freelist_malloc.cpp
rename to libc/src/__support/freelist_heap.cpp
index cfffa0425ff66..6925d3c3c0eed 100644
--- a/libc/src/stdlib/freelist_malloc.cpp
+++ b/libc/src/__support/freelist_heap.cpp
@@ -1,4 +1,4 @@
-//===-- Implementation for freelist_malloc --------------------------------===//
+//===-- Implementation for freelist_heap ----------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -8,11 +8,6 @@
 
 #include "src/__support/freelist_heap.h"
 #include "src/__support/macros/config.h"
-#include "src/stdlib/aligned_alloc.h"
-#include "src/stdlib/calloc.h"
-#include "src/stdlib/free.h"
-#include "src/stdlib/malloc.h"
-#include "src/stdlib/realloc.h"
 
 #include <stddef.h>
 
@@ -30,22 +25,4 @@ LIBC_CONSTINIT FreeListHeapBuffer<SIZE> freelist_heap_buffer;
 
 FreeListHeap<> *freelist_heap = &freelist_heap_buffer;
 
-LLVM_LIBC_FUNCTION(void *, malloc, (size_t size)) {
-  return freelist_heap->allocate(size);
-}
-
-LLVM_LIBC_FUNCTION(void, free, (void *ptr)) { return freelist_heap->free(ptr); }
-
-LLVM_LIBC_FUNCTION(void *, calloc, (size_t num, size_t size)) {
-  return freelist_heap->calloc(num, size);
-}
-
-LLVM_LIBC_FUNCTION(void *, realloc, (void *ptr, size_t size)) {
-  return freelist_heap->realloc(ptr, size);
-}
-
-LLVM_LIBC_FUNCTION(void *, aligned_alloc, (size_t alignment, size_t size)) {
-  return freelist_heap->aligned_allocate(alignment, size);
-}
-
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index 7b7e55db391fa..3fc385d2351cb 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -318,99 +318,58 @@ add_entrypoint_object(
     libc.include.stdlib
 )
 
-if(NOT LIBC_TARGET_OS_IS_GPU)
-  if(LLVM_LIBC_INCLUDE_SCUDO)
-    set(SCUDO_DEPS "")
-
-    include(${LIBC_SOURCE_DIR}/../compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake)
-
-    # scudo distinguishes riscv32 and riscv64, so we need to translate the architecture
-    set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})
-    if(LIBC_TARGET_ARCHITECTURE_IS_RISCV64)
-      set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv64)
-    elseif(LIBC_TARGET_ARCHITECTURE_IS_RISCV32)
-      set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv32)
-    endif()
-
-    if(NOT (LIBC_TARGET_ARCHITECTURE_FOR_SCUDO IN_LIST ALL_SCUDO_STANDALONE_SUPPORTED_ARCH))
-      message(FATAL_ERROR "Architecture ${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO} is not supported by SCUDO.
-        Either disable LLVM_LIBC_INCLUDE_SCUDO or change your target architecture.")
-    endif()
-
-    list(APPEND SCUDO_DEPS RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
-        RTScudoStandaloneCWrappers.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO})
-
-    list(APPEND SCUDO_DEPS
-      RTGwpAsan.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
-      RTGwpAsanBacktraceLibc.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
-      RTGwpAsanSegvHandler.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
-      )
-
-    add_entrypoint_external(
-      malloc
-      DEPENDS
-        ${SCUDO_DEPS}
-    )
-    add_entrypoint_external(
-      calloc
-      DEPENDS
-        ${SCUDO_DEPS}
-    )
-    add_entrypoint_external(
-      realloc
-      DEPENDS
-        ${SCUDO_DEPS}
-    )
-    add_entrypoint_external(
-      aligned_alloc
-      DEPENDS
-        ${SCUDO_DEPS}
-    )
-    add_entrypoint_external(
-      free
-      DEPENDS
-        ${SCUDO_DEPS}
-    )
-  else()
-    # Only use freelist malloc for baremetal targets.
-    add_entrypoint_object(
-      freelist_malloc
-      SRCS
-        freelist_malloc.cpp
-      HDRS
-        malloc.h
-      DEPENDS
-        libc.src.__support.freelist_heap
-      COMPILE_OPTIONS
-        -DLIBC_FREELIST_MALLOC_SIZE=${LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE}
-    )
-    get_target_property(freelist_malloc_is_skipped libc.src.stdlib.freelist_malloc "SKIPPED")
-    if(LIBC_TARGET_OS_IS_BAREMETAL AND NOT freelist_malloc_is_skipped)
-      add_entrypoint_object(
-        malloc
-        ALIAS
-        DEPENDS
-          .freelist_malloc
-      )
-    else()
-      add_entrypoint_external(
-        malloc
-      )
-    endif()
-
-    add_entrypoint_external(
-      free
-    )
-    add_entrypoint_external(
-      calloc
-    )
-    add_entrypoint_external(
-      realloc
-    )
-    add_entrypoint_external(
-      aligned_alloc
-    )
+if(LLVM_LIBC_INCLUDE_SCUDO)
+  set(SCUDO_DEPS "")
+
+  include(${LIBC_SOURCE_DIR}/../compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake)
+
+  # scudo distinguishes riscv32 and riscv64, so we need to translate the architecture
+  set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})
+  if(LIBC_TARGET_ARCHITECTURE_IS_RISCV64)
+    set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv64)
+  elseif(LIBC_TARGET_ARCHITECTURE_IS_RISCV32)
+    set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv32)
+  endif()
+
+  if(NOT (LIBC_TARGET_ARCHITECTURE_FOR_SCUDO IN_LIST ALL_SCUDO_STANDALONE_SUPPORTED_ARCH))
+    message(FATAL_ERROR "Architecture ${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO} is not supported by SCUDO.
+      Either disable LLVM_LIBC_INCLUDE_SCUDO or change your target architecture.")
   endif()
+
+  list(APPEND SCUDO_DEPS RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
+      RTScudoStandaloneCWrappers.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO})
+
+  list(APPEND SCUDO_DEPS
+    RTGwpAsan.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
+    RTGwpAsanBacktraceLibc.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
+    RTGwpAsanSegvHandler.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
+    )
+
+  add_entrypoint_external(
+    malloc
+    DEPENDS
+      ${SCUDO_DEPS}
+  )
+  add_entrypoint_external(
+    calloc
+    DEPENDS
+      ${SCUDO_DEPS}
+  )
+  add_entrypoint_external(
+    realloc
+    DEPENDS
+      ${SCUDO_DEPS}
+  )
+  add_entrypoint_external(
+    aligned_alloc
+    DEPENDS
+      ${SCUDO_DEPS}
+  )
+  add_entrypoint_external(
+    free
+    DEPENDS
+      ${SCUDO_DEPS}
+  )
 endif()
 
 if(NOT LLVM_LIBC_FULL_BUILD)
@@ -421,6 +380,39 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
   add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
 endif()
 
+if(LIBC_TARGET_OS_IS_BAREMETAL)
+  add_entrypoint_object(
+    malloc
+    ALIAS
+    DEPENDS
+      .${LIBC_TARGET_OS}.malloc
+  )
+  add_entrypoint_object(
+    free
+    ALIAS
+    DEPENDS
+      .${LIBC_TARGET_OS}.free
+  )
+  add_entrypoint_object(
+    calloc
+    ALIAS
+    DEPENDS
+      .${LIBC_TARGET_OS}.calloc
+  )
+  add_entrypoint_object(
+    realloc
+    ALIAS
+    DEPENDS
+      .${LIBC_TARGET_OS}.realloc
+  )
+  add_entrypoint_object(
+    aligned_alloc
+    ALIAS
+    DEPENDS
+      .${LIBC_TARGET_OS}.aligned_alloc
+  )
+endif()
+
 if(LIBC_TARGET_OS_IS_GPU)
   add_entrypoint_object(
     malloc
diff --git a/libc/src/stdlib/baremetal/CMakeLists.txt b/libc/src/stdlib/baremetal/CMakeLists.txt
index 551a83a36b20e..67ab1979e4d10 100644
--- a/libc/src/stdlib/baremetal/CMakeLists.txt
+++ b/libc/src/stdlib/baremetal/CMakeLists.txt
@@ -5,3 +5,53 @@ add_entrypoint_object(
   HDRS
     ../abort.h
 )
+
+add_entrypoint_object(
+  malloc
+  SRCS
+    malloc.cpp
+  HDRS
+    ../malloc.h
+  DEPENDS
+    libc.src.__support.freelist_heap
+)
+
+add_entrypoint_object(
+  free
+  SRCS
+    free.cpp
+  HDRS
+    ../free.h
+  DEPENDS
+    libc.src.__support.freelist_heap
+)
+
+add_entrypoint_object(
+  calloc
+  SRCS
+    calloc.cpp
+  HDRS
+    ../calloc.h
+  DEPENDS
+    libc.src.__support.freelist_heap
+)
+
+add_entrypoint_object(
+  realloc
+  SRCS
+    realloc.cpp
+  HDRS
+    ../realloc.h
+  DEPENDS
+    libc.src.__support.freelist_heap
+)
+
+add_entrypoint_object(
+  aligned_alloc
+  SRCS
+    aligned_alloc.cpp
+  HDRS
+    ../aligned_alloc.h
+  DEPENDS
+    libc.src.__support.freelist_heap
+)
diff --git a/libc/src/stdlib/baremetal/aligned_alloc.cpp b/libc/src/stdlib/baremetal/aligned_alloc.cpp
new file mode 100644
index 0000000000000..4594bf32dc1b1
--- /dev/null
+++ b/libc/src/stdlib/baremetal/aligned_alloc.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation for freelist_malloc --------------------------------===//
+//
+// 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/freelist_heap.h"
+#include "src/__support/macros/config.h"
+#include "src/stdlib/aligned_alloc.h"
+
+#include <stddef.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(void *, aligned_alloc, (size_t alignment, size_t size)) {
+  return freelist_heap->aligned_allocate(alignment, size);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdlib/baremetal/calloc.cpp b/libc/src/stdlib/baremetal/calloc.cpp
new file mode 100644
index 0000000000000..c24caa2a180eb
--- /dev/null
+++ b/libc/src/stdlib/baremetal/calloc.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation for freelist_malloc --------------------------------===//
+//
+// 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/freelist_heap.h"
+#include "src/__support/macros/config.h"
+#include "src/stdlib/calloc.h"
+
+#include <stddef.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(void *, calloc, (size_t num, size_t size)) {
+  return freelist_heap->calloc(num, size);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdlib/baremetal/free.cpp b/libc/src/stdlib/baremetal/free.cpp
new file mode 100644
index 0000000000000..5be5f72491e04
--- /dev/null
+++ b/libc/src/stdlib/baremetal/free.cpp
@@ -0,0 +1,19 @@
+//===-- Implementation for freelist_malloc --------------------------------===//
+//
+// 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/freelist_heap.h"
+#include "src/__support/macros/config.h"
+#include "src/stdlib/free.h"
+
+#include <stddef.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(void, free, (void *ptr)) { return freelist_heap->free(ptr); }
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdlib/baremetal/malloc.cpp b/libc/src/stdlib/baremetal/malloc.cpp
new file mode 100644
index 0000000000000..2d64c250ed15d
--- /dev/null
+++ b/libc/src/stdlib/baremetal/malloc.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation for freelist_malloc --------------------------------===//
+//
+// 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/freelist_heap.h"
+#include "src/__support/macros/config.h"
+#include "src/stdlib/malloc.h"
+
+#include <stddef.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(void *, malloc, (size_t size)) {
+  return freelist_heap->allocate(size);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdlib/baremetal/realloc.cpp b/libc/src/stdlib/baremetal/realloc.cpp
new file mode 100644
index 0000000000000..f3957e94d7d16
--- /dev/null
+++ b/libc/src/stdlib/baremetal/realloc.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation for freelist_malloc --------------------------------===//
+//
+// 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/freelist_heap.h"
+#include "src/__support/macros/config.h"
+#include "src/stdlib/realloc.h"
+
+#include <stddef.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(void *, realloc, (void *ptr, size_t size)) {
+  return freelist_heap->realloc(ptr, size);
+}
+
+} // namespace LIBC_NAMESPACE_DECL

Copy link

github-actions bot commented Jul 14, 2024

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

Copy link
Contributor

@PiJoules PiJoules left a comment

Choose a reason for hiding this comment

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

LGTM

I think the build failure is from the targets being under if(LLVM_LIBC_INCLUDE_SCUDO) which I think should be false here.

@nickdesaulniers
Copy link
Member

Has merge conflicts.

@SchrodingerZhu
Copy link
Contributor

see also #119259

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, thanks for the cleanup

@SchrodingerZhu
Copy link
Contributor

@lntue this seems to be a better clean up

libc.src.__support.CPP.cstddef
libc.src.__support.CPP.array
libc.src.__support.CPP.optional
libc.src.__support.CPP.span
libc.src.__support.libc_assert
libc.src.string.memory_utils.inline_memcpy
libc.src.string.memory_utils.inline_memset
COMPILE_OPTIONS
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can you move the COMPILE_OPTIONS part to above DEPENDS?

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.

There should be a separate test for each function.
@petrhosek petrhosek merged commit 4e2a9e5 into llvm:main Dec 12, 2024
11 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 12, 2024

LLVM Buildbot has detected a new failure on builder libc-x86_64-debian-dbg-asan running on libc-x86_64-debian while building libc at step 4 "annotate".

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

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[       OK ] LlvmLibcStrtouint32Test.CleanBaseSixteenDecode (9 us)
[ RUN      ] LlvmLibcStrtouint32Test.MessyBaseSixteenDecode
[       OK ] LlvmLibcStrtouint32Test.MessyBaseSixteenDecode (4 us)
[ RUN      ] LlvmLibcStrtouint32Test.AutomaticBaseSelection
[       OK ] LlvmLibcStrtouint32Test.AutomaticBaseSelection (4 us)
Ran 14 tests.  PASS: 14  FAIL: 0
@@@BUILD_STEP libc-fuzzer@@@
Running: ninja libc-fuzzer
[1/2] Building CXX object projects/libc/src/__support/CMakeFiles/libc.src.__support.freelist_heap.dir/freelist_heap.cpp.o
[2/2] Linking CXX executable projects/libc/fuzzing/__support/libc.fuzzing.__support.freelist_heap_fuzz
FAILED: projects/libc/fuzzing/__support/libc.fuzzing.__support.freelist_heap_fuzz 
: && /usr/bin/clang++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fno-omit-frame-pointer -O1 -fsanitize=address -fdiagnostics-color -fsanitize=fuzzer -g  projects/libc/fuzzing/__support/CMakeFiles/libc.fuzzing.__support.freelist_heap_fuzz.dir/freelist_heap_fuzz.cpp.o -o projects/libc/fuzzing/__support/libc.fuzzing.__support.freelist_heap_fuzz  projects/libc/src/__support/CPP/CMakeFiles/libc.src.__support.CPP.new.dir/./new.cpp.o  projects/libc/src/__support/CMakeFiles/libc.src.__support.freelist.dir/./freelist.cpp.o  projects/libc/src/__support/CMakeFiles/libc.src.__support.freetrie.dir/./freetrie.cpp.o  projects/libc/src/errno/CMakeFiles/libc.src.errno.errno.__internal__.dir/./libc_errno.cpp.o  projects/libc/src/__support/OSUtil/linux/CMakeFiles/libc.src.__support.OSUtil.linux.linux_util.dir/./exit.cpp.o  projects/libc/src/__support/OSUtil/linux/CMakeFiles/libc.src.__support.OSUtil.linux.linux_util.dir/./fcntl.cpp.o  projects/libc/src/__support/CMakeFiles/libc.src.__support.freelist_heap.dir/./freelist_heap.cpp.o && :
/usr/bin/ld: projects/libc/src/__support/CMakeFiles/libc.src.__support.freelist_heap.dir/./freelist_heap.cpp.o:(.data+0x8): undefined reference to `__llvm_libc_heap_limit'
/usr/bin/ld: projects/libc/fuzzing/__support/libc.fuzzing.__support.freelist_heap_fuzz: hidden symbol `__llvm_libc_heap_limit' isn't defined
/usr/bin/ld: final link failed: bad value
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
['ninja', 'libc-fuzzer'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 164, in step
    yield
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 155, in main
    run_command(['ninja', 'libc-fuzzer'])
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 179, in run_command
    util.report_run_cmd(cmd, cwd=directory)
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian-dbg-asan/llvm-zorg/zorg/buildbot/builders/annotated/util.py", line 49, in report_run_cmd
    subprocess.check_call(cmd, shell=shell, *args, **kwargs)
  File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ninja', 'libc-fuzzer']' returned non-zero exit status 1.
@@@STEP_FAILURE@@@

@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 12, 2024

LLVM Buildbot has detected a new failure on builder libc-x86_64-debian running on libc-x86_64-debian while building libc at step 4 "annotate".

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

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[       OK ] LlvmLibcRoundToIntegerTest.InfinityAndNaN (4 us)
[ RUN      ] LlvmLibcRoundToIntegerTest.RoundNumbers
[       OK ] LlvmLibcRoundToIntegerTest.RoundNumbers (6 us)
[ RUN      ] LlvmLibcRoundToIntegerTest.SubnormalRange
[       OK ] LlvmLibcRoundToIntegerTest.SubnormalRange (884 ms)
Ran 3 tests.  PASS: 3  FAIL: 0
@@@BUILD_STEP libc-fuzzer@@@
Running: ninja libc-fuzzer
[1/2] Building CXX object projects/libc/src/__support/CMakeFiles/libc.src.__support.freelist_heap.dir/freelist_heap.cpp.o
[2/2] Linking CXX executable projects/libc/fuzzing/__support/libc.fuzzing.__support.freelist_heap_fuzz
FAILED: projects/libc/fuzzing/__support/libc.fuzzing.__support.freelist_heap_fuzz 
: && /usr/bin/clang++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fsanitize=fuzzer -O3 -DNDEBUG  projects/libc/fuzzing/__support/CMakeFiles/libc.fuzzing.__support.freelist_heap_fuzz.dir/freelist_heap_fuzz.cpp.o -o projects/libc/fuzzing/__support/libc.fuzzing.__support.freelist_heap_fuzz  projects/libc/src/__support/CPP/CMakeFiles/libc.src.__support.CPP.new.dir/./new.cpp.o  projects/libc/src/__support/CMakeFiles/libc.src.__support.freelist.dir/./freelist.cpp.o  projects/libc/src/__support/CMakeFiles/libc.src.__support.freetrie.dir/./freetrie.cpp.o  projects/libc/src/errno/CMakeFiles/libc.src.errno.errno.__internal__.dir/./libc_errno.cpp.o  projects/libc/src/__support/OSUtil/linux/CMakeFiles/libc.src.__support.OSUtil.linux.linux_util.dir/./exit.cpp.o  projects/libc/src/__support/OSUtil/linux/CMakeFiles/libc.src.__support.OSUtil.linux.linux_util.dir/./fcntl.cpp.o  projects/libc/src/__support/CMakeFiles/libc.src.__support.freelist_heap.dir/./freelist_heap.cpp.o && :
/usr/bin/ld: projects/libc/src/__support/CMakeFiles/libc.src.__support.freelist_heap.dir/./freelist_heap.cpp.o:(.data._ZN22__llvm_libc_20_0_0_gitL21freelist_heap_symbolsE+0x8): undefined reference to `__llvm_libc_heap_limit'
/usr/bin/ld: projects/libc/fuzzing/__support/libc.fuzzing.__support.freelist_heap_fuzz: hidden symbol `__llvm_libc_heap_limit' isn't defined
/usr/bin/ld: final link failed: bad value
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
['ninja', 'libc-fuzzer'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 164, in step
    yield
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 155, in main
    run_command(['ninja', 'libc-fuzzer'])
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 179, in run_command
    util.report_run_cmd(cmd, cwd=directory)
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian/llvm-zorg/zorg/buildbot/builders/annotated/util.py", line 49, in report_run_cmd
    subprocess.check_call(cmd, shell=shell, *args, **kwargs)
  File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ninja', 'libc-fuzzer']' returned non-zero exit status 1.
@@@STEP_FAILURE@@@

@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 12, 2024

LLVM Buildbot has detected a new failure on builder libc-x86_64-debian-dbg running on libc-x86_64-debian while building libc at step 4 "annotate".

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

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[       OK ] LlvmLibcStrtouint32Test.CleanBaseSixteenDecode (8 us)
[ RUN      ] LlvmLibcStrtouint32Test.MessyBaseSixteenDecode
[       OK ] LlvmLibcStrtouint32Test.MessyBaseSixteenDecode (3 us)
[ RUN      ] LlvmLibcStrtouint32Test.AutomaticBaseSelection
[       OK ] LlvmLibcStrtouint32Test.AutomaticBaseSelection (4 us)
Ran 14 tests.  PASS: 14  FAIL: 0
@@@BUILD_STEP libc-fuzzer@@@
Running: ninja libc-fuzzer
[1/2] Building CXX object projects/libc/src/__support/CMakeFiles/libc.src.__support.freelist_heap.dir/freelist_heap.cpp.o
[2/2] Linking CXX executable projects/libc/fuzzing/__support/libc.fuzzing.__support.freelist_heap_fuzz
FAILED: projects/libc/fuzzing/__support/libc.fuzzing.__support.freelist_heap_fuzz 
: && /usr/bin/clang++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -fsanitize=fuzzer -g  projects/libc/fuzzing/__support/CMakeFiles/libc.fuzzing.__support.freelist_heap_fuzz.dir/freelist_heap_fuzz.cpp.o -o projects/libc/fuzzing/__support/libc.fuzzing.__support.freelist_heap_fuzz  projects/libc/src/__support/CPP/CMakeFiles/libc.src.__support.CPP.new.dir/./new.cpp.o  projects/libc/src/__support/CMakeFiles/libc.src.__support.freelist.dir/./freelist.cpp.o  projects/libc/src/__support/CMakeFiles/libc.src.__support.freetrie.dir/./freetrie.cpp.o  projects/libc/src/errno/CMakeFiles/libc.src.errno.errno.__internal__.dir/./libc_errno.cpp.o  projects/libc/src/__support/OSUtil/linux/CMakeFiles/libc.src.__support.OSUtil.linux.linux_util.dir/./exit.cpp.o  projects/libc/src/__support/OSUtil/linux/CMakeFiles/libc.src.__support.OSUtil.linux.linux_util.dir/./fcntl.cpp.o  projects/libc/src/__support/CMakeFiles/libc.src.__support.freelist_heap.dir/./freelist_heap.cpp.o && :
/usr/bin/ld: projects/libc/src/__support/CMakeFiles/libc.src.__support.freelist_heap.dir/./freelist_heap.cpp.o:(.data+0x8): undefined reference to `__llvm_libc_heap_limit'
/usr/bin/ld: projects/libc/fuzzing/__support/libc.fuzzing.__support.freelist_heap_fuzz: hidden symbol `__llvm_libc_heap_limit' isn't defined
/usr/bin/ld: final link failed: bad value
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
['ninja', 'libc-fuzzer'] exited with return code 1.
The build step threw an exception...
Traceback (most recent call last):
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 164, in step
    yield
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 155, in main
    run_command(['ninja', 'libc-fuzzer'])
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian-dbg/build/../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py", line 179, in run_command
    util.report_run_cmd(cmd, cwd=directory)
  File "/home/llvm-libc-buildbot/home/sivachandra/libc-x86_64-debian/libc-x86_64-debian-dbg/llvm-zorg/zorg/buildbot/builders/annotated/util.py", line 49, in report_run_cmd
    subprocess.check_call(cmd, shell=shell, *args, **kwargs)
  File "/usr/lib/python3.11/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['ninja', 'libc-fuzzer']' returned non-zero exit status 1.
@@@STEP_FAILURE@@@

@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 13, 2024

LLVM Buildbot has detected a new failure on builder openmp-offload-libc-amdgpu-runtime running on omp-vega20-1 while building libc at step 8 "Add check check-libc-amdgcn-amd-amdhsa".

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

Here is the relevant piece of the build log for the reference
Step 8 (Add check check-libc-amdgcn-amd-amdhsa) failure: test (failure)
...
[1606/2692] Building CXX object libc/test/src/stdlib/CMakeFiles/libc.test.src.stdlib.strtoint32_test.__hermetic__.__build__.dir/strtoint32_test.cpp.o
[1607/2692] Running integration test libc.test.integration.src.__support.GPU.scan_reduce_test
[1608/2692] Running integration test libc.test.integration.startup.gpu.startup_rpc_interface_test
[1609/2692] Linking CXX executable libc/test/integration/startup/gpu/libc.test.integration.startup.gpu.startup_rpc_stream_test.__build__
[1610/2692] Running integration test libc.test.integration.startup.gpu.startup_rpc_stream_test
[1611/2692] Building CXX object libc/test/UnitTest/CMakeFiles/LibcTest.hermetic.dir/LibcTest.cpp.o
[1612/2692] Linking CXX static library libc/test/UnitTest/libLibcTest.hermetic.a
[1613/2692] Linking CXX static library libc/test/UnitTest/libLibcMemoryHelpers.hermetic.a
[1614/2692] Linking CXX static library libc/test/UnitTest/libLibcFPTestHelpers.hermetic.a
[1615/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.freelist_heap_test.__hermetic__.__build__
FAILED: libc/test/src/__support/libc.test.src.__support.freelist_heap_test.__hermetic__.__build__ 
: && /home/ompworker/bbot/openmp-offload-libc-amdgpu-runtime/llvm.build/./bin/clang++ --target=amdgcn-amd-amdhsa -O3 -DNDEBUG --target=amdgcn-amd-amdhsa -Wno-multi-gpu -mcpu=gfx906 -flto -Wl,-mllvm,-amdgpu-lower-global-ctor-dtor=0 -nostdlib -static -Wl,-mllvm,-amdhsa-code-object-version=5 libc/startup/gpu/amdgpu/CMakeFiles/libc.startup.gpu.amdgpu.crt1.dir/start.cpp.o libc/test/src/__support/CMakeFiles/libc.test.src.__support.freelist_heap_test.__hermetic__.__build__.dir/fake_heap.s.o libc/test/src/__support/CMakeFiles/libc.test.src.__support.freelist_heap_test.__hermetic__.__build__.dir/freelist_heap_test.cpp.o -o libc/test/src/__support/libc.test.src.__support.freelist_heap_test.__hermetic__.__build__  libc/test/UnitTest/libLibcTest.hermetic.a  libc/test/UnitTest/libLibcHermeticTestSupport.hermetic.a  libc/test/src/__support/liblibc.test.src.__support.freelist_heap_test.__hermetic__.libc.a && :
ld.lld: error: duplicate symbol: _end
>>> defined in libc/startup/gpu/amdgpu/CMakeFiles/libc.startup.gpu.amdgpu.crt1.dir/start.cpp.o
>>> defined in libc/test/src/__support/CMakeFiles/libc.test.src.__support.freelist_heap_test.__hermetic__.__build__.dir/fake_heap.s.o
clang++: error: ld.lld command failed with exit code 1 (use -v to see invocation)
[1616/2692] Linking CXX executable libc/test/integration/src/stdio/gpu/libc.test.integration.src.stdio.gpu.printf_test.__build__
[1617/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.cstddef_test.__hermetic__.__build__
[1618/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.mutex_test.__hermetic__.__build__
[1619/2692] Linking CXX executable libc/test/include/libc.test.include.stdckdint_test.__hermetic__.__build__
[1620/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.limits_test.__hermetic__.__build__
[1621/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.span_test.__hermetic__.__build__
[1622/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.endian_internal_test.__hermetic__.__build__
[1623/2692] Linking CXX executable libc/test/src/stdbit/libc.test.src.stdbit.stdc_leading_zeros_uc_test.__hermetic__.__build__
[1624/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.int_seq_test.__hermetic__.__build__
[1625/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.optional_test.__hermetic__.__build__
[1626/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.algorithm_test.__hermetic__.__build__
[1627/2692] Linking CXX executable libc/test/include/libc.test.include.issubnormal_test.__hermetic__.__build__
[1628/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.bitset_test.__hermetic__.__build__
[1629/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.type_traits_test.__hermetic__.__build__
[1630/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.memory_size_test.__hermetic__.__build__
[1631/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.char_vector_test.__hermetic__.__build__
[1632/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.arg_list_test.__hermetic__.__build__
[1633/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.fixedvector_test.__hermetic__.__build__
[1634/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.atomic_test.__hermetic__.__build__
[1635/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.str_to_float_test.__hermetic__.__build__
[1636/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.math_extras_test.__hermetic__.__build__
[1637/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.array_test.__hermetic__.__build__
[1638/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.str_to_integer_test.__hermetic__.__build__
[1639/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.stringstream_test.__hermetic__.__build__
[1640/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.blockstore_test.__hermetic__.__build__
[1641/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.stringview_test.__hermetic__.__build__
[1642/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.bit_test.__hermetic__.__build__
[1643/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.integer_literals_test.__hermetic__.__build__
[1644/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.high_precision_decimal_test.__hermetic__.__build__
[1645/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.string_test.__hermetic__.__build__
[1646/2692] Linking CXX executable libc/test/src/math/smoke/libc.test.src.math.smoke.fmaximum_mag_numf_test.__hermetic__.__build__
[1647/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.big_int_test.__hermetic__.__build__
[1648/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.integer_to_string_test.__hermetic__.__build__

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.

8 participants