Skip to content
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

[libc] fix build on aarch64 #73739

Merged
merged 1 commit into from
Nov 29, 2023
Merged

[libc] fix build on aarch64 #73739

merged 1 commit into from
Nov 29, 2023

Conversation

SchrodingerZhu
Copy link
Contributor

  • avoid implicit narrowing conversion
  • move hsearch entrypoints to FULL_BUILD

* avoid implicit narrowing conversion
* move hsearch entrypoints to FULL_BUILD
@llvmbot llvmbot added the libc label Nov 29, 2023
@llvmbot
Copy link
Member

llvmbot commented Nov 29, 2023

@llvm/pr-subscribers-libc

Author: Schrodinger ZHU Yifan (SchrodingerZhu)

Changes
  • 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 --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) {

@SchrodingerZhu
Copy link
Contributor Author

@lntue There is another seemingly strange error on x86-64:

image

Should I try to fix it by including subparts of type_traits?

@lntue
Copy link
Contributor

lntue commented Nov 29, 2023

@lntue There is another seemingly strange error on x86-64:

Should I try to fix it by including subparts of type_traits?

I'll investigate that error. Look like something messing up the _Float16 type detection macros.

@lntue lntue merged commit e399a31 into llvm:main Nov 29, 2023
4 checks passed
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.

3 participants