aboutsummaryrefslogtreecommitdiff
path: root/libtcc.c
Commit message (Collapse)AuthorAgeFilesLines
* section alignmentseyko2016-04-221-1/+1
| | | | | | 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.
* Improve hash performanceVlad Vissoultchev2016-04-171-7/+8
| | | | | | | | | | | | - 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)
* allow to compile tcc by pccseyko2016-04-151-1/+1
| | | | | * pcc have only __linux__ macro (and no __linux) * pcc don't have __clear_cache proc
* preprocessor oprtion -C (keep comments)seyko2016-04-151-0/+20
| | | | | This is done by impression of the pcc -C option. Usual execution path and speed are not changed.
* Simplify @listfiles parsingVlad Vissoultchev2016-04-131-39/+17
| | | | This moves listfiles parsing inline in `tcc_parse_args1`
* Allow tcc arguments to be read from @listfilesseyko2016-04-131-27/+84
| | | | | | | | | | | | | | | | | 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.
* Implement -dM preprocessor option as in gccVlad Vissoultchev2016-04-061-2/+4
| | | | | | 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.
* -fnormalize-inc-dirsseyko2016-04-031-0/+93
| | | | | | remove non-existent or duplicate directories from include paths if -fnormalize-inc-dirs is specified. This will help to compile current coreutils package
* tccpp: cleanup #include_nextgrischka2015-11-201-92/+0
| | | | | | | | | | | | | | | | 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" c3975cf27c792d493e76a2058a1eaf588324053e && p[1] == '.' is not a reliable way to lookahead
* tccgen: asm_label cleanupgrischka2015-11-201-1/+1
| | | | | | | - avoid memory allocation by using its (int) token number - avoid additional function parameter by using Attribute Also: fix some strange looking error messages
* Trivial changes to avoid some compiler warnings.Edmund Grimley Evans2015-11-191-1/+1
|
* libtcc.c: Completely replace tcc_normalize_inc_dirs.Edmund Grimley Evans2015-11-111-73/+26
|
* win: include dirs: add some docs, minor refactorAvi Halachmi (:avih)2015-11-081-4/+18
|
* fix tcc_mormalize_inc_dirs namingseyko2015-11-081-2/+2
|
* win: fix incorrect directory detectionAvi Halachmi (:avih)2015-11-081-1/+2
| | | | Allow other flags too...
* win: fix dir comparison during include dirs processingAvi Halachmi (:avih)2015-11-081-16/+60
| | | | Use native Windows API via wrapper with stat-like API.
* normalize inc dirs, symplify include_nextseyko2015-11-051-0/+80
| | | | | | | | | 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
* Define __WINT_TYPE__ as int in NetBSDKamil Rytarowski2015-10-111-1/+1
|
* Add support for -D__NetBSD__Kamil Rytarowski2015-10-111-0/+5
|
* Revert all of my changes to directories & codingstyle.gus knight2015-07-291-0/+2322
|
* Reorganize the source tree.gus knight2015-07-271-2322/+0
| | | | | | | | | | * 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...
* Clean up lots of rogue tabs.gus knight2015-07-271-9/+9
| | | | | | 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.
* Trim trailing spaces everywhere.gus knight2015-07-271-1/+1
|
* redo of the -dD optionseyko2015-05-131-1/+16
| | | | | | | | 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"
* some -bench fixesseyko2015-05-121-1/+1
| | | | print stats to stderr, not to stdout
* minor pp optimizationsseyko2015-05-121-0/+4
| | | | | | * remove free_defines() from tcc_preprocess() all cleanup will be done in tcc_delete * move a preprocessor file closing to tcc_delete too
* restore a max memory usage printing for a new MEM_DEBUG when -benchseyko2015-05-121-3/+6
|
* a new version of the MEM_DEBUGseyko2015-05-121-25/+180
|
* allow to use MEM_DEBUG with libtccseyko2015-05-111-0/+1
|
* tcc_add_dll is not used if TCC_TARGET_PEseyko2015-05-101-0/+2
| | | | after "tccpp: fix issues, add tests"
* define __OPTIMIZE__ if -ON (N != 0)seyko2015-05-101-0/+9
| | | | this is gcc behaviour
* warn if multile -o option is givenseyko2015-05-101-0/+4
|
* tccpp: fix issues, add testsgrischka2015-05-091-55/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 a3fc54345949535524d01319e1ca6378b7c2c201 a715d7143d9d17da17e67fec6af1c01409a71a31 (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)
* -traditional and -iwithprefix optionsseyko2015-05-031-0/+27
|
* fix "tcc test.c -Wl,,--oformat,binary"seyko2015-05-031-1/+5
| | | | | set linker options only when "s->output_type == TCC_OUTPUT_EXE" otherwise tcc will produce a wrong object file
* fix "tcc test.c -UAAA -UBBB"seyko2015-05-031-1/+0
| | | | | no need to call tcc_free() inside tcc_undefine_symbol() Otherwise we get segmentation fault inside tcc_delete()
* replace PARSE_FLAG_ASM_COMMENTS with PARSE_FLAG_ASM_FILEseyko2015-04-271-1/+1
| | | | | after "assign PARSE_FLAG_ASM_COMMENTS only for asm files" functions of this flags are identical
* preprocess: "assign PARSE_FLAG_ASM_COMMENTS only for asm files"seyko2015-04-271-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* clarify error message when library not foundseyko2015-04-161-1/+1
| | | | | a prior error message: cannot find 'program_resolve_lib' after a patch: cannot find library 'libprogram_resolve_lib'
* implement #pragma comment(lib,...)Steven G. Messervey2015-04-151-0/+18
|
* Revert "implement #pragma comment(lib,...)"Steven G. Messervey2015-04-151-31/+13
| | | | | | This reverts commit 8615bb40fb39bf7435462ca54cbbc24aaecae502. Reverting as it breaks on MinGW targets
* implement #pragma comment(lib,...)Steven G. Messervey2015-04-151-13/+31
|
* ability to specify a type of the input file with the -x switchseyko2015-04-121-19/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* -fdollar-in-identifiers switch which enables '$' in identifiersseyko2015-04-121-0/+1
| | | | | | | | | | 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.
* replace a method to force bcheck.o linkingseyko2015-04-121-5/+8
| | | | | | * 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
* Fix for Microsoft compilersseyko2015-04-111-1/+1
| | | | | | | Correction for the commit db08122d31a681e593c6679140d2df0cc63c8784 As pointed Thomas Preud'homme buf[] may be used outside of the block whit code: name = block;
* option to use an old algorithm of the array in struct initializationseyko2015-04-101-0/+1
| | | | | | 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.
* fix a preprocessor for .Sseyko2015-04-101-1/+4
| | | | | | 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.
* fix a preprocessor for .Sseyko2015-04-101-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | * 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
* fix installation amd bcheck for Windowsseyko2015-04-101-0/+11
| | | | | | | | | | | | | | | | | | | | | | * 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.