[libc-commits] [libc] [libc] fix build on aarch64 (PR #73739)

via libc-commits libc-commits at lists.llvm.org
Tue Nov 28 19:17:37 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

<details>
<summary>Changes</summary>

* avoid implicit narrowing conversion
* move hsearch entrypoints to FULL_BUILD

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


5 Files Affected:

- (modified) libc/config/linux/aarch64/entrypoints.txt (+8-8) 
- (modified) libc/config/linux/arm/entrypoints.txt (+1-9) 
- (modified) libc/config/linux/riscv/entrypoints.txt (+8-8) 
- (modified) libc/src/__support/bit.h (+2-2) 
- (modified) libc/test/src/__support/hash_test.cpp (+1-1) 


``````````diff
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index ecefa5884adb3eb..7a60c44570c4e8a 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -130,14 +130,6 @@ set(TARGET_LIBC_ENTRYPOINTS
     #libc.src.stdio.scanf
     #libc.src.stdio.fscanf
 
-    # search.h entrypoints
-    libc.src.search.hcreate
-    libc.src.search.hcreate_r
-    libc.src.search.hsearch
-    libc.src.search.hsearch_r
-    libc.src.search.hdestroy
-    libc.src.search.hdestroy_r
-
     # sys/mman.h entrypoints
     libc.src.sys.mman.madvise
     libc.src.sys.mman.mmap
@@ -459,6 +451,14 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.signal.sigfillset
     libc.src.signal.signal
 
+    # search.h entrypoints
+    libc.src.search.hcreate
+    libc.src.search.hcreate_r
+    libc.src.search.hsearch
+    libc.src.search.hsearch_r
+    libc.src.search.hdestroy
+    libc.src.search.hdestroy_r
+
     # threads.h entrypoints
     libc.src.threads.call_once
     libc.src.threads.cnd_broadcast
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index ee701c04b2e2a8a..b7783ace90a886d 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -88,15 +88,7 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.stdlib.strtoll
     libc.src.stdlib.strtoul
     libc.src.stdlib.strtoull
-
-    # search.h entrypoints
-    libc.src.search.hcreate
-    libc.src.search.hcreate_r
-    libc.src.search.hsearch
-    libc.src.search.hsearch_r
-    libc.src.search.hdestroy
-    libc.src.search.hdestroy_r
-
+    
     # sys/mman.h entrypoints
     libc.src.sys.mman.mmap
     libc.src.sys.mman.munmap
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 1ccb40108bd8507..28687ef8e234e2f 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -136,14 +136,6 @@ set(TARGET_LIBC_ENTRYPOINTS
     libc.src.stdio.scanf
     libc.src.stdio.fscanf
 
-    # search.h entrypoints
-    libc.src.search.hcreate
-    libc.src.search.hcreate_r
-    libc.src.search.hsearch
-    libc.src.search.hsearch_r
-    libc.src.search.hdestroy
-    libc.src.search.hdestroy_r
-
     # sys/mman.h entrypoints
     libc.src.sys.mman.madvise
     libc.src.sys.mman.mmap
@@ -492,6 +484,14 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.spawn.posix_spawn_file_actions_destroy
     libc.src.spawn.posix_spawn_file_actions_init
 
+    # search.h entrypoints
+    libc.src.search.hcreate
+    libc.src.search.hcreate_r
+    libc.src.search.hsearch
+    libc.src.search.hsearch_r
+    libc.src.search.hdestroy
+    libc.src.search.hdestroy_r
+
     # threads.h entrypoints
     libc.src.threads.call_once
     libc.src.threads.cnd_broadcast
diff --git a/libc/src/__support/bit.h b/libc/src/__support/bit.h
index ab2e07744a866f2..ba7fc31de1227c7 100644
--- a/libc/src/__support/bit.h
+++ b/libc/src/__support/bit.h
@@ -31,11 +31,11 @@ template <typename T> LIBC_INLINE int constexpr correct_zero(T val, int bits) {
 template <typename T> LIBC_INLINE constexpr int clz(T val);
 template <> LIBC_INLINE int clz<unsigned char>(unsigned char val) {
   return __builtin_clz(static_cast<unsigned int>(val)) -
-         8 * (sizeof(unsigned int) - sizeof(unsigned char));
+         8 * static_cast<int>(sizeof(unsigned int) - sizeof(unsigned char));
 }
 template <> LIBC_INLINE int clz<unsigned short>(unsigned short val) {
   return __builtin_clz(static_cast<unsigned int>(val)) -
-         8 * (sizeof(unsigned int) - sizeof(unsigned short));
+         8 * static_cast<int>(sizeof(unsigned int) - sizeof(unsigned short));
 }
 template <> LIBC_INLINE int clz<unsigned int>(unsigned int val) {
   return __builtin_clz(val);
diff --git a/libc/test/src/__support/hash_test.cpp b/libc/test/src/__support/hash_test.cpp
index 612efd544c66f9f..f23a43a3bc5e4de 100644
--- a/libc/test/src/__support/hash_test.cpp
+++ b/libc/test/src/__support/hash_test.cpp
@@ -29,7 +29,7 @@ template <class T> struct AlignedMemory {
 };
 
 size_t sizes[] = {0, 1, 23, 59, 1024, 5261};
-char values[] = {0, 1, 23, 59, 102, -1};
+uint8_t values[] = {0, 1, 23, 59, 102, 255};
 
 // Hash value should not change with different alignments.
 TEST(LlvmLibcHashTest, SanityCheck) {

``````````

</details>


https://github.com/llvm/llvm-project/pull/73739


More information about the libc-commits mailing list