Here a modified version of the patch, tested on OpenBSD (stable), FreeBSD and DragonFly.
On Thu, 26 Nov 2020 at 16:15, David CARLIER <devne...@gmail.com> wrote: > > Are they with / without the fix ? Because normally the changes would > address those I saw them too. > > On Thu, 26 Nov 2020 at 16:14, Christian Jullien <eli...@orange.fr> wrote: > > > > Same result, also NetBSD still fails with: > > > > -bash-5.0$ ./configure > > Binary directory /usr/local/bin > > TinyCC directory /usr/local/lib/tcc > > Library directory /usr/local/lib > > Include directory /usr/local/include > > Manual directory /usr/local/share/man > > Info directory /usr/local/share/info > > Doc directory /usr/local/share/doc > > Source path /home/jullien/tinycc > > C compiler gcc (7.4) > > Target OS NetBSD > > CPU x86_64 > > Config ldl=no > > Creating config.mak and config.h > > config.h is unchanged > > -bash-5.0$ gmake > > gmake[1]: Entering directory '/home/jullien/tinycc/lib' > > ../tcc -c bt-exe.c -o ../bt-exe.o -B.. -I.. > > In file included from bt-exe.c:6: > > In file included from ../tccrun.c:21: > > In file included from ../tcc.h:29: > > In file included from /usr/include/stdlib.h:37: > > /usr/include/sys/cdefs.h:441: error: #error "No function renaming possible" > > gmake[1]: *** [Makefile:83: ../bt-exe.o] Error 1 > > gmake[1]: Leaving directory '/home/jullien/tinycc/lib' > > gmake: *** [Makefile:269: libtcc1.a] Error 2 > > > > > > -----Original Message----- > > From: Tinycc-devel > > [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On Behalf Of > > Sudipto Mallick > > Sent: Thursday, November 26, 2020 16:50 > > To: tinycc-devel@nongnu.org > > Subject: Re: [Tinycc-devel] [PATCH] DragonFlyBSD build fix proposal > > > > Great achievement > > > > On OpenBSD x86_64, applied your patch and tried to compile, to get an > > error that ucontext_t doesn't have uc_rbp as a member; i think that > > was a typo and would be: sc_rbp. fixing that, it compiled smoothly > > tried to compile a c file using this newly built tcc fails with crt0.o > > etc. not found error :( > > > > ~smlckz > > > > _______________________________________________ > > Tinycc-devel mailing list > > Tinycc-devel@nongnu.org > > https://lists.nongnu.org/mailman/listinfo/tinycc-devel > > > > > > _______________________________________________ > > Tinycc-devel mailing list > > Tinycc-devel@nongnu.org > > https://lists.nongnu.org/mailman/listinfo/tinycc-devel
From fd91cd9a46528c3efeb7fe44014763cdf6eecf2a Mon Sep 17 00:00:00 2001 From: David Carlier <devne...@gmail.com> Date: Thu, 26 Nov 2020 16:27:33 +0000 Subject: [PATCH] BSD systems build fixes. --- lib/bcheck.c | 8 ++++++++ libtcc.c | 6 +++++- tcc.h | 11 +++++++++++ tccrun.c | 3 +++ 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/bcheck.c b/lib/bcheck.c index 06c5b60..0fa84ef 100644 --- a/lib/bcheck.c +++ b/lib/bcheck.c @@ -22,6 +22,7 @@ #include <stdarg.h> #include <string.h> #include <setjmp.h> +#include <pthread.h> #if !defined(__FreeBSD__) \ && !defined(__FreeBSD_kernel__) \ @@ -65,6 +66,7 @@ || defined(__NetBSD__) \ || defined(__dietlibc__) +#include <sys/mman.h> #define INIT_SEM() #define EXIT_SEM() #define WAIT_SEM() @@ -220,9 +222,15 @@ typedef struct alloca_list_struct { #define BOUND_TID_TYPE DWORD #define BOUND_GET_TID GetCurrentThreadId() #elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || defined(__riscv) +#if defined(__linux__) #define BOUND_TID_TYPE pid_t #define BOUND_GET_TID syscall (SYS_gettid) #else +// Note: each platform has its own thread id api, pthread_self might suffice for starter +#define BOUND_TID_TYPE int64_t +#define BOUND_GET_TID (int64_t)(pthread_self()) +#endif +#else #define BOUND_TID_TYPE int #define BOUND_GET_TID 0 #endif diff --git a/libtcc.c b/libtcc.c index 3698632..f7e364f 100644 --- a/libtcc.c +++ b/libtcc.c @@ -894,6 +894,9 @@ LIBTCCAPI TCCState *tcc_new(void) # if defined(__OpenBSD__) tcc_define_symbol(s, "__OpenBSD__", "__OpenBSD__"); # endif +# if defined(__DragonFly__) + tcc_define_symbol(s, "__DragonFly__", "__DragonFly__"); +# endif #endif /* TinyCC & gcc defines */ @@ -926,11 +929,12 @@ LIBTCCAPI TCCState *tcc_new(void) # if defined(__FreeBSD__) || defined (__FreeBSD_kernel__) \ || defined(__NetBSD__) || defined(__OpenBSD__) tcc_define_symbol(s, "__WINT_TYPE__", "int"); -# ifdef __FreeBSD__ +# if defined(__FreeBSD__) || defined(__NetBSD__) /* define __GNUC__ to have some useful stuff from sys/cdefs.h that are unconditionally used in FreeBSDs other system headers :/ */ tcc_define_symbol(s, "__GNUC__", "2"); tcc_define_symbol(s, "__GNUC_MINOR__", "7"); + tcc_define_symbol(s, "__GNUCLIKE_BUILTIN_VARARGS__", "1"); tcc_define_symbol(s, "__builtin_alloca", "alloca"); # endif # else diff --git a/tcc.h b/tcc.h index 3c130ec..2de8bc9 100644 --- a/tcc.h +++ b/tcc.h @@ -25,6 +25,11 @@ #define _DARWIN_C_SOURCE #include "config.h" +#ifdef __TINYC__ +// errno uses TLS unlike FreeBSD +#define __thread +#endif + #include <stdarg.h> #include <stdlib.h> #include <stdio.h> @@ -40,11 +45,17 @@ # include <unistd.h> # include <sys/time.h> # ifndef CONFIG_TCC_STATIC +# ifdef _TINYC_ +# define __pure +# endif # include <dlfcn.h> # endif /* XXX: need to define this to use them in non ISOC99 context */ extern float strtof (const char *__nptr, char **__endptr); extern long double strtold (const char *__nptr, char **__endptr); +# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__) +extern char **environ; +# endif #endif #ifdef _WIN32 diff --git a/tccrun.c b/tccrun.c index 17f1eeb..f453f3f 100644 --- a/tccrun.c +++ b/tccrun.c @@ -648,6 +648,9 @@ static void rt_getcontext(ucontext_t *uc, rt_context *rc) # elif defined(__NetBSD__) rc->ip = uc->uc_mcontext.__gregs[_REG_RIP]; rc->fp = uc->uc_mcontext.__gregs[_REG_RBP]; +# elif defined(__OpenBSD__) + rc->ip = uc->sc_rip; + rc->fp = uc->sc_rbp; # else rc->ip = uc->uc_mcontext.gregs[REG_RIP]; rc->fp = uc->uc_mcontext.gregs[REG_RBP]; -- 2.28.0
_______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel