Skip to content

[libc] Breakup freelist_malloc into separate files #119806

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 3 commits into from
Dec 16, 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.
@petrhosek
Copy link
Member Author

This is a reland of #98784.

@llvmbot
Copy link
Member

llvmbot commented Dec 13, 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/119806.diff

17 Files Affected:

  • (modified) libc/config/baremetal/aarch64/entrypoints.txt (-1)
  • (modified) libc/config/baremetal/arm/entrypoints.txt (-1)
  • (modified) libc/config/baremetal/riscv/entrypoints.txt (-1)
  • (modified) libc/fuzzing/__support/CMakeLists.txt (+1)
  • (added) libc/fuzzing/__support/fake_heap.s (+15)
  • (modified) libc/src/__support/CMakeLists.txt (+7-1)
  • (added) libc/src/__support/freelist_heap.cpp (+19)
  • (modified) libc/src/stdlib/CMakeLists.txt (+10-28)
  • (modified) libc/src/stdlib/baremetal/CMakeLists.txt (+50)
  • (renamed) libc/src/stdlib/baremetal/aligned_alloc.cpp (+1-22)
  • (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)
  • (modified) libc/test/src/__support/CMakeLists.txt (-2)
  • (modified) libc/test/src/__support/freelist_heap_test.cpp (+4)
  • (removed) libc/test/src/__support/freelist_malloc_test.cpp (-54)
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 71b49d98942916..694cd7b1993ca2 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -184,7 +184,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/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 71b49d98942916..694cd7b1993ca2 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -184,7 +184,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 e84d139d09dd8e..6dc5df830eb000 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/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/fuzzing/__support/CMakeLists.txt b/libc/fuzzing/__support/CMakeLists.txt
index 9d6589d78fb819..e24c4450fdd940 100644
--- a/libc/fuzzing/__support/CMakeLists.txt
+++ b/libc/fuzzing/__support/CMakeLists.txt
@@ -27,6 +27,7 @@ add_libc_fuzzer(
 add_libc_fuzzer(
   freelist_heap_fuzz
   SRCS
+    fake_heap.s
     freelist_heap_fuzz.cpp
   DEPENDS
     libc.src.__support.freelist_heap
diff --git a/libc/fuzzing/__support/fake_heap.s b/libc/fuzzing/__support/fake_heap.s
new file mode 100644
index 00000000000000..69522f53c8b1fd
--- /dev/null
+++ b/libc/fuzzing/__support/fake_heap.s
@@ -0,0 +1,15 @@
+//===-- Test fake definition for heap symbols -----------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+.globl _end, __llvm_libc_heap_limit
+
+.bss
+_end:
+.fill 1024
+__llvm_libc_heap_limit:
+
diff --git a/libc/src/__support/CMakeLists.txt b/libc/src/__support/CMakeLists.txt
index 8f85740f70a06e..70ed67c156d1ae 100644
--- a/libc/src/__support/CMakeLists.txt
+++ b/libc/src/__support/CMakeLists.txt
@@ -48,13 +48,19 @@ add_header_library(
     .freetrie
 )
 
-add_header_library(
+add_object_library(
   freelist_heap
+  SRCS
+    freelist_heap.cpp
   HDRS
     freelist_heap.h
+  COMPILE_OPTIONS
+    -DLIBC_FREELIST_MALLOC_SIZE=${LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE}
   DEPENDS
     .block
+    .freelist
     .freestore
+    .freetrie
     libc.src.__support.CPP.cstddef
     libc.src.__support.CPP.array
     libc.src.__support.CPP.optional
diff --git a/libc/src/__support/freelist_heap.cpp b/libc/src/__support/freelist_heap.cpp
new file mode 100644
index 00000000000000..4deb0e0f09e223
--- /dev/null
+++ b/libc/src/__support/freelist_heap.cpp
@@ -0,0 +1,19 @@
+//===-- 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.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/freelist_heap.h"
+#include "src/__support/macros/config.h"
+
+#include <stddef.h>
+
+namespace LIBC_NAMESPACE_DECL {
+
+static LIBC_CONSTINIT FreeListHeap freelist_heap_symbols;
+FreeListHeap *freelist_heap = &freelist_heap_symbols;
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/stdlib/CMakeLists.txt b/libc/src/stdlib/CMakeLists.txt
index 14d06534a6049a..40ba9ead9a7ae6 100644
--- a/libc/src/stdlib/CMakeLists.txt
+++ b/libc/src/stdlib/CMakeLists.txt
@@ -323,7 +323,7 @@ add_entrypoint_object(
     .rand_util
 )
 
-if(NOT LIBC_TARGET_OS_IS_GPU)
+if(NOT LIBC_TARGET_OS_IS_BAREMETAL AND NOT LIBC_TARGET_OS_IS_GPU)
   if(LLVM_LIBC_INCLUDE_SCUDO)
     set(SCUDO_DEPS "")
 
@@ -349,7 +349,7 @@ if(NOT LIBC_TARGET_OS_IS_GPU)
 
     list(APPEND SCUDO_DEPS RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
         RTScudoStandaloneCWrappers.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO})
-    
+
     if (COMPILER_RT_BUILD_GWP_ASAN)
       list(APPEND SCUDO_DEPS
         RTGwpAsan.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
@@ -389,32 +389,8 @@ if(NOT LIBC_TARGET_OS_IS_GPU)
         ${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
-    )
-    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
+      malloc
     )
     add_entrypoint_external(
       calloc
@@ -425,6 +401,12 @@ if(NOT LIBC_TARGET_OS_IS_GPU)
     add_entrypoint_external(
       aligned_alloc
     )
+    add_entrypoint_external(
+      free
+    )
+    add_entrypoint_external(
+      mallopt
+    )
   endif()
 endif()
 
@@ -513,7 +495,7 @@ if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
   add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
 endif()
 
-if(LIBC_TARGET_OS_IS_GPU)
+if(LIBC_TARGET_OS_IS_BAREMETAL OR LIBC_TARGET_OS_IS_GPU)
   add_entrypoint_object(
     malloc
     ALIAS
diff --git a/libc/src/stdlib/baremetal/CMakeLists.txt b/libc/src/stdlib/baremetal/CMakeLists.txt
index 551a83a36b20e8..67ab1979e4d104 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/freelist_malloc.cpp b/libc/src/stdlib/baremetal/aligned_alloc.cpp
similarity index 53%
rename from libc/src/stdlib/freelist_malloc.cpp
rename to libc/src/stdlib/baremetal/aligned_alloc.cpp
index fe56fad769378a..e9548719c3a63f 100644
--- a/libc/src/stdlib/freelist_malloc.cpp
+++ b/libc/src/stdlib/baremetal/aligned_alloc.cpp
@@ -6,35 +6,14 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "src/stdlib/aligned_alloc.h"
 #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>
 
 namespace LIBC_NAMESPACE_DECL {
 
-static LIBC_CONSTINIT FreeListHeap freelist_heap_symbols;
-FreeListHeap *freelist_heap = &freelist_heap_symbols;
-
-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);
 }
diff --git a/libc/src/stdlib/baremetal/calloc.cpp b/libc/src/stdlib/baremetal/calloc.cpp
new file mode 100644
index 00000000000000..2b3b83cebc8acc
--- /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/stdlib/calloc.h"
+#include "src/__support/freelist_heap.h"
+#include "src/__support/macros/config.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 00000000000000..1e25fe5f2dcfea
--- /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/stdlib/free.h"
+#include "src/__support/freelist_heap.h"
+#include "src/__support/macros/config.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 00000000000000..a299282667fcd5
--- /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/stdlib/malloc.h"
+#include "src/__support/freelist_heap.h"
+#include "src/__support/macros/config.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 00000000000000..fb25c68ec42964
--- /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/stdlib/realloc.h"
+#include "src/__support/freelist_heap.h"
+#include "src/__support/macros/config.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
diff --git a/libc/test/src/__support/CMakeLists.txt b/libc/test/src/__support/CMakeLists.txt
index bcc86effd9a52c..59bce9b96e3964 100644
--- a/libc/test/src/__support/CMakeLists.txt
+++ b/libc/test/src/__support/CMakeLists.txt
@@ -63,11 +63,9 @@ if(LLVM_LIBC_FULL_BUILD)
     SRCS
       fake_heap.s
       freelist_heap_test.cpp
-      freelist_malloc_test.cpp
     DEPENDS
       libc.src.__support.CPP.span
       libc.src.__support.freelist_heap
-      libc.src.stdlib.freelist_malloc
       libc.src.string.memcmp
       libc.src.string.memcpy
   )
diff --git a/libc/test/src/__support/freelist_heap_test.cpp b/libc/test/src/__support/freelist_heap_test.cpp
index 991c158825a888..07b9a09d77bba6 100644
--- a/libc/test/src/__support/freelist_heap_test.cpp
+++ b/libc/test/src/__support/freelist_heap_test.cpp
@@ -9,6 +9,10 @@
 #include "src/__support/CPP/span.h"
 #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/string/memcmp.h"
 #include "src/string/memcpy.h"
 #include "test/UnitTest/Test.h"
diff --git a/libc/test/src/__support/freelist_malloc_test.cpp b/libc/test/src/__support/freelist_malloc_test.cpp
deleted file mode 100644
index 793e2498304fb9..00000000000000
--- a/libc/test/src/__support/freelist_malloc_test.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-//===-- Unittests 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/stdlib/aligned_alloc.h"
-#include "src/stdlib/calloc.h"
-#include "src/stdlib/free.h"
-#include "src/stdlib/malloc.h"
-#include "test/UnitTest/Test.h"
-
-using LIBC_NAMESPACE::Block;
-using LIBC_NAMESPACE::freelist_heap;
-using LIBC_NAMESPACE::FreeListHeap;
-using LIBC_NAMESPACE::FreeListHeapBuffer;
-
-TEST(LlvmLibcFreeListMalloc, Malloc) {
-  constexpr size_t kAllocSize = 256;
-  constexpr size_t kCallocNum = 4;
-  constexpr size_t kCallocSize = 64;
-
-  void *ptr1 = LIBC_NAMESPACE::malloc(kAllocSize);
-  auto *block = Block::from_usable_space(ptr1);
-  EXPECT_GE(block->inner_size(), kAllocSize);
-
-  LIBC_NAMESPACE::free(ptr1);
-  ASSERT_NE(block->next(), static_cast<Block *>(nullptr));
-  ASSERT_EQ(block->next()->next(), static_cast<Block *>(nullptr));
-  size_t heap_size = block->inner_size();
-
-  void *ptr2 = LIBC_NAMESPACE::calloc(kCallocNum, kCallocSize);
-  ASSERT_EQ(ptr2, ptr1);
-  EXPECT_GE(block->inner_size(), kCallocNum * kCallocSize);
-
-  for (size_t i = 0; i < kCallocNum * kCallocSize; ++i)
-    EXPECT_EQ(reinterpret_cast<uint8_t *>(ptr2)[i], uint8_t(0));
-
-  LIBC_NAMESPACE::free(ptr2);
-  EXPECT_EQ(block->inner_size(), heap_size);
-
-  constexpr size_t ALIGN = kAllocSize;
-  void *ptr3 = LIBC_NAMESPACE::aligned_alloc(ALIGN, kAllocSize);
-  EXPECT_NE(ptr3, static_cast<void *>(nullptr));
-  EXPECT_EQ(reinterpret_cast<uintptr_t>(ptr3) % ALIGN, size_t(0));
-  auto *aligned_block = reinterpret_cast<Block *>(ptr3);
-  EXPECT_GE(aligned_block->inner_size(), kAllocSize);
-
-  LIBC_NAMESPACE::free(ptr3);
-  EXPECT_EQ(block->inner_size(), heap_size);
-}

@petrhosek petrhosek merged commit 7bf3137 into llvm:main Dec 16, 2024
11 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 16, 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/10422

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.strtoint64_test.__hermetic__.__build__.dir/strtoint64_test.cpp.o
[1607/2692] Linking CXX executable libc/test/integration/src/__support/GPU/libc.test.integration.src.__support.GPU.scan_reduce_test.__build__
[1608/2692] Linking CXX executable libc/test/integration/startup/gpu/libc.test.integration.startup.gpu.startup_rpc_stream_test.__build__
[1609/2692] Running integration test libc.test.integration.src.__support.GPU.scan_reduce_test
[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/libLibcFPTestHelpers.hermetic.a
[1614/2692] Linking CXX static library libc/test/UnitTest/libLibcMemoryHelpers.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/stdbit/libc.test.src.stdbit.stdc_leading_zeros_uc_test.__hermetic__.__build__
[1619/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.mutex_test.__hermetic__.__build__
[1620/2692] Linking CXX executable libc/test/src/stdbit/libc.test.src.stdbit.stdc_leading_zeros_us_test.__hermetic__.__build__
[1621/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.endian_internal_test.__hermetic__.__build__
[1622/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.span_test.__hermetic__.__build__
[1623/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.limits_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.bitset_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/src/__support/CPP/libc.test.src.__support.CPP.optional_test.__hermetic__.__build__
[1628/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.arg_list_test.__hermetic__.__build__
[1629/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.memory_size_test.__hermetic__.__build__
[1630/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.fixedvector_test.__hermetic__.__build__
[1631/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.atomic_test.__hermetic__.__build__
[1632/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.str_to_integer_test.__hermetic__.__build__
[1633/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.str_to_float_test.__hermetic__.__build__
[1634/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.char_vector_test.__hermetic__.__build__
[1635/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.stringstream_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/libc.test.src.__support.integer_literals_test.__hermetic__.__build__
[1638/2692] Linking CXX executable libc/test/src/__support/libc.test.src.__support.blockstore_test.__hermetic__.__build__
[1639/2692] Linking CXX executable libc/test/src/__support/CPP/libc.test.src.__support.CPP.array_test.__hermetic__.__build__
[1640/2692] Linking CXX executable libc/test/src/math/smoke/libc.test.src.math.smoke.remquof16_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.high_precision_decimal_test.__hermetic__.__build__
[1644/2692] Linking CXX executable libc/test/src/__support/FPUtil/libc.test.src.__support.FPUtil.fpbits_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__

@llvm-ci
Copy link
Collaborator

llvm-ci commented Dec 16, 2024

LLVM Buildbot has detected a new failure on builder premerge-monolithic-linux running on premerge-linux-1 while building libc at step 7 "test-build-unified-tree-check-all".

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

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
...
PASS: UBSan-AddressSanitizer-x86_64 :: TestCases/ImplicitConversion/signed-integer-truncation-ignorelist.c (92964 of 96986)
PASS: UBSan-Minimal-x86_64 :: TestCases/uadd-overflow.cpp (92965 of 96986)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/ImplicitConversion/signed-integer-truncation-or-sign-change-summary.cpp (92966 of 96986)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/ImplicitConversion/signed-integer-truncation-summary.cpp (92967 of 96986)
PASS: UBSan-MemorySanitizer-x86_64 :: TestCases/Misc/Posix/diag-stacktrace.cpp (92968 of 96986)
PASS: UBSan-MemorySanitizer-lld-x86_64 :: TestCases/TypeCheck/vptr.cpp (92969 of 96986)
PASS: UBSan-MemorySanitizer-x86_64 :: TestCases/TypeCheck/Function/function.cpp (92970 of 96986)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/ImplicitConversion/unsigned-integer-truncation-summary.cpp (92971 of 96986)
PASS: UBSan-Standalone-lld-x86_64 :: TestCases/Integer/bit-int-pass.c (92972 of 96986)
TIMEOUT: MLIR :: Examples/standalone/test.toy (92973 of 96986)
******************** TEST 'MLIR :: Examples/standalone/test.toy' FAILED ********************
Exit Code: 1
Timeout: Reached timeout of 60 seconds

Command Output (stdout):
--
# RUN: at line 1
"/etc/cmake/bin/cmake" "/build/buildbot/premerge-monolithic-linux/llvm-project/mlir/examples/standalone" -G "Ninja"  -DCMAKE_CXX_COMPILER=/usr/bin/clang++  -DCMAKE_C_COMPILER=/usr/bin/clang   -DLLVM_ENABLE_LIBCXX=OFF -DMLIR_DIR=/build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir  -DLLVM_USE_LINKER=lld  -DPython3_EXECUTABLE="/usr/bin/python3.10"
# executed command: /etc/cmake/bin/cmake /build/buildbot/premerge-monolithic-linux/llvm-project/mlir/examples/standalone -G Ninja -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -DCMAKE_C_COMPILER=/usr/bin/clang -DLLVM_ENABLE_LIBCXX=OFF -DMLIR_DIR=/build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir -DLLVM_USE_LINKER=lld -DPython3_EXECUTABLE=/usr/bin/python3.10
# .---command stdout------------
# | -- The CXX compiler identification is Clang 16.0.6
# | -- The C compiler identification is Clang 16.0.6
# | -- Detecting CXX compiler ABI info
# | -- Detecting CXX compiler ABI info - done
# | -- Check for working CXX compiler: /usr/bin/clang++ - skipped
# | -- Detecting CXX compile features
# | -- Detecting CXX compile features - done
# | -- Detecting C compiler ABI info
# | -- Detecting C compiler ABI info - done
# | -- Check for working C compiler: /usr/bin/clang - skipped
# | -- Detecting C compile features
# | -- Detecting C compile features - done
# | -- Looking for histedit.h
# | -- Looking for histedit.h - found
# | -- Found LibEdit: /usr/include (found version "2.11") 
# | -- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.11") 
# | -- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version "2.9.13") 
# | -- Using MLIRConfig.cmake in: /build/buildbot/premerge-monolithic-linux/build/lib/cmake/mlir
# | -- Using LLVMConfig.cmake in: /build/buildbot/premerge-monolithic-linux/build/lib/cmake/llvm
# | -- Linker detection: unknown
# | -- Performing Test LLVM_LIBSTDCXX_MIN
# | -- Performing Test LLVM_LIBSTDCXX_MIN - Success
# | -- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR
# | -- Performing Test LLVM_LIBSTDCXX_SOFT_ERROR - Success
# | -- Performing Test CXX_SUPPORTS_CUSTOM_LINKER
# | -- Performing Test CXX_SUPPORTS_CUSTOM_LINKER - Success
# | -- Performing Test C_SUPPORTS_FPIC
# | -- Performing Test C_SUPPORTS_FPIC - Success
# | -- Performing Test CXX_SUPPORTS_FPIC

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.

4 participants