Skip to content

[libc] Implement search/lsearch #131431

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 4 commits into from
Mar 19, 2025
Merged

[libc] Implement search/lsearch #131431

merged 4 commits into from
Mar 19, 2025

Conversation

c8ef
Copy link
Contributor

@c8ef c8ef commented Mar 15, 2025

@c8ef c8ef marked this pull request as ready for review March 15, 2025 05:46
@llvmbot llvmbot added the libc label Mar 15, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 15, 2025

@llvm/pr-subscribers-libc

Author: Connector Switch (c8ef)

Changes

ref:


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

9 Files Affected:

  • (modified) libc/config/linux/aarch64/entrypoints.txt (+1)
  • (modified) libc/config/linux/x86_64/entrypoints.txt (+1)
  • (modified) libc/include/search.yaml (+10)
  • (modified) libc/src/search/CMakeLists.txt (+13)
  • (modified) libc/src/search/lfind.cpp (+1-1)
  • (added) libc/src/search/lsearch.cpp (+39)
  • (added) libc/src/search/lsearch.h (+20)
  • (modified) libc/test/src/search/CMakeLists.txt (+10)
  • (added) libc/test/src/search/lsearch_test.cpp (+48)
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index ab1917259519b..c1e688ea7e86b 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -999,6 +999,7 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.search.hsearch_r
     libc.src.search.insque
     libc.src.search.lfind
+    libc.src.search.lsearch
     libc.src.search.remque
 
     # threads.h entrypoints
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index a29478898fe70..3cb9ee82752b3 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -1113,6 +1113,7 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.search.hsearch_r
     libc.src.search.insque
     libc.src.search.lfind
+    libc.src.search.lsearch
     libc.src.search.remque
 
     # threads.h entrypoints
diff --git a/libc/include/search.yaml b/libc/include/search.yaml
index b7ce06d48e704..f6f5d6cb062e5 100644
--- a/libc/include/search.yaml
+++ b/libc/include/search.yaml
@@ -69,3 +69,13 @@ functions:
       - type: size_t *
       - type: size_t
       - type: __lsearchcompare_t
+  - name: lsearch
+    standards:
+      - POSIX
+    return_type: void *
+    arguments:
+      - type: const void *
+      - type: void *
+      - type: size_t *
+      - type: size_t
+      - type: __lsearchcompare_t
diff --git a/libc/src/search/CMakeLists.txt b/libc/src/search/CMakeLists.txt
index 497657f40f2f0..d78ea062342a1 100644
--- a/libc/src/search/CMakeLists.txt
+++ b/libc/src/search/CMakeLists.txt
@@ -110,3 +110,16 @@ add_entrypoint_object(
     libc.src.__support.CPP.cstddef
     libc.src.__support.memory_size
 )
+
+add_entrypoint_object(
+  lsearch
+  SRCS
+    lsearch.cpp
+  HDRS
+    lsearch.h
+  DEPENDS
+    libc.include.search
+    libc.src.__support.CPP.cstddef
+    libc.src.__support.memory_size
+    libc.src.string.memory_utils.inline_memcpy
+)
diff --git a/libc/src/search/lfind.cpp b/libc/src/search/lfind.cpp
index c8bf07de0b903..b10065aef2a93 100644
--- a/libc/src/search/lfind.cpp
+++ b/libc/src/search/lfind.cpp
@@ -1,4 +1,4 @@
-//===-- Implementation of lfind   -------------------------------*- C++ -*-===//
+//===-- Implementation of lfind ---------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
diff --git a/libc/src/search/lsearch.cpp b/libc/src/search/lsearch.cpp
new file mode 100644
index 0000000000000..e28dc3488413d
--- /dev/null
+++ b/libc/src/search/lsearch.cpp
@@ -0,0 +1,39 @@
+//===-- Implementation of lsearch -------------------------------*- 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/search/lsearch.h"
+#include "src/__support/CPP/cstddef.h" // cpp::byte
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/memory_size.h"
+#include "src/string/memory_utils/inline_memcpy.h"
+
+namespace LIBC_NAMESPACE_DECL {
+LLVM_LIBC_FUNCTION(void *, lsearch,
+                   (const void *key, void *base, size_t *nmemb, size_t size,
+                    int (*compar)(const void *, const void *))) {
+  if (key == nullptr || base == nullptr || nmemb == nullptr ||
+      compar == nullptr)
+    return nullptr;
+
+  size_t byte_len = 0;
+  if (internal::mul_overflow(*nmemb, size, &byte_len))
+    return nullptr;
+
+  const cpp::byte *next = reinterpret_cast<const cpp::byte *>(base);
+  const cpp::byte *end = next + byte_len;
+  for (; next < end; next += size)
+    if (compar(key, next) == 0)
+      return const_cast<cpp::byte *>(next);
+
+  *nmemb += 1;
+  inline_memcpy(const_cast<cpp::byte *>(end), key, size);
+  return const_cast<cpp::byte *>(end);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/search/lsearch.h b/libc/src/search/lsearch.h
new file mode 100644
index 0000000000000..c95e01d396cd0
--- /dev/null
+++ b/libc/src/search/lsearch.h
@@ -0,0 +1,20 @@
+//===-- Implementation header for lsearch -----------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_SEARCH_LSEARCH_H
+#define LLVM_LIBC_SRC_SEARCH_LSEARCH_H
+
+#include "src/__support/macros/config.h"
+#include <stddef.h> // size_t
+
+namespace LIBC_NAMESPACE_DECL {
+void *lsearch(const void *key, void *base, size_t *nmemb, size_t size,
+              int (*compar)(const void *, const void *));
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_SEARCH_LSEARCH_H
diff --git a/libc/test/src/search/CMakeLists.txt b/libc/test/src/search/CMakeLists.txt
index a1f9aac2094c9..9f34d4d3fd259 100644
--- a/libc/test/src/search/CMakeLists.txt
+++ b/libc/test/src/search/CMakeLists.txt
@@ -35,3 +35,13 @@ add_libc_unittest(
   DEPENDS
     libc.src.search.lfind
 )
+
+add_libc_unittest(
+  lsearch_test
+  SUITE
+    libc_search_unittests
+  SRCS
+    lsearch_test.cpp
+  DEPENDS
+    libc.src.search.lsearch
+)
diff --git a/libc/test/src/search/lsearch_test.cpp b/libc/test/src/search/lsearch_test.cpp
new file mode 100644
index 0000000000000..22ac37f18b7bd
--- /dev/null
+++ b/libc/test/src/search/lsearch_test.cpp
@@ -0,0 +1,48 @@
+//===-- Unittests for lsearch ---------------------------------------------===//
+//
+// 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/search/lsearch.h"
+#include "test/UnitTest/Test.h"
+
+int compar(const void *a, const void *b) {
+  return *reinterpret_cast<const int *>(a) != *reinterpret_cast<const int *>(b);
+}
+
+TEST(LlvmLibcLsearchTest, SearchHead) {
+  int list[3] = {1, 2, 3};
+  size_t len = 3;
+  int key = 1;
+  void *ret = LIBC_NAMESPACE::lsearch(&key, list, &len, sizeof(int), compar);
+  ASSERT_TRUE(ret == &list[0]);
+}
+
+TEST(LlvmLibcLsearchTest, SearchMiddle) {
+  int list[3] = {1, 2, 3};
+  size_t len = 3;
+  int key = 2;
+  void *ret = LIBC_NAMESPACE::lsearch(&key, list, &len, sizeof(int), compar);
+  ASSERT_TRUE(ret == &list[1]);
+}
+
+TEST(LlvmLibcLsearchTest, SearchTail) {
+  int list[3] = {1, 2, 3};
+  size_t len = 3;
+  int key = 3;
+  void *ret = LIBC_NAMESPACE::lsearch(&key, list, &len, sizeof(int), compar);
+  ASSERT_TRUE(ret == &list[2]);
+}
+
+TEST(LlvmLibcLsearchTest, SearchNonExistent) {
+  int list[4] = {1, 2, 3, 0};
+  size_t len = 3;
+  int key = 4;
+  void *ret = LIBC_NAMESPACE::lsearch(&key, list, &len, sizeof(int), compar);
+  ASSERT_TRUE(ret == &list[3]);
+  ASSERT_EQ(key, list[3]);
+  ASSERT_EQ(len, 4UL);
+}

@c8ef
Copy link
Contributor Author

c8ef commented Mar 17, 2025

Gentle ping~

Copy link
Contributor

@lntue lntue left a comment

Choose a reason for hiding this comment

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

Can you also enable it for linux/riscv? The implementation looks quite generic.

@c8ef
Copy link
Contributor Author

c8ef commented Mar 18, 2025

Can you also enable it for linux/riscv? The implementation looks quite generic.

Done.

@c8ef
Copy link
Contributor Author

c8ef commented Mar 19, 2025

Not sure why the checkout failed on Buildkite, it seems unrelated.

@c8ef c8ef merged commit af7c8c4 into llvm:main Mar 19, 2025
14 of 16 checks passed
@c8ef c8ef deleted the search branch March 19, 2025 00:41
@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 19, 2025

LLVM Buildbot has detected a new failure on builder libc-riscv32-qemu-yocto-fullbuild-dbg running on rv32gc-qemu-system while building libc at step 4 "annotate".

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

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)
...
ninja: no work to do.
@@@BUILD_STEP libc-unit-tests@@@
Running: ninja libc-unit-tests
[1/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.insque.__internal__.dir/insque.cpp.o
[2/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.remque.__internal__.dir/remque.cpp.o
[3/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.lfind.__internal__.dir/lfind.cpp.o
[4/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.lsearch.__internal__.dir/lsearch.cpp.o
[5/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.hdestroy_r.__internal__.dir/hdestroy_r.cpp.o
[6/991] Linking CXX executable libc/test/src/search/libc.test.src.search.lfind_test.__build__
[7/991] Building CXX object libc/test/src/search/CMakeFiles/libc.test.src.search.lsearch_test.__build__.dir/lsearch_test.cpp.o
FAILED: libc/test/src/search/CMakeFiles/libc.test.src.search.lsearch_test.__build__.dir/lsearch_test.cpp.o 
/usr/local/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_20_0_0_git -D_DEBUG -I/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc -isystem /home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/libc/include -mabi=ilp32d -march=rv32imafdc --target=riscv32-unknown-linux-gnu --sysroot=/opt/riscv/sysroot --gcc-toolchain=/opt/riscv -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -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 -g -std=gnu++17 --target=riscv32-unknown-linux-gnu -fpie -DLIBC_FULL_BUILD -ffreestanding -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ffixed-point -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wstrict-prototypes -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wthread-safety -MD -MT libc/test/src/search/CMakeFiles/libc.test.src.search.lsearch_test.__build__.dir/lsearch_test.cpp.o -MF libc/test/src/search/CMakeFiles/libc.test.src.search.lsearch_test.__build__.dir/lsearch_test.cpp.o.d -o libc/test/src/search/CMakeFiles/libc.test.src.search.lsearch_test.__build__.dir/lsearch_test.cpp.o -c /home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/src/search/lsearch_test.cpp
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/src/search/lsearch_test.cpp:47:3: error: no matching member function for call to 'test'
   47 |   ASSERT_EQ(len, 4UL);
      |   ^~~~~~~~~~~~~~~~~~~
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:438:29: note: expanded from macro 'ASSERT_EQ'
  438 | #define ASSERT_EQ(LHS, RHS) LIBC_TEST_BINOP_(EQ, LHS, RHS, return)
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:430:26: note: expanded from macro 'LIBC_TEST_BINOP_'
  430 |   LIBC_TEST_SCAFFOLDING_(test(LIBC_NAMESPACE::testing::TestCond::COND, LHS,    \
      |                          ^~~~
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:423:7: note: expanded from macro 'LIBC_TEST_SCAFFOLDING_'
  423 |   if (TEST)                                                                    \
      |       ^~~~
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:144:8: note: candidate template ignored: deduced conflicting types for parameter 'ValType' ('size_t' (aka 'unsigned int') vs. 'unsigned long')
  144 |   bool test(TestCond Cond, ValType LHS, ValType RHS, const char *LHSStr,
      |        ^
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:151:8: note: candidate template ignored: deduced conflicting types for parameter 'ValType' ('size_t' (aka 'unsigned int') vs. 'unsigned long')
  151 |   bool test(TestCond Cond, ValType LHS, ValType RHS, const char *LHSStr,
      |        ^
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:159:8: note: candidate template ignored: deduced conflicting types for parameter 'ValType' ('size_t' (aka 'unsigned int') vs. 'unsigned long')
  159 |   bool test(TestCond Cond, ValType LHS, ValType RHS, const char *LHSStr,
      |        ^
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:177:8: note: candidate template ignored: deduced conflicting types for parameter 'ValType' ('size_t' (aka 'unsigned int') vs. 'unsigned long')
  177 |   bool test(TestCond Cond, ValType LHS, ValType RHS, const char *LHSStr,
      |        ^
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:185:8: note: candidate template ignored: deduced conflicting types for parameter 'ValType' ('size_t' (aka 'unsigned int') vs. 'unsigned long')
  185 |   bool test(TestCond Cond, ValType LHS, ValType RHS, const char *LHSStr,
      |        ^
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:168:8: note: candidate template ignored: substitution failure [with ValType = size_t]: implicit instantiation of undefined template '__llvm_libc_20_0_0_git::cpp::enable_if<false, unsigned int>'
  168 |   bool test(TestCond Cond, ValType LHS, cpp::nullptr_t, const char *LHSStr,
      |        ^
1 error generated.
[8/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.hdestroy.__internal__.dir/hdestroy.cpp.o
[9/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.hsearch_r.__internal__.dir/hsearch_r.cpp.o
[10/991] Building CXX object libc/test/src/search/CMakeFiles/libc.test.src.search.insque_test.__build__.dir/insque_test.cpp.o
[11/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.hcreate_r.__internal__.dir/hcreate_r.cpp.o
[12/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.hcreate.__internal__.dir/hcreate.cpp.o
[13/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.hsearch.__internal__.dir/hsearch.cpp.o
Step 8 (libc-unit-tests) failure: libc-unit-tests (failure)
@@@BUILD_STEP libc-unit-tests@@@
Running: ninja libc-unit-tests
[1/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.insque.__internal__.dir/insque.cpp.o
[2/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.remque.__internal__.dir/remque.cpp.o
[3/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.lfind.__internal__.dir/lfind.cpp.o
[4/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.lsearch.__internal__.dir/lsearch.cpp.o
[5/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.hdestroy_r.__internal__.dir/hdestroy_r.cpp.o
[6/991] Linking CXX executable libc/test/src/search/libc.test.src.search.lfind_test.__build__
[7/991] Building CXX object libc/test/src/search/CMakeFiles/libc.test.src.search.lsearch_test.__build__.dir/lsearch_test.cpp.o
FAILED: libc/test/src/search/CMakeFiles/libc.test.src.search.lsearch_test.__build__.dir/lsearch_test.cpp.o 
/usr/local/bin/clang++ -DLIBC_NAMESPACE=__llvm_libc_20_0_0_git -D_DEBUG -I/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc -isystem /home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/build/libc/include -mabi=ilp32d -march=rv32imafdc --target=riscv32-unknown-linux-gnu --sysroot=/opt/riscv/sysroot --gcc-toolchain=/opt/riscv -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -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 -g -std=gnu++17 --target=riscv32-unknown-linux-gnu -fpie -DLIBC_FULL_BUILD -ffreestanding -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti -ffixed-point -Wconversion -Wno-sign-conversion -Wimplicit-fallthrough -Wwrite-strings -Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic -Wstrict-prototypes -Wextra-semi -Wnewline-eof -Wnonportable-system-include-path -Wthread-safety -MD -MT libc/test/src/search/CMakeFiles/libc.test.src.search.lsearch_test.__build__.dir/lsearch_test.cpp.o -MF libc/test/src/search/CMakeFiles/libc.test.src.search.lsearch_test.__build__.dir/lsearch_test.cpp.o.d -o libc/test/src/search/CMakeFiles/libc.test.src.search.lsearch_test.__build__.dir/lsearch_test.cpp.o -c /home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/src/search/lsearch_test.cpp
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/src/search/lsearch_test.cpp:47:3: error: no matching member function for call to 'test'
   47 |   ASSERT_EQ(len, 4UL);
      |   ^~~~~~~~~~~~~~~~~~~
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:438:29: note: expanded from macro 'ASSERT_EQ'
  438 | #define ASSERT_EQ(LHS, RHS) LIBC_TEST_BINOP_(EQ, LHS, RHS, return)
      |                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:430:26: note: expanded from macro 'LIBC_TEST_BINOP_'
  430 |   LIBC_TEST_SCAFFOLDING_(test(LIBC_NAMESPACE::testing::TestCond::COND, LHS,    \
      |                          ^~~~
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:423:7: note: expanded from macro 'LIBC_TEST_SCAFFOLDING_'
  423 |   if (TEST)                                                                    \
      |       ^~~~
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:144:8: note: candidate template ignored: deduced conflicting types for parameter 'ValType' ('size_t' (aka 'unsigned int') vs. 'unsigned long')
  144 |   bool test(TestCond Cond, ValType LHS, ValType RHS, const char *LHSStr,
      |        ^
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:151:8: note: candidate template ignored: deduced conflicting types for parameter 'ValType' ('size_t' (aka 'unsigned int') vs. 'unsigned long')
  151 |   bool test(TestCond Cond, ValType LHS, ValType RHS, const char *LHSStr,
      |        ^
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:159:8: note: candidate template ignored: deduced conflicting types for parameter 'ValType' ('size_t' (aka 'unsigned int') vs. 'unsigned long')
  159 |   bool test(TestCond Cond, ValType LHS, ValType RHS, const char *LHSStr,
      |        ^
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:177:8: note: candidate template ignored: deduced conflicting types for parameter 'ValType' ('size_t' (aka 'unsigned int') vs. 'unsigned long')
  177 |   bool test(TestCond Cond, ValType LHS, ValType RHS, const char *LHSStr,
      |        ^
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:185:8: note: candidate template ignored: deduced conflicting types for parameter 'ValType' ('size_t' (aka 'unsigned int') vs. 'unsigned long')
  185 |   bool test(TestCond Cond, ValType LHS, ValType RHS, const char *LHSStr,
      |        ^
/home/libcrv32buildbot/bbroot/libc-riscv32-qemu-yocto-fullbuild-dbg/llvm-project/libc/test/UnitTest/LibcTest.h:168:8: note: candidate template ignored: substitution failure [with ValType = size_t]: implicit instantiation of undefined template '__llvm_libc_20_0_0_git::cpp::enable_if<false, unsigned int>'
  168 |   bool test(TestCond Cond, ValType LHS, cpp::nullptr_t, const char *LHSStr,
      |        ^
1 error generated.
[8/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.hdestroy.__internal__.dir/hdestroy.cpp.o
[9/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.hsearch_r.__internal__.dir/hsearch_r.cpp.o
[10/991] Building CXX object libc/test/src/search/CMakeFiles/libc.test.src.search.insque_test.__build__.dir/insque_test.cpp.o
[11/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.hcreate_r.__internal__.dir/hcreate_r.cpp.o
[12/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.hcreate.__internal__.dir/hcreate.cpp.o
[13/991] Building CXX object libc/src/search/CMakeFiles/libc.src.search.hsearch.__internal__.dir/hsearch.cpp.o
[14/991] Building CXX object libc/test/src/search/CMakeFiles/libc.test.src.search.hsearch_test.__build__.dir/hsearch_test.cpp.o
[15/991] Running unit test libc.test.src.__support.CPP.algorithm_test.__unit__

@c8ef
Copy link
Contributor Author

c8ef commented Mar 19, 2025

Looks like size_t isn't equivalent to unsigned long on 32-bit platforms. I'll update this to size_t{4} tonight.

llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Mar 19, 2025
bherrera pushed a commit to misttech/fuchsia that referenced this pull request Apr 1, 2025
…ed long` mismatch on riscv32 in test. (#132028)

Fix regression:
llvm/llvm-project#131431 (comment)

GitOrigin-RevId: 4caa353e46645cee8b43f8f69a0aabf96e23a39d
Original-Revision: e249c02a959796131f0dc2b62d861bb2b44421c0
Roller-URL: https://cr-buildbucket.appspot.com/build/8719946549197360369
CQ-Do-Not-Cancel-Tryjobs: true
Change-Id: I3de21bec82a08d843a9f9e67dbb9d9b738b915b0
Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/1231722
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