-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[libc] Update riscv entrypoints to be on par with x86 #138597
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
Conversation
This patch updates the riscv entrypoints with almost all functions that are currently supported on x86. I left six functions commented, as I'll send separate PRs to enable them: * poll: needs a new syscall implementation * utimes: needs a new syscall implementation * setitimer: test never finished in rv32 * getitimer: test fails in rv32 * exp10m1f: test case doesn't build but it's an easy fix * sqrtulk: needs to be implemented I also added the 16-bit fp functions, however, they are not enabled due to a cmake check in float16-macros.h. To enable 16-bit fp in riscv, we need to update the buildbots with a clang version that includes the fix from commit PR llvm#119481
@llvm/pr-subscribers-libc Author: Mikhail R. Gadelha (mikhailramalho) ChangesThis patch updates the riscv entrypoints with almost all functions that are currently supported on x86. I left six functions commented, as I'll send separate PRs to enable them:
I also added the 16-bit fp functions, however, they are not enabled due to a cmake check in float16-macros.h. To enable 16-bit fp in riscv, we need to update the buildbots with a clang version that includes the fix from commit PR #119481 Full diff: https://github.com/llvm/llvm-project/pull/138597.diff 2 Files Affected:
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index e0b20e4ff24b5..d2fc128b35a3c 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -91,12 +91,16 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.string.strxfrm
# strings.h entrypoints
- libc.src.strings.index
- libc.src.strings.rindex
libc.src.strings.bcmp
libc.src.strings.bcopy
libc.src.strings.bzero
+ libc.src.strings.ffs
+ libc.src.strings.ffsl
+ libc.src.strings.ffsll
+ libc.src.strings.index
+ libc.src.strings.rindex
libc.src.strings.strcasecmp
+ libc.src.strings.strncasecmp
# inttypes.h entrypoints
libc.src.inttypes.imaxabs
@@ -177,6 +181,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.stdbit.stdc_trailing_zeros_us
# stdlib.h entrypoints
+ libc.src.stdlib.a64l
libc.src.stdlib.abs
libc.src.stdlib.atof
libc.src.stdlib.atoi
@@ -184,6 +189,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.stdlib.atoll
libc.src.stdlib.bsearch
libc.src.stdlib.div
+ libc.src.stdlib.l64a
libc.src.stdlib.labs
libc.src.stdlib.ldiv
libc.src.stdlib.llabs
@@ -248,6 +254,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.sys.mman.mlock2
libc.src.sys.mman.mlockall
libc.src.sys.mman.mmap
+ libc.src.sys.mman.mremap
libc.src.sys.mman.mprotect
libc.src.sys.mman.msync
libc.src.sys.mman.munlock
@@ -282,6 +289,9 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.sys.statvfs.fstatvfs
libc.src.sys.statvfs.statvfs
+ # sys/utimes.h entrypoints
+ # libc.src.sys.time.utimes
+
# sys/utsname.h entrypoints
libc.src.sys.utsname.uname
@@ -322,6 +332,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.unistd.fsync
libc.src.unistd.ftruncate
libc.src.unistd.getcwd
+ libc.src.unistd.getentropy
libc.src.unistd.geteuid
libc.src.unistd.getpid
libc.src.unistd.getppid
@@ -351,8 +362,17 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.unistd.write
# wchar.h entrypoints
+ libc.src.wchar.btowc
libc.src.wchar.wcslen
libc.src.wchar.wctob
+
+ # sys/uio.h entrypoints
+ libc.src.sys.uio.writev
+ libc.src.sys.uio.readv
+
+ # sys/time.h entrypoints
+ # libc.src.sys.time.setitimer
+ # libc.src.sys.time.getitimer
)
if(LLVM_LIBC_INCLUDE_SCUDO)
@@ -431,6 +451,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.exp
libc.src.math.exp10
libc.src.math.exp10f
+ # libc.src.math.exp10m1f
libc.src.math.exp2
libc.src.math.exp2f
libc.src.math.exp2m1f
@@ -627,6 +648,130 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ufromfpxf
libc.src.math.ufromfpxl
)
+if(LIBC_TYPES_HAS_CFLOAT16)
+ list(APPEND TARGET_LIBM_ENTRYPOINTS
+ # complex.h C23 _Complex _Float16 entrypoints
+ libc.src.complex.crealf16
+ libc.src.complex.cimagf16
+ libc.src.complex.conjf16
+ libc.src.complex.cprojf16
+ )
+endif()
+
+if(LIBC_TYPES_HAS_FLOAT16)
+ list(APPEND TARGET_LIBM_ENTRYPOINTS
+ # math.h C23 _Float16 entrypoints
+ libc.src.math.acosf16
+ libc.src.math.acoshf16
+ libc.src.math.acospif16
+ libc.src.math.asinf16
+ libc.src.math.asinhf16
+ libc.src.math.atanhf16
+ libc.src.math.canonicalizef16
+ libc.src.math.ceilf16
+ libc.src.math.copysignf16
+ libc.src.math.cosf16
+ libc.src.math.coshf16
+ libc.src.math.cospif16
+ libc.src.math.exp10f16
+ libc.src.math.exp10m1f16
+ libc.src.math.exp2f16
+ libc.src.math.exp2m1f16
+ libc.src.math.expf16
+ libc.src.math.expm1f16
+ libc.src.math.f16add
+ libc.src.math.f16addf
+ libc.src.math.f16addl
+ libc.src.math.f16div
+ libc.src.math.f16divf
+ libc.src.math.f16divl
+ libc.src.math.f16fma
+ libc.src.math.f16fmaf
+ libc.src.math.f16fmal
+ libc.src.math.f16mul
+ libc.src.math.f16mulf
+ libc.src.math.f16mull
+ libc.src.math.f16sqrt
+ libc.src.math.f16sqrtf
+ libc.src.math.f16sqrtl
+ libc.src.math.f16sub
+ libc.src.math.f16subf
+ libc.src.math.f16subl
+ libc.src.math.fabsf16
+ libc.src.math.fdimf16
+ libc.src.math.floorf16
+ libc.src.math.fmaf16
+ libc.src.math.fmaxf16
+ libc.src.math.fmaximum_mag_numf16
+ libc.src.math.fmaximum_magf16
+ libc.src.math.fmaximum_numf16
+ libc.src.math.fmaximumf16
+ libc.src.math.fminf16
+ libc.src.math.fminimum_mag_numf16
+ libc.src.math.fminimum_magf16
+ libc.src.math.fminimum_numf16
+ libc.src.math.fminimumf16
+ libc.src.math.fmodf16
+ libc.src.math.frexpf16
+ libc.src.math.fromfpf16
+ libc.src.math.fromfpxf16
+ libc.src.math.getpayloadf16
+ libc.src.math.hypotf16
+ libc.src.math.ilogbf16
+ libc.src.math.iscanonicalf16
+ libc.src.math.issignalingf16
+ libc.src.math.ldexpf16
+ libc.src.math.llogbf16
+ libc.src.math.llrintf16
+ libc.src.math.llroundf16
+ libc.src.math.log10f16
+ libc.src.math.log2f16
+ libc.src.math.logbf16
+ libc.src.math.logf16
+ libc.src.math.lrintf16
+ libc.src.math.lroundf16
+ libc.src.math.modff16
+ libc.src.math.nanf16
+ libc.src.math.nearbyintf16
+ libc.src.math.nextafterf16
+ libc.src.math.nextdownf16
+ libc.src.math.nexttowardf16
+ libc.src.math.nextupf16
+ libc.src.math.remainderf16
+ libc.src.math.remquof16
+ libc.src.math.rintf16
+ libc.src.math.roundevenf16
+ libc.src.math.roundf16
+ libc.src.math.scalblnf16
+ libc.src.math.scalbnf16
+ libc.src.math.setpayloadf16
+ libc.src.math.setpayloadsigf16
+ libc.src.math.sinf16
+ libc.src.math.sinhf16
+ libc.src.math.sinpif16
+ libc.src.math.sqrtf16
+ libc.src.math.tanf16
+ libc.src.math.tanhf16
+ libc.src.math.tanpif16
+ libc.src.math.totalorderf16
+ libc.src.math.totalordermagf16
+ libc.src.math.truncf16
+ libc.src.math.ufromfpf16
+ libc.src.math.ufromfpxf16
+ )
+
+ if(LIBC_TYPES_HAS_FLOAT128)
+ list(APPEND TARGET_LIBM_ENTRYPOINTS
+ # math.h C23 mixed _Float16 and _Float128 entrypoints
+ libc.src.math.f16addf128
+ libc.src.math.f16divf128
+ libc.src.math.f16fmaf128
+ libc.src.math.f16mulf128
+ libc.src.math.f16sqrtf128
+ libc.src.math.f16subf128
+ )
+ endif()
+endif()
if(LIBC_TYPES_HAS_CFLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
@@ -736,6 +881,7 @@ if(LIBC_COMPILER_HAS_FIXED_POINT)
libc.src.stdfix.sqrtuhr
libc.src.stdfix.sqrtuk
libc.src.stdfix.sqrtur
+ # libc.src.stdfix.sqrtulk
libc.src.stdfix.sqrtulr
libc.src.stdfix.uhksqrtus
libc.src.stdfix.uksqrtui
@@ -749,7 +895,6 @@ if(LIBC_COMPILER_HAS_FIXED_POINT)
libc.src.stdfix.uhkbits
libc.src.stdfix.kbits
libc.src.stdfix.ukbits
- # TODO: https://github.com/llvm/llvm-project/issues/115778
libc.src.stdfix.lkbits
libc.src.stdfix.ulkbits
libc.src.stdfix.bitshr
@@ -789,6 +934,39 @@ endif()
if(LLVM_LIBC_FULL_BUILD)
list(APPEND TARGET_LIBC_ENTRYPOINTS
+ # ctype.h entrypoints
+ libc.src.ctype.isalnum_l
+ libc.src.ctype.isalpha_l
+ libc.src.ctype.isblank_l
+ libc.src.ctype.iscntrl_l
+ libc.src.ctype.isdigit_l
+ libc.src.ctype.isgraph_l
+ libc.src.ctype.islower_l
+ libc.src.ctype.isprint_l
+ libc.src.ctype.ispunct_l
+ libc.src.ctype.isspace_l
+ libc.src.ctype.isupper_l
+ libc.src.ctype.isxdigit_l
+ libc.src.ctype.tolower_l
+ libc.src.ctype.toupper_l
+
+ # stdlib.h entrypoints
+ libc.src.stdlib.strtod_l
+ libc.src.stdlib.strtof_l
+ libc.src.stdlib.strtol_l
+ libc.src.stdlib.strtold_l
+ libc.src.stdlib.strtoll_l
+ libc.src.stdlib.strtoul_l
+ libc.src.stdlib.strtoull_l
+
+ # string.h entrypoints
+ libc.src.string.strcoll_l
+ libc.src.string.strxfrm_l
+
+ # strings.h entrypoints
+ libc.src.strings.strcasecmp_l
+ libc.src.strings.strncasecmp_l
+
# assert.h entrypoints
libc.src.assert.__assert_fail
@@ -864,6 +1042,11 @@ if(LLVM_LIBC_FULL_BUILD)
libc.src.pthread.pthread_rwlockattr_init
libc.src.pthread.pthread_rwlockattr_setkind_np
libc.src.pthread.pthread_rwlockattr_setpshared
+ libc.src.pthread.pthread_spin_destroy
+ libc.src.pthread.pthread_spin_init
+ libc.src.pthread.pthread_spin_lock
+ libc.src.pthread.pthread_spin_trylock
+ libc.src.pthread.pthread_spin_unlock
libc.src.pthread.pthread_self
libc.src.pthread.pthread_setname_np
libc.src.pthread.pthread_setspecific
@@ -998,9 +1181,20 @@ if(LLVM_LIBC_FULL_BUILD)
libc.src.time.gmtime_r
libc.src.time.mktime
libc.src.time.nanosleep
+ libc.src.time.strftime
+ libc.src.time.strftime_l
libc.src.time.time
libc.src.time.timespec_get
+ # locale.h entrypoints
+ libc.src.locale.localeconv
+ libc.src.locale.duplocale
+ libc.src.locale.freelocale
+ libc.src.locale.localeconv
+ libc.src.locale.newlocale
+ libc.src.locale.setlocale
+ libc.src.locale.uselocale
+
# unistd.h entrypoints
libc.src.unistd.__llvm_libc_syscall
libc.src.unistd._exit
@@ -1020,6 +1214,13 @@ if(LLVM_LIBC_FULL_BUILD)
# sys/socket.h entrypoints
libc.src.sys.socket.bind
libc.src.sys.socket.socket
+ libc.src.sys.socket.socketpair
+ libc.src.sys.socket.send
+ libc.src.sys.socket.sendto
+ libc.src.sys.socket.sendmsg
+ libc.src.sys.socket.recv
+ libc.src.sys.socket.recvfrom
+ libc.src.sys.socket.recvmsg
)
endif()
diff --git a/libc/config/linux/riscv/headers.txt b/libc/config/linux/riscv/headers.txt
index b38659e0b8daf..01b0bf36498ce 100644
--- a/libc/config/linux/riscv/headers.txt
+++ b/libc/config/linux/riscv/headers.txt
@@ -1,41 +1,38 @@
set(TARGET_PUBLIC_HEADERS
+ libc.include.arpa_inet
libc.include.assert
libc.include.complex
libc.include.ctype
libc.include.dirent
libc.include.dlfcn
+ libc.include.elf
+ libc.include.endian
libc.include.errno
libc.include.fcntl
libc.include.features
libc.include.fenv
libc.include.float
- libc.include.stdint
libc.include.inttypes
libc.include.limits
+ libc.include.link
+ libc.include.locale
libc.include.malloc
libc.include.math
+ libc.include.poll
libc.include.pthread
libc.include.sched
+ libc.include.search
+ libc.include.setjmp
libc.include.signal
libc.include.spawn
- libc.include.setjmp
- libc.include.stdckdint
libc.include.stdbit
+ libc.include.stdckdint
libc.include.stdfix
+ libc.include.stdint
libc.include.stdio
libc.include.stdlib
libc.include.string
libc.include.strings
- libc.include.search
- libc.include.termios
- libc.include.threads
- libc.include.time
- libc.include.unistd
- libc.include.wchar
- libc.include.uchar
-
- libc.include.arpa_inet
-
libc.include.sys_auxv
libc.include.sys_epoll
libc.include.sys_ioctl
@@ -53,4 +50,11 @@ set(TARGET_PUBLIC_HEADERS
libc.include.sys_types
libc.include.sys_utsname
libc.include.sys_wait
+ libc.include.sysexits
+ libc.include.termios
+ libc.include.threads
+ libc.include.time
+ libc.include.uchar
+ libc.include.unistd
+ libc.include.wchar
)
|
This PR depends on #138425 being fixed, otherwise, rv32 will fail to build without |
This is now ready to land. |
Sorry, this is ready to review. |
This patch updates the riscv entrypoints with almost all functions that are currently supported on x86. I left six functions commented, as I'll send separate PRs to enable them: * poll: needs a new syscall implementation * utimes: needs a new syscall implementation * setitimer: test never finished in rv32 * getitimer: test fails in rv32 * exp10m1f: test case doesn't build but it's an easy fix * sqrtulk: needs to be implemented I also added the 16-bit fp functions, however, they are not enabled due to a cmake check in float16-macros.h. To enable 16-bit fp in riscv, we need to update the buildbots with a clang version that includes the fix from commit PR llvm#119481
This patch updates the riscv entrypoints with almost all functions that are currently supported on x86. I left six functions commented, as I'll send separate PRs to enable them:
I also added the 16-bit fp functions, however, they are not enabled due to a cmake check in float16-macros.h. To enable 16-bit fp in riscv, we need to update the buildbots with a clang version that includes the fix from commit PR #119481