tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Release Candidate - please test


From: Alexander Gladysh
Subject: Re: [Tinycc-devel] Release Candidate - please test
Date: Sun, 9 Mar 2008 21:26:17 +0300

> > I'm trying to build it under OS X (10.5.2 Leopard). Is it supported at all 
> > BTW?

> Appearently not, but if you can make it work ...

I'll try, but that 11KLOC tcc.c source file scares me much :-)

>  > ...
>  > Got output as follows:
>
> > $ make
>  > gcc -O2 -g -Wall -mpreferred-stack-boundary=2 -march=i386
>  > -falign-functions=0 -fno-strict-aliasing -Wno-pointer-sign
>  > -Wno-sign-compare -o tcc tcc.c -lm -ldl
>  > tcc.c: In function 'rt_get_caller_pc':
>  > tcc.c:9857: error: request for member 'gregs' in something not a
>  > structure or union
>
>  The code in question is about basic stack backtrace support with
>  tcc -run ...
>
>  To begin with you could just disable the feature similar to
>  _WIN32/CONFIG_TCCBOOT at lines 9834 and 10015).

I made it compile with help of Google (so, that's pretty much a
Cargo-cult programming).
However make test segfaults. See logs below. Would try do disable the
feature as you've suggested.

Alexander.

Difference:

diff --git a/bcheck.c b/bcheck.c
index 0ec2a4b..d9ff138 100644
--- a/bcheck.c
+++ b/bcheck.c
@@ -21,7 +21,8 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <string.h>
-#if !defined(__FreeBSD__) && !defined(__DragonFly__) && !defined(__OpenBSD__)
+#if !defined(__FreeBSD__) && !defined(__DragonFly__) \
+ && !defined(__OpenBSD__) && !defined(__APPLE__)
 #include <malloc.h>
 #endif

@@ -37,7 +38,7 @@
 #define HAVE_MEMALIGN

 #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__dietlibc__) \
-    || defined(__UCLIBC__) || defined(__OpenBSD__)
+    || defined(__UCLIBC__) || defined(__OpenBSD__) || defined(__APPLE__)
 #warning Bound checking not fully supported in this environment.
 #undef CONFIG_TCC_MALLOC_HOOKS
 #undef HAVE_MEMALIGN
diff --git a/tcc.c b/tcc.c
index 56b8069..de64a41 100644
--- a/tcc.c
+++ b/tcc.c
@@ -9853,6 +9853,8 @@ static int rt_get_caller_pc(unsigned long *paddr,
         *paddr = uc->uc_mcontext.mc_eip;
 #elif defined(__dietlibc__)
         *paddr = uc->uc_mcontext.eip;
+#elif defined(__APPLE__)
+        *paddr = uc->uc_mcontext->__ss.__eip; /* TODO: ?! */
 #else
         *paddr = uc->uc_mcontext.gregs[REG_EIP];
 #endif
@@ -9862,6 +9864,8 @@ static int rt_get_caller_pc(unsigned long *paddr,
         fp = uc->uc_mcontext.mc_ebp;
 #elif defined(__dietlibc__)
         fp = uc->uc_mcontext.ebp;
+#elif defined(__APPLE__)
+        fp = uc->uc_mcontext->__ss.__ebp; /* TODO: ?! */
 #else
         fp = uc->uc_mcontext.gregs[REG_EBP];
 #endif

Output of make test:

$ make test
gcc -O2 -g -Wall -mpreferred-stack-boundary=2 -march=i386
-falign-functions=0 -fno-strict-aliasing -Wno-pointer-sign
-Wno-sign-compare -I. -o tcctest.ref tcctest.c
tcctest.c:266:5: warning: multi-line comment
tcctest.c: In function 'string_test':
tcctest.c:312: warning: format '%lx' expects type 'long unsigned int',
but argument 3 has type 'int'
tcctest.c: In function 'array_test':
tcctest.c:566: warning: format '%d' expects type 'int', but argument 2
has type 'long unsigned int'
tcctest.c:567: warning: format '%d' expects type 'int', but argument 2
has type 'long unsigned int'
tcctest.c:569: warning: format '%d' expects type 'int', but argument 2
has type 'long unsigned int'
tcctest.c:571: warning: format '%d' expects type 'int', but argument 2
has type 'long unsigned int'
tcctest.c:572: warning: format '%d' expects type 'int', but argument 2
has type 'long unsigned int'
tcctest.c: In function 'isid':
tcctest.c:645: warning: suggest parentheses around comparison in operand of &
tcctest.c:645: warning: suggest parentheses around comparison in operand of &
tcctest.c:645: warning: suggest parentheses around comparison in operand of |
tcctest.c: In function 'struct_test':
tcctest.c:762: warning: format '%d' expects type 'int', but argument 2
has type 'long unsigned int'
tcctest.c:762: warning: format '%d' expects type 'int', but argument 3
has type 'long unsigned int'
tcctest.c:762: warning: format '%d' expects type 'int', but argument 4
has type 'long unsigned int'
tcctest.c:762: warning: format '%d' expects type 'int', but argument 5
has type 'long unsigned int'
tcctest.c:784: warning: format '%d' expects type 'int', but argument 2
has type 'long unsigned int'
tcctest.c:784: warning: format '%d' expects type 'int', but argument 3
has type 'long unsigned int'
tcctest.c:786: warning: format '%d' expects type 'int', but argument 2
has type 'long unsigned int'
tcctest.c:786: warning: format '%d' expects type 'int', but argument 3
has type 'long unsigned int'
tcctest.c:788: warning: format '%d' expects type 'int', but argument 2
has type 'long unsigned int'
tcctest.c:788: warning: format '%d' expects type 'int', but argument 3
has type 'long unsigned int'
tcctest.c:790: warning: format '%d' expects type 'int', but argument 2
has type 'long unsigned int'
tcctest.c:790: warning: format '%d' expects type 'int', but argument 3
has type 'long unsigned int'
tcctest.c:793: warning: format '%d' expects type 'int', but argument 2
has type 'long unsigned int'
tcctest.c:794: warning: format '%d' expects type 'int', but argument 2
has type 'long unsigned int'
tcctest.c: At top level:
tcctest.c:975: warning: return type defaults to 'int'
tcctest.c:985: warning: return type defaults to 'int'
tcctest.c: In function 'struct_assign_test':
tcctest.c:1033: warning: unused variable 'lsta1'
tcctest.c: In function 'cast_test':
tcctest.c:1089: warning: overflow in implicit constant conversion
tcctest.c:1092: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1092: warning: format '%d' expects type 'int', but argument
3 has type 'long unsigned int'
tcctest.c:1105: warning: array subscript has type 'char'
tcctest.c:1109: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1110: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1111: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1070: warning: unused variable 's'
tcctest.c: At top level:
tcctest.c:1124: warning: braces around scalar initializer
tcctest.c:1124: warning: (near initialization for 'sinit3[2]')
tcctest.c:1124: warning: braces around scalar initializer
tcctest.c:1124: warning: (near initialization for 'sinit3[2]')
tcctest.c:1126: warning: missing braces around initializer
tcctest.c:1126: warning: (near initialization for 'sinit5[0]')
tcctest.c:1150: warning: missing braces around initializer
tcctest.c:1150: warning: (near initialization for 'sinit16[0].a')
tcctest.c:1156: warning: missing braces around initializer
tcctest.c:1156: warning: (near initialization for 'sinit17[0]')
tcctest.c: In function 'init_test':
tcctest.c:1190: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1191: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1197: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1224: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1225: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1232: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c: In function 'c99_bool_test':
tcctest.c:1293: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c: In function 'bitfield_test':
tcctest.c:1316: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c: In function 'float_test':
tcctest.c:1409: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1410: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1411: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1422: warning: this decimal constant is unsigned only in ISO C90
tcctest.c:1425: warning: this decimal constant is unsigned only in ISO C90
tcctest.c:1403: warning: unused variable 'fb'
tcctest.c: In function 'funcptr_test':
tcctest.c:1457: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1458: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1459: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1460: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c: In function 'longlong_test':
tcctest.c:1584: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1594: warning: integer constant is too large for 'long' type
tcctest.c: In function 'vprintf1':
tcctest.c:1670: warning: implicit declaration of function 'putchar'
tcctest.c: In function 'whitespace_test':
tcctest.c:1687: warning: unused variable 'str'
tcctest.c: In function 'sizeof_test':
tcctest.c:1760: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1761: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1762: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1763: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1764: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1765: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1766: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1768: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1771: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1774: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1775: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1776: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1777: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1778: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1779: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c:1780: warning: format '%d' expects type 'int', but argument
2 has type 'long unsigned int'
tcctest.c: At top level:
tcctest.c:1897: warning: type qualifiers ignored on function return type
tcctest.c: In function 'asm_test':
tcctest.c:1937: warning: integer constant is too large for 'long' type
tcctest.c: At top level:
tcctest.c:920: warning: 'tab_reinit' defined but not used
./tcctest.ref > test.ref
/bin/sh: line 1: 27451 Segmentation fault      ./tcctest.ref > test.ref
make: *** [test.ref] Error 139

Stack trace from gdb ./tcctest.ref:

(gdb) run
Starting program: /Users/agladysh/projects/tcc/tcctest.ref
Reading symbols for shared libraries ++. done
string:
ab3c
ABC:
c=r
wc=a 0x1234 c
foo1_string='bar
testa'

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: 13 at address: 0x00000000
0x8fe18b42 in __dyld_misaligned_stack_error ()
(gdb) bt
#0  0x8fe18b42 in __dyld_misaligned_stack_error ()
#1  0x58000000 in ?? ()
#2  0x000025d2 in ps (s=0x5b1e "test\n") at tcctest.c:295
#3  0x00003cf1 in string_test () at tcctest.c:320
#4  0x000050e8 in main (argc=1, argv=0xbffff290) at tcctest.c:491




reply via email to

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