-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Compiling on musl #36
Comments
I get the following when trying to compile on Alpine:
It turns out that musl does not implement those functions. "Legacy functions operating on ucontext_t (getcontext, setcontext, makecontext, swapcontext) are not implemented. They are no longer part of POSIX, but cooperative multi-tasking applications use them. ucontext_t also appears as an argument to sigaction handlers which cannot be used portably." http://wiki.musl-libc.org/wiki/Open_Issues This is similar to how OS X is lacking such functions as explained in /usr/local/plan9/src/libthread/threadimpl.h, so I just added #include "x86_64-ucontext.h" to that file and I am hoping that everything I need (Venti) compiles fine. I also removed the #include <ucontext.h> to stop errors about redefinitions. Now I'm stuck with
libthread didn't compile?!?!?!!?!
I add a
They're implemented for other platforms in that directory, but not for 64-bit x86 Linux. |
These functions are indeed deprecated in POSIX. I think one of the reason These functions are still very useful, but easy to implement locally. You can also take a look to libtask, where Russ already did most of the code |
Any progress on this? I'm getting similar errors on a current Void x86_64-musl >>> cd /builddir/plan9port-df2d9ec9d169626cdc2a23829bb2831738215722/src/cmd; mk all
9l -o o.9import 9import.o -Wl,-z,relro -Wl,-z,now -Wl,--as-needed
/bin/ld: /builddir/plan9port-df2d9ec9d169626cdc2a23829bb2831738215722/lib/libthread.a(thread.o): in function `threadalloc':
/builddir/plan9port-df2d9ec9d169626cdc2a23829bb2831738215722/src/libthread/thread.c:130: undefined reference to `getcontext'
/bin/ld: /builddir/plan9port-df2d9ec9d169626cdc2a23829bb2831738215722/src/libthread/thread.c:154: undefined reference to `makecontext'
/bin/ld: /builddir/plan9port-df2d9ec9d169626cdc2a23829bb2831738215722/lib/libthread.a(thread.o): in function `contextswitch':
/builddir/plan9port-df2d9ec9d169626cdc2a23829bb2831738215722/src/libthread/thread.c:308: undefined reference to `swapcontext'
/bin/ld: /builddir/plan9port-df2d9ec9d169626cdc2a23829bb2831738215722/src/libthread/thread.c:308: undefined reference to `swapcontext'
collect2: error: ld returned 1 exit status
mk: 9l -o o.9import ... : exit status=exit(1)
mk: for i in ... : exit status=exit(1)
|
i found this library that implements the ucontext functions for musl: https://code.foxkit.us/adelie/libucontext/ i was able to build plan9port on void x86_64-musl with the library ( diff --git a/bin/9l b/bin/9l
index 6195815f..d1a980cc 100755
--- a/bin/9l
+++ b/bin/9l
@@ -38,9 +38,9 @@ case "$tag" in
*Linux*)
ld=${CC9:-gcc}
userpath=true
- extralibs="$extralibs -lutil -lresolv"
+ extralibs="$extralibs -lutil -lresolv -lucontext"
case "${SYSVERSION:-`uname -r`}" in
- 2.6.* | 3.* | 4.*)
+ 2.6.* | [3-9].* | [1-9][0-9].*)
extralibs="$extralibs -lpthread"
;;
esac
diff --git a/lib/linux-isnptl.c b/lib/linux-isnptl.c
index e4c23c63..c44d97ad 100644
--- a/lib/linux-isnptl.c
+++ b/lib/linux-isnptl.c
@@ -1,3 +1,4 @@
+#include <sys/types.h>
#include <pthread.h>
#include <unistd.h>
#include <stdlib.h>
diff --git a/src/lib9/dirread.c b/src/lib9/dirread.c
index 40fbe3c7..b13803e6 100644
--- a/src/lib9/dirread.c
+++ b/src/lib9/dirread.c
@@ -10,13 +10,7 @@ extern int _p9dir(struct stat*, struct stat*, char*, Dir*, char**, char*);
static int
mygetdents(int fd, struct dirent *buf, int n)
{
- off_t off;
- int nn;
-
- /* This doesn't match the man page, but it works in Debian with a 2.2 kernel */
- off = p9seek(fd, 0, 1);
- nn = getdirentries(fd, (void*)buf, n, &off);
- return nn;
+ return getdents(fd, (void*)buf, n);
}
#elif defined(__APPLE__)
static int |
same here, on
tried applying the patch that @huglovefan posted to the version that is in the repo as i'm writing this but it failed due to modifications and lack of a bin/9l | 2 +-
src/lib9/dirread.c | 8 +-------
2 files changed, 2 insertions(+), 8 deletions(-)
diff --git a/bin/9l b/bin/9l
index a10aab7..103fd54 100755
--- a/bin/9l
+++ b/bin/9l
@@ -25,7 +25,7 @@ case "$tag" in
*Linux*)
ld=${CC9:-gcc}
userpath=true
- extralibs="$extralibs -lutil -lresolv -lpthread"
+ extralibs="$extralibs -lutil -lresolv -lpthread -lucontext"
;;
*Darwin*x86_64*)
ld="${CC9:-gcc} -m64"
diff --git a/src/lib9/dirread.c b/src/lib9/dirread.c
index c232eb8..7c8d48d 100644
--- a/src/lib9/dirread.c
+++ b/src/lib9/dirread.c
@@ -10,13 +10,7 @@ extern int _p9dir(struct stat*, struct stat*, char*, Dir*, char**, char*);
static int
mygetdents(int fd, struct dirent *buf, int n)
{
- off_t off;
- int nn;
-
- /* This doesn't match the man page, but it works in Debian with a 2.2 kernel */
- off = p9seek(fd, 0, 1);
- nn = getdirentries(fd, (void*)buf, n, &off);
- return nn;
+ return getdents(fd, (void*)buf, n);
}
#elif defined(__APPLE__)
static int |
This issue is resolved by commit 1857120. |
I've tried installing plan9port on void linux (musl version) to find it fails. Paul Onyschuk posted some patches at https://groups.google.com/forum/#!topic/plan9port-dev/trEfAGRHPfA . I wonder if these could be incorporated? His post has no replies and there are no other issues about this open or closed here, so I'm not sure what's the status on this.
The text was updated successfully, but these errors were encountered: