Commit Graph

296 Commits (1443039416dd02750765efde1af35e31c8d41be3)

Author SHA1 Message Date
grischka f3c1ea6c2d #define __GNUC__ = 2.1
__GNUC__ nowadays as macro seems to mean the "GNU C dialect"
rather than the compiler itself.  See also

  http://gcc.gnu.org/ml/gcc/2008-07/msg00026.html

This patch will probably cause problems of various kinds but
maybe we should try nonetheless.
2016-10-15 16:01:16 +02:00
grischka 4d247c00a3 tccgen/tccelf: move code from libtcc.c 2016-10-15 15:55:31 +02:00
Christian Jullien 3e32479594 Add more OpenBSD support. 2016-10-15 15:08:44 +02:00
grischka b42cb16b65 Misc. fixes
Makefile :
- do not 'uninstall' peoples /usr/local/doc entirely
libtcc.c :
- MEM_DEBUG : IDE-friendly output "file:line: ..."
- always ELF for objects
tccgen.c :
- fix memory leak in new switch code
- move static 'in_sizeof' out of function
profiling :
- define 'static' to empty
resolve_sym() :
- replace by dlsym()

win32/64: fix R_XXX_RELATIVE fixme
- was fixed for i386 already in
  8e4d64be2f
- do not -Lsystemdir if compiling to .o
2016-10-05 18:34:17 +02:00
grischka 1c4cf18556 tccpp: no cache for include if #elif seen
#ifndef guards are cached, however after #elif on the
same level, the file must be re-read.

Also: preprocess asm as such even when there is no
assembler (arm).
2016-10-04 17:31:40 +02:00
grischka 78f1c10e0f configure: fix tcc_lddir, cpu
... and other minor cosmetic fixes
2016-10-03 12:33:40 +02:00
grischka c5b9ae4e3f Revert "-fnormalize-inc-dirs"
Too much code. gcc 3.x doesn't have that either.

This reverts commit 41785a0bf9.
This reverts commit 21665f4338.
2016-10-01 21:57:22 +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
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 2f1174550e libtcc: -Wl,... incremental parsing
parse -Wl linker options immediately
2016-10-01 20:49:38 +02:00
grischka 2d6aa65067 Revert "output all sections if we produce an executable file"
-- Not a fix
This reverts commit 089ce6235c.

Revert "handle a -s option by executing sstrip/strip program"
-- related, not a fix.
This reverts commit 5cd4393a54.
2016-10-01 20:48:01 +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 acac35c125 libtcc: filetype cleanup
- does not change signature of tcc_add_file
2016-10-01 20:46:16 +02:00
grischka 766ba3694d tccpp: cleanup
- "utf8 in identifiers"
  from 936819a1b9

- CValue: remove member str.data_allocated
- make tiny allocator private to tccpp

- allocate macro_stack objects on heap
  because otherwise it could crash after error/setjmp
  in preprocess_delete():end_macro()

- mov "TinyAlloc" defs to tccpp.c

- define_push: take int* str again
2016-10-01 20:26:50 +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
grischka 09a487eb2b libtcc: cleanup -x<filetype> switch code
Abusing filename[0] as type is just too much of a hack.
-- From 0536407204
2016-10-01 20:04:58 +02:00
grischka e630113771 Revert "ability to compile multiple *.c files with -c switch"
copy & paste coding, twisted control flow
This reverts commit a13f183e4c.

Also, set linker args for DLLs also.
2016-10-01 20:04:33 +02:00
grischka 07e47b3dd6 tccpp: restore -D symbols for multiple sources
... also for built-in defines

The case:
    $ tcc -D FOO a.c b.c
with
    // a.c
    #undef FOO

    // b.c
    #ifndef FOO
    # error -D FOO has been lost
    #endif
2016-10-01 19:58:13 +02:00
grischka cf32bb8812 Revert "--whole-archive support"
- would parse linker args in two different places
- would mess up "tcc -v ..." output:
  	tcc -v test.c
  	-> test.c
  	+> test.c
- would use function "tcc_load_alacarte()" to do the contrary of
  what its name suggests.

This reverts commit 19a169ceb8.
2016-10-01 19:56:25 +02:00
Jean-Claude Beaudoin d5a1e32ac3 Prevent tail spin crash when option -pthread is used. 2016-09-29 16:23:11 -04:00
Jean-Claude Beaudoin 889ee28ed5 Rein in unintended external functions on Windows. 2016-09-27 01:43:40 -04:00
Christian Jullien e037fd3364 pstrcpy looks to be needed by Windows win32/win64 builds. Reverted as PUB_FUNC to allow tcc.exe build again. 2016-09-26 07:02:42 +02:00
Christian Jullien 6db7a2157b Merge branch 'mob' of git://repo.or.cz/tinycc into mypatch
Add Visual Studio processor identification
2016-09-26 06:42:43 +02:00
Christian Jullien 30238b1ebd Add Microsoft processor identification 2016-09-26 06:41:31 +02:00
Jean-Claude Beaudoin ff158bffe6 Rein in unintended external functions. 2016-09-25 22:32:41 -04:00
Christian Jullien c1b101cbaf Improve __*LP*__ predefined macros 2016-09-25 12:03:23 +02:00
grischka 9e0e05eb4e Redo "fix line number in macro redefined message"
Smaller change to fix more cases

This reverts commit 0f36f60faa.
2016-05-25 18:51:36 +02:00
seyko 19a169ceb8 --whole-archive support
A patch is implemented as suggested in tinycc-devel mail list.

    From: Reuben Thomas
    Date: Thu, 31 Jul 2014 16:52:53 +0100
    Subject: [PATCH] Add --{no,}-whole-archive support

    I resurrected the patch supplied to the mailing list in 2009
    Since --whole-archive is a useful flag to get tcc working with
    autotools, and of course in its own right, I suggest you have a look
    at the patch and see if it is acceptable. I cannot see any suggestion
    that it was actively rejected last time round, just no evidence that
    it was ever added.
2016-05-20 15:12:32 +03:00
seyko 9d679e3916 memory model macros __{L,}LP64__
a patch from tcc bugzilla.
    From: Reuben Thomas
    Date: Thu, 31 Jul 2014 13:50:13 +0100
    Subject: [PATCH] libtcc.c: add memory model macros __{L,}LP64__
2016-05-15 21:07:05 +03:00
grischka fe845cf53d tccpp: cleanup options -dD -dM, remove -C
The lexer is for reading files, not for writing.

Also :
- macro_is_equal(): avoid crash if redefining __FILE__
2016-05-05 14:12:53 +02:00
grischka caebbc3ee1 tccgen: scope levels for local symbols
... for fast redeclaration checks

Also, check function parameters too:
    void foo(int a) { int a; ... }

Also, try to fix struct/union/enum's on different scopes:
    { struct xxx { int x; };
         { struct xxx { int y; }; ... }}
and some (probably not all) combination with incomplete
declarations "struct xxx;"

Replaces 2bfedb1867
and 07d896c8e5

Fixes cf95ac399c
2016-05-05 10:39:09 +02:00
seyko 2bfedb1867 -fno-type-redefinition-check
don't catch redefinition for local vars. With this option on
    tcc accepts the following code:
    int main()
    {
        int a = 0;
        long a = 0;
    }
    But if you shure there is no problem with your local variables,
    then a compilation speed can be improved if you have a lots of
    the local variables (50000+)
2016-05-04 17:17:51 +03:00
seyko edcb15c31f section alignment
Alignment of unknown sections changed from 32 to PTR_SIZE
    This is gcc/pcc default value. This helps to use
    tcc as linux kernel compiler.
2016-04-22 18:25:40 +03:00
Vlad Vissoultchev 224236f57c Improve hash performance
- better `TOK_HASH_FUNC`
- increases `hash_ident` initial size to 16k (from 8k)
- `cstr_cat` uses single `realloc` + `memcpy`
- `cstr_cat` can append terminating zero
- `tok_str_realloc` initial size to 16 (from 8)
- `parse_define` uses static `tokstr_buf`
- `next` uses static `tokstr_buf`
- fixes two latent bugs (wrong deallocations in libtcc.c:482 and
  tccpp.c:2987)
2016-04-17 17:25:55 +03:00
seyko 5ee097fce9 allow to compile tcc by pcc
* pcc have only __linux__ macro (and no __linux)
    * pcc don't have __clear_cache proc
2016-04-15 17:41:49 +03:00
seyko c6dc756d4e preprocessor oprtion -C (keep comments)
This is done by impression of the pcc -C option.
    Usual execution path and speed are not changed.
2016-04-15 17:15:11 +03:00
Vlad Vissoultchev cb5f6b063b Simplify @listfiles parsing
This moves listfiles parsing inline in `tcc_parse_args1`
2016-04-13 11:35:24 +03:00
seyko 989b5ee8ae Allow tcc arguments to be read from @listfiles
From: Vlad Vissoultchev
    Date: Tue, 12 Apr 2016 20:43:15 +0300
    Subject: Allow tcc arguments to be read from @listfiles

    This allows all @ prefixed arguments to be treated as listfiles
    containing list of source files or tcc options where each one is on a
    separate line. Can be used to benchmark compilation speed with
    non-trivial amount of source files.

    The impl of `tcc_parse_args` had to be moved to a new function that is
    able to be called recursively w/ the original one remaining as a driver
    of the new one. Listfiles parsing happens in a new
    `args_parser_add_listfile` function that uses `tcc_open`/`tcc_close/inp`
    for buffered file input.
2016-04-13 07:05:38 +03:00
Vlad Vissoultchev e946eb2a41 Implement -dM preprocessor option as in gcc
There was already support for -dD option but in contrast -dM dumps only `#define` directives w/o actual preprocessor output.

The original -dD output differs from gcc output by additional comment in front of `#define`s so this quirk is left for -dM as well.
2016-04-06 18:57:11 +03:00
seyko 41785a0bf9 -fnormalize-inc-dirs
remove non-existent or duplicate directories from include paths
    if -fnormalize-inc-dirs is specified. This will help
    to compile current coreutils package
2016-04-03 11:42:15 +03:00
grischka 0b3612631f tccpp: cleanup #include_next
tcc_normalize_inc_dirs: normally no problem to be absolutly
gcc compatible as long as it can be done the tiny way.

This reverts to the state before recent related commits and
reimplements a (small) part of it to fix the reported problem.


Also: Revert "parsing "..." sequence"
c3975cf27c

	&& p[1] == '.'

is not a reliable way to lookahead
2015-11-20 12:05:55 +01:00
grischka 54cf57ab1a tccgen: asm_label cleanup
- avoid memory allocation by using its (int) token number
- avoid additional function parameter by using Attribute

Also: fix some strange looking error messages
2015-11-20 11:22:56 +01:00
Edmund Grimley Evans ba99a70cd8 Trivial changes to avoid some compiler warnings. 2015-11-19 18:26:47 +00:00
Edmund Grimley Evans c39bc9caa7 libtcc.c: Completely replace tcc_normalize_inc_dirs. 2015-11-11 21:18:01 +00:00
Avi Halachmi (:avih) 951c23f257 win: include dirs: add some docs, minor refactor 2015-11-08 16:28:00 +02:00
seyko 763dd22b35 fix tcc_mormalize_inc_dirs naming 2015-11-08 11:42:56 +03:00
Avi Halachmi (:avih) ec67dc482f win: fix incorrect directory detection
Allow other flags too...
2015-11-08 04:33:30 +02:00
Avi Halachmi (:avih) acbab220c8 win: fix dir comparison during include dirs processing
Use native Windows API via wrapper with stat-like API.
2015-11-08 03:56:25 +02:00
seyko a6276b7a78 normalize inc dirs, symplify include_next
include dirs are prepared as in gcc
    - for each duplicate path keep just the first one
    - remove each include_path that exists in sysinclude_paths

    include_next streamlined by introducing inc_path_index
    in the BufferedFile
2015-11-05 19:52:49 +03:00
Kamil Rytarowski 6cb74ecacf Define __WINT_TYPE__ as int in NetBSD 2015-10-11 11:59:20 +02:00
Kamil Rytarowski 5860b639c6 Add support for -D__NetBSD__ 2015-10-11 03:12:35 +02: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
seyko 80322adaa0 redo of the -dD option
functionality was broken some time ago and was removed
    by the "tccpp: fix issues, add tests"

    fix: LINE_MACRO_OUTPUT_FORMAT_NONE in pp_line()
    means: output '\n' and not "don't output at all"
2015-05-13 12:16:00 +03:00
seyko cf92f7aacb some -bench fixes
print stats to stderr, not to stdout
2015-05-12 22:02:51 +03:00
seyko 06e0753fce minor pp optimizations
* remove free_defines() from tcc_preprocess()
        all cleanup will be done in tcc_delete
    * move a preprocessor file closing to tcc_delete too
2015-05-12 21:32:32 +03:00
seyko 1234beccb8 restore a max memory usage printing for a new MEM_DEBUG when -bench 2015-05-12 16:07:09 +03:00
seyko 121e95d115 a new version of the MEM_DEBUG 2015-05-12 11:56:39 +03:00
seyko ae09051c81 allow to use MEM_DEBUG with libtcc 2015-05-11 18:05:31 +03:00
seyko cb7e820eae tcc_add_dll is not used if TCC_TARGET_PE
after "tccpp: fix issues, add tests"
2015-05-10 11:37:36 +03:00
seyko ff06d4258e define __OPTIMIZE__ if -ON (N != 0)
this is gcc behaviour
2015-05-10 10:21:37 +03:00
seyko c497f9c82c warn if multile -o option is given 2015-05-10 10:13:35 +03: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 fca58734fb -traditional and -iwithprefix options 2015-05-03 20:10:57 +03:00
seyko 576aeb3aa9 fix "tcc test.c -Wl,,--oformat,binary"
set linker options only when "s->output_type == TCC_OUTPUT_EXE"
    otherwise tcc will produce a wrong object file
2015-05-03 14:17:18 +03:00
seyko 2ba219f781 fix "tcc test.c -UAAA -UBBB"
no need to call tcc_free() inside tcc_undefine_symbol()
    Otherwise we get segmentation fault inside tcc_delete()
2015-05-03 13:58:27 +03:00
seyko bbcb54a1f4 replace PARSE_FLAG_ASM_COMMENTS with PARSE_FLAG_ASM_FILE
after "assign PARSE_FLAG_ASM_COMMENTS only for asm files"
    functions of this flags are identical
2015-04-27 16:36:58 +03:00
seyko 2df290073b preprocess: "assign PARSE_FLAG_ASM_COMMENTS only for asm files"
resolve a problem with the following test.c program, tcc -E test.c

    #ifdef	_XOPEN_SOURCE
    # define __USE_XOPEN	1
    # if (_XOPEN_SOURCE - 0) >= 500
    #  define __USE_XOPEN_EXTENDED	1
    #  define __USE_UNIX98	1
    #  undef _LARGEFILE_SOURCE
    #  define _LARGEFILE_SOURCE	1
    #  if (_XOPEN_SOURCE - 0) >= 600
    #   define __USE_XOPEN2K	1
    #   undef __USE_ISOC99
    #   define __USE_ISOC99		1
    #  endif
    # else
    #  ifdef _XOPEN_SOURCE_EXTENDED
    #   define __USE_XOPEN_EXTENDED	1
    #  endif
    # endif
    #endif

    int main() {}

    // # 17 "aaa.c"
    // aaa.c:17: error: #endif without matching #if
2015-04-27 15:25:49 +03:00
seyko b472d53672 clarify error message when library not found
a prior error message: cannot find 'program_resolve_lib'
    after a patch: cannot find library 'libprogram_resolve_lib'
2015-04-16 07:30:24 +03:00
Steven G. Messervey aeaff94ec1 implement #pragma comment(lib,...) 2015-04-15 22:56:21 -04:00
Steven G. Messervey e50d68e417 Revert "implement #pragma comment(lib,...)"
This reverts commit 8615bb40fb.

Reverting as it breaks on MinGW targets
2015-04-15 21:24:15 -04:00
Steven G. Messervey 8615bb40fb implement #pragma comment(lib,...) 2015-04-15 17:00:26 -04:00
seyko 0536407204 ability to specify a type of the input file with the -x switch
Usage example: tcc -xc ex5.cgi
    From a gcc docs:

    You can specify the input language explicitly with the -x option:

    -x language
    Specify explicitly the language for the following input files
    (rather than letting the compiler choose a default based on the file
    name suffix). This option applies to all following input files until
    the next -x option. Possible values for language are:

        c  c-header  c-cpp-output
        c++  c++-header  c++-cpp-output
        objective-c  objective-c-header  objective-c-cpp-output
        objective-c++ objective-c++-header objective-c++-cpp-output
        assembler  assembler-with-cpp
        ada
        f77  f77-cpp-input f95  f95-cpp-input
        java

    -x none
    Turn off any specification of a language, so that subsequent files
    are handled according to their file name suffixes (as they are if -x
    has not been used at all)
2015-04-12 15:35:37 +03:00
seyko dcb36587b5 -fdollar-in-identifiers switch which enables '$' in identifiers
library Cello: http://libcello.org/ which uses `$` and several
    variations of as macros.

    There is also RayLanguage which also uses it as a macro for a kind of
    ObjC style message passing: https://github.com/kojiba/RayLanguage

    This is a patch from Daniel Holden.
2015-04-12 15:32:03 +03:00
seyko e7a60e4d01 replace a method to force bcheck.o linking
* define __bound_init as external_global_sym insteed of the compiling
      a tiny program
    * remove warning about buf[] when CONFIG_TCC_BCHECK is not defined
2015-04-12 04:47:15 +03:00
seyko 4bb9dd44f1 Fix for Microsoft compilers
Correction for the commit db08122d31
    As pointed Thomas Preud'homme buf[] may be used outside of the block
    whit code:
        name = block;
2015-04-11 16:22:34 +03:00
seyko 5c9dde7255 option to use an old algorithm of the array in struct initialization
This is for a case when no '{' is used in the initialization code.
    An option name is -fold-struct-init-code. A linux 2.4.26 can't
    find initrd when compiled with a new algorithm.
2015-04-10 23:44:10 +03:00
seyko d81611b641 fix a preprocessor for .S
Lets assume that in *.S files a preprocessor directive
    follow '#' char w/o spaces between. Otherwise there is
    too many problems with the content of the comments.
2015-04-10 16:53:29 +03:00
seyko 70dbe169b2 fix a preprocessor for .S
* tell a right line number in error message
      if a #line directive is wrong

    * don't print an error message if we preprocess a .S file
      and #line directive is wrong. This is the case of
      the
        # 4026 bytes
      comment in *.S file.

    * preprocess_skip: skip a line with
	    if (parse_flags & PARSE_FLAG_ASM_COMMENTS)
       		p = parse_line_comment(p);
      if line starts with # and a preprocessor command not found.

      A test program:
      #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
	# This repeats until either a device doesn't exist, or until
      #endif

    * remove a second definition of the TOK_FLAG_* and PARSE_FLAG_*
      from the tccpp.c
2015-04-10 16:31:12 +03:00
seyko 7e7e6148fd fix installation amd bcheck for Windows
* define targetos=Windows when --enable-tcc32-mingw, --enable-cygwin, ...
    * use TARGETOS insteed HOST_OS when selecting PROGS
    * use "$(tccdir)" insteed $(tccdir) on install (spaces in path)
    * install tcc.exe too
    * produce bcheck.o when cross-compiling too (lib/Makefile)
    * force bcheck.o linking by compiling inside tcc_set_output_type()
      a dummy program with local array. Otherwise bcheck.o may be not linked.
    * replace %xz format specifier with %p in bcheck (don't supported on
      Windows)
    * call a __bound_init when __bound_ptr_add, __bound_ptr_indir,
      __bound_new_region, __bound_delete_region called.
      This is because a __bound_init inside ".init" section is not called
      on Windows for unknown reason.
    * print on stderr a message when an illegal pointer is returned:
        there is no segmentation violation on Windows for a program
        compiled with "tcc -b"
    * remove "C:" subdir on clean if $HOST_OS = "Linux"
    * default CFLAGS="-Wall -g -O0" insteed CFLAGS="-Wall -g -O2"
      to speed up compilation and more precise debugging.
2015-04-10 07:37:31 +03:00
seyko 5cd4393a54 handle a -s option by executing sstrip/strip program 2015-04-10 06:53:48 +03:00
seyko dec959358a fix the bug #31403: parser bug in structure
- a warning: unnamed struct/union that defines no instances
    - allow a nested named struct declaration w/o identifier
      only when option -fms-extensions is used
2015-04-10 06:31:58 +03:00
seyko db08122d31 Fix for Microsoft compilers
Miccrosoft Visual Sudio (Express) 2008 and 2010 do not accept variable
    definitions C99 style, reported by Fabio <oldfaber@gmail.com>
2015-03-29 11:52:16 +03:00
seyko 3b7f5008fd fix for the previous commit (compilation on RPi) 2015-03-26 11:28:11 +03:00
seyko acef4ff244 make a bound checking more compatible with Windows 64
On Linux 32:   sizeof(long)=32 == sizeof(void *)=32
    on Linux 64:   sizeof(long)=64 == sizeof(void *)=64
    on Windows 64: sizeof(long)=32 != sizeof(void *)=64
2015-03-26 07:47:45 +03:00
seyko 724425addf fix for a -dumpversion option: move it before -dD
Options must be sorted and a long one must preceed a short one.
What was before:
    tcc -dumpversion
    tcc: error: invalid option -- '-dumpversion'
2015-03-23 20:58:27 +03:00
seyko 8f6390061d fix for: x86_64-tcc compiled by i386-tcc is wrong
A test program (must be compiled by the above version of the tcc):

    /* Tickle a bug in TinyC on 64-bit systems:
     * the LSB of the top word or ARGP gets set
     * for no obvious reason.
     *
     * Source: a legacy language interpreter which
     * has a little stack / stack pointer for arguments.
     *
     * Output is: 0x8049620 0x10804961c
     * Should be: 0x8049620 0x804961c
     */
    #include <stdio.h>
    #define NARGS 20000
    int ARG[NARGS];
    int *ARGSPACE = ARG;
    int *ARGP = ARG - 1;
    main() { printf("%p %p\n", ARGSPACE, ARGP); }
2015-03-23 19:24:55 +03:00
seyko e2650608cd fix to allow build tcc by build-tcc.bat
move call to print_defines() from tcc.c to the libtcc.c
    define a print_defines() as a ST_FUNC
2015-03-19 08:07:35 +03:00
seyko b5f88b593a Turn on a implicit-function-declaration warning by default.
A non declared function leads to a seriuos problems. And while
gcc don't turn this warning on lets tcc do it. This warning
can be turned off by -Wno-implicit-function-declaration option.
And autor must explicitly do this if program must be compiled
with this warning off.
2015-03-03 16:32:25 +03:00
seyko e374a733d6 -std=c99 option for the tcc: allow to use a tcc as a reference compiler for "make test"
tcc will igmore this option.
2015-03-03 16:25:02 +03:00
seyko c45a8695eb A reverse of the commit 14745bdeb because of the problems while compiling linux 2.4.26
A test program:
    ///////////
    typedef unsigned int __u32;
    static inline const __u32 __fswab32(__u32 x)
    {
	return ({ __u32 __tmp = (x) ; ___swab32(__tmp); });
    }
    void func()
    {
	int aaa = 1;
	int snd_wnd = 2;
	int TCP_FLAG_ACK = 3;
	int pred_flags = (__builtin_constant_p((__u32)
	    (((aaa << 26) |
	    (__builtin_constant_p((__u32)((TCP_FLAG_ACK))) ?
		({ __u32 __x = (((TCP_FLAG_ACK))); ((__u32)( (((__u32)(__x) & (__u32)0x000000ffUL) << 24) | (((__u32)(__x) & (__u32)0x0000ff00UL) << 8) | (((__u32)(__x) & (__u32)0x00ff0000UL) >> 8) | (((__u32)(__x) & (__u32)0xff000000UL) >> 24) )); }) : __fswab32(((TCP_FLAG_ACK)))) | snd_wnd))) ? ({ __u32 __x = ((((aaa << 26) | (__builtin_constant_p((__u32)((TCP_FLAG_ACK))) ? ({ __u32 __x = (((TCP_FLAG_ACK))); ((__u32)( (((__u32)(__x) & (__u32)0x000000ffUL) << 24) | (((__u32)(__x) & (__u32)0x0000ff00UL) << 8) | (((__u32)(__x) & (__u32)0x00ff0000UL) >> 8) | (((__u32)(__x) & (__u32)0xff000000UL) >> 24) )); }) : __fswab32(((TCP_FLAG_ACK)))) | snd_wnd))); ((__u32)( (((__u32)(__x) & (__u32)0x000000ffUL) << 24) | (((__u32)(__x) & (__u32)0x0000ff00UL) << 8) | (((__u32)(__x) & (__u32)0x00ff0000UL) >> 8) | (((__u32)(__x) & (__u32)0xff000000UL) >> 24) )); }) : __fswab32((((aaa << 26) | (__builtin_constant_p((__u32)((TCP_FLAG_ACK))) ? ({ __u32 __x = (((TCP_FLAG_ACK))); ((__u32)( (((__u32)(__x) & (__u32)0x000000ffUL) << 24) | (((__u32)(__x) & (__u32)0x0000ff00UL) << 8) | (((__u32)(__x) & (__u32)0x00ff0000UL) >> 8) | (((__u32)(__x) & (__u32)0xff000000UL) >> 24) )); })
		: __fswab32(((TCP_FLAG_ACK)))) | snd_wnd))));
    }
    ////////////
error: ';' expected (got "(")
2015-03-03 15:44:29 +03:00
seyko a429d40f06 tcc_free(table_ident) in preprocess_new() if table_ident != NULL 2015-03-03 14:54:46 +03:00
seyko e2a8fd4520 tcc_undefine_symbol(): free an alloced symbol 2015-03-03 14:50:41 +03:00
seyko b7b9f9f511 A gcc preprocessor option -dD added
With this option on a defines are included into the output
(inside comments). This will allow to debug a problems like:

    In file included from math.c:8:
    In file included from /usr/include/math.h:43:
    /usr/include/bits/nan.h:52: warning: NAN redefined
2015-03-03 14:25:57 +03:00
seyko 50cdccf3ef Added a gcc preprocessor options -P, -P1
tcc -E -P
  do not output a #line directive, a gcc compatible option

tcc -E -P1
  don't follow a gcc preprocessor style and do output a standard
  #line directive. In such case we don't lose a location info when
  we going to compile a resulting file wtith a compiler not
  understanding a gnu style line info.
2015-03-03 14:19:14 +03:00
Edmund Grimley Evans b14ef0e24b Add arm64 (AArch64) as a target architecture. 2015-02-23 22:51:03 +00:00
Edmund Grimley Evans 738606dbd5 Use RELA relocations properly for R_DATA_PTR on x86_64.
libtcc.c: Add greloca, a generalisation of greloc that takes an addend.
tcc.h: Add greloca and put_elf_reloca.
tccelf.c: Add put_elf_reloca, a generalisation of put_elf_reloc.
tccgen.c: On x86_64, use greloca instead of greloc in init_putv.
2015-02-21 21:29:03 +00:00
seyko c334b59142 Warn about a conflicting compile options spectified on the command line.
Try "tcc -E -c tccasm.c -o tccasm.o"
2015-01-06 22:19:45 +03:00