tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] RE : CYGWIN support, Is __cdecl supported, esp. on linux?


From: Christian JULLIEN
Subject: [Tinycc-devel] RE : CYGWIN support, Is __cdecl supported, esp. on linux?
Date: Thu, 30 Jul 2015 14:21:29 +0200 (CEST)

With this diff I'm able to compile tcc and libttc.a ROOTB on Cygwin.
Using tcc fails because it is not able to find crt*.o
Invsetigating why:


diff --git a/lib/bcheck.c b/lib/bcheck.c
index 829e33d..542a9b6 100644
--- a/lib/bcheck.c
+++ b/lib/bcheck.c
@@ -17,6 +17,11 @@
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
+#if defined(__CYGWIN__)
+#undef __CYGWIN__
+#define __CYGWIN__TCC__
+#endif
+
 #include <stdlib.h>
 #include <stdio.h>
 #include <stdarg.h>
@@ -48,7 +53,8 @@
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) \
     || defined(__DragonFly__) || defined(__dietlibc__) \
     || defined(__UCLIBC__) || defined(__OpenBSD__) || defined(__NetBSD__) \
-    || defined(_WIN32) || defined(TCC_UCLIBC)
+    || defined(_WIN32) || defined(TCC_UCLIBC) \
+    || defined(__CYGWIN__TCC__)
 #warning Bound checking does not support malloc (etc.) in this environment.
 #undef CONFIG_TCC_MALLOC_HOOKS
 #undef HAVE_MEMALIGN
diff --git a/libtcc.c b/libtcc.c
index df98bb0..4568aa3 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1129,6 +1129,9 @@ LIBTCCAPI TCCState *tcc_new(void)
     tcc_define_symbol(s, "__linux__", NULL);
     tcc_define_symbol(s, "__linux", NULL);
 # endif
+# if defined(__CYGWIN__)
+    tcc_define_symbol(s, "__CYGWIN__", NULL);
+# endif
 # if defined(__FreeBSD__)
 #  define str(s) #s
     tcc_define_symbol(s, "__FreeBSD__", str( __FreeBSD__));
diff --git a/tccrun.c b/tccrun.c
index 55db310..0b7ebd1 100644
--- a/tccrun.c
+++ b/tccrun.c
@@ -540,6 +540,8 @@ static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level)
         *paddr = uc->uc_mcontext.mc_rip;
 #elif defined(__NetBSD__)
         *paddr = uc->uc_mcontext.__gregs[_REG_RIP];
+#elif defined(__CYGWIN__)
+        *paddr = uc->uc_mcontext.rip;
 #else
         *paddr = uc->uc_mcontext.gregs[REG_RIP];
 #endif
@@ -551,6 +553,8 @@ static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level)
         fp = uc->uc_mcontext.mc_rbp;
 #elif defined(__NetBSD__)
         fp = uc->uc_mcontext.__gregs[_REG_RBP];
+#elif defined(__CYGWIN__)
+        fp = uc->uc_mcontext.rbp;
 #else
         fp = uc->uc_mcontext.gregs[REG_RBP];
 #endif


----- message d'origine -----
De : "Christian JULLIEN" <address@hidden>
date jeu. 30/07/2015 10:22 (GMT +02:00)
À : "tinycc-devel" <address@hidden>
Objet : [Tinycc-devel] CYGWIN support, Is __cdecl supported, esp. on linux?

Hi All,

I'm trying to make tcc compile ROOTB on Cygwin and I already have tcc.exe running with very few patches (see below).
The problem I'm facing is a parse error with __cdecl declarations from cygwin includes.

Even on a standard Linux machine running mod tcc, the following code:
void __cdecl foo(void)
{
}

fails with
address@hidden ~/tinycc $ ./tcc -c foo.c
foo.c:1: error: ';' expected (got "foo")
Am I missing something?

Here is my first diff to support Cygwin, at least on x64.

diff --git a/libtcc.c b/libtcc.c
index df98bb0..4568aa3 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1129,6 +1129,9 @@ LIBTCCAPI TCCState *tcc_new(void)
     tcc_define_symbol(s, "__linux__", NULL);
     tcc_define_symbol(s, "__linux", NULL);
 # endif
+# if defined(__CYGWIN__)
+    tcc_define_symbol(s, "__CYGWIN__", NULL);
+# endif
 # if defined(__FreeBSD__)
 #  define str(s) #s
     tcc_define_symbol(s, "__FreeBSD__", str( __FreeBSD__));
diff --git a/tccrun.c b/tccrun.c
index 55db310..0b7ebd1 100644
--- a/tccrun.c
+++ b/tccrun.c
@@ -540,6 +540,8 @@ static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level)
         *paddr = uc->uc_mcontext.mc_rip;
 #elif defined(__NetBSD__)
         *paddr = uc->uc_mcontext.__gregs[_REG_RIP];
+#elif defined(__CYGWIN__)
+        *paddr = uc->uc_mcontext.rip;
 #else
         *paddr = uc->uc_mcontext.gregs[REG_RIP];
 #endif
@@ -551,6 +553,8 @@ static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level)
         fp = uc->uc_mcontext.mc_rbp;
 #elif defined(__NetBSD__)
         fp = uc->uc_mcontext.__gregs[_REG_RBP];
+#elif defined(__CYGWIN__)
+        fp = uc->uc_mcontext.rbp;
 #else
         fp = uc->uc_mcontext.gregs[REG_RBP];
 #endif




_______________________________________________
Tinycc-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/tinycc-devel


reply via email to

[Prev in Thread] Current Thread [Next in Thread]