wvstreams: add musl support

This commit is contained in:
uriahheep 2015-09-23 21:39:14 -04:00
parent 2d8fd71baf
commit 03b7a1d132
8 changed files with 252 additions and 1 deletions

View File

@ -0,0 +1,28 @@
Build argp object files with -fPIC.
The argp bundled dependency is linked to the libwvutils.so shared library.
MIPS will refuce to link a non-PIC library with a shared one.
We fix this problem by building the argp source files using -fPIC since
the libargp static library will only be used to link to libwvutils.so
as instructed by the following rule in the root Makefile:
ifeq ($(USE_WVSTREAMS_ARGP),1)
utils/wvargs.o-CPPFLAGS += -Iargp
libwvutils.so-LIBS += -Largp -largp
Signed-off-by: Markos Chandras <markos.chandras@imgtec.com>
Index: argp/Makefile.in
===================================================================
--- argp/Makefile.in.old
+++ argp/Makefile.in
@@ -137,7 +137,7 @@ AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
-CFLAGS = @CFLAGS@
+CFLAGS = @CFLAGS@ -fPIC
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CYGPATH_W = @CYGPATH_W@

View File

@ -0,0 +1,11 @@
--- xplc/modulemgr.cc.old 2015-09-23 21:09:18.684676331 -0400
+++ xplc/modulemgr.cc 2015-09-23 21:07:19.369914303 -0400
@@ -30,7 +30,5 @@
# include <stdint.h>
#endif
-#ifdef HAVE_LIMITS_H
-# include <limits.h>
+#include <limits.h>
-#endif
#if !defined(WIN32)

View File

@ -0,0 +1,20 @@
--- uniconf/wvconfemu.cc.old 2015-09-22 02:07:38.395970444 -0400
+++ uniconf/wvconfemu.cc 2015-09-22 02:02:26.111102649 -0400
@@ -11,7 +11,7 @@
#include "strutils.h"
//#define DEBUG_DEL_CALLBACK 1
-#ifdef DEBUG_DEL_CALLBACK
+#if defined(DEBUG_DEL_CALLBACK) && defined(HAVE_EXECINFO_H)
#include <execinfo.h>
#endif
@@ -338,7 +338,7 @@
return;
}
-#ifdef DEBUG_DEL_CALLBACK
+#if defined(DEBUG_DEL_CALLBACK) && defined(HAVE_EXECINFO_H)
void* trace[10];
int count = backtrace(trace, sizeof(trace)/sizeof(trace[0]));
char** tracedump = backtrace_symbols(trace, count);

View File

@ -0,0 +1,11 @@
--- utils/wvcrash.cc.old 2015-09-22 02:27:09.219293510 -0400
+++ utils/wvcrash.cc 2015-09-22 02:37:15.577967752 -0400
@@ -409,7 +409,7 @@
void wvcrash_setup(const char *_argv0, const char *_desc)
{
if (_argv0)
- argv0 = basename(_argv0);
+ argv0 = strrchr(_argv0, '/') ? strrchr(_argv0, '/')+1 : _argv0;
__wvcrash_init_buffers(argv0);
if (_desc)
{

View File

@ -0,0 +1,50 @@
--- utils/wvcrash.cc.old 2015-09-22 01:51:19.515241821 -0400
+++ utils/wvcrash.cc 2015-09-22 01:53:44.101443017 -0400
@@ -28,7 +28,10 @@
// FIXME: this file mostly only works in Linux
#ifdef __linux
+#ifdef HAVE_EXECINFO_H
# include <execinfo.h>
+#endif
+
#include <unistd.h>
#ifdef __USE_GNU
@@ -268,8 +271,10 @@
}
wr(fd, "\nBacktrace:\n");
+#ifdef HAVE_EXECINFO_H
backtrace_symbols_fd(trace,
backtrace(trace, sizeof(trace)/sizeof(trace[0])), fd);
+#endif
if (pid > 0)
{
@@ -451,6 +456,7 @@
* ctx.ContextFlags = CONTEXT_FULL;
* GetThreadContext(hThread, &ctx);
*/
+#ifdef HAVE_EXECINFO_H
int backtrace(CONTEXT &ctx)
{
HANDLE hProcess = (HANDLE)GetCurrentProcess();
@@ -521,6 +527,7 @@
return 1;
}
+#endif
static void exception_desc(FILE *file, unsigned exception,
@@ -588,7 +595,9 @@
fprintf(stderr, "Exception 0x%08X:\n ", info->exception);
exception_desc(stderr, info->exception, info->data1, info->data2);
fprintf(stderr, "\n at instruction 0x%08X in thread 0x%08X\n", info->ip, GetCurrentThreadId());
+#ifdef HAVE_EXECINFO_H
backtrace(*pExceptionPointers->ContextRecord);
+#endif
fprintf(stderr, "--------------------------------------------------------\n");

View File

@ -0,0 +1,11 @@
--- utils/wvtask.cc.old 2015-09-22 05:49:32.911132004 -0400
+++ utils/wvtask.cc 2015-09-22 05:50:36.230115961 -0400
@@ -540,7 +540,7 @@
const void *WvTaskMan::current_top_of_stack()
{
-#ifdef HAVE_LIBC_STACK_END
+#if defined(HAVE_LIBC_STACK_END) && defined(__GLIBC__)
extern const void *__libc_stack_end;
if (use_shared_stack() || current_task == NULL)
return __libc_stack_end;

View File

@ -0,0 +1,120 @@
--- utils/wvtask.cc.old 2015-09-22 05:49:32.911132004 -0400
+++ utils/wvtask.cc 2015-09-22 06:48:44.627809854 -0400
@@ -200,7 +200,9 @@
stacktop = (char *)alloca(0);
context_return = 0;
+#ifdef __GLIBC__
assert(getcontext(&get_stack_return) == 0);
+#endif
if (context_return == 0)
{
// initial setup - start the stackmaster() task (never returns!)
@@ -266,13 +268,17 @@
state = &old_task->mystate;
context_return = 0;
+#ifdef __GLIBC__
assert(getcontext(state) == 0);
+#endif
int newval = context_return;
if (newval == 0)
{
// saved the state, now run the task.
context_return = val;
+#ifdef __GLIBC__
setcontext(&task.mystate);
+#endif
return -1;
}
else
@@ -320,13 +326,17 @@
#endif
context_return = 0;
+#ifdef __GLIBC__
assert(getcontext(&current_task->mystate) == 0);
+#endif
int newval = context_return;
if (newval == 0)
{
// saved the task state; now yield to the toplevel.
context_return = val;
+#ifdef __GLIBC__
setcontext(&toplevel);
+#endif
return -1;
}
else
@@ -342,7 +352,9 @@
void WvTaskMan::get_stack(WvTask &task, size_t size)
{
context_return = 0;
+#ifdef __GLIBC__
assert(getcontext(&get_stack_return) == 0);
+#endif
if (context_return == 0)
{
assert(magic_number == -WVTASK_MAGIC);
@@ -372,7 +384,9 @@
// initial setup
stack_target = &task;
context_return = size/1024 + (size%1024 > 0);
+#ifdef __GLIBC__
setcontext(&stackmaster_task);
+#endif
}
else
{
@@ -410,7 +424,9 @@
assert(magic_number == -WVTASK_MAGIC);
context_return = 0;
+#ifdef __GLIBC__
assert(getcontext(&stackmaster_task) == 0);
+#endif
val = context_return;
if (val == 0)
{
@@ -420,7 +436,9 @@
// all current stack allocations) and go back to get_stack
// (or the constructor, if that's what called us)
context_return = 1;
+#ifdef __GLIBC__
setcontext(&get_stack_return);
+#endif
}
else
{
@@ -475,7 +493,9 @@
// back here from longjmp; someone wants stack space.
context_return = 0;
+#ifdef __GLIBC__
assert(getcontext(&task->mystate) == 0);
+#endif
if (context_return == 0)
{
// done the setjmp; that means the target task now has
@@ -511,7 +531,9 @@
}
else
{
+#ifdef __GLIBC__
assert(getcontext(&task->func_call) == 0);
+#endif
task->func_call.uc_stack.ss_size = task->stacksize;
task->func_call.uc_stack.ss_sp = task->stack;
task->func_call.uc_stack.ss_flags = 0;
@@ -522,9 +544,11 @@
(void (*)(void))call_func, 1, task);
context_return = 0;
+#ifdef __GLIBC__
assert(getcontext(&task->func_return) == 0);
if (context_return == 0)
setcontext(&task->func_call);
+#endif
}
// the task's function terminated.

View File

@ -1,7 +1,7 @@
# Template file for 'wvstreams'
pkgname=wvstreams
version=4.6.1
revision=9
revision=10
build_style=gnu-configure
maintainer="Enno Boland <gottox@voidlinux.eu>"
license="LGPL-2"