Commit Graph

92 Commits (19d8b8a17383863d45823e37f20a94cc1d55c3a6)

Author SHA1 Message Date
Larry Doolittle 19d8b8a173 Spelling fixes in C comments only 2017-05-07 21:38:09 -07:00
grischka 7acf9aa862 final adjustments for release
- configure/Makefiles: minor adjustments

- build-tcc.bat: add -static to gcc options
  (avoids libgcc_s*.dll dependency with some mingw versions)

- tccpe.c/tcctools.c: eliminate MAX_PATH
  (not available for cross compilers)

- tccasm.c: use uint64_t/strtoull in unary()
  (unsigned long sometimes is only uint32_t, as always on windows)

- tccgen.c: Revert (f077d16c) "tccgen: gen_cast: cast FLOAT to DOUBLE"
  Was a rather experimental, tentative commit, not really necessary
  and somewhat ugly too.

- cleanup recent osx support:
  - Makefile/libtcc.c: cleanup copy&paste code
  - tccpp.c: restore deleted function
2017-04-25 21:01:54 +02:00
grischka 536ed76d5a tccgen/win32: let __declspec(dllimport) imply extern
Also, retain storage qualifiers in type_decl, in particular
also for function pointers.  This allows to get rid of this
very early hack in decl()
    type.t |= (btype.t & VT_STATIC); /* Retain "static". */
which was to fix the case of
    int main() { static int (*foo)(); ...

Also:
- missing __declspec(dllimport) is an error now
- except if the symbol is "_imp__symbol"
- demonstrate export/import of data in the dll example (while
  'extern' isn't strictly required with dllimport anymore)
- new function 'patch_storage()' replaces 'weaken_symbol()'
  and 'apply_visibility()'
- new function 'update_storage()' applies storage attributes
  to Elf symbols.
- put_extern_sym/2 accepts new pseudo section SECTION_COMMON
- add -Wl,-export-all-symbols as alias for -rdynamic
- add -Wl,-subsystem=windows for mingw compatibility
- redefinition of 'sym' error for initialized global data
2017-04-04 08:34:52 +02: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
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
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
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
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
Pavlas, Zdenek 0486939291 win32: support "-Wl,--large-address-aware" option 2016-12-30 03:01:33 -08:00
Thomas Preud'homme 097cf3aa5e Control symbol table of which to relocate symbols
Pass pointer to symbol table to relocate the symbols of in relocate_syms
2016-12-03 17:26:51 +00:00
Thomas Preud'homme 64b5ee2dea Rename add_elf_sym to set_elf_sym
add_elf_sym is a confusing name because it is not clear what the
function does compared to put_elf_sym. As a matter of fact, put_elf_sym
also adds a symbol in a symbol table. Besides, "add_elf_sym" fails to
convey that the function can be used to update a symbol (for instance
its value). "set_elf_sym" seems like a more appropriate name: it will
set a symbol to a given set of properties (value, size, etc.) and create
a new one if non exist for that name as one would expect.
2016-12-03 17:26:51 +00:00
grischka 0be098929a tccpp_new/delete and other cleanups 2016-10-17 23:24:01 +02:00
grischka 78f1c10e0f configure: fix tcc_lddir, cpu
... and other minor cosmetic fixes
2016-10-03 12:33:40 +02:00
grischka 0d9f88ea67 libtcc: reimplement option -Wl,[-no]-whöle-archive
- taking advantage of previous commit "incremental -Wl parsing"
2016-10-01 20:54:45 +02:00
grischka 9c5bb16447 Revert part of "fix installation amd bcheck for Windows"
tccelf.c : force linking bcheck by adding elf symbol __bound_init
bcheck.c : use (size_t)1 for x86_64

Fixes 7e7e6148fd
2016-10-01 20:47:36 +02:00
grischka eacdc426d7 libtcc: cleanup @listfile
Also:
- allow more than one item per line
- respect "quoted items" and escaped quotes \"
  (also for LIBTCCAPI tcc_setoptions)

- cleanup some copy & paste
2016-10-01 20:19:37 +02:00
Jean-Claude Beaudoin 889ee28ed5 Rein in unintended external functions on Windows. 2016-09-27 01:43:40 -04:00
Vlad Vissoultchev 34feee0ed6 Move utility functions `trimfront/back` to tccpp.c
These are used in `libtcc.c` now and cannot remain in `tccpe.c`
2016-04-13 14:33:21 +03:00
Edmund Grimley Evans 569fba6db9 Merge the integer members of union CValue into "uint64_t i". 2015-11-17 19:09:35 +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
gus knight d6b64e2574 Clean up lots of rogue tabs.
Still some more tabs to be taken care of. arm-gen.c and tcccoff.c
have so many style issues that I'm just going to throw clang-format
at them.
2015-07-27 14:14:41 -04:00
gus knight 41031221c8 Trim trailing spaces everywhere. 2015-07-27 12:43:40 -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
grischka 12f43953ed win64: fix resource file support 2014-08-01 10:51:28 +02:00
grischka 2ac238fc50 tccpe: adjust for new 'hidden' symbols feature
in order to avoid conflicts with windows specific (ab)usage
of the Elf32_Sym -> st_other field.
2014-04-17 17:01:28 +02:00
grischka 112148172b tccpe: speed up .def file loading
The fgets replacement meant to work with "int fd"
was just too slow.
2014-04-13 20:30:46 +02: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
grischka d443644de3 tccpe: cleanup "imports per ordinal"
- tccpe.c: avoid conflict with imp_sym->st_value, cleanup
- _parseLibs.bat, _tcc.bat: no instructions for usage, removed.

from commit 642b6d0f50
2014-01-06 19:32:50 +01:00
grischka 4ad186c5ef i386: use __fixdfdi instead of __tcc_cvt_ftol
Variants __fixsfdi/__fixxfdi are not needed for now because
the value is converted to double always.

Also:
- remove __tcc_fpinit for unix as it seems redundant by the
  __setfpucw call in the startup code
- avoid reference to s->runtime_main in cross compilers
- configure: fix --with-libgcc help
- tcctok.h: cleanup
2014-01-06 19:07:08 +01:00
YX Hao 642b6d0f50 Add the possibility to use noname functions by ordinal
tcc.c:
process.h:177:20: note: expected 'char * const*' but argument is of type 'char const*const*'

tccpe.c:
Add the possibility to use noname functions by ordinal.
use def file: "AliasName @n"

build-tcc.bat:
1. Enable 32 bits mode on 64 bits OS.
2. build doc.

_parseLibs.bat:
Convenient to use "*.def + *.c" instead of *.a, just use -l*

_tcc.bat:
a practice of _parseLibs.bat

Signed-off-by: YX Hao <lifenjoiner@163.com>
2013-09-19 21:50:38 +08:00
grischka 13b997668e win32: fix libtcc support
For "tcc -run file.c", I was trying to initialize the FP control
in a function in libtcc1.a (_runmain) before calling main.

Unfortunately that turned out to cause problems with for example
libtcc_test since such usage doesn't necessarily define a 'main'
function.

So for tcc -run we're back to relying on the FP control word
that is set in the startup code of tcc.exe rsp. libtcc.dll.

This fixes part of commit 73faaea227
2013-09-10 15:36:56 +02:00
grischka 73faaea227 i386-gen: preserve fp control word in gen_cvt_ftoi
- Use runtime function for conversion
- Also initialize fp with tcc -run on windows

This fixes a bug where
  double x = 1.0;
  double y = 1.0000000000000001;
  double z = x < y ? 0 : sqrt (x*x - y*y);
caused a bad sqrt because rounding precision for the x < y comparison
was different to the one used within the sqrt function.

This also fixes a bug where
  printf("%d, %d", (int)pow(10, 2), (int)pow(10, 2));
would print
  100, 99

Unrelated:
  win32: document relative include & lib lookup
  win32: normalize_slashes: do not mirror silly gcc behavior
  This reverts part of commit 8a81f9e103
  winapi: add missing WINAPI decl. for some functions
2013-08-28 22:55:05 +02:00
Roy 807dc7c8de tccpe: pstrcpy() will truncate .stabstr section name, use strncpy() instead. 2013-06-06 09:26:31 +08:00
Urs Janssen 0bdbd49eac add version number to manpage
avoid c++/c99 style comments in preprocessor directives
avoid leadings whitespaces in preprocessor directives
mention implemented variable length arrays in documentation
fixed ambiguous option in texi2html call (Austin English)
2013-02-17 00:48:51 +01:00
grischka 05108a3b0a libtcc: new LIBTCCAPI tcc_set_options(TCCState*, const char*str)
This replaces       -> use instead:
-----------------------------------
- tcc_set_linker    -> tcc_set_options(s, "-Wl,...");
- tcc_set_warning   -> tcc_set_options(s, "-W...");
- tcc_enable_debug  -> tcc_set_options(s, "-g");

parse_args is moved to libtcc.c (now tcc_parse_args).

Also some cleanups:
- reorder TCCState members
- add some comments here and there
- do not use argv's directly, make string copies
- use const char* in tcc_set_linker
- tccpe: use fd instead of fp

tested with -D MEM_DEBUG: 0 bytes left
2013-02-12 19:13:28 +01:00
grischka 248dc67506 win32: Honor "-Wl,-subsystem=console/gui" option 2013-02-04 17:58:37 +01:00
grischka 82bcbd027f portability: fix void* <-> target address conversion confusion
- #define addr_t as ElfW(Addr)
- replace uplong by addr_t
- #define TCC_HAS_RUNTIME_PLTGOT and use it
2013-02-04 16:24:59 +01:00
grischka 2f6b8469cc safety: replace occurrences of strcpy by pstrcpy 2013-01-31 13:23:19 +01:00
grischka b7e75ccdb0 tccpe: no debug, no stabs 2013-01-30 18:39:26 +01:00
Thomas Preud'homme 8c56b0cf90 Revert "Added what I call virtual io to tinycc this way we can make a monolitic executable or library that contains all needed to compile programs, truly tinycc portable."
This reverts commit 59e18aee0e.
tcc is being stabilized now in order to do a new release soon.
Therefore, such a change is not appropriate now.
2013-01-14 17:34:07 +01:00
Thomas Preud'homme 60a3ff5f2c Revert "pe: fix tcc not linking to user32 and gdi32"
This reverts commit 943574aba5.
The empty string in "libs" was intended behavior, as can be seen from
the "if (0 == *p)" below.
2013-01-14 17:21:06 +01:00
mingodad 59e18aee0e Added what I call virtual io to tinycc this way we can make a monolitic executable or library that contains all needed to compile programs, truly tinycc portable.
Tested under linux exec the "mk-it" shell script and you'll end up with a portable tinycc executable that doesn't depend on anything else.
2013-01-11 00:04:38 +00:00
Roy Tam 943574aba5 pe: fix tcc not linking to user32 and gdi32 2012-11-02 16:59:21 +08:00
grischka a35b3059bb tcc.h: define TCC_IS_NATIVE
- disable tccrun feature for non-native (cross-) compilers
- define uplong for target adress size
- fix using -Wl,-Ttext=... for Win64 (tccpe: ADDR3264 imagebase)
2012-03-05 20:15:56 +01:00
grischka bf374a5f23 rename error/warning -> tcc_(error/warning) 2011-08-11 17:07:56 +02:00
grischka e844fb11c2 libtcc: support more than one crtprefix
Looks like gcc has that.  Oh Deer!
2011-08-06 16:49:30 +02:00
grischka aa80e5b1ff tccpe: cleanup ELFW() macros etc. 2011-07-14 19:23:04 +02:00
grischka df4c0892f3 tccrun: win64: add unwind function table for dynamic code
This works only when tcc.exe is compiled using MSC.  MinGW does
something in the startup code that defeats it.
2011-07-14 19:09:49 +02:00