tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] tcc on x86_64


From: Sergei Trofimovich
Subject: [Tinycc-devel] tcc on x86_64
Date: Thu, 16 Jul 2009 23:38:27 +0300

Hi! tcc is really fast compiler!

I tried to play with it and have managed to build master branch of 
http://midnight-commander.org/
by tcc on amd64. I grabbed tcc from git://repo.or.cz/tinycc.git

1.
mc compiled and even runs but fails on certain user's operations. I suspect 
it's a tcc's miscompilation.
In order to debug it i tried valgrind, but even hello_world tcc's produced 
binaries are
unvalgrindable on my gcc/glibc:
$ cat > hello.c<<EOF
....> int main() { printf("hello!\n"); return 0; }
....> EOF
$ tcc ./hello.c -o hi
$ valgrind ./hi
--12247-- WARNING: Serious error when reading debug info
--12247-- When reading debug info from /tmp/hi:
--12247-- Last block truncated in .debug_info; ignoring
Inconsistency detected by ld.so: rtld.c: 1243: dl_main: Assertion 
`_rtld_local._dl_rtld_map.l_libname' failed!
Glibc screwed. Where is an error? glibc being too restrictive? tcc generating 
bad elf64? valgrind misloading
nonstandard elf?

2.
During compilation I've noticed some evil warnings:
tccgen.c:4091: warning: cast to pointer from integer of different size
tccgen.c:4114: warning: cast to pointer from integer of different size

They frightened me as 'long' is 64bit on gcc and 'int' is 32bit.
Are those generated jumps incorrect or tcc emits 32bit wide addresses?

3.
./include/stddef.h:typedef __SIZE_TYPE__ size_t;
./libtcc.c:    tcc_define_symbol(s, "__SIZE_TYPE__", "unsigned int");
./libtcc.c:    tcc_define_symbol(s, "__PTRDIFF_TYPE__", "int");
Is it ok? I expected 'unsigned long' and 'long' here on X86_64.

4.
$ cat f.c
int f() { return 3; }
$ tcc -c f.c -o f.o
$ objdump -d f.o

f.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <f>:
   0:   55                      push   %rbp
   1:   48 89 e5                mov    %rsp,%rbp
   4:   48 81 ec 00 00 00 00    sub    $0x0,%rsp
   b:   b8 03 00 00 00          mov    $0x3,%eax
  10:   e9 00 00 00 00          jmpq   15 <f+0x15>
  15:   c9                      leaveq 
  16:   c3                      retq 

I understand, tcc isn't intended to generate efficient code, but:

* -fomit-frame-pointer would be cool to have (it should be easy to implement)
* 'sub    $0x0,%rsp' could be eliminated as a trivial common case
* 'jmpq 15' could be eliminated as a trivial common case

Thanks!

-- 

  Sergei

Attachment: signature.asc
Description: PGP signature


reply via email to

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