tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] win32 build is broken, may caused by jiang's changes


From: Roy Tam
Subject: Re: [Tinycc-devel] win32 build is broken, may caused by jiang's changes
Date: Fri, 16 May 2014 15:12:30 +0800

2014-05-16 14:47 GMT+08:00 Roy Tam <address@hidden>:
> 2014-05-16 12:18 GMT+08:00 jiang <address@hidden>:
>>
>> 于 2014年05月15日 08:58, Roy Tam 写道:
>>
>> Hello list,
>>
>> win32 tcc build is broken now:
>>
>> GNU gdb (GDB) 7.5
>> Copyright (C) 2012 Free Software Foundation, Inc.
>> License GPLv3+: GNU GPL version 3 or later
>> <http://gnu.org/licenses/gpl.html>
>> This is free software: you are free to change and redistribute it.
>> There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
>> and "show warranty" for details.
>> This GDB was configured as "i686-pc-mingw32".
>> For bug reporting instructions, please see:
>> <http://www.gnu.org/software/gdb/bugs/>...
>> Reading symbols from D:\tinycc\tcc.exe...done.
>> (gdb) r
>> Starting program: D:\tinycc\tcc.exe -B../win32 -I../include -c
>> bcheck.c -o i386-win32/bcheck.o -I.. -g -DTCC_TARGET_I386
>> -DTCC_TARGET_PE
>> [New Thread 808.0x1780]
>>
>> Program received signal SIGSEGV, Segmentation fault.
>> 0x7c92100b in ntdll!RtlEnumerateGenericTableLikeADirectory ()
>>    from C:\WINDOWS\system32\ntdll.dll
>> (gdb) bt
>> #0  0x7c92100b in ntdll!RtlEnumerateGenericTableLikeADirectory ()
>>    from C:\WINDOWS\system32\ntdll.dll
>> #1  0x77c0b90d in msvcrt!_lock () from C:\WINDOWS\system32\msvcrt.dll
>> #2  0x77c10efa in msvcrt!fputs () from C:\WINDOWS\system32\msvcrt.dll
>> #3  0x00000000 in ?? ()
>> (gdb) frame 2
>> #2  0x77c10efa in msvcrt!fputs () from C:\WINDOWS\system32\msvcrt.dll
>> (gdb) info frame
>> Stack level 2, frame at 0x12f2ac:
>>  eip = 0x77c10efa in msvcrt!fputs; saved eip 0x0
>>  called by frame at 0x12f2b0, caller of frame at 0x12f2a8
>>  Arglist at 0x12f2a4, args:
>>  Locals at 0x12f2a4, Previous frame's sp is 0x12f2ac
>>  Saved registers:
>>   eip at 0x12f2a8
>> (gdb)
>>
>> fix push_macro, asked Tom to help me test
>> 52891b6ff680a03c966776b530cf94de9f831b07
>>
>
> It is not fixed to me.
> After some debugging, s1->ppfp is used without checking in tccpp.c:1760
> http://repo.or.cz/w/tinycc.git/blob/07614b5e22073cbb2c1b298ab906d57372619604:/tccpp.c#l1760
>

and it is because #pragma pack is not enabled in preprocessor, and
unknown #pragma tries to be written to output file pointer s1->ppfp
which is not set in general compiling.

my diff of tccpp.c for testing:
diff --git a/tccpp.c b/tccpp.c
index 91c2aee..b4c1dba 100644
--- a/tccpp.c
+++ b/tccpp.c
@@ -1627,7 +1627,7 @@ skip:
         break;
     case TOK_PRAGMA:
         next();
-        if (tok == TOK_pack && parse_flags & PARSE_FLAG_PACK) {
+        if (tok == TOK_pack /*&& parse_flags & PARSE_FLAG_PACK*/) {
             /*
               This may be:
               #pragma pack(1) // set
@@ -1757,11 +1757,14 @@ pack_error:
                 }
             }
         }else{
-            fputs("#pragma ", s1->ppfp);
+            if(s1->ppfp) fputs("#pragma ", s1->ppfp);
+            else printf("#pragma ");
             while (tok != TOK_LINEFEED){
-                fputs(get_tok_str(tok, &tokc), s1->ppfp);
+                if(s1->ppfp) fputs(get_tok_str(tok, &tokc), s1->ppfp);
+                else printf("%s ",get_tok_str(tok, &tokc));
                 next();
             }
+            if(!s1->ppfp) printf("\n");
             goto the_end;
         }
         break;

but does the push_macro work? I got this:
../tcc.exe -B../win32 -I../include -c bcheck.c -o i386-win32/bcheck.o
-I..  -O2  -DTCC_TARGET_I386 -DTCC_TARGET_PE
In file included from bcheck.c:20:
../win32/include/stdlib.h:80: warning: stack empty
In file included from bcheck.c:20:
../win32/include/stdlib.h:316: warning: stack empty
In file included from bcheck.c:21:
../win32/include/stdio.h:268: warning: stack empty
In file included from bcheck.c:21:
../win32/include/stdio.h:269: warning: stack empty


and it is something like:
#pragma push_macro("long")
#undef long

  typedef struct {
    long double x;
  } _LONGDOUBLE;

#pragma pop_macro("long")



reply via email to

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