[libc] [libunwind] Enough to get `libc` to build `clang` (PR #97231)
https://github.com/izaakschroeder created https://github.com/llvm/llvm-project/pull/97231 Companion to https://github.com/llvm/llvm-project/issues/97191 >From 31dc769c1866a4a0100dde0a3743c215a9a5f5eb Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 1/2] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 2/2] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` (PR #97231)
https://github.com/izaakschroeder edited https://github.com/llvm/llvm-project/pull/97231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 1/3] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 2/3] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 3/3] [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, + [ArgSpec] + >, ] // Functions >; ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
https://github.com/izaakschroeder edited https://github.com/llvm/llvm-project/pull/97231 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 1/5] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 2/5] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 3/5] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 4/5] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 5/5] [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}) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 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 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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder 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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder 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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder 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 Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 6/6] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entrypoints.txt |
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 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 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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder 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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder 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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder 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 7c4a98e5fb1304f6dc438f92ae3f57d3161ad3e3 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 6/6] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entrypoints.txt |
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 1/8] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 2/8] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 3/8] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 4/8] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 5/8] [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 fd8af1e0b88213e7029eb180b12abbd72eb91741 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 6/8] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entrypoints.txt |
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 1/9] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 2/9] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 3/9] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 4/9] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 5/9] [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 d4257c176073abccec419cb5cf65afaa99fa6bcf Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 6/9] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entrypoints.txt |
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 1/9] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 2/9] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 3/9] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 4/9] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 5/9] [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 d4257c176073abccec419cb5cf65afaa99fa6bcf Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 6/9] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entrypoints.txt |
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 1/9] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 2/9] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 3/9] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 4/9] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 5/9] [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 d4257c176073abccec419cb5cf65afaa99fa6bcf Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 6/9] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entrypoints.txt |
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 d4257c176073abccec419cb5cf65afaa99fa6bcf Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/11] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/11] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/11] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/11] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/11] [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 d4257c176073abccec419cb5cf65afaa99fa6bcf Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/11] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/12] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/12] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/12] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/12] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/12] [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 d4257c176073abccec419cb5cf65afaa99fa6bcf Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/12] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/13] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/13] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/13] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/13] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/13] [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 d4257c176073abccec419cb5cf65afaa99fa6bcf Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/13] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/15] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/15] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/15] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/15] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/15] [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 d4257c176073abccec419cb5cf65afaa99fa6bcf Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/15] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/16] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/16] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/16] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/16] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/16] [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 d4257c176073abccec419cb5cf65afaa99fa6bcf Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/16] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/10] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/10] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/10] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/10] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/10] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/10] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/12] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/12] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/12] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/12] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/12] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/12] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/13] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/13] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/13] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/13] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/13] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/13] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/14] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/14] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/14] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/14] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/14] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/14] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/15] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/15] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/15] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/15] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/15] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/15] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/17] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/17] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/17] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/17] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/17] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/17] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/17] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/17] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/17] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/17] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/17] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/17] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/17] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/17] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/17] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/17] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/17] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/17] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/17] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/17] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/17] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/17] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/17] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/17] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/18] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/18] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/18] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/18] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/18] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/18] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/19] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/19] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/19] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/19] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/19] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/19] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/19] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/19] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/19] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/19] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/19] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/19] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/20] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/20] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/20] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/20] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/20] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/20] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/20] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/20] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/20] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/20] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/20] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/20] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/20] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/20] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/20] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/20] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/20] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/20] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/20] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/20] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/20] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/20] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/20] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/20] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libcxx] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/21] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/21] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/21] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/21] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/21] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/21] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libcxx] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/22] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/22] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/22] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/22] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/22] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/22] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libcxx] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/23] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/23] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/23] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/23] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/23] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/23] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libc] [libcxx] [libunwind] [WIP] Enough to get `libc` to build `clang` on `aarch64` (PR #97231)
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 Date: Sun, 30 Jun 2024 13:33:16 -0700 Subject: [PATCH 01/24] [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 Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH 02/24] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif >From 1083aecfe1be3c1cf427d4ffd2b4fad3d5129d4c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:44:52 -0700 Subject: [PATCH 03/24] [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, + [ArgSpec] + >, ] // Functions >; >From e9628ce037c225c3769cec2589745f7978e7edc4 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:06:19 -0700 Subject: [PATCH 04/24] [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; -#elif defined(LIBC_COPT_PUBLIC_PACKAGING) -using ExitCallbackList = ReverseOrderBlockStore; #else -using ExitCallbackList = FixedVector; +using ExitCallbackList = ReverseOrderBlockStore; #endif extern ExitCallbackList atexit_callbacks; >From e3ed9aac99ede8be5d6d228f43c652423206e67c Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 14:15:21 -0700 Subject: [PATCH 05/24] [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 1f98bd663772b963c192293ad7359fe0ffdada25 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Mon, 1 Jul 2024 12:07:37 -0700 Subject: [PATCH 06/24] [libc]: `sys_time.utimes` placeholder --- libc/config/linux/aarch64/entry
[libunwind] [libunwind] Remove needless `sys/uio.h` (PR #97495)
https://github.com/izaakschroeder created https://github.com/llvm/llvm-project/pull/97495 No reference to `readv` or `writev`. >From 03b4411534405fc4a4e9dcb5ec94afdd455a8e38 Mon Sep 17 00:00:00 2001 From: Izaak Schroeder Date: Sun, 30 Jun 2024 13:33:38 -0700 Subject: [PATCH] [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 #include #include -#include #include #define _LIBUNWIND_CHECK_LINUX_SIGRETURN 1 #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Remove needless `sys/uio.h` (PR #97495)
izaakschroeder wrote: /cc @michaelrj-google @jhuber6 https://github.com/llvm/llvm-project/pull/97495 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Remove needless `sys/uio.h` (PR #97495)
https://github.com/izaakschroeder edited https://github.com/llvm/llvm-project/pull/97495 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] [libunwind] Remove needless `sys/uio.h` (PR #97495)
https://github.com/izaakschroeder edited https://github.com/llvm/llvm-project/pull/97495 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits