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

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


Author: Schrodinger ZHU Yifan
Date: 2023-11-28T22:39:00-05:00
New Revision: e399a317ef63d05991f6b15f74247eee6bfc5279

URL: https://github.com/llvm/llvm-project/commit/e399a317ef63d05991f6b15f74247eee6bfc5279
DIFF: https://github.com/llvm/llvm-project/commit/e399a317ef63d05991f6b15f74247eee6bfc5279.diff

LOG: [libc] fix build on aarch64 (#73739)

* avoid implicit narrowing conversion
* move hsearch entrypoints to FULL_BUILD

Added: 
    

Modified: 
    libc/config/linux/aarch64/entrypoints.txt
    libc/config/linux/arm/entrypoints.txt
    libc/config/linux/riscv/entrypoints.txt
    libc/src/__support/bit.h
    libc/test/src/__support/hash_test.cpp

Removed: 
    


################################################################################
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 
diff erent alignments.
 TEST(LlvmLibcHashTest, SanityCheck) {


        


More information about the libc-commits mailing list