tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Tinycc Amalgamation file


From: Anton Shepelev
Subject: Re: [Tinycc-devel] Tinycc Amalgamation file
Date: Fri, 23 Nov 2018 12:12:29 +0300

Mike Parsons:

>Hi all ... I am trying to create a WebAssembly version of
>tinycc using the emscripten tool chain and was wondering if
>there exists a single amalgamated source file for tinycc?
>For example, like that which is offered by sqlite.org
>https://sqlite.org/howtocompile.html.

This is a reply from Bart at comp.lang.c (where I fixed two
important typos):

I don't remember seeing an amalgamated version. Perhaps
there's some confusion because if the ONE_SOURCE macro is
defined, then when you compile tcc.c, it will also compile
all source code of tcc as a single translation unit.
(Otherwise it will be built as two lots, .exe and .dll.)

If an actual single file is required, that looks easy, but
my investigations reveal this include structure (standard
headers and many duplicate tcc.h not shown):

100 tcc.c
201     tcc.h
301         config.h
302         libtcc.h
303         elf.h
304         stab.h
401             stab.def
305         tcctok.h
501             i386-tok.h      WIN32
202     libtcc.c
600         (tcc.h)
601         tccpp.c
602         tccgen.c
603         tccelf.c
604         tccrun.c
605         i386-gen.c          WIN32
606         i386-lib.c          WIN32
607         i386-asm.c          WIN32
203     tcctools.c
700         (tcc.h)
701         process.h           WIN32 (./win32/include)
801             _mingw.h        WIN32 (./win32/include)

When I tried to create such a file manually, then I got
compile errors.

If someone really wants a single C source for Tiny C, for a
fixed configuration and with no need to maintain the result,
then then using simple pre-processing /might/ work:

  C:cc7inycc-mob>bcc -e tcc.c
  Compiling tcc.c to tcc.i

  C:cc7inycc-mob>bcc tcc.i
  Compiling tcc.i to tcc.exe

  C:cc7inycc-mob>tcc -v
  tcc version 0.9.27 (x86_64 Windows)

However, there were problems trying to do the same with gcc
-E (I could build tcc.exe from the preprocessed file, but
couldn't run it - incompatible exe format or something). So
perhaps try a different compiler, although the result may be
specific to that compiler.

(To build tcc.c here for Windows 64, I defined these macros
at the start:

  #define TCC_TARGET_PE
  #define TCC_TARGET_X86_64
  #define ONE_SOURCE 1

while config.h contained:
  #define TCC_VERSION "0.9.27"

)

Perhaps I should add that this 'one-source' version is for
the main tcc executable. However, building a working Tiny C
installation also involves using that tcc.exe to build its
libraries: compiling a further bunch of .c and .S files into
.o then combining into .a.

There is also a specific directory structure needed to
properly run that version of tcc.

I couldn't find trace of an amalgamated version online, so
it sounds like this project is not so suitable for that, not
if one tcc.c file is expected to take care of everything
necessary.



reply via email to

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