tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Do you know of any forks of TinyCC?


From: grischka
Subject: Re: [Tinycc-devel] Do you know of any forks of TinyCC?
Date: Sat, 07 May 2016 11:05:51 +0200
User-agent: Thunderbird 2.0.0.23 (Windows/20090812)

David Mertens wrote: ---
Nope. I had to learn by diving into the source myself. But if you want to
learn the process of compilation, you should just try to follow the series
of function calls to compile code.

First commits to tinycc are from 2001
http://repo.or.cz/tinycc.git/shortlog/18a8013fe71a63633948bc40412f7939fe34907d

They are functional AFAICS, on i386.

For example download a snapshot (7kB) from Fabrice Bellard's initial revision
http://repo.or.cz/tinycc.git/snapshot/27f6e16bae9d0f73acec07f61aea696ab5adc680.tar.gz

add this on top of tcc.c --------->
  void expr(void);
  void decl(int);
  #ifdef _WIN32
  #include <windows.h>
  void *dlsym(int x, const char *func) {
      return GetProcAddress(GetModuleHandle("msvcrt"), func);
  }
  #endif
<---------------------------------------

compile:
  $ gcc tcc.c -o tcc
or
  $ cl -MD tcc.c

create hello.c ------------------------->
  #define HELLO "Hello!\n"
  int main (int argc, char **argv)
  {
      int i;
      printf(HELLO);
      i = 0;
      while (i < argc) {
          printf("arg %d = %s\n", i, argv[i]);
          i++;
      }
      return 0;
  }
<---------------------------------------

and run it:
  $ tcc hello.c 111 222 333

  Hello!
  arg 0 = hello.c
  arg 1 = 111
  arg 2 = 222
  arg 3 = 333

As you can see, it works.  With preprocessor and all. ;)

-- gr

On Fri, May 6, 2016 at 1:16 AM, <address@hidden> wrote:

I want to understand how TCC works, in the way it is now it confuses me
greatly. Maybe you know of some forks that maybe dropped some of it's
features and made source a bit easier to understand? Or, maybe I should
look at some old enough commit, before TCC learned to compile asm code, and
things of this sort?





reply via email to

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