Commit Graph

2188 Commits

Author SHA1 Message Date
Christian Jullien
206829415a Linux was incorrectly identified in banner when compiled on macOS Darwin 2017-02-26 08:02:53 +01:00
grischka
bb93064d78 makefile: unify cross with native builds
supports building cross compilers on the fly without need
for configure --enable-cross

   $ make cross          # all compilers
   $ make cross-TARGET   # only TARGET-compiler & its libtcc1.a

with TARGET one from
   i386 x86_64 i386-win32 x86_64-win32 arm arm64 arm-wince c67

Type 'make help' for more information
2017-02-25 12:51:04 +01:00
Christian Jullien
669f61117d Cygwin Makefile was to aggresive to remove entire lib/ 2017-02-24 22:51:10 +01:00
Christian Jullien
2e0a8f9b37 Update Cygwin Makefile for new libtcc1-xx.a layout 2017-02-24 22:39:06 +01:00
grischka
569255e6c4 cross-compilers: allow individual configuration
since configure supports only native configuration
a file 'cross-tcc.mak' needs to be created manually.
It is included in the Makefile if present.

# ----------------------------------------------------
# Example config-cross.mak:
#
# windows -> i386-linux cross-compiler
# (it expects the linux files in <prefix>/i386-linux)

ROOT-i386 = {B}/i386-linux
CRT-i386 = $(ROOT-i386)/usr/lib
LIB-i386 = $(ROOT-i386)/lib:$(ROOT-i386)/usr/lib
INC-i386 = {B}/lib/include:$(ROOT-i386)/usr/include
DEF-i386 += -D__linux__

# ----------------------------------------------------

Also:
- use libtcc1-<target>.a instead of directories
- add dummy arm assembler
- remove include dependencies from armeabi.c/lib-arm64.c
- tccelf/ld_add_file: add SYSROOT (when defined) to absolute
  filenames coming from ld-scripts
2017-02-23 08:41:57 +01:00
Christian Jullien
576bee9a37 Add note about native Windows bootstrap using Cygwin. 2017-02-23 06:45:26 +01:00
Michael Matz
3e4c296eba x86-64-asm: Fix mov im64,rax encoding
the avoidance of mov im32->reg64 wasn't working when reg64 was rax.
While fixing this also fix instructions which had the REX prefix
hardcoded in opcode and so didn't support extended registers which
would have added another REX prefix.
2017-02-23 00:16:25 +01:00
Michael Matz
e209b7dac4 Update ChangeLog
with more things I remember having done :)
2017-02-20 20:24:30 +01:00
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
Christian Jullien
399237850d Update cygwin Makefile after recent Windows source changes 2017-02-18 14:53:31 +01:00
grischka
5286529632 tcc -hh: show more options 2017-02-18 09:55:46 +01:00
grischka
2d3b9559bf tcctools.c: integrate tiny_libmaker/_impdef
usage:
    tcc -ar [rcsv] lib files...
    tcc -impdef lib.dll [-v] [-o lib.def]

also:
- support more files with -c: tcc -c f1.c f2.c ...
- fix a bug which caused tcc f1.c f2.S to produce no asm
- allow tcc -ar @listfile too
- change prototype: _void_ tcc_set_options(...)
- apply -Wl,-whole-archive when a librariy is given
  as libxxx.a also (not just for -lxxx)
2017-02-18 09:55:34 +01:00
Steffen Nurpmeso
f34b1feaca -Wl, --enable-new-dtags for DT_RUNPATH instead of DT_RPATH
Today by accident i had to deal with linker problems of some
software and found an issue that mentioned DT_RUNPATH, which
mentioned that DT_RPATH is legacy and searched for
$LD_LIBRARY_PATH, whereas the newer DT_RUNPATH is searched
thereafter.  Completely unencrypted!  Well.  For what's it worth,
i for one am astonished because of course i want to override
$LD_LIBRARY_PATH, but it surely has its merites, smart people came
to the conclusion, did they.

The attached diff below seems to be sufficient to support
DT_RUNPATH instead of DT_RPATH with tcc(1).  But i have no insight
in what --enable-new-dtags is supposed to change in addition, so
i wonder.

Ciao!

--steffen

 libtcc.c     | 2 ++
 tcc-doc.texi | 4 ++++
 tcc.h        | 1 +
 tccelf.c     | 3 ++-
 4 files changed, 9 insertions(+), 1 deletion(-)
2017-02-18 09:54:41 +01:00
grischka
096125d963 win32: adjust new unicode support
- lib/Makefile: add (win)crt1_w.o

- crt1.c/_runtmain: return to tcc & only use for UNICODE
  (because it might be not 100% reliable with for example
  wildcards (tcc *.c -run ...)

- tccrun.c/tccpe.c: load -run startup_code only if called
  from tcc_run(). Otherwise main may not be defined.  See
  libtcc_test.c

- tests2/Makefile: pass extra options in FLAGS to allow
  overriding TCC

Also:
- tccpe.c: support weak attribute.  (I first tried to solve
  the problem above by using it but then didn't)
2017-02-18 09:51:23 +01:00
Christian Jullien
39b2afeb7c Temporary remove 76_dollards_in_identifiers when run on Windows as this test failes. To be checked why. 2017-02-18 08:12:00 +01:00
Christian Jullien
9bd04fa000 Makefile for Windows native tcc handles recent UNICODE support 2017-02-18 08:00:58 +01:00
YX Hao
86e3cd0c5a Add support for Unicode entries 'wmain' and 'wWinMain' on Windows
'-run' suported. argvs are converted.
But don't use compliled Unicode CLI exe-file to get inputs interactively in other codepage!
Please add other compliling supports than 'build-tcc.bat' (Who is good at them).
2017-02-17 21:09:26 +08:00
Christian Jullien
f33801e25e Add entry to run tests2 tests 2017-02-17 08:05:38 +01:00
Christian Jullien
d61985b37a tiny_impldef.exe was not built by Makefile 2017-02-16 07:01:44 +01:00
Christian Jullien
7b99c3ac2c Fix wrong name for 85 test. 2017-02-15 09:00:38 +01:00
Vlad Vissoultchev
67fe371f84 win32: build-tcc.bat: figure out correct bitness of cl.exe 2017-02-14 11:45:35 +02:00
Christian Jullien
5550e4336f Improve cygwin Makefile that now support TARGET=32/64 to force final version for 32/64 platform 2017-02-14 05:51:45 +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
13056da039 mems & leaks
- define_start: set above preprocess_start because now
  preprocess_start is defining macros.

- free "cmd_include_files"
- free defines always (after error-longjmps)
- close all files (after error-longjmps)
- tccpe.c: free imports always
- libtcc.c: call tcc_memstats only after all states have
  been deleted.
2017-02-13 18:23:55 +01:00
grischka
a4a20360e9 fixes & cleanups
- tccgen.c/tcc.h: allow function declaration after use:
      int f() { return g(); }
      int g() { return 1; }
  may be a warning but not an error
  see also 76cb1144ef

- tccgen.c: redundant code related to inline functions removed
  (functions used anywhere have sym->c set automatically)

- tccgen.c: make 32bit llop non-equal test portable
  (probably not on C67)

- dynarray_add: change prototype to possibly avoid aliasing
  problems or at least warnings

- lib/alloca*.S: ".section .note.GNU-stack,"",%progbits" removed
  (has no effect)

- tccpe: set SizeOfCode field (for correct upx decompression)

- libtcc.c: fixed alternative -run invocation
      tcc "-run -lxxx ..." file.c
  (meant to load the library after file).
  Also supported now:
      tcc files ... options ... -run @ arguments ...
2017-02-13 18:23:43 +01:00
Christian Jullien
9817204d8a Detect native version from default gcc target. 2017-02-12 17:06:27 +01:00
grischka
ec6a997f80 tccgen: yet another nocode_wanted fix
Some code in gen_opl was depending on a gvtst label
which in nocode_wanted mode is not set.

This was causing vstack leaks and crashes with for example

  long long ll;
  if (0)
      return ll - 10 < 0;
2017-02-12 13:21:20 +01:00
Christian Jullien
417a1ed384 Add Makefile to build native tcc 32/64 on Windows using cygwin 2017-02-12 12:14:27 +01:00
Michael Matz
983520d721 arm64: Fix 42_function_test
Like in 77d7ea04a some relocs need to be handled as possibly
needing a PLT/GOT slot in TCC until TCC can transfer dynamic relocs
to executables.
2017-02-11 10:16:55 +01:00
Michael Matz
15f990bf71 Fix testsuite invocations
The return code of $(FILTER) clobbers the return code of
TCC itself.  So just prepend messages to the generated output file
and ignore return codes.
2017-02-11 14:27:21 +01:00
grischka
ee5425fe95 libtcc: support multiple -Wl,-rpath=...'s 2017-02-11 09:54:01 +01:00
grischka
362cafb471 arm: libtcc1.a needs gcc with -fPIC 2017-02-11 09:30:20 +01:00
Vlad Vissoultchev
910a6bc859 Add pre-build step in VS2015 projects to generate config.h from VERSION 2017-02-09 13:31:12 +02:00
grischka
5efa75d9b8 update VERSION to 0.9.27
Also:
- in tests: generate .expect files only if not yet present,
  because
  1) some files were adjusted manually
  2) switching git branche might change timestamps and
     cause unwanted update
2017-02-08 19:56:15 +01:00
grischka
aa0a45be05 win32: build-tcc.bat: add some options
In particular:

-c <compiler> : Allow using tcc to compile itself
-i <dir>      : Create installation in dir

Summary:

usage: build-tcc.bat [ options ... ]
options:
  -c prog              use prog (gcc or tcc) to compile tcc
  -c "prog options"    use prog with options to compile tcc
  -t 32/64             force 32/64 bit default target
  -v "version"         set tcc version
  -i dir               install tcc into dir
  -d                   create tcc-doc.html too (needs makeinfo)
2017-02-08 19:53:49 +01:00
grischka
e596b871a9 win32: include/winapi: remove more files
Also: use _assert, older msvcrt does not have _wassert
2017-02-08 19:53:02 +01:00
grischka
90316c7c26 tcc: don't use pstrcpy, fix win32 spanwn quoting
- we're now exporting tcc_prefixed symbols from libtcc only

- On windows, the msvcrt startup code would remove backslashes
  from commandline arguments such as
      -DFOO=\"foo\"
  which would appear in argv as
      -DFOO="foo"
  Therefor before passing these to spawnvp, we need to restore
  the backslashes.
2017-02-08 19:49:28 +01:00
grischka
68666eee2a tccgen: factor out gfunc_return
Also:
- on windows i386 and x86-64, structures of size <= 8 are
  NOT returned in registers if size is not one of 1,2,4,8.
- cleanup: put all tv-push/pop/swap/rot into one place
2017-02-08 19:45:31 +01:00
grischka
f077d16c20 tccgen: gen_cast: cast FLOAT to DOUBLE
... to avoid precision loss when casting to int,
also when saving FLOATs to stack
2017-02-05 14:30:20 +01:00
grischka
3b84e61ead Revert "partial revert of the commit 4ad186c5ef61"
There seems nothing wrong.  With

    int t1 = 176401255;
    float f = 0.25;
    int t2 = t1 * f; // 176401255 * 0.25 = 44100313.75

according to the arithmetic conversion rules, the number
176401255 needs to be converted to float, and the compiler
can choose either the nearest higher or nearest lower
representable number "in an implementation-defined manner".

Which may be 176401248 or 176401264.  So as result both
44100312 and 44100313 are correct.

This reverts commit 664c19ad5e.
2017-02-05 14:30:19 +01:00
grischka
85fca9e924 tccrun: sort sections
Sort executable before other sections.

Also, apply RUN_SECTION_ALIGNMENT=63 for TCC_TARGET_I386
as well.
2017-02-05 14:00:42 +01:00
grischka
ea2c36c5a9 tccrun: 'selinux' mmap: use only one mapping
In the previous implementation, the rx mapping was never
used.  Therefor it is assumed that it is not needed.

With only one mapping there is no reason to use a real
/tmp/.xxxx file either as we can use an anonymous mapping.
2017-02-05 13:58:14 +01:00
David Mertens
5420bb8a67 SECTION_ALIGNMENT -> RUN_SECTION_ALIGNMENT, and tweaks
Based on feedback from grischka, this commit
(1) updates the name of the alignment constant to be more specific
(2) aligns all sections, including the first (which previosly was
    not aligned)
(3) reduces the x86-64 alignment from 512 to 64 bytes.

The original x86-64 alignment of 512 bytes was based on testing.
After ensuring that the initial section is also aligned, the same
tests indicated that 64 bytes is sufficient.
2017-01-08 07:27:24 -05:00
David Mertens
5d1bc3fbd4 Architecture-specific section alignment
Tests found excessive cache thrashing on x86-64 architectures. The
problem was traced to the alignment of sections. This patch sets up
an architecture-specific alignment of 512 bytes for x86-64 and 16
bytes for all others. It uses preprocessor directives that, hopefully,
make it easy to tweak for other architectures.
2017-01-06 16:56:23 -05:00
Pavlas, Zdenek
0486939291 win32: support "-Wl,--large-address-aware" option 2016-12-30 03:01:33 -08:00
Avi Halachmi (:avih)
9b3e4c5895 tests: don't assume $(CC) is gcc
This also allows self hosting + testing when $(CC) is tcc.
2016-12-24 20:59:10 +02: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
Michael Matz
4beb469c91 Fix pseudo leak
Once-allocated buffers (here a string) that aren't explicitely freed
at program end but rather freed at _exit about 1 nanosecond later
are regarded a leak with MEM_DEBUG, so explicitely free it.  Blaeh :-/
2016-12-20 05:42:25 +01:00
Michael Matz
42e2a67f23 Fix some code suppression fallout
Some more subtle issues with code suppression:
- outputting asms but not their operand setup is broken
- but global asms must always be output
- statement expressions are transparent to code suppression
- vtop can't be transformed from VT_CMP/VT_JMP when nocode_wanted

Also remove .exe files from tests2 if they don't fail.
2016-12-20 04:58:34 +01:00
grischka
559ee1e940 i386-gen: fix USE_EBX
Restore ebx from *ebp because alloca might change esp.

Also disable USE_EBX for upcoming release.

Actually the benefit is less than one would expect, it
appears that tcc can't do much with more than 3 registers
except with extensive use of long longs where the disassembly
looks much prettier (and shorter also).

Also: tccgen/expr_cond() : fix wrong gv/save_regs order
2016-12-19 00:33:01 +01:00