Commit Graph

784 Commits (b7d89ff8228145fe68e4ba8a4f73faca5f85cac5)
 

Author SHA1 Message Date
Kirill Smelkov 1203348302 tcc -E: Let output_default be <file>.o instead of a.out
This affectes where `tcc -E -MD file.c` will place generated dependency
information -- previously, for `tcc -E` output_default was a.out, and so
deps were put into a.d .

Avoid this behaviour, by treating `tcc -E` as `tcc -c` with respect to
output_default computation.

This will not hurt anything else (preprocessor outputs to either stdout,
or to explicitely given (-o <file>) destination, so no default filename
is used here), and on the other hand `tcc -E -MD file.c` now puts
dependencies into file.d (the same behaviour as for gcc -E).

v2:

- restructured condition a bit to make it more clear
2010-06-21 20:49:46 +04:00
Kirill Smelkov 0c928da96d tcc: Draft suppoprt for -MD/-MF options
In build systems, this is used to automatically collect target
dependencies, e.g.

    ---- 8< (hello.c) ----
    #include "hello.h"
    #include <stdio.h>

    int main()
    {
        printf("Hello World!\n");
        return 0;
    }

$ tcc -MD -c hello.c    # -> hello.o, hello.d
$ cat hello.d
hello.o : \
        hello.c \
        hello.h \
        /usr/include/stdio.h \
        /usr/include/features.h \
        /usr/include/bits/predefs.h \
        /usr/include/sys/cdefs.h \
        /usr/include/bits/wordsize.h \
        /usr/include/gnu/stubs.h \
        /usr/include/bits/wordsize.h \
        /usr/include/gnu/stubs-32.h \
        /home/kirr/local/tcc/lib/tcc/include/stddef.h \
        /usr/include/bits/types.h \
        /usr/include/bits/wordsize.h \
        /usr/include/bits/typesizes.h \
        /usr/include/libio.h \
        /usr/include/_G_config.h \
        /usr/include/wchar.h \
        /home/kirr/local/tcc/lib/tcc/include/stdarg.h \
        /usr/include/bits/stdio_lim.h \
        /usr/include/bits/sys_errlist.h \

NOTE: gcc supports -MD only for .c -> .o, but in tcc, we generate
dependencies for whatever action is being taken. E.g. for .c -> exe, the
result will be:

$ tcc -MD -o hello hello.c  # -> hello, hello.d
hello: \
        /usr/lib/crt1.o \
        /usr/lib/crti.o \
        hello.c \
        hello.h \
        /usr/include/stdio.h \
        /usr/include/features.h \
        /usr/include/bits/predefs.h \
        /usr/include/sys/cdefs.h \
        /usr/include/bits/wordsize.h \
        /usr/include/gnu/stubs.h \
        /usr/include/bits/wordsize.h \
        /usr/include/gnu/stubs-32.h \
        /home/kirr/local/tcc/lib/tcc/include/stddef.h \
        /usr/include/bits/types.h \
        /usr/include/bits/wordsize.h \
        /usr/include/bits/typesizes.h \
        /usr/include/libio.h \
        /usr/include/_G_config.h \
        /usr/include/wchar.h \
        /home/kirr/local/tcc/lib/tcc/include/stdarg.h \
        /usr/include/bits/stdio_lim.h \
        /usr/include/bits/sys_errlist.h \
        /usr/lib/libc.so \
        /lib/libc.so.6 \
        /usr/lib/ld-linux.so.2 \
        /lib/ld-linux.so.2 \
        /usr/lib/libc_nonshared.a \
        /lib/libc.so.6 \
        /usr/lib/libc_nonshared.a \
        /home/kirr/local/tcc/lib/tcc/libtcc1.a \
        /usr/lib/crtn.o \

So tcc dependency generator is a bit more clever than one used in gcc :)

Also, I've updated TODO and Changelog (in not-yet-released section).

v2:

(Taking inputs from grischka and me myself)

- put code to generate deps file into a function.
- used tcc_fileextension() instead of open-coding
- generate deps only when compilation/preprocessing was successful

v3:

- use pstrcpy instead of snprintf(buf, sizeof(buf), "%s", ...)
2010-06-21 20:49:02 +04:00
grischka 3ba37e1e3f tccgen: Revert yuanbin's recent patches
This reverts commits 670993..d35138
Maybe these commits fixed something but also seemed to cause problems.
2010-06-21 18:21:44 +02:00
Claudio Bley 433ecdfc9d implemented C99 for loop with variable declaration 2010-06-21 11:57:32 +02:00
Kirill Smelkov bdae4a59c3 tcc: Refactor "compute default outfile name" into libtcc function
Since for upcoming -MD support default _compile_ output file be needed
even when preprocesssing (tcc -E), let's move this code out of one
particular condition block into a common function, so that we could use
it in deps generation code too.

v2:

- As suggested by grischka, moved into libtcc function instead of always
  computing near start of main()
- There is a FIXME about how to return result - I don't want to bother
  callers with allocating temp buffers, not I think it will be a good
  idea to hook default_target to TCCState. Clearly, I'm to used to
  things like std::string and python's str...
2010-06-20 21:36:47 +04:00
Kirill Smelkov a919a373da Add input files/libs and reloc_output switch to TCCState
files[0], and reloc_outpu will be needed for (upcoming in the next
patch) "compute default outfile name" refactored into libtcc function.

Also, since for symmetry and from libification point of view, it makes
some sense to also put all information about what was given as input to
compilation into TCCState, let's not only put files[0], but all
files and all libraries given explicitely by user.

One point: I've used bitfield for reloc_output & trimmed down
output_type to 8 bits so that TCCState stays the same in size, and also
access to output_type is (hopefully) is not slower.

By the way -- as of today, sizeof(TCCState) on i686-pc-linux-gnu is 2884
bytes...
2010-06-20 20:30:01 +04:00
Kirill Smelkov 66b54af8ea tcc: Fix typo in error (it's '%s', not '%s) 2010-06-16 16:51:55 +04:00
Kirill Smelkov 87db8b637e chmod a-x i386-gen.c
No need to keep executable bit on plain C source.
2010-06-16 14:37:30 +04:00
grischka 632ee5a540 Revert "Complain for static fct declared w/o file scope"
This reverts commit e9406c09a3.

We don't want errors for static local function pointers, such as:
  {
    static void (*fn)();
    ...
  }
2010-06-15 17:03:23 +02:00
grischka 10b4802869 Fix "Fix bashims in configure ..." for MSYS
Fixes commit dc265feb63
2010-06-15 17:02:35 +02:00
grischka 5fcd1fef1c Fix last commits: remove CRLF, chmod 644 tccgen.c 2010-06-15 17:02:09 +02:00
yuanbin d351384fdc tccgen: skip ')' in front of ',' for initializer 2010-06-13 14:50:53 +08:00
yuanbin 952e83e0ca tccgen: skip fields from same union 2010-06-13 02:37:28 +08:00
yuanbin d6ce75b4d6 tccgen.c: skip fields from same union 2010-06-13 01:12:36 +08:00
Kirill Smelkov 5344b2e73b .gitignore += *.o *.a
Ignores libtcc.o, libtcc.a and a bunch of other files (see previous
patch for details)
2010-06-12 18:26:37 +04:00
Kirill Smelkov de7a214c17 .cvsignore -> .gitignore
We no longer use CVS, so let's teach Git about what files to ignore...

... though doing `git status` after make + `make test` still gives
untracked content:

    # Untracked files:
    #   (use "git add <file>..." to include in what will be committed)
    #
    #       alloca86-bt.o
    #       alloca86.o
    #       bcheck.o
    #       libtcc.a
    #       libtcc.o
    #       libtcc1.a
    #       libtcc1.o
    #       tcc.o

See next patch about this stuff.
2010-06-12 18:18:19 +04:00
yuanbin dd72577759 tccgen: initial the last member of union 2010-06-11 21:18:05 +08:00
yuanbin 6709933d78 tccgen: initial last member of union 2010-06-11 20:48:33 +08:00
Thomas Preud'homme dc265feb63 Fix bashims in configure and gcctestsuite.sh.
configure and gcctestsuite.sh shell scripts contains bashisms although being
bourne shell script. This patch fixes the following bashisms:
* Use of $RANDOM variable (replaced by reading in /dev/urandom)
* Use == in tests instead of just =
* Use $[] for arithmetic computation istead of $(())
2010-05-26 14:08:29 +02:00
Daniel Glöckner a867f42597 don't discard SHT_((PRE)INIT|FINI)_ARRAY sections 2010-05-15 01:26:56 +02:00
Daniel Glöckner 128e46f91b ARM: add support for R_ARM_V4BX 2010-05-15 01:23:34 +02:00
Daniel Glöckner 20a1cba286 ARM: implement rt_get_caller_pc 2010-05-14 14:22:32 +02:00
Daniel Glöckner 741841d863 ARM: allow jumps > 32MB on -run
This is needed to reach tinycc's PLT from the compiled program.
2010-05-14 13:07:59 +02:00
Daniel Glöckner a64727ba7d append ULL to big constants 2010-05-13 22:18:33 +02:00
Daniel Glöckner 3de023b6c6 ARM: use uint32_t for opcodes
fixes cross compiling on x86_64
2010-05-13 22:17:09 +02:00
Daniel Glöckner 6eac6b7254 Revert "tccpp: Allow local labels to start with a dot"
This reverts commit f740485a5a.

It breaks access to structure elements starting with L
2010-05-06 21:42:37 +02:00
Thomas Preud'homme 8eb86ab78d Add nan, snan and inf float constants 2010-05-06 02:20:35 +02:00
Thomas Preud'homme 2220467fcf Don't load libtcc1 on arch where it doesn't exist
ARM architecture doesn't have any libtcc1 implementation but tcc load
libtcc1.a in all case. This patch add a conditional preprocessor
instruction to load libtcc1.a only when there is an implementation for
the target architecture.
2010-05-01 17:20:28 +02:00
Thomas Preud'homme a28b18fa16 Link alias symbols together
Make sure alias symbols resolve to the same address in program .bss or .data
section. This ensure for example that if a program reference environ (via an
extern char **environ declaration) and the libc change its value via the
__environ alias after the R_ARCH_COPY relocation have been performed, then
the program will see the new value.
2010-05-01 16:45:36 +02:00
Henry Kroll III 036ff17916 reverse another unnecessary change
-m32 is set elsewhere now.
2010-04-29 23:52:20 -07:00
Henry Kroll III 1f62f2253c recursive Makefiles should use $(MAKE), not "make"
add clean: target for lib/tcc1.def
2010-04-29 23:06:23 -07:00
Henry Kroll III c7a4e11bf1 remove superfluous LIBS=. (leftover from work on --disable-statc) 2010-04-28 16:15:19 -07:00
Henry Kroll III 209caeedee Summary of commits + added some brief comments to Makefile
Summary of what was changed or added so far:
    These won't work on Win32

* --disable-static option builds libtcca.so.1.0 and associated simlinks.
  This replaces libtcca.a, which is a static library with a dynamic one.

* --with-selinux option uses mmap to enable tcc -run to work with Selinux.

* attempt to build tcc1.def on i386 / x86_64 when --enable-cross is used.

  If successful, this gets around the "_start not found" or "_winstart not
  found" messages when i386-win32-tcc is run on these systems. I say "if"
  because it gave me fits of trouble on my system and not all others have
  been tested yet. tcc1.def is not a real .def file by the way, but it works,
  so it's kind of a dancing bear at this point. We're not concerned that
  it's getting the steps wrong. We're just happy it's not eating us for lunch.
2010-04-26 23:20:35 -07:00
Henry Kroll III ac0b7d82d8 don't build tcc1.def on Windows.
I think the Windows build portion of the Makefile already
provides their own version. If not, we can remove the check.
2010-04-26 01:27:15 -07:00
Henry Kroll III 765992396f Makefile fixup:
* additional make target for lib/tcc1.def on non-win32 builds
  tcc1.def was formerly lib/libtcc1.a but has bee made into its
  own Makefile target, tcc1.def

* use mv instead of cp on config.h
  this fixes a mistake I made which caused Makefile to rebuild
  all targets every time

* make links from libtcc.so.1.0 to libtcc.so.1 and libtcc.so
2010-04-25 13:34:02 -07:00
Henry Kroll III 07eb850608 make --enable-cross work properly on x86_64
merge more changes from Fedora spec file into Makefile
I did a lot of reading on Makefiles. It should be a lot less hacked now that I got rid of my temporary cross-build script. I had to build i386-win32-tcc as 32 bit in order to use it to build the windows version of libtcc1.a and move that into lib directory. Still testing, but it does build windows fib.exe smoothly now and generates shard lib, libtcc.so.1.0 and test links against it.
2010-04-25 00:35:25 -07:00
Henry Kroll III 1a8e7d9fbb Merge branch 'mob' of ssh://repo.or.cz/srv/git/tinycc into makefile 2010-04-25 00:32:10 -07:00
Henry Kroll III 239fdf0b87 remove make_libtcc1_win32.sh shell script
and merge commands into Makefile
2010-04-24 22:16:39 -07:00
Henry Kroll III eb78e94300 reverse make win32 version of libtcc1.a patch 2010-04-24 21:58:12 -07:00
Henry Kroll III 80b4c698c2 make win32 version of libtcc1.a for cross-compiler on x86 / x86_64 2010-04-24 13:27:56 -07:00
Henry Kroll III b0b29d8013 put tcc in /usr/lib64/tcc on distros that have it 2010-04-24 03:30:46 -07:00
Henry Kroll III 2ab42855cb make --with-selinux work with libtcc, too 2010-04-24 03:28:54 -07:00
Henry Kroll III a4ed587f61 add --disable-static option to build libtcc.so instead of libtcc.a
for distros that want static libs
2010-04-24 02:35:43 -07:00
Henry Kroll III 1578322b06 fix typo in configure 2010-04-24 02:32:41 -07:00
Henry Kroll III 4686236091 i386-win32-tcc fails to build a valid win32 executable if built
on x86_64 using --enable-cross. The easiest way to fix this is
to put -m32 in the Makefile.

Committer: Henry Kroll <henry@comptune.com>

Committer: Henry Kroll <henry@comptune.com>
2010-04-23 18:36:12 -07:00
Henry Kroll III be7e339d8a Use mmap instead of exec mem for Selinux machines. Fixes crash on Fedora. 2010-04-20 23:43:02 -07:00
Thomas Preud'homme a64a6f36a0 Replace malloc+strcpy by tcc_strdup in ld_load_file_list 2010-04-20 22:25:16 +02:00
Thomas Preud'homme 6525a15919 Fix "already done" test in libname_to_filename()
if "(libname == '\0')" should be instead "if (libname != '\0')"
2010-04-20 16:21:13 +02:00
Thomas Preud'homme 4d5fcfb971 Delete unused vtop_saved variable in unary_type 2010-04-20 16:12:41 +02:00
Thomas Preud'homme 3ad3168125 Clean changes introduced by 47abdbd
* Replace the save/load_buffer_state by a dynarray approach:
  - Filename and libname are added to a dynarray when first encountered
  - Load repeatedly the files in the dynarray until no new undefined
    symbol are encountered
* Replace snprintf by sprintf in libname_to_filename
* Use tcc_fileextension in filename_to_libname
* Introduce a tcc_strcpy_part fonction to copy only a subset of a
  string
* Move new_undef_syms declaration from tcc.h to tccelf.c
2010-04-20 16:02:42 +02:00