From: Ben Wolsieffer <Ben.Wolsieffer(a)hefring.com>
fork() can be implemented using either the fork or clone syscalls on MMU
systems. Therefore the stub is only generated if neither __NR_fork nor
__NR_clone are defined. The stub code manually undefines __NR_fork on
no-MMU systems in an attempt to enable the stub, but this doesn't work
because __NR_clone is still defined. It is not appropriate to undefine
__NR_clone because clone is available on no-MMU, it is just not capable
of implementing fork.
This patch directly enables the fork stub if __ARCH_USE_MMU__ is not
defined. This eliminates the need to undefine __NR_fork, so this code is
removed
Signed-off-by: Ben Wolsieffer <ben.wolsieffer(a)hefring.com>
---
libc/sysdeps/linux/common/stubs.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/libc/sysdeps/linux/common/stubs.c b/libc/sysdeps/linux/common/stubs.c
index c17e509b9..634dcde0d 100644
--- a/libc/sysdeps/linux/common/stubs.c
+++ b/libc/sysdeps/linux/common/stubs.c
@@ -34,10 +34,6 @@ __attribute_used__ static int ret_enosys_stub(void)
link_warning(stub, #stub ": this function is not implemented") \
strong_alias(ret_enosys_stub, stub)
-#ifndef __ARCH_USE_MMU__
-# undef __NR_fork
-#endif
-
#ifdef __arm__
# define __NR_fadvise64_64 __NR_arm_fadvise64_64
# define __NR_fadvise64 __NR_arm_fadvise64_64
@@ -120,7 +116,7 @@ make_stub(fgetxattr)
make_stub(flistxattr)
#endif
-#if !defined __NR_fork && !defined __NR_clone
+#if !defined __ARCH_USE_MMU__ || (!defined __NR_fork && !defined __NR_clone)
make_stub(fork)
#endif
--
2.42.0
From: Ben Wolsieffer <Ben.Wolsieffer(a)hefring.com>
The stub code undefs __NR_fork on no-MMU systems, but it also needs to
undef __NR_clone since fork can now be implemented using clone, and
clone is not available either on no-MMU systems.
---
libc/sysdeps/linux/common/stubs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libc/sysdeps/linux/common/stubs.c b/libc/sysdeps/linux/common/stubs.c
index c17e509b9..11849e3ba 100644
--- a/libc/sysdeps/linux/common/stubs.c
+++ b/libc/sysdeps/linux/common/stubs.c
@@ -36,6 +36,7 @@ __attribute_used__ static int ret_enosys_stub(void)
#ifndef __ARCH_USE_MMU__
# undef __NR_fork
+# undef __NR_clone
#endif
#ifdef __arm__
--
2.42.0
The commit cf649082c7d4 ("remove forced gcc optimization") removed -O3
optimization specified in the code for the function _fork_parent, but at
the same time it removed the 'static inline' part of the function
definition. That change seems unintended and _fork_parent is not a part
of the libc interface. Make it static inline again.
Signed-off-by: Max Filippov <jcmvbkbc(a)gmail.com>
---
libc/unistd/daemon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libc/unistd/daemon.c b/libc/unistd/daemon.c
index 53fd902bfd72..599c3c8e6cd4 100644
--- a/libc/unistd/daemon.c
+++ b/libc/unistd/daemon.c
@@ -63,7 +63,7 @@
/* use clone() to get fork() like behavior here -- we just want to disassociate
* from the controlling terminal
*/
-pid_t _fork_parent(void)
+static inline pid_t _fork_parent(void)
{
INTERNAL_SYSCALL_DECL(err);
register long ret = INTERNAL_SYSCALL(clone, err, 2, CLONE_VM, 0);
--
2.30.2
Hi,
I'm seeing a failure building ISL using uclibc-ng and GCC 13.2
[ALL ] /home/ctng/x-tools/x86_64-multilib-linux-uclibc/lib/gcc/x86_64-multilib-linux-uclibc/13.2.0/../../../../x86_64-multilib-linux-uclibc/bin/ld.bfd:
isl_test2.o: non-canonical reference to canonical protected function
`__pthread_key_create' in
/home/ctng/x-tools/x86_64-multilib-linux-uclibc/x86_64-multilib-linux-uclibc/sysroot/lib64/libc.so.1
[ALL ] /home/ctng/x-tools/x86_64-multilib-linux-uclibc/lib/gcc/x86_64-multilib-linux-uclibc/13.2.0/../../../../x86_64-multilib-linux-uclibc/bin/ld.bfd:
failed to set dynamic section sizes: bad value
I don't really understand all the ins and outs but it looks like some
libstdc++ APIs used by ISLs test code boils down to a call to
__pthread_key_create which is marked protected so ld complains.
I can successfully build the same code with glibc (haven't tried
musl). So I'm reaching out to uclibc-ng rather than binutils or GCC.
Any thoughts on what might be the problem and what the solution might be?