https://github.com/izaakschroeder updated https://github.com/llvm/llvm-project/pull/97231
>From 31dc769c1866a4a0100dde0a3743c215a9a5f5eb Mon Sep 17 00:00:00 2001 From: Izaak Schroeder <izaak.schroe...@gmail.com> Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 1/6] [libc]: add missing aarch64 headers --- libc/config/linux/aarch64/entrypoints.txt | 3 +++ libc/config/linux/aarch64/headers.txt | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index 8a26536cea9a0..b59400db81fed 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -308,6 +308,9 @@ set(TARGET_LIBC_ENTRYPOINTS libc.src.unistd.unlink libc.src.unistd.unlinkat libc.src.unistd.write + + # XXX + libc.src.assert.__assert_fail ) set(TARGET_LIBM_ENTRYPOINTS diff --git a/libc/config/linux/aarch64/headers.txt b/libc/config/linux/aarch64/headers.txt index 7d25877cefcc8..ed126d6128871 100644 --- a/libc/config/linux/aarch64/headers.txt +++ b/libc/config/linux/aarch64/headers.txt @@ -31,4 +31,10 @@ set(TARGET_PUBLIC_HEADERS libc.include.sys_ioctl # Disabled due to epoll_wait syscalls not being available on this platform. # libc.include.sys_epoll + + # XXX + libc.include.sys_auxv + libc.include.fcntl + libc.include.sched + libc.include.sys_stat ) >From a5f8ee220c088a39d9b4bf60986166e83ffafffa Mon Sep 17 00:00:00 2001 From: Izaak Schroeder <izaak.schroe...@gmail.com> Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 2/6] [libunwind]: remove needless `sys/uio.h` No reference to `readv` or `writev`. --- libunwind/src/UnwindCursor.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index 66fe8e2a32cca..677e842d8a22b 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -36,7 +36,6 @@ #include <errno.h> #include <signal.h> #include <sys/syscall.h> -#include <sys/uio.h> #include <unistd.h> #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder <izaak.schroe...@gmail.com> Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 3/6] [libc]: function spec for `getauxval` --- libc/spec/gnu_ext.td | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libc/spec/gnu_ext.td b/libc/spec/gnu_ext.td index 161bb4e4a0d9d..e360c766c5c54 100644 --- a/libc/spec/gnu_ext.td +++ b/libc/spec/gnu_ext.td @@ -237,7 +237,11 @@ def GnuExtensions : StandardSpec<"GNUExtensions"> { [], // Types [], // Enumerations [ - //TODO: Add getauxval here + FunctionSpec< + "getauxval", + RetValSpec<UnsignedLongType>, + [ArgSpec<UnsignedLongType>] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder <izaak.schroe...@gmail.com> Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 4/6] [libc]: hack `ExitCallbackList` always public --- libc/src/stdlib/exit_handler.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libc/src/stdlib/exit_handler.h b/libc/src/stdlib/exit_handler.h index 8494c2f2e526e..db731a46f44c9 100644 --- a/libc/src/stdlib/exit_handler.h +++ b/libc/src/stdlib/exit_handler.h @@ -31,10 +31,8 @@ struct AtExitUnit { #if defined(LIBC_TARGET_ARCH_IS_GPU) using ExitCallbackList = FixedVector<AtExitUnit, 64>; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore<AtExitUnit, 32>; #else -using ExitCallbackList = FixedVector<AtExitUnit, CALLBACK_LIST_SIZE_FOR_TESTS>; +using ExitCallbackList = ReverseOrderBlockStore<AtExitUnit, 32>; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder <izaak.schroe...@gmail.com> Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 5/6] [libc]: add `Scrt1.o` --- libc/startup/linux/CMakeLists.txt | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libc/startup/linux/CMakeLists.txt b/libc/startup/linux/CMakeLists.txt index 336c5d0f6bfa2..b721d15091227 100644 --- a/libc/startup/linux/CMakeLists.txt +++ b/libc/startup/linux/CMakeLists.txt @@ -118,6 +118,15 @@ merge_relocatable_object( .do_start ) +# HACK: Is this even ok? +# For reference: `Scrt1` is used when `-fpie` vs `crt1` for `-fno-pie` +merge_relocatable_object( + Scrt1 + .${LIBC_TARGET_ARCHITECTURE}.start + .${LIBC_TARGET_ARCHITECTURE}.tls + .do_start +) + add_startup_object( crti SRC @@ -131,7 +140,7 @@ add_startup_object( ) add_custom_target(libc-startup) -set(startup_components crt1 crti crtn) +set(startup_components Scrt1 crt1 crti crtn) foreach(target IN LISTS startup_components) set(fq_target_name libc.startup.linux.${target}) add_dependencies(libc-startup ${fq_target_name}) >From 3865e451c5ac1e3122acaedecae9c277825bd5fc Mon Sep 17 00:00:00 2001 From: Izaak Schroeder <izaak.schroe...@gmail.com> Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 6/6] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entrypoints.txt | 1 + libc/config/linux/x86_64/entrypoints.txt | 3 ++ libc/spec/linux.td | 12 ++++++- libc/spec/spec.td | 1 + libc/src/sys/time/CMakeLists.txt | 10 ++++++ libc/src/sys/time/linux/CMakeLists.txt | 38 +++++++++++++++++++++++ libc/src/sys/time/linux/utimes.cpp | 14 +++++++++ libc/src/sys/time/utimes.h | 18 +++++++++++ 8 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 libc/src/sys/time/CMakeLists.txt create mode 100644 libc/src/sys/time/linux/CMakeLists.txt create mode 100644 libc/src/sys/time/linux/utimes.cpp create mode 100644 libc/src/sys/time/utimes.h diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt index b59400db81fed..f259f30f8b377 100644 --- a/libc/config/linux/aarch64/entrypoints.txt +++ b/libc/config/linux/aarch64/entrypoints.txt @@ -311,6 +311,7 @@ set(TARGET_LIBC_ENTRYPOINTS # XXX libc.src.assert.__assert_fail + libc.src.sys_time.utimes ) set(TARGET_LIBM_ENTRYPOINTS diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt index e1922ca94b97e..05ab170127a9d 100644 --- a/libc/config/linux/x86_64/entrypoints.txt +++ b/libc/config/linux/x86_64/entrypoints.txt @@ -330,6 +330,9 @@ set(TARGET_LIBC_ENTRYPOINTS # wchar.h entrypoints libc.src.wchar.wctob + + # XXX + libc.src.sys_time.utimes ) set(TARGET_LIBM_ENTRYPOINTS diff --git a/libc/spec/linux.td b/libc/spec/linux.td index 82630ff413c73..faeefd70f2263 100644 --- a/libc/spec/linux.td +++ b/libc/spec/linux.td @@ -148,7 +148,17 @@ def Linux : StandardSpec<"Linux"> { ], [StructTimevalType], // Types [], // Enumerations - [] // Functions + [ + FunctionSpec< + "utimes", + RetValSpec<IntType>, + [ + ArgSpec<IntType>, + ArgSpec<ConstCharPtr>, + ArgSpec<ConstStructTimevalPtr>, + ] + >, + ] // Functions >; diff --git a/libc/spec/spec.td b/libc/spec/spec.td index a3a5db7465b39..17c0589ab1d55 100644 --- a/libc/spec/spec.td +++ b/libc/spec/spec.td @@ -148,6 +148,7 @@ def StructRUsagePtr : PtrType<StructRUsage>; def StructTimevalType : NamedType<"struct timeval">; def StructTimevalPtr : PtrType<StructTimevalType>; +def ConstStructTimevalPtr : ConstType<StructTimevalPtr>; def RestrictedStructTimevalPtr : RestrictedPtrType<StructTimevalType>; def SuSecondsT : NamedType<"suseconds_t">; diff --git a/libc/src/sys/time/CMakeLists.txt b/libc/src/sys/time/CMakeLists.txt new file mode 100644 index 0000000000000..aa26589e0d961 --- /dev/null +++ b/libc/src/sys/time/CMakeLists.txt @@ -0,0 +1,10 @@ +if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS}) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS}) +endif() + +add_entrypoint_object( + utimes + ALIAS + DEPENDS + .${LIBC_TARGET_OS}.wait +) diff --git a/libc/src/sys/time/linux/CMakeLists.txt b/libc/src/sys/time/linux/CMakeLists.txt new file mode 100644 index 0000000000000..49517ced71d1d --- /dev/null +++ b/libc/src/sys/time/linux/CMakeLists.txt @@ -0,0 +1,38 @@ +add_entrypoint_object( + wait + SRCS + wait.cpp + HDRS + ../wait.h + DEPENDS + libc.include.sys_wait + libc.include.sys_syscall + libc.src.__support.OSUtil.osutil + libc.src.errno.errno +) + +add_entrypoint_object( + wait4 + SRCS + wait4.cpp + HDRS + ../wait4.h + DEPENDS + libc.include.sys_wait + libc.include.sys_syscall + libc.src.__support.OSUtil.osutil + libc.src.errno.errno +) + +add_entrypoint_object( + waitpid + SRCS + waitpid.cpp + HDRS + ../waitpid.h + DEPENDS + libc.include.sys_wait + libc.include.sys_syscall + libc.src.__support.OSUtil.osutil + libc.src.errno.errno +) diff --git a/libc/src/sys/time/linux/utimes.cpp b/libc/src/sys/time/linux/utimes.cpp new file mode 100644 index 0000000000000..e6bba9d96cf30 --- /dev/null +++ b/libc/src/sys/time/linux/utimes.cpp @@ -0,0 +1,14 @@ +#include "src/__support/common.h" +#include "src/errno/libc_errno.h" + +namespace LIBC_NAMESPACE { + +LLVM_LIBC_FUNCTION( + int, + utimes, + (int dirfd, const char *pathname, const struct timeval times[2]) +) { + return EINVAL; +} + +} // namespace LIBC_NAMESPACE diff --git a/libc/src/sys/time/utimes.h b/libc/src/sys/time/utimes.h new file mode 100644 index 0000000000000..eb2bcc3f15f25 --- /dev/null +++ b/libc/src/sys/time/utimes.h @@ -0,0 +1,18 @@ +//===-- Implementation header for socket ------------------------*- 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_SYS_TIME_UTIMES_H +#define LLVM_LIBC_SRC_SYS_TIME_UTIMES_H + +namespace LIBC_NAMESPACE { + +int utimes(int dirfd, const char *pathname, const struct timeval times[2]); + +} // namespace LIBC_NAMESPACE + +#endif // LLVM_LIBC_SRC_SYS_TIME_UTIMES_H _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits