Commit Graph

64 Commits (5f33d313c8a2455ff9036cd7f7028339bdbde622)

Author SHA1 Message Date
grischka 5f33d313c8 tcc: re-enable correct option -r support
Forgot about it.  It allows to compile several
sources (and other .o's) to one single .o file;

    tcc -r -o all.o f1.c f2.c f3.S o4.o ...

Also:
- option -fold-struct-init-code removed, no effect anymore
- (tcc_)set_environment() moved to tcc.c
- win32/lib/(win)crt1 minor fix & add dependency
- debug line output for asm (tcc -c -g xxx.S) enabled
- configure/Makefiles: x86-64 -> x86_64 changes
- README: cleanup
2017-02-20 18:58:08 +01:00
grischka 43d9a7de9b updates & cleanups (tcc-doc/Changelog/TODO ...)
- tcc-doc.texi: commandline option info update
- Changelog/TODO: update
- tests/tcctest.py: removed
- tests/Makefile: weaktest fixed
- tests/tests2: some files renamed and/or converted to unix LF
- configure/Makefile: --enable-static option (no dll on win32)
- win32/build-tcc.bat: msvc support
- win32/tcc-win32.txt: build info update
- win32/vs2015/: VS solution removed
- win32/include/tcc/tcc_libm.h: #include statement fixed
- tcc.c: -include <file> option help info
- .gitignore: cleanup
2017-02-13 19:03:29 +01:00
grischka 71c5ce5ced tests: OOT build fixes etc.
tests/Makefile: fix out-of-tree build issues

Also:

- win64: align(16) MEM_DEBUG user memory
  on win64 the struct jmp_buf in the TCCState structure which we
  allocate by tcc_malloc needs alignment 16 because the msvcrt
  setjmp uses MMX instructions.

- libtcc_test.c: win32/64 need __attribute__((dllimport)) for
  extern data objects

- tcctest.c: exclude stuff that gcc does not compile
  except for relocation_test() the other issues are mostly ASM
  related.  We should probably check GCC versions but I have
  no idea which mingw/gcc versions support what and which don't.

- lib/Makefile: use tcc to compile libtcc1.a (except on arm
  which needs arm-asm
2016-12-20 18:05:33 +01:00
grischka a1c12b9fb9 tests: add memory leak test
Also ...

tcctest.c:
- exclude stuff that gcc doesn't compile on windows.

libtcc.c/tccpp.c:
- use unsigned for memory sizes to avoid printf format warnings
- use "file:line: message" to make IDE error parsers happy.

tccgen.c: fix typo
2016-12-18 22:05:42 +01:00
grischka 2b7ee000cd tests: add .so/.dll creation test
Also remove bitfield test from tcctest.c because gcc
versions don't agree among each other.
2016-12-15 17:04:07 +01:00
grischka c2ad11ac70 tccgen: fix long long -> char/short cast
This was causing assembler bugs in a tcc compiled by itself
at i386-asm.c:352 when ExprValue.v was changed to uint64_t:

    if (op->e.v == (int8_t)op->e.v)
        op->type |= OP_IM8S;

A general test case:

    #include <stdio.h>
    int main(int argc, char **argv)
    {
        long long ll = 4000;
        int i = (char)ll;
        printf("%d\n", i);
        return 0;
    }

Output was "4000", now "-96".

Also: add "asmtest2" as asmtest with tcc compiled by itself
2016-10-02 01:39:14 +02:00
grischka afdbc5b815 build: restore out-of-tree support 2016-10-01 21:06:53 +02:00
grischka 0a624782df build: revert Makefiles to 0.9.26 state (mostly)
Except
- that libtcc1.a is now installed in subdirs i386/ etc.
- the support for arm and arm64
- some of the "Darwin" fixes
- tests are mosly unchanged

Also
- removed the "legacy links for cross compilers" (was total mess)
- removed "out-of-tree" build support (was broken anyway)
2016-10-01 21:06:33 +02:00
Michael Matz 4d68828259 tests: Compile asmtest.S without -m32
Don't hardcode that option, if you want it do make CC="gcc -m32".
The test assembles with -m64 as well now.
2016-05-11 18:58:14 +02:00
grischka a94e8d439a tccgen: scopes levels for local symbols (update 2)
allow
    typedef int xxx;
    typedef int xxx;
in the same scope as long as it is the same type
2016-05-06 08:32:54 +02:00
Vlad Vissoultchev acc8f602e5 Revert "Fix tests Makefiles on Windows"
This reverts commit fa2472c172.
2016-04-17 17:24:17 +03:00
seyko d3e85e80fd Identifiers can start and/or contain '.' in *.S
modified version of the old one which don't allow '.'
    in #define Identifiers. This allow correctly preprocess
    the following code in *.S

        #define SRC(y...)               \
        9999: y;                        \
        .section __ex_table, "a";       \
        .long 9999b, 6001f      ;       \
        // .previous

        SRC(1: movw (%esi), %bx)
        6001:

    A test included.
2016-04-05 10:43:50 +03:00
Vlad Vissoultchev fa2472c172 Fix tests Makefiles on Windows
Compiled tcc.exe location is under $(top_srcdir)/win32
2016-03-14 18:11:49 +02:00
Edmund Grimley Evans f4082851ea Enable variable-length arrays on arm64.
arm64-gen.c: Implement gen_vla_sp_save, gen_vla_sp_restore, gen_vla_alloc.
tests/Makefile: Run vla_test on arm64.
2015-10-31 11:04:52 +00:00
gus knight 89ad24e7d6 Revert all of my changes to directories & codingstyle. 2015-07-29 16:57:12 -04:00
gus knight 47e06c6d4e Reorganize the source tree.
* Documentation is now in "docs".
 * Source code is now in "src".
 * Misc. fixes here and there so that everything still works.

I think I got everything in this commit, but I only tested this
on Linux (Make) and Windows (CMake), so I might've messed
something up on other platforms...
2015-07-27 16:03:25 -04:00
grischka 30df3189b1 tccpp: fix issues, add tests
* fix some macro expansion issues
* add some pp tests in tests/pp
* improved tcc -E output for better diff'ability
* remove -dD feature (quirky code, exotic feature,
  didn't work well)

Based partially on ideas / researches from PipCet

Some issues remain with VA_ARGS macros (if used in a
rather tricky way).

Also, to keep it simple, the pp doesn't automtically
add any extra spaces to separate tokens which otherwise
would form wrong tokens if re-read from tcc -E output
(such as '+' '=')  GCC does that, other compilers don't.

 * cleanups
  - #line 01 "file" / # 01 "file" processing
  - #pragma comment(lib,"foo")
  - tcc -E: forward some pragmas to output (pack, comment(lib))
  - fix macro parameter list parsing mess from
    a3fc543459
    a715d7143d
    (some coffee might help, next time ;)
  - introduce TOK_PPSTR - to have character constants as
    written in the file (similar to TOK_PPNUM)
  - allow '\' appear in macros
  - new functions begin/end_macro to:
      - fix switching macro levels during expansion
      - allow unget_tok to unget more than one tok
  - slight speedup by using bitflags in isidnum_table

Also:
  - x86_64.c : fix decl after statements
  - i386-gen,c : fix a vstack leak with VLA on windows
  - configure/Makefile : build on windows (MSYS) was broken
  - tcc_warning: fflush stderr to keep output order (win32)
2015-05-09 14:29:39 +02:00
seyko 5ce2154c74 -fdollar-in-identifiers addon
* disable a -fdollar-in-identifiers option in assembler files
    * a test is added

    This is a patch addon from Daniel Holden.
2015-04-20 03:44:08 +03:00
Edmund Grimley Evans 03303628c7 tests/Makefile: Quote to avoid: /bin/sh: 1: [: !=: unexpected operator 2015-03-07 18:10:45 +00:00
seyko d972472c53 Disable floating-point test for ARM soft-float
From: Matteo Cypriani <mcy@lm7.fr>
    Date: Fri, 5 Sep 2014 23:22:56 -0400
    Subject: Disable floating-point test for ARM soft-float

    tcc is not yet capable of doing softfloat floating-point operations on
    ARM, therefore we disable this test for these platforms. Note that tcc
    displays a warning to warn ARM users about this limitation
    (debian)
2015-03-04 09:52:47 +03:00
seyko f1e4b2b7f3 disable-BTESTS 2015-03-04 09:49:19 +03:00
Matteo Cypriani b84cdf6214 Clear CFLAGS & LDFLAGS in tests
Clear CFLAGS and LDFLAGS to build the tests, in case the main Makefile
passes some flags that aren't handled by tcc (we are not compiling tcc
here, we are using tcc to compile the tests).
2014-09-07 11:15:31 -04:00
minux 469ae3a7e5 build: ignore and properly clean tests/vla_test 2014-04-12 01:10:58 -04:00
Vincent Lefevre 3e9a7e9d69 Corrected spelling mistakes in comments and strings 2014-04-07 13:31:00 +02:00
mingodad bed865275d Add the generated executables ending with "-cc" and "-tcc" to the makefile "clean" 2014-03-26 14:32:03 +00:00
Thomas Preud'homme d3d89900f6 Don't hardcode gcc in tests Makefile 2014-03-09 22:54:48 +08:00
grischka 32a4962593 tcctest: add back testXb (self compile with -b)
- Thanks to Kirill "tcc -b itself" should work now
  (was removed in d5f4df09ff)

Also:

- tests/Makefile:
  - fix spurious --I from 767410b875
  - lookup boundtest.c via VPATH (for out-of-tree build)
  - test[123]b?: fail on diff error
  - Windows: test3 now works (from e31579b076)
  - abitest: a libtcc.a made by gcc is not usable for tcc
    on WIndows - using source instead (libtcc.c)

- tccpe:
  - avoid gcc warning (x86_64)
2014-01-21 13:25:14 +01:00
Thomas Preud'homme 767410b875 Various Makefile fixes for cross-compilation
- Build libtcc1 for cross-compiler on arm (arm to X cross compilers)
- Install libtcc1 and includes for arm to i386 cross compiler
- Add basic check of cross-compilers (compile ex1.c)
2014-01-09 17:15:08 +08:00
grischka 2bd0daabbe misc. fixes
- tccgen: error out for cast to void, as in
      void foo(void) { return 1; }
  This avoids an assertion failure in x86_64-gen.c, also.
  also fix tests2/03_struct.c accordingly

- Error: "memory full" - be more specific

- Makefiles: remove circular dependencies, lookup tcctest.c from VPATH

- tcc.h: cleanup lib, include, crt and libgcc search paths"
  avoid duplication or trailing slashes with no CONFIG_MULTIARCHDIR
  (as from 9382d6f1a0)

- tcc.h: remove ";{B}" from PE search path
  in ce5e12c2f9 James Lyon wrote:
  "... I'm not sure this is the right way to fix this problem."
  And the answer is: No, please. (copying libtcc1.a for tests instead)

- win32/build_tcc.bat: do not move away a versioned file
2014-01-06 19:56:26 +01:00
James Lyon 41b3c7a507 Improved variable length array support.
VLA storage is now freed when it goes out of scope. This makes it
possible to use a VLA inside a loop without consuming an unlimited
amount of memory.

Combining VLAs with alloca() should work as in GCC - when a VLA is
freed, memory allocated by alloca() after the VLA was created is also
freed. There are some exceptions to this rule when using goto: if a VLA
is in scope at the goto, jumping to a label will reset the stack pointer
to where it was immediately after the last VLA was created prior to the
label, or to what it was before the first VLA was created if the label
is outside the scope of any VLA. This means that in some cases combining
alloca() and VLAs will free alloca() memory where GCC would not.
2013-04-27 22:58:52 +01:00
James Lyon 1caee8ab3b Sorted out CMake on x86-64 and fixed silly XMM# bug introduced when working on Win64 stdargs.
I removed the XMM6/7 registers from the register list because they are not used
on Win64 however they are necessary for parameter passing on x86-64. I have now
restored them but not marked them with RC_FLOAT so they will not be used except
for parameter passing.
2013-04-25 22:30:53 +01:00
James Lyon 05fa2e754b Workaround for MinGWs use of 80-bit long double on Win32.
This is incompatible with MSVC and TCC on Win32.

Bounds checking appears to be broken (test4).
2013-04-19 23:21:33 +01:00
James Lyon 55ea6d3fc1 x86-64 ABI fixes.
abitest now passes; however test1-3 fail in init_test. All other tests
pass. I need to re-test Win32 and Linux-x86.

I've added a dummy implementation of gfunc_sret to c67-gen.c so it
should now compile, and I think it should behave as before I created
gfunc_sret.
2013-04-19 00:46:49 +01:00
James Lyon 2bbfaf436f Tests in abitest.c now work on Win32.
I expect that Linux-x86 is probably fine. All other architectures
except ARM are definitely broken since I haven't yet implemented
gfunc_sret for these, although replicating the current behaviour
should be straightforward.
2013-04-18 17:27:34 +01:00
James Lyon ce5e12c2f9 Added ABI compatibility tests with native compiler using libtcc.
Only one test so far, which fails on Windows (with MinGW as the native
compiler - I've tested the MinGW output against MSVC and it appears the
two are compatible).

I've also had to modify tcc.h so that tcc_set_lib_path can point to the
directory containing libtcc1.a on Windows to make the libtcc dependent
tests work. I'm not sure this is the right way to fix this problem.
2013-04-17 21:52:44 +01:00
James Lyon e31579b076 Fixed tests on Windows (including out-of-tree problems)
Modified tcctest.c so that it uses 'double' in place of 'long double'
with MinGW since this is what TCC does, and what Visual C++ does. Added
an option -norunsrc to tcc to allow argv[0] to be set independently of
the compiled source when using tcc -run, which allows tests that rely on
the value of argv[0] to work in out-of-tree builds.

Also added Makefile rules to automatically update out-of-tree build
Makefiles when in-tree Makefiles have changed.
2013-04-17 20:32:07 +01:00
grischka 8042121d74 tcc -vv/--print-search-dirs: print more info
tests/Makefile:
- print-search-dirs when 'hello' fails
- split off hello-run

win32/include/_mingw.h:
- fix for compatibility with mingw headers
  (While our headers in win32 are from mingw-64 and don't have
  the problem)

tiny_libmaker:
- don't use "dangerous" mktemp
2013-02-10 00:38:40 +01:00
grischka 7a477d70ca lib/Makefile: use CC, add bcheck to libtcc1.a
Also:
- fix "make tcc_p" (profiling version)
- remove old gcc flags:
  -mpreferred-stack-boundary=2 -march=i386 -falign-functions=0
- remove test "hello" for Darwin (cannot compile to file)
2013-02-06 19:01:07 +01:00
grischka d5f4df09ff tests: cleanup
tests:
- add "hello" to test first basic compilation to file/memory
- add "more" test (tests2 suite)
- remove some tests

tests2:
- move into tests dir
- Convert some files from DOS to unix LF
- remove 2>&1 redirection

win32:
- tccrun.c: modify exception filter to exit correctly (needed for btest)
- tcctest.c: exclude weak_test() (feature does not exist on win32)
2013-02-05 14:27:38 +01:00
Thomas Preud'homme de35a3389f Use gcc to generate tcctest.gcc 2013-01-25 20:14:10 +01:00
Akim Demaille 3f09b90d21 build: fix VPATH builds
* configure (fn_dirname): New.
Use it to ensure the creation of proper symlinks to Makefiles.
(config.mak): Define top_builddir and top_srcdir.
(CPPFLAGS): Be sure to find the headers.
* Makefile, lib/Makefile, tests/Makefile, tests2/Makefile: Adjust
to set VPATH properly.
Fix confusion between top_builddir and top_srcdir.
2012-12-18 10:06:20 +01:00
Kirill Smelkov 031ff872be tests: Add tests for compile/run tcc.c with `tcc -b` then compile tcc.c again, then run tcctest.c
Just like with test[123] add their test[123]b variants. After previous 3
patchs all test pass here on Debian GNU/Linux on i385 with gcc-4.7 with
or without memory randomization turned on.
2012-12-09 19:43:40 +04:00
Kirill Smelkov 168aed4984 tests: btest should only run on targets supporting bcheck
After 40a54c43 (Repair bounds-checking runtime), and in particular
5d648485 (Now btest pass!) `make test` was broken on ARCH != i386,
because I've changed btest to unconditionally run on all arches.

But bounds-checking itsels is only supported on i386 and oops...

Fix it.

Reported-by: Thomas Preud'homme <robotux@celest.fr>
2012-11-24 12:54:03 +04:00
Kirill Smelkov b2a02961b4 Add support for __builtin_frame_address(level)
Continuing d6072d37 (Add __builtin_frame_address(0)) implement
__builtin_frame_address for levels greater than zero, in order for
tinycc to be able to compile its own lib/bcheck.c after
cffb7af9 (lib/bcheck: Prevent __bound_local_new / __bound_local_delete
from being miscompiled).

I'm new to the internals, and used the most simple way to do it.
Generated code is not very good for levels >= 2, compare

                gcc                         tcc

    level=0     mov    %ebp,%eax            lea    0x0(%ebp),%eax

    level=1     mov    0x0(%ebp),%eax       mov    0x0(%ebp),%eax

    level=2     mov    0x0(%ebp),%eax       mov    0x0(%ebp),%eax
                mov    (%eax),%eax          mov    %eax,-0x10(%ebp)
                                            mov    -0x10(%ebp),%eax
                                            mov    (%eax),%eax

    level=3     mov    0x0(%ebp),%eax       mov    0x0(%ebp),%eax
                mov    (%eax),%eax          mov    (%eax),%ecx
                mov    (%eax),%eax          mov    (%ecx),%eax

But this is still an improvement and for bcheck we need level=1 for
which the code is good.

For the tests I had to force gcc use -O0 to not inline the functions.
And -fno-omit-frame-pointer just in case.

If someone knows how to improve the generated code - help is
appreciated.

Thanks,
Kirill

Cc: Michael Matz <matz@suse.de>
Cc: Shinichiro Hamaji <shinichiro.hamaji@gmail.com>
2012-11-16 10:22:14 +04:00
Kirill Smelkov 5d648485bd Now btest pass!
Thanks to two previous commits now btest tests pass, at least on Linux.

Signed-off-by: Kirill Smelkov <kirr@navytux.spb.ru>
2012-11-13 22:23:01 +04:00
Thomas Preud'homme a7f010ee8a Honour *FLAGS everywhere
Add CPPFLAGS, CFLAGS and LDFLAGS everywhere it's missing.
2012-11-06 15:20:53 +01:00
Milutin Jovanović d54e24cc0e tests: Minor adjustments selecting which tests are run on each platform.
The intent is for 'make test' to pass cleanly on each platform, and thus easier
spotting of regressions. Linux is best supported by most tests running and
passing. Mac OSX passes mosts tests that do not make/link with binary files,
due to lack of mach-o file support.

!!! I have very limited knowledge of Windows platform, and cannot comment why
all tests(1) fail. I have posted to newsgroup asking for someone to test
Windows platform.
2012-06-27 14:48:08 -04:00
grischka ab936aeb8c cleanup some partially broken patches
- tests/Makefile:
  fix commit de54586d5b
  This hunk it unrelated to the other changes (which are about MacOSX).
  It is not useful and partially wrong.  Optional tests are meant to
  stay optional, btest would work only for i386

- tcc.h:
  fix commit c52d79605a by unknown
  The message says it's for MINTW but the patch has obviously
  no effect for MINGW (which defines __GNUC__).  However the patch
  seems useful for MSC which however needs _strto(u)i64 with underscore.

- Makefile:
  fix commit 5280293d6b
  Do not build tcc.o with -DONE_SOURCE because we finally build tcc
  from tcc.o and libtcc.a/so
2012-04-18 18:43:09 +02:00
Milutin Jovanovic de54586d5b Further changes improving the OSX build. Everything builds. libtest passes.
Other tests still have issues, currently with weak linking.

One of the primary stumbling blocks on OSX is the lack of support for
mach-o binaries. Therefore all tcc usage on OSX has to be limited to elf
binaries, presumably produced by tcc itself.

Therefore I had to enable building of tiny_libmaker for OSX. Then changed
the make to use tcc and tiny_libmaker to compile the tcclib1.

In order to compile the tests, specifically the parts that use weak linking,
I have had to define MACOSX_DEPLOYMENT_TARGET to 10.2, which seems like a
hack, but extensive searching seems to indicate that this is the only way
to make apple gcc allow weak linking. Using any other value, bigger or smaller
breaks weak linking.

Also added _ANSI_SOURCE define required by some OSX headers, and some cosmetic
gitignore changes. I believe these changes should not impact other platforms.
2012-03-06 13:26:36 -05:00
Milutin Jovanovic 8ca8b08890 Patch attempting to build OSX TinyCC.
Applied patch found on stackoverflow (link below). I also found some
related changes that looked like logically needed. The stackoverflow
changes addressed only two registers which were breaking a compile.
However reading the code in the same file shows two other register
accesses that, while not breaking the build, should have the same fix.

http://stackoverflow.com/questions/3712902/problems-compiling-tcc-on-os-x/3713144#3713144

The test driver was changed by changing 'cp -u' into 'cp' as '-u' is not
supported on mac osx.

I found that osx build required the WITHOUT_LIBTCC define. I suspect the
reason for this is tcc unability to handle mach-o files. In order to
properly address this I had to change 'configure' to propagate target os
name to Makefile.

Current state is that simple tests work, but not the whole 'make test'
suite runs.

To the best of my knowledge, these changes should not impact other
platforms.
2012-02-09 12:53:17 -05:00