Eric Biggers | 22 May 22:09 2016
Picon

[BUG] assertion failure when compiling initialization of array of structs on x86_64

Hello,

When I tried compiling some of my code with tcc, I encountered an assertion
failure, which I have reduced to the following minimal example:

struct S {
        long a;
};

void f(struct S *x)
{
        struct S y[1] = { *x };
}

$ tcc -c bug.c
tcc: x86_64-gen.c:418: load: Assertion `((ft & VT_BTYPE) == VT_INT) || ((ft & VT_BTYPE) == VT_LLONG) ||
((ft & VT_BTYPE) == VT_PTR) || ((ft & VT_BTYPE) == VT_ENUM) || ((ft & VT_BTYPE) == VT_FUNC)' failed.
Aborted (core dumped)

Paul Kienzle | 21 May 07:02 2016
Picon

using tinycc to compile python plugins

Hi,

In order to allow users to compile plugins for our python program, I put together a python package with the compiler and enough logic to tell my program where the compiler lives on disk:


Since this could be useful for other Windows python applications, I would like to upload this to pypi package distribution site.

Is it okay to use the name tinycc for the package?

Suggestions what I might call it instead?

Thanks in advance,

    - Paul

<div><div dir="ltr">Hi,<div><br></div>
<div>In order to allow users to compile plugins for our python program, I put together a python package with the compiler and enough logic to tell my program where the compiler lives on disk:</div>
<div><br></div>
<div>&nbsp; &nbsp; <a href="https://github.com/SasView/tinycc">https://github.com/SasView/tinycc</a><br>
</div>
<div><br></div>
<div>Since this could be useful for other Windows python applications, I would like to upload this to pypi package distribution site.</div>
<div><br></div>
<div>Is it okay to use the name tinycc for the package?</div>
<div><br></div>
<div>Suggestions what I might call it instead?</div>
<div><br></div>
<div>Thanks in advance,</div>
<div><br></div>
<div>&nbsp; &nbsp; - Paul</div>
<div><br></div>
<div><a href="mailto:pkienzle@...">pkienzle@...</a></div>
</div></div>
Chris Marshall | 20 May 14:24 2016
Picon

tcc port to cygwin

Atttached is a first cut port of the TinyCC build to the cygwin platform.

The mains problems seem to be from managing the different include files.
I hand added some defines to libtcc1.c for __INTPTR_TYPE__ and a few
others to get that to build.

However, it is now failing to build bcheck.c with:

 >  ../tcc -B.. -c bcheck.c -o x86_64/bcheck.o -I.. -Wall -g -O0 
-Wdeclaration-after-statement -Wno-deprecated-declarations 
-Wno-strict-aliasing -Wno-pointer-sign -Wno-sign-compare 
-Wno-unused-result -Wno-uninitialized -fno-strict-aliasing -fPIC 
-DTCC_TARGET_X86_64
 >  In file included from bcheck.c:20:
 >  In file included from /usr/include/stdlib.h:18:
 >  /usr/include/sys/reent.h:196: error: ')' expected (got "*")
 >  Makefile:116: recipe for target 'x86_64/bcheck.o' failed
 >  make[1]: *** [x86_64/bcheck.o] Error 1

Looking at the origin of the error message in the skip() routine
in tccpp.c, I could not find any place that skip() was called with
an argument of ')'.  Is there some other place that message
could be coming from.  Seems like it might be a possible
problem in the preprocessing....

--Chris

From f1ee3de3a4c24157c9927cb3706f4e902ae88710 Mon Sep 17 00:00:00 2001
From: Chris Marshall <devel.chm.01 <at> gmail.com>
Date: Fri, 20 May 2016 08:02:03 -0400
Subject: [PATCH] Basic port to cygwin of mob tcc

The remaining issues appear to be ones relating to include file
problems.  Specifically, the local include/stddef.h and others
seem to be inconsistent with those from the native gcc (as in
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/include/stddef.h or others.
---
 conftest.c    | 2 ++
 lib/libtcc1.c | 5 +++++
 libtcc.c      | 3 +++
 tccrun.c      | 8 ++++++++
 4 files changed, 18 insertions(+)

diff --git a/conftest.c b/conftest.c
index fa07a1b..8fe2e01 100644
--- a/conftest.c
+++ b/conftest.c
 <at>  <at>  -18,6 +18,8  <at>  <at> 
 # define TRIPLET_OS "linux"
 #elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
 # define TRIPLET_OS "kfreebsd"
+#elif defined (__CYGWIN__)
+# define TRIPLET_OS "cygwin"
 #elif !defined (__GNU__)
 # define TRIPLET_OS "unknown"
 #endif
diff --git a/lib/libtcc1.c b/lib/libtcc1.c
index a5fee7b..05ec15b 100644
--- a/lib/libtcc1.c
+++ b/lib/libtcc1.c
 <at>  <at>  -28,6 +28,11  <at>  <at>  the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  
 */

+#define __INTPTR_TYPE__ long int
+#define __INTPTR_MAX__ 9223372036854775807L
+#define __INT32_TYPE__ int
+#define __INT32_MAX__ 2147483647
+
 #include <stdint.h>

 #define W_TYPE_SIZE   32
diff --git a/libtcc.c b/libtcc.c
index b0fcdf9..44caf21 100644
--- a/libtcc.c
+++ b/libtcc.c
 <at>  <at>  -1131,6 +1131,9  <at>  <at>  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__)
     tcc_define_symbol(s, "__FreeBSD__", "__FreeBSD__");
 # endif
diff --git a/tccrun.c b/tccrun.c
index 9ee70e4..af539e3 100644
--- a/tccrun.c
+++ b/tccrun.c
 <at>  <at>  -496,6 +496,8  <at>  <at>  static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level)
         *paddr = uc->uc_mcontext->__ss.__eip;
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
         *paddr = uc->uc_mcontext.mc_eip;
+#elif defined(__CYGWIN__)
+        *paddr = uc->uc_mcontext.eip;
 #elif defined(__dietlibc__)
         *paddr = uc->uc_mcontext.eip;
 #elif defined(__NetBSD__)
 <at>  <at>  -509,6 +511,8  <at>  <at>  static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level)
         fp = uc->uc_mcontext->__ss.__ebp;
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
         fp = uc->uc_mcontext.mc_ebp;
+#elif defined(__CYGWIN__)
+        fp = uc->uc_mcontext.ebp;
 #elif defined(__dietlibc__)
         fp = uc->uc_mcontext.ebp;
 #elif defined(__NetBSD__)
 <at>  <at>  -544,6 +548,8  <at>  <at>  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
 <at>  <at>  -555,6 +561,8  <at>  <at>  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
-- 
2.5.3

From f1ee3de3a4c24157c9927cb3706f4e902ae88710 Mon Sep 17 00:00:00 2001
From: Chris Marshall <devel.chm.01 <at> gmail.com>
Date: Fri, 20 May 2016 08:02:03 -0400
Subject: [PATCH] Basic port to cygwin of mob tcc

The remaining issues appear to be ones relating to include file
problems.  Specifically, the local include/stddef.h and others
seem to be inconsistent with those from the native gcc (as in
/usr/lib/gcc/x86_64-pc-cygwin/4.9.3/include/stddef.h or others.
---
 conftest.c    | 2 ++
 lib/libtcc1.c | 5 +++++
 libtcc.c      | 3 +++
 tccrun.c      | 8 ++++++++
 4 files changed, 18 insertions(+)

diff --git a/conftest.c b/conftest.c
index fa07a1b..8fe2e01 100644
--- a/conftest.c
+++ b/conftest.c
 <at>  <at>  -18,6 +18,8  <at>  <at> 
 # define TRIPLET_OS "linux"
 #elif defined (__FreeBSD__) || defined (__FreeBSD_kernel__)
 # define TRIPLET_OS "kfreebsd"
+#elif defined (__CYGWIN__)
+# define TRIPLET_OS "cygwin"
 #elif !defined (__GNU__)
 # define TRIPLET_OS "unknown"
 #endif
diff --git a/lib/libtcc1.c b/lib/libtcc1.c
index a5fee7b..05ec15b 100644
--- a/lib/libtcc1.c
+++ b/lib/libtcc1.c
 <at>  <at>  -28,6 +28,11  <at>  <at>  the Free Software Foundation, 59 Temple Place - Suite 330,
 Boston, MA 02111-1307, USA.  
 */

+#define __INTPTR_TYPE__ long int
+#define __INTPTR_MAX__ 9223372036854775807L
+#define __INT32_TYPE__ int
+#define __INT32_MAX__ 2147483647
+
 #include <stdint.h>

 #define W_TYPE_SIZE   32
diff --git a/libtcc.c b/libtcc.c
index b0fcdf9..44caf21 100644
--- a/libtcc.c
+++ b/libtcc.c
 <at>  <at>  -1131,6 +1131,9  <at>  <at>  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__)
     tcc_define_symbol(s, "__FreeBSD__", "__FreeBSD__");
 # endif
diff --git a/tccrun.c b/tccrun.c
index 9ee70e4..af539e3 100644
--- a/tccrun.c
+++ b/tccrun.c
 <at>  <at>  -496,6 +496,8  <at>  <at>  static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level)
         *paddr = uc->uc_mcontext->__ss.__eip;
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
         *paddr = uc->uc_mcontext.mc_eip;
+#elif defined(__CYGWIN__)
+        *paddr = uc->uc_mcontext.eip;
 #elif defined(__dietlibc__)
         *paddr = uc->uc_mcontext.eip;
 #elif defined(__NetBSD__)
 <at>  <at>  -509,6 +511,8  <at>  <at>  static int rt_get_caller_pc(addr_t *paddr, ucontext_t *uc, int level)
         fp = uc->uc_mcontext->__ss.__ebp;
 #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
         fp = uc->uc_mcontext.mc_ebp;
+#elif defined(__CYGWIN__)
+        fp = uc->uc_mcontext.ebp;
 #elif defined(__dietlibc__)
         fp = uc->uc_mcontext.ebp;
 #elif defined(__NetBSD__)
 <at>  <at>  -544,6 +548,8  <at>  <at>  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
 <at>  <at>  -555,6 +561,8  <at>  <at>  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
--

-- 
2.5.3

Chris Marshall | 19 May 16:48 2016
Picon

how to debug include problems with tcc?

I'm working to port the tcc build process to cygwin
and its native posix environment.  tcc.exe seems to
build fine but I'm having include problems with the
compilation of lib/bcheck.c.

Is there any way to see exactly what is generated
in the failing include files with command line switches
or other techniques?


--Chris
<div><div dir="ltr">
<div>
<div>
<div>
<div>
<div></div>I'm working to port the tcc build process to cygwin <br>and its native posix environment.&nbsp; tcc.exe seems to <br>build fine but I'm having include problems with the <br>compilation of lib/bcheck.c.<br><br>
</div>Is there any way to see exactly what is generated <br>
</div>in the failing include files with command line switches <br>
</div>or other techniques?<br><br><br>
</div>
<div>--Chris</div>
</div></div>
Christian Jullien | 16 May 10:12 2016
Picon

spawnvp V.S. _spawnvp on Windows

Hi,

 

When I build tinycc on Windows (both 32/64 bit).

 

I always get this warning:

 

../tcc.c:136:39: warning: passing argument 3 of 'spawnvp' from incompatible pointer type [-Wincompatible-pointer-types]

     int ret = spawnvp(P_NOWAIT, prog, (const char *const*)argv);

 

Looking a spawnvp documentation from Microsoft, I get:

 

This POSIX function is deprecated. Use the ISO C++ conformant spawnvp instead.

 

So I replaced spawnvp by _spawnvp and no more warning when using mingw32/64 gcc compilers.

 

Please Windows maintainer (if any), can you consider this very simple change?

 

Christian

<div><div class="WordSection1">
<p class="MsoNormal"><span lang="FR">Hi,<p></p></span></p>
<p class="MsoNormal"><span lang="FR"><p>&nbsp;</p></span></p>
<p class="MsoNormal">When I build tinycc on Windows (both 32/64 bit).<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">I always get this warning:<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">../tcc.c:136:39: warning: passing argument 3 of 'spawnvp' from incompatible pointer type [-Wincompatible-pointer-types]<p></p></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp; int ret = spawnvp(P_NOWAIT, prog, (const char *const*)argv);<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">Looking a spawnvp documentation from Microsoft, I get:<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal"><span lang="EN">This POSIX function is deprecated. Use the ISO C++ conformant </span>spawnvp <span lang="EN">instead.<p></p></span></p>
<p class="MsoNormal"><span lang="EN"><p>&nbsp;</p></span></p>
<p class="MsoNormal"><span lang="EN">So I replaced spawnvp by _spawnvp and no more warning when using mingw32/64 gcc compilers.<p></p></span></p>
<p class="MsoNormal"><span lang="EN"><p>&nbsp;</p></span></p>
<p class="MsoNormal"><span lang="EN">Please Windows maintainer (if any), can you consider this very simple change?<p></p></span></p>
<p class="MsoNormal"><span lang="EN"><p>&nbsp;</p></span></p>
<p class="MsoNormal"><span lang="EN">Christian</span><p></p></p>
</div></div>
Sergey Korshunoff | 16 May 09:50 2016
Picon

-C option

I simplified a -C option handling. Currently a code in my repo is like
in [mob]. Only check in parse_line_commen remain.
https://github.com/seyko2/tinycc/commit/acd6224a7fda62fe003e9901b85ef9a8d5dae851

Christian Jullien | 14 May 11:48 2016
Picon

Recent asm changes break Windows 64 built

F:\tinycc\win64>.\tcc -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c ../lib/alloca86_64.S

../lib/alloca86_64.S:15: error: bad operand with opcode 'and'

 

F:\tinycc\win64>tiny_libmaker lib/libtcc1.a libtcc1.o alloca86_64.o crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o

Can't open file alloca86_64.o

<div><div class="WordSection1">
<p class="MsoNormal">F:\tinycc\win64&gt;.\tcc -DTCC_TARGET_PE -DTCC_TARGET_X86_64 -c ../lib/alloca86_64.S<p></p></p>
<p class="MsoNormal">../lib/alloca86_64.S:15: error: bad operand with opcode 'and'<p></p></p>
<p class="MsoNormal"><p>&nbsp;</p></p>
<p class="MsoNormal">F:\tinycc\win64&gt;tiny_libmaker lib/libtcc1.a libtcc1.o alloca86_64.o crt1.o wincrt1.o dllcrt1.o dllmain.o chkstk.o<p></p></p>
<p class="MsoNormal">Can't open file alloca86_64.o<p></p></p>
</div></div>
Sergey Korshunoff | 14 May 09:24 2016
Picon

tcc compilation on MSYS2

MSYS2 is current environment for Qt and other software development on
Windows. It is a mingw+cygwin with a package manager (pacman), ported
from ARCH Linux. MSYS2 allow to build
mingw32/mingw64/cygwin32/cygwin64 programs in unix-like environment.
Currenly tcc can not be build on this environment (mix of unix and
windows). I think a system name (uname output) is needed to
select/reject some code in sources of the tcc.

Sergey Korshunoff | 13 May 16:41 2016
Picon

patches for discussion

I have the following patches in github repo (requests in tinycc bugzilla):

+ memory model macros __{L,}LP64__
https://github.com/seyko2/tinycc/commit/eb2a3a8ae941817a5bea7e561999b4c463873a0f

+ short_call_convention
https://github.com/seyko2/tinycc/commit/558614d3f822de03bb6267f47a24487faa69d29a

+ --whole-archive support
https://github.com/seyko2/tinycc/commit/65e42df4d0fedb340f42652bb49fdacc7bc3e05c

PS: there is request (Bugzilla) to implement
bug #37244: tinycc: lacks -nostartfiles -nodefaultlibs support, needed by Wine
http://savannah.nongnu.org/bugs/?37244

Sergey Korshunoff | 13 May 06:59 2016
Picon

tcc helped to catch bug in linux 2.4.37 - 2.6.32

Hi!
A bug in kernels 2.4.37.11, RHEL6u7 kernel 2.6.32-573.7.1.el6 found by
using tcc as compiler.
https://github.com/seyko2/tccboot/commit/cee8898165a7bc5aefa8170f6a0290fb2500acf4

Description:
  /* Test for the divl bug.*/ must be prefixed by call to the
kernel_fpu_begin().
Bug is fixed in 3.4 kernel. It is present in 3.0.36 kernel.

How to catched:
A tccboot kernel traps sometimes when compiled by tcc. A problem was
before and temporaly solved by reordering of the source file order.

Sergey Korshunoff | 12 May 16:24 2016
Picon

.fill .rept broken by "Clean up 64bit immediate support"

Hi!
Compiling tccboot with "Clean up 64bit immediate support" there are an
error now:
linux/arch/i386/kernel/head.S:380: error: repeat < 0; .fill ignored
It is caused by

 typedef struct ExprValue {
-    uint32_t v;
+    uint64_t v;
     Sym *sym;
 } ExprValue;

Is this change must be for x86_64 only?


Gmane