diff --git a/.gitignore b/.gitignore index 518cae4..36c8aac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,72 +1,64 @@ +*~ +\#* +.#* *.o *.a -a.out *.exe +*.dll +*.obj +*.pdb +*.lib +*.exp *.log +*.bz2 +*.zip +.gdb_history +a.out tcc_g tcc -/*-tcc -tc2.c -doc -tc3s.c -p3.c -tc1.c -error.c -i386-gen1.c -test.out1 -test.out1b -test.out2 -test.out2b -test.out3 -test.out3b -web.sh -memdebug.c -bench -Makefile.uClibc -boundtest -prog.ref -test.ref -test.out -tcc-doc.html -ideas -tcctest.ref -linux.tcc -ldtest -libtcc_test -instr.S -p.c -p2.c -tcctest[1234] -test[1234].out -tests/tcclib.h -tests/tcctest.cc -tests/weaktest.*.o.txt -tests/tests2/fred.txt -tests/tests2/*.exe -tests/hello -tests/abitest-*cc -tests/vla_test -.gdb_history -tcc.1 -tcc.pod +*-tcc + config.h config.mak config.texi +conftest* tags TAGS -.DS_Store -*.swp +tcc.1 +tcc.pod +tcc-doc.html +tcc-doc.info + lib/x86_64 lib/i386 lib/x86_64-win32 lib/i386-win32 lib/arm lib/arm64 -tcc-doc.info -conftest* -tiny_libmaker -*.dSYM -*~ -\#* -.#* -win32/* + +win32/doc +win32/libtcc +win32/lib/32 +win32/lib/64 +win32/include/float.h +win32/include/stdarg.h +win32/include/stdbool.h +win32/include/stddef.h +win32/include/varargs.h +win32/include/tcclib.h + +tests/test.out* +tests/test*.out +tests/tcctest[1234] +tests/tcctest.gcc +tests/*.ref +tests/*.txt +tests/*.gcc +tests/*-cc* +tests/*-tcc* +tests/libtcc_test +tests/vla_test +tests/hello +tests/tests2/fred.txt + +libtcc*.def diff --git a/Changelog b/Changelog index 7cc19c8..6928536 100644 --- a/Changelog +++ b/Changelog @@ -1,126 +1,35 @@ Version 0.9.27: -Licensing: - -- TinyCC partly relicensed to MIT license - User interface: - -- define __STDC_HOSTED__ (Michael Matz, Urs Janssen) -- added support for CPATH, C_INCLUDE_PATH and LD_LIBRARY_PATH (Andrew Aladjev -and Urs Janssen) -- added option -norunsrc to control argv[0] with tcc -run (James Lyon) -- improve --with-libgcc configure help (grischka) -- improve error message when memory is full (grischka) -- improve wording about compiler switches in documentation (Thomas Preud'homme) -- use GNU triplet prefix for cross compiler names (Thomas Preud'homme) -- ignore unknown linker optimization and as-needed option (Austin English) - -Features: - -- added ABI tests with native compiler using libtcc (James Lyon) -- added CMake build system with support for cross-compilation (James Lyon) -- improved variable length array support (James Lyon) -- add the possibility to use noname functions by ordinal (YX Hao) -- add a install-strip target to install tcc (Thomas Preud'homme) -- add runtime selection of float ABI on ARM (Thomas Preud'homme) -- add shared lib support on x86-64 (Michael Matz) +- -x[c|a|n] filetype option (Sergey Korshunoff) +- -P[1], -dD, -dM preprocessor options (Sergey Korshunoff) +- -Wl,-(no-)whole-archive linker option (Reuben Thomas) +- -mms-bitfields option (David Mertens) +- -include option (Michael Matz) +- @listfile support (Vlad Vissoultchev) +- CPATH, C_INCLUDE_PATH and LD_LIBRARY_PATH environment variables support + (Andrew Aladjev, Urs Janssen) Platforms: -- support Debian GNU/kfreeBSD 64bit userspace (Thomas Preud'homme) -- fix GNU/Hurd interpreter path (Thomas Preud'homme) -- fix configure script for FreeBSD host (Thomas Preud'homme) -- make tcc -run work reliably on ARM by flushing caches (Thomas Preud'homme) -- many x86-64 ABI fixes incl. XMM register passing (James Lyon) -- improve compatibility with mingw's long double (James Lyon) -- avoid .stabstr section name to be truncated on win32 (Roy) -- add support for load/store of _Bool value (Thomas Preud'homme) -- detect instruction with incorrect operands on x86-64 (Thomas Preud'homme) -- improved relocations on ARM (Thomas Preud'homme) -- add va_* macro implementation for ARM (Thomas Preud'homme) -- define __ARM_EABI__, __ARMEL__ and __ARM_PCS_VFP (Thomas Preud'homme) -- provide a runtime library for ARM (Thomas Preud'homme) +- new AARCH64 (arm64) target (Edmund Grimley Evans) - vastly improved support for ARM hard float calling convention -(Thomas Preud'homme, Daniel Glöckner) -- tcc can uses libtcc1 on ARM (Thomas Preud'homme) -- use __fixdfdi for all float to integer conversion (grischka) -- simplify startup code for unix platforms (grischka) -- improve ELF generated on ARM (Thomas Preud'homme) -- add support for thumb to ARM relocation (Thomas Preud'homme) -- fix globbing to match MSVC on Windows (Thomas Preud'homme) -- deprecate FPA and OABI support for ARM (Thomas Preud'homme) -- warn about softfloat not being supported on ARM (Thomas Preud'homme) + (Thomas Preud'homme, Daniel Glöckner) +- provide a runtime library for ARM (Thomas Preud'homme) +- many x86-64 ABI fixes incl. XMM register passing and tests (James Lyon) +- ABI tests with native compiler using libtcc (James Lyon) -Bug fixes: -- many code clean up (Urs Janssen, grischka) -- fixes of other's patches (grischka, Ramsay Jones, Michael Matz) -- fix documentation about __TINYC__ (Urs Janssen) -- improve build of documentation (Urs Janssen) -- improve build instructions (Jov) -- switch from texi2html to makeinfo --html to build tcc-doc.html (James Lyon) -- improve out of tree build (James Lyon) -- improved passing and returning of struct (James Lyon) -- fix CMake build on i386 and x86-64 (James Lyon) -- fix i386 calling convention issue (James Lyon) -- fix error in Windows build of tests (James Lyon) -- fix x86-64 long double passing (James Lyon) -- fix crash with undefined struct (grischka) -- normalize slashes on win32 to always use backslashes (grischka) -- use runtime function for float to int conversion on i386 (grischka) -- improved documentation for include and lib lookup on win32 (grischka) -- detect redefinition of function (Thomas Preud'homme) -- detect the use of array of functions (Thomas Preud'homme) -- detect use of enumerator with wrong enumeration (Thomas Preud'homme) -- detect redefinition of enumerator or enumeration (Thomas Preud'homme) -- set the user-defined library search paths first (Vittorio Giovara) -- detect usage of incomplete types inside struct/union (Amine Najahi) -- various macro bug fixes (Joseph Poirier) -- avoid wrong trigger of assert on x86-64 platform (Thomas Preud'homme) -- fix NaN comparison (Thomas Preud'homme) -- use libtcc for static linking with runtime library (Thomas Preud'homme) -- fix negation of 0.0 and -0.0 values (Thomas Preud'homme) -- fix use of long long as if condition (Thomas Preud'homme) -- disable bound check if libgcc is used (Thomas Preud'homme) -- error out when casting to void (grischka) -- remove circular dependency in Makefile (grischka) -- stop preventing gcc to do strict aliasing (grischka) -- fix Windows build of tcc (grischka) -- build runtime library for arm cross compiler (Thomas Preud'homme) -- fix installation of arm cross-compiler (Thomas Preud'homme) -- add basic test for cross-compiler (Thomas Preud'homme) -- fix failure when generating PE on x86-64 (Archidemon) -- fix floating point unary minus and plus (Michael Matz) -- add more tests for signed zero float (Michael Matz) -- fix precision of double on x86-64 (Vincent Lefevre) -- fix bound checking of argv with -run switch (Kirill Smelkov) -- work around a wine cmd bug when building tcc on Windows (Austin English) -- reenable some bound check tests (grischka) -- boundtest.c lookup honors VPATH (grischka) -- diff compared to CC in test[123]b? are now errors (grischka) -- fix test3 on Windows (grischka) -- prevent gcc from building (non functional) libtcc.a (grischka) -- fix warning related to PE file generation on x86-64 (grischka) -- stop mixing ordinary and implicit rule in Makefile (Iavael) -- fix integer to double conversion on ARM (Thomas Preud'homme) -- fix parameter passing of structure < 4 bytes on ARM (Thomas Preud'homme) -- disable builtin_frame_address test on ARM due to gcc bug (Thomas Preud'homme) -- fix initialization of struct on ARM (Thomas Preud'homme) -- fix parameter passing of (unsigned) long long bitfield (Thomas Preud'homme) -- improve float to integer tests (Thomas Preud'homme) -- fix relocation of Thumb branch to ARM function (Thomas Preud'homme) -- fix char wrong compatibility with [un]signed char (Thomas Preud'homme) -- choose the code to compile based on target in libtcc1 (Thomas Preud'homme) -- fix various clang warnings (Thomas Preud'homme) -- don't hardcode tcc in Makefile for tests (Thomas Preud'homme) -- fix relocation of __bound_init bound checking code (Thomas Preud'homme) -- accept only one basic type for a given variable (Thomas Preud'homme) -- fix error when using va_* with tcc using libgcc (Thomas Preud'homme) -- support GOT32 and PLT32 reloc on the same symbol (Thomas Preud'homme) -- fix memory leak due to symbol attributes (mingodad) -- partially fix bound checking of argv and arge (Thomas Preud'homme) -- fix possible dereference when getting name of symbol (grischka) -- fix va_list type definition on x86-64 (Daniel Glöckner) -- reduce number of scan-build false positive (mingodad) +Features: +- VLA (variable length array) improved (James Lyon, Pip Cet) +- import functions by ordinal in .def files on windows (YX Hao) +- x86/x86-64 assembler much improved (Michael Matz) +- simple dead code suppression (Edmund Grimley Evans, Michael Matz, grischka) +- implement round/fmin/fmax etc. math on windows (Avi Halachmi) +- #pragma once support (Sergey Korshunoff, Vlad Vissoultchev, ...) +- switch/case code improved (Zdenek Pavlas) +- ~15% faster by TinyAlloc fast memory allocator (Vlad Vissoultchev) + +Licensing: +- TinyCC partly relicensed to MIT license (See RELICENSING file). version 0.9.26: diff --git a/Makefile b/Makefile index 9527d12..c13ce37 100644 --- a/Makefile +++ b/Makefile @@ -26,14 +26,16 @@ LINK_LIBTCC = LIBS = ifdef CONFIG_WIN32 - LIBTCC = libtcc.dll + ifneq ($(DISABLE_STATIC),no) + LIBTCC = libtcc.dll + endif else LIBS=-lm ifndef CONFIG_NOLDL LIBS+=-ldl endif # make libtcc as static or dynamic library? - ifdef DISABLE_STATIC + ifeq ($(DISABLE_STATIC),yes) LIBTCC=libtcc.so ifndef DISABLE_RPATH LINK_LIBTCC += -Wl,-rpath,"$(libdir)" @@ -92,7 +94,7 @@ ARM64_FILES = $(CORE_FILES) arm64-gen.c arm64-link.c C67_FILES = $(CORE_FILES) c67-gen.c c67-link.c tcccoff.c ifdef CONFIG_WIN32 - PROGS+=tiny_impdef$(EXESUF) tiny_libmaker$(EXESUF) $(LIBTCC) + PROGS+=tiny_impdef$(EXESUF) tiny_libmaker$(EXESUF) ifeq ($(ARCH),x86-64) NATIVE_FILES=$(WIN64_FILES) PROGS_CROSS=$(WIN32_CROSS) $(X64_CROSS) $(ARM_CROSS) $(ARM64_CROSS) $(C67_CROSS) $(WINCE_CROSS) @@ -272,14 +274,14 @@ install: mkdir -p "$(tccdir)/examples" mkdir -p "$(tccdir)/doc" mkdir -p "$(tccdir)/libtcc" - $(INSTALLBIN) -m755 $(PROGS) "$(tccdir)" + $(INSTALLBIN) -m755 $(PROGS) $(subst libtcc.a,,$(LIBTCC)) "$(tccdir)" $(INSTALL) -m644 libtcc1.a $(TOPSRC)/win32/lib/*.def "$(tccdir)/lib" cp -r $(TOPSRC)/win32/include/. "$(tccdir)/include" cp -r $(TOPSRC)/win32/examples/. "$(tccdir)/examples" cp $(TOPSRC)/tests/libtcc_test.c "$(tccdir)/examples" $(INSTALL) -m644 $(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h "$(tccdir)/include" - $(INSTALL) -m644 tcc-doc.html $(TOPSRC)/win32/tcc-win32.txt "$(tccdir)/doc" - $(INSTALL) -m644 $(TOPSRC)/libtcc.h libtcc.def "$(tccdir)/libtcc" + $(INSTALL) -m644 $(TOPSRC)/libtcc.h $(subst .dll,.def,$(LIBTCC)) "$(tccdir)/libtcc" + -$(INSTALL) -m644 $(TOPSRC)/win32/tcc-win32.txt tcc-doc.html "$(tccdir)/doc" ifdef CONFIG_CROSS mkdir -p "$(tccdir)/lib/32" mkdir -p "$(tccdir)/lib/64" diff --git a/TODO b/TODO index e6e5b07..5e6f7bf 100644 --- a/TODO +++ b/TODO @@ -2,16 +2,8 @@ TODO list: Bugs: -- fix macro substitution with nested definitions (ShangHongzhang) - FPU st(0) is left unclean (kwisatz haderach). Incompatible with optimized gcc/msc code - -- constructors -- cast bug (Peter Wang) -- define incomplete type if defined several times (Peter Wang). -- test binutils/gcc compile -- tci patch + argument. -- see -lxxx bug (Michael Charity). - see transparent union pb in /urs/include/sys/socket.h - precise behaviour of typeof with arrays ? (__put_user macro) but should suffice for most cases) @@ -26,11 +18,10 @@ Bugs: - finish varargs.h support (gcc 3.2 testsuite issue) - fix static functions declared inside block - fix multiple unions init -- sizeof, alignof, typeof can still generate code in some cases. -- Fix the remaining libtcc memory leaks. - make libtcc fully reentrant (except for the compilation stage itself). - struct/union/enum definitions in nested scopes (see also Debian bug #770657) - __STDC_IEC_559__: float f(void) { static float x = 0.0 / 0.0; return x; } +- memory may be leaked after errors (longjmp). Portability: @@ -42,14 +33,10 @@ Portability: Linking: -- static linking does not work -- with "-run" and libtcc, no PLT is used, so branches may be out of - range and relocations may fail; as a result libtest fails on arm64; see: - https://lists.gnu.org/archive/html/tinycc-devel/2015-03/msg00111.html +- static linking (-static) does not work Bound checking: -- '-b' bug. - fix bound exit on RedHat 7.3 - setjmp is not supported properly in bound checking. - fix bound check code with '&' on local variables (currently done @@ -61,11 +48,10 @@ Missing features: - disable-asm and disable-bcheck options - __builtin_expect() -- improve '-E' option. - atexit (Nigel Horne) -- packed attribute - C99: add complex types (gcc 3.2 testsuite issue) - postfix compound literals (see 20010124-1.c) +- interactive mode / integrated debugger Optimizations: @@ -81,9 +67,8 @@ Not critical: normative example - only relevant when using gotos! -> must add boolean variable to tell if compound literal was already initialized). -- add PowerPC or ARM code generator and improve codegen for RISC (need +- add PowerPC generator and improve codegen for RISC (need to suppress VT_LOCAL and use a base register instead). -- interactive mode / integrated debugger - fix preprocessor symbol redefinition - add portable byte code generator and interpreter for other unsupported architectures. @@ -108,3 +93,8 @@ Fixed (probably): - #include_next support for /usr/include/limits ? - function pointers/lvalues in ? : (linux kernel net/core/dev.c) - win32: add __stdcall, check GetModuleHandle for dlls. +- macro substitution with nested definitions (ShangHongzhang) +- with "-run" and libtcc, a PLT is now built. +- '-E' option was improved +- packed attribute is now supported +- ARM and ARM64 code generators have been added. diff --git a/configure b/configure index 42821ce..3799805 100755 --- a/configure +++ b/configure @@ -19,6 +19,7 @@ TMPH=$TMPN.h # default parameters build_cross="no" use_libgcc="no" +disable_static="" prefix="" execprefix="" bindir="" @@ -53,6 +54,7 @@ targetos=`uname` case $targetos in MINGW*) mingw32=yes;; MSYS*) mingw32=yes;; + CYGWIN*) mingw32=yes; cygwin=yes; cross_prefix="mingw32-";; DragonFly) noldl=yes;; OpenBSD) noldl=yes;; FreeBSD) noldl=yes;; @@ -69,6 +71,8 @@ source_path_used="yes" if test -z "$source_path" -o "$source_path" = "." ; then source_path=`pwd` source_path_used="no" + # mingw compilers might not understand cygwin paths + if test $cygwin = "yes"; then source_path="."; fi fi for opt do @@ -126,12 +130,12 @@ for opt do ;; --enable-mingw32) mingw32="yes" ; cross_prefix="i686-pc-mingw32-" ; cpu=x86 ;; - --enable-cygwin) mingw32="yes" ; cygwin="yes" ; cross_prefix="mingw32-" ; cpu=x86 - ;; --enable-cross) build_cross="yes" ;; --disable-static) disable_static="yes" ;; + --enable-static) disable_static="no" + ;; --disable-rpath) disable_rpath="yes" ;; --strip-binaries) strip_binaries="yes" @@ -288,12 +292,12 @@ Advanced options (experts only): --cpu=CPU CPU [$cpu] --strip-binaries strip symbol tables from resulting binaries --disable-static make libtcc.so instead of libtcc.a + --enable-static make libtcc.a instead of libtcc.dll (win32) --disable-rpath disable use of -rpath with the above --with-libgcc use libgcc_s.so.1 instead of libtcc1.a in dynamic link --enable-mingw32 build windows version on linux with mingw32 - --enable-cygwin build windows version on windows with cygwin --enable-cross build cross compilers - --with-selinux use mmap for exec mem [needs writable /tmp] + --with-selinux use mmap for executable memory (with tcc -run) --sysincludepaths=... specify system include paths, colon separated --libpaths=... specify system library paths, colon separated --crtprefix=... specify locations of crt?.o, colon separated @@ -309,15 +313,16 @@ ar="${cross_prefix}${ar}" strip="${cross_prefix}${strip}" CONFTEST=./conftest$EXESUF +if ! $cc -o $CONFTEST $source_path/conftest.c 2>/dev/null ; then + echo "configure: error: '$cc' failed to compile conftest.c." +else + gcc_major="$($CONFTEST version)" + gcc_minor="$($CONFTEST minor)" +fi if test -z "$cross_prefix" ; then - if ! $cc -o $CONFTEST $source_path/conftest.c 2>/dev/null ; then - echo "configure: error: '$cc' failed to compile conftest.c." - else - bigendian="$($CONFTEST bigendian)" - gcc_major="$($CONFTEST version)" - gcc_minor="$($CONFTEST minor)" - if test "$mingw32" = "no" ; then + bigendian="$($CONFTEST bigendian)" + if test "$mingw32" = "no" ; then if test -z "$triplet"; then tt="$($CONFTEST triplet)" @@ -348,8 +353,6 @@ if test -z "$cross_prefix" ; then if test -f "/lib/ld-uClibc.so.0" ; then confvars="$confvars uClibc" fi - - fi fi else # if cross compiling, cannot launch a program, so make a static guess @@ -365,7 +368,7 @@ for i in $W_OPTIONS; do O_PRESENT="$(grep -- -W$i cc_help.txt)" if test -n "$O_PRESENT"; then CFLAGS="$CFLAGS -W$i"; fi done -W_OPTIONS="deprecated-declarations strict-aliasing pointer-sign sign-compare unused-result uninitialized" +W_OPTIONS="pointer-sign sign-compare unused-result" for i in $W_OPTIONS; do O_PRESENT="$(grep -- -W$i cc_help.txt)" if test -n "$O_PRESENT"; then CFLAGS="$CFLAGS -Wno-$i"; fi @@ -481,12 +484,6 @@ fi if test "$mingw32" = "yes" ; then echo "CONFIG_WIN32=yes" >> config.mak fi -if test "$cygwin" = "yes" ; then - echo "#ifndef _WIN32" >> $TMPH - echo "# define _WIN32" >> $TMPH - echo "#endif" >> $TMPH - echo "AR=ar" >> config.mak -fi if test "$bigendian" = "yes" ; then echo "WORDS_BIGENDIAN=yes" >> config.mak echo "#define WORDS_BIGENDIAN 1" >> $TMPH @@ -498,8 +495,8 @@ fi if test "$build_cross" = "yes" ; then echo "CONFIG_CROSS=yes" >> config.mak fi -if test "$disable_static" = "yes" ; then - echo "DISABLE_STATIC=yes" >> config.mak +if test -n "$disable_static" ; then + echo "DISABLE_STATIC=$disable_static" >> config.mak fi if test "$disable_rpath" = "yes" ; then echo "DISABLE_RPATH=yes" >> config.mak diff --git a/tcc-doc.texi b/tcc-doc.texi index 9f136ed..db1d28f 100644 --- a/tcc-doc.texi +++ b/tcc-doc.texi @@ -176,29 +176,15 @@ In a script, it gives the following header: #!/usr/local/bin/tcc -run -L/usr/X11R6/lib -lX11 @end example -@item -mms-bitfields -Use an algorithm for bitfield alignment consistent with MSVC. Default is -gcc's algorithm. - -@item -mfloat-abi (ARM only) -Select the float ABI. Possible values: @code{softfp} and @code{hard} - -@item -dumpversion -Print only the compiler version and nothing else. - @item -v Display TCC version. @item -vv -Show included files. As sole argument, print search dirs (as below). +Show included files. As sole argument, print search dirs. -vvv shows tries too. @item -bench Display compilation statistics. -@item -print-search-dirs -Print the configured installation directory and a list of library -and include directories tcc will search. - @end table Preprocessor options: @@ -220,6 +206,10 @@ also be defined: @option{-DF(a)=a+1} @item -Usym Undefine preprocessor symbol @samp{sym}. + +@item -E +Preprocess only, to stdout or file (with -o). + @end table Compilation flags: @@ -337,6 +327,9 @@ Modify executable layout. @item -Wl,-Bsymbolic Set DT_SYMBOLIC tag. +@item -Wl,-(no-)whole-archive +Turn on/off linking of all objects in archives. + @end table Debugger options: @@ -370,6 +363,31 @@ Generate makefile fragment with dependencies. @item -MF depfile Use @file{depfile} as output for -MD. +@item -print-search-dirs +Print the configured installation directory and a list of library +and include directories tcc will search. + +@item -dumpversion +Print version. + +@end table + +Target specific options: + +@table @option +@item -mms-bitfields +Use an algorithm for bitfield alignment consistent with MSVC. Default is +gcc's algorithm. + +@item -mfloat-abi (ARM only) +Select the float ABI. Possible values: @code{softfp} and @code{hard} + +@item -mno-sse +Do not use sse registers on x86-64 + +@item -m32, -m64 +Pass command line to the i386/x86-64 cross compiler. + @end table Note: GCC options @option{-Ox}, @option{-fx} and @option{-mx} are diff --git a/tcc.c b/tcc.c index 0c60d64..c5a1f0e 100644 --- a/tcc.c +++ b/tcc.c @@ -109,6 +109,7 @@ static void help(void) " -E preprocess only\n" " -P[1] no / alternative #line output with -E\n" " -dD -dM output #define directives with -E\n" + " -include file include file above each input file\n" "Linker options:\n" " -Ldir add library path 'dir'\n" " -llib link with dynamic or static library 'lib'\n" diff --git a/tests/Makefile b/tests/Makefile index 39c4830..dbd035f 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -187,7 +187,7 @@ speedtest: ex2 ex3 weaktest: tcctest.c test.ref $(TCC) -c $< -o weaktest.tcc.o - $(CC) -c $< -o weaktest.gcc.o -I. $(CFLAGS) + $(CC) -c $< -o weaktest.gcc.o $(NATIVE_DEFINES) $(CFLAGS) -w -O0 -std=gnu99 -fno-omit-frame-pointer objdump -t weaktest.tcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.tcc.o.txt objdump -t weaktest.gcc.o | grep ' w ' | sed -e 's/.* \([a-zA-Z0-9_]*\)$$/\1/' | LC_ALL=C sort > weaktest.gcc.o.txt diff weaktest.gcc.o.txt weaktest.tcc.o.txt && echo "Weak Auto Test OK" @@ -254,7 +254,8 @@ cache: tcc_g # clean clean: rm -f *~ *.o *.a *.bin *.i *.ref *.out *.out? *.out?b *.cc *.gcc \ -*-cc *-gcc *-tcc *.exe hello libtcc_test vla_test tcctest[1234] ex? tcc_g + *-cc *-gcc *-tcc *.exe hello libtcc_test vla_test tcctest[1234] \ + ex? tcc_g *.def weaktest.*.txt $(MAKE) -C tests2 $@ $(MAKE) -C pp $@ diff --git a/tests/tcctest.py b/tests/tcctest.py deleted file mode 100644 index 817250f..0000000 --- a/tests/tcctest.py +++ /dev/null @@ -1,15 +0,0 @@ -import subprocess -import sys -import difflib - -def main(): - reference = subprocess.check_output([sys.argv[1]]) - compare = subprocess.check_output(sys.argv[2:]) - failed = False - for line in difflib.unified_diff(reference.split('\n'), compare.split('\n'), fromfile='cc', tofile='tcc', lineterm=''): - failed = True - print line - sys.exit(1 if failed else 0) - -if __name__ == '__main__': - main() diff --git a/tests/tests2/84-hex-float.c b/tests/tests2/84_hex-float.c similarity index 100% rename from tests/tests2/84-hex-float.c rename to tests/tests2/84_hex-float.c diff --git a/tests/tests2/84-hex-float.expect b/tests/tests2/84_hex-float.expect similarity index 100% rename from tests/tests2/84-hex-float.expect rename to tests/tests2/84_hex-float.expect diff --git a/tests/tests2/85-asm-outside-function.c b/tests/tests2/85_asm-outside-function.c similarity index 100% rename from tests/tests2/85-asm-outside-function.c rename to tests/tests2/85_asm-outside-function.c diff --git a/tests/tests2/85-asm-outside-function.expect b/tests/tests2/85_asm-outside-function.expect similarity index 100% rename from tests/tests2/85-asm-outside-function.expect rename to tests/tests2/85_asm-outside-function.expect diff --git a/tests/tests2/86-memory-model.c b/tests/tests2/86_memory-model.c old mode 100755 new mode 100644 similarity index 95% rename from tests/tests2/86-memory-model.c rename to tests/tests2/86_memory-model.c index ca30737..744c3e2 --- a/tests/tests2/86-memory-model.c +++ b/tests/tests2/86_memory-model.c @@ -1,38 +1,38 @@ -#include - -int -main() -{ -#if defined(__LLP64__) - if (sizeof(short) == 2 - && sizeof(int) == 4 - && sizeof(long int) == 4 - && sizeof(long long int) == 8 - && sizeof(void*) == 8) { - (void)printf("Ok\n"); - } else { - (void)printf("KO __LLP64__\n"); - } -#elif defined(__LP64__) - if (sizeof(short) == 2 - && sizeof(int) == 4 - && sizeof(long int) == 8 - && sizeof(long long int) == 8 - && sizeof(void*) == 8) { - (void)printf("Ok\n"); - } else { - (void)printf("KO __LP64__\n"); - } -#elif defined(__ILP32__) - if (sizeof(short) == 2 - && sizeof(int) == 4 - && sizeof(long int) == 4 - && sizeof(void*) == 4) { - (void)printf("Ok\n"); - } else { - (void)printf("KO __ILP32__\n"); - } -#else - (void)printf("KO no __*LP*__ defined.\n"); -#endif -} +#include + +int +main() +{ +#if defined(__LLP64__) + if (sizeof(short) == 2 + && sizeof(int) == 4 + && sizeof(long int) == 4 + && sizeof(long long int) == 8 + && sizeof(void*) == 8) { + (void)printf("Ok\n"); + } else { + (void)printf("KO __LLP64__\n"); + } +#elif defined(__LP64__) + if (sizeof(short) == 2 + && sizeof(int) == 4 + && sizeof(long int) == 8 + && sizeof(long long int) == 8 + && sizeof(void*) == 8) { + (void)printf("Ok\n"); + } else { + (void)printf("KO __LP64__\n"); + } +#elif defined(__ILP32__) + if (sizeof(short) == 2 + && sizeof(int) == 4 + && sizeof(long int) == 4 + && sizeof(void*) == 4) { + (void)printf("Ok\n"); + } else { + (void)printf("KO __ILP32__\n"); + } +#else + (void)printf("KO no __*LP*__ defined.\n"); +#endif +} diff --git a/tests/tests2/86-memory-model.expect b/tests/tests2/86_memory-model.expect old mode 100755 new mode 100644 similarity index 75% rename from tests/tests2/86-memory-model.expect rename to tests/tests2/86_memory-model.expect index a28de60..7326d96 --- a/tests/tests2/86-memory-model.expect +++ b/tests/tests2/86_memory-model.expect @@ -1 +1 @@ -Ok +Ok diff --git a/tests/tests2/82_nocode_wanted.c b/tests/tests2/89_nocode_wanted.c similarity index 96% rename from tests/tests2/82_nocode_wanted.c rename to tests/tests2/89_nocode_wanted.c index a0ec890..73e0a4b 100644 --- a/tests/tests2/82_nocode_wanted.c +++ b/tests/tests2/89_nocode_wanted.c @@ -3,7 +3,7 @@ static void kb_wait_1(void) { unsigned long timeout = 2; do { - (1 ? + (1 ? printf("timeout=%ld\n", timeout) : ({ while (1) @@ -17,7 +17,7 @@ static void kb_wait_2(void) { unsigned long timeout = 2; do { - (1 ? + (1 ? printf("timeout=%ld\n", timeout) : ({ for (;;) @@ -31,7 +31,7 @@ static void kb_wait_2_1(void) { unsigned long timeout = 2; do { - (1 ? + (1 ? printf("timeout=%ld\n", timeout) : ({ do { @@ -46,7 +46,7 @@ static void kb_wait_2_2(void) { unsigned long timeout = 2; do { - (1 ? + (1 ? printf("timeout=%ld\n", timeout) : ({ label: @@ -61,7 +61,7 @@ static void kb_wait_3(void) { unsigned long timeout = 2; do { - (1 ? + (1 ? printf("timeout=%ld\n", timeout) : ({ int i = 1; @@ -78,7 +78,7 @@ static void kb_wait_4(void) { unsigned long timeout = 2; do { - (1 ? + (1 ? printf("timeout=%ld\n", timeout) : ({ switch(timeout) { diff --git a/tests/tests2/82_nocode_wanted.expect b/tests/tests2/89_nocode_wanted.expect similarity index 100% rename from tests/tests2/82_nocode_wanted.expect rename to tests/tests2/89_nocode_wanted.expect diff --git a/tests/tests2/86-struct-init.c b/tests/tests2/90_struct-init.c similarity index 100% rename from tests/tests2/86-struct-init.c rename to tests/tests2/90_struct-init.c diff --git a/tests/tests2/86-struct-init.expect b/tests/tests2/90_struct-init.expect similarity index 100% rename from tests/tests2/86-struct-init.expect rename to tests/tests2/90_struct-init.expect diff --git a/tests/tests2/87_ptr_longlong_arith32.c b/tests/tests2/91_ptr_longlong_arith32.c similarity index 100% rename from tests/tests2/87_ptr_longlong_arith32.c rename to tests/tests2/91_ptr_longlong_arith32.c diff --git a/tests/tests2/87_ptr_longlong_arith32.expect b/tests/tests2/91_ptr_longlong_arith32.expect similarity index 100% rename from tests/tests2/87_ptr_longlong_arith32.expect rename to tests/tests2/91_ptr_longlong_arith32.expect diff --git a/win32/Makefile b/win32/Makefile index 0b0c5b5..f52da4b 100644 --- a/win32/Makefile +++ b/win32/Makefile @@ -110,7 +110,7 @@ tarball: @cp -r lib $(TARNAME) @cp -r libtcc $(TARNAME) @cp -r tools $(TARNAME) - @cp -r vs2015 $(TARNAME) +# @cp -r vs2015 $(TARNAME) @cp -r build-tcc.bat $(TARNAME) @cp -r i386-win32-tcc.exe $(TARNAME) @cp -r libtcc.def $(TARNAME) diff --git a/win32/build-tcc.bat b/win32/build-tcc.bat index 0598119..77c0067 100644 --- a/win32/build-tcc.bat +++ b/win32/build-tcc.bat @@ -1,10 +1,11 @@ @rem ------------------------------------------------------ -@rem batch file to build tcc using mingw gcc or tcc itself +@rem batch file to build tcc using mingw, msvc or tcc itself @rem ------------------------------------------------------ @echo off -set CC=gcc -Os -s -fno-strict-aliasing +set CC=gcc -Os -s + set T=32 if %PROCESSOR_ARCHITECTURE%_==AMD64_ set T=64 if %PROCESSOR_ARCHITEW6432%_==AMD64_ set T=64 @@ -16,7 +17,7 @@ goto :a0 :usage echo usage: build-tcc.bat [ options ... ] echo options: -echo -c prog use prog (gcc or tcc) to compile tcc +echo -c prog use prog (gcc/tcc/cl) to compile tcc echo -c "prog options" use prog with options to compile tcc echo -t 32/64 force 32/64 bit default target echo -v "version" set tcc version @@ -24,6 +25,21 @@ echo -i dir install tcc into dir echo -d create tcc-doc.html too (needs makeinfo) exit /B 1 +:cl +@echo off +set CMD=cl +:c0 +set ARG=%1 +set ARG=%ARG:.dll=.lib% +if (%1)==(-shared) set ARG=-LD +if (%1)==(-o) shift && set ARG=-Fe%2 +set CMD=%CMD% %ARG% +shift +if not (%1)==() goto :c0 +echo on +%CMD% -O1 -W2 -Zi -MT -GS- -nologo -link -opt:ref,icf +@exit /B %ERRORLEVEL% + :a2 shift :a1 @@ -31,6 +47,7 @@ shift :a0 if not (%1)==(-c) goto :a3 set CC=%~2 +if (%2)==(cl) set CC=@call :cl goto :a2 :a3 if not (%1)==(-t) goto :a4 diff --git a/win32/include/tcc/tcc_libm.h b/win32/include/tcc/tcc_libm.h index c9a6ad1..44b96e2 100644 --- a/win32/include/tcc/tcc_libm.h +++ b/win32/include/tcc/tcc_libm.h @@ -1,7 +1,7 @@ #ifndef _TCC_LIBM_H_ #define _TCC_LIBM_H_ -#include "../include/math.h" +#include "../math.h" /* TCC uses 8 bytes for double and long double, so effectively the l variants * are never used. For now, they just run the normal (double) variant. diff --git a/win32/tcc-win32.txt b/win32/tcc-win32.txt index da07e44..9299e68 100644 --- a/win32/tcc-win32.txt +++ b/win32/tcc-win32.txt @@ -107,23 +107,26 @@ Compilation from source: ------------------------ * You can use the MinGW and MSYS tools available at - http://www.mingw.org Untar the TCC archive and type in the MSYS shell: - ./configure [--prefix installpath] make make install - The default install location is c:\Program Files\tcc + The default install location is c:\Program Files\tcc * Alternatively you can compile TCC with just GCC from MinGW using + > build-tcc.bat (from the win32 directory) - build-tcc.bat (from the win32 directory) + Also MSVC can be used with the "VSTools Developer Command Prompt": + > build-tcc.bat -c cl - To install, copy the entire contents of the win32 directory to - where you want. + or with a tcc (needs to be in a different directory) + > build-tcc.bat -c some-tcc-dir\tcc.exe + + Also you can copy/install everything into another directory: + > build-tcc.bat -i Limitations: diff --git a/win32/vs2015/PreBuild.bat b/win32/vs2015/PreBuild.bat deleted file mode 100644 index 9d2f8b1..0000000 --- a/win32/vs2015/PreBuild.bat +++ /dev/null @@ -1,9 +0,0 @@ -set /p VERSION= < %~dp0..\..\VERSION - -:config.h -echo> .\config.h #define TCC_VERSION "%VERSION%" -echo>> .\config.h #ifdef TCC_TARGET_X86_64 -echo>> .\config.h #define CONFIG_TCC_LIBPATHS "{B}/lib/64;{B}/lib" -echo>> .\config.h #else -echo>> .\config.h #define CONFIG_TCC_LIBPATHS "{B}/lib/32;{B}/lib" -echo>> .\config.h #endif diff --git a/win32/vs2015/libtcc.vcxproj b/win32/vs2015/libtcc.vcxproj deleted file mode 100644 index af179c3..0000000 --- a/win32/vs2015/libtcc.vcxproj +++ /dev/null @@ -1,220 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {41F2DA74-9707-49A3-A466-157C7028BD79} - Win32Proj - libtcc - 8.1 - - - - DynamicLibrary - true - v140 - MultiByte - - - DynamicLibrary - false - v140 - true - MultiByte - - - DynamicLibrary - true - v140 - MultiByte - - - DynamicLibrary - false - v140 - true - MultiByte - - - - - - - - - - - - - - - - - - - - - true - $(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath); - - - true - $(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath); - - - false - $(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath); - - - false - $(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath); - - - - - - Level3 - Disabled - ONE_SOURCE;LIBTCC_AS_DLL;TCC_TARGET_PE;TCC_TARGET_I386;WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBTCC_EXPORTS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - EditAndContinue - - - Windows - true - - - copy $(TargetPath) $(SolutionDir).. - - - $(ProjectDir)PreBuild.bat - - - Generate config.h - - - - - - - Level3 - Disabled - ONE_SOURCE;LIBTCC_AS_DLL;TCC_TARGET_PE;TCC_TARGET_X86_64;_DEBUG;_WINDOWS;_USRDLL;LIBTCC_EXPORTS;%(PreprocessorDefinitions) - EditAndContinue - - - Windows - true - - - copy $(TargetPath) $(SolutionDir).. - - - $(ProjectDir)PreBuild.bat - - - Generate config.h - - - - - Level3 - - - MaxSpeed - true - true - ONE_SOURCE;LIBTCC_AS_DLL;TCC_TARGET_PE;TCC_TARGET_I386;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBTCC_EXPORTS;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - copy $(TargetPath) $(SolutionDir).. - - - $(ProjectDir)PreBuild.bat - - - Generate config.h - - - - - Level3 - - - MaxSpeed - true - true - ONE_SOURCE;LIBTCC_AS_DLL;TCC_TARGET_PE;TCC_TARGET_X86_64;NDEBUG;_WINDOWS;_USRDLL;LIBTCC_EXPORTS;%(PreprocessorDefinitions) - - - Windows - true - true - true - - - copy $(TargetPath) $(SolutionDir).. - - - $(ProjectDir)PreBuild.bat - - - Generate config.h - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/win32/vs2015/tcc.sln b/win32/vs2015/tcc.sln deleted file mode 100644 index 9015cd0..0000000 --- a/win32/vs2015/tcc.sln +++ /dev/null @@ -1,41 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.25123.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "tcc", "tcc.vcxproj", "{6E7932A7-B123-48EB-AB39-40867AF28105}" - ProjectSection(ProjectDependencies) = postProject - {41F2DA74-9707-49A3-A466-157C7028BD79} = {41F2DA74-9707-49A3-A466-157C7028BD79} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtcc", "libtcc.vcxproj", "{41F2DA74-9707-49A3-A466-157C7028BD79}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {6E7932A7-B123-48EB-AB39-40867AF28105}.Debug|x64.ActiveCfg = Debug|x64 - {6E7932A7-B123-48EB-AB39-40867AF28105}.Debug|x64.Build.0 = Debug|x64 - {6E7932A7-B123-48EB-AB39-40867AF28105}.Debug|x86.ActiveCfg = Debug|Win32 - {6E7932A7-B123-48EB-AB39-40867AF28105}.Debug|x86.Build.0 = Debug|Win32 - {6E7932A7-B123-48EB-AB39-40867AF28105}.Release|x64.ActiveCfg = Release|x64 - {6E7932A7-B123-48EB-AB39-40867AF28105}.Release|x64.Build.0 = Release|x64 - {6E7932A7-B123-48EB-AB39-40867AF28105}.Release|x86.ActiveCfg = Release|Win32 - {6E7932A7-B123-48EB-AB39-40867AF28105}.Release|x86.Build.0 = Release|Win32 - {41F2DA74-9707-49A3-A466-157C7028BD79}.Debug|x64.ActiveCfg = Debug|x64 - {41F2DA74-9707-49A3-A466-157C7028BD79}.Debug|x64.Build.0 = Debug|x64 - {41F2DA74-9707-49A3-A466-157C7028BD79}.Debug|x86.ActiveCfg = Debug|Win32 - {41F2DA74-9707-49A3-A466-157C7028BD79}.Debug|x86.Build.0 = Debug|Win32 - {41F2DA74-9707-49A3-A466-157C7028BD79}.Release|x64.ActiveCfg = Release|x64 - {41F2DA74-9707-49A3-A466-157C7028BD79}.Release|x64.Build.0 = Release|x64 - {41F2DA74-9707-49A3-A466-157C7028BD79}.Release|x86.ActiveCfg = Release|Win32 - {41F2DA74-9707-49A3-A466-157C7028BD79}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/win32/vs2015/tcc.vcxproj b/win32/vs2015/tcc.vcxproj deleted file mode 100644 index 29543d7..0000000 --- a/win32/vs2015/tcc.vcxproj +++ /dev/null @@ -1,195 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - Debug - x64 - - - Release - x64 - - - - {6E7932A7-B123-48EB-AB39-40867AF28105} - Win32Proj - tcc - 8.1 - - - - Application - true - v140 - Unicode - - - Application - false - v140 - true - Unicode - - - Application - true - v140 - Unicode - - - Application - false - v140 - true - Unicode - - - - - - - - - - - - - - - - - - - - - true - $(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath); - - - true - $(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath); - - - false - $(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath); - - - false - $(ProjectDir);$(VC_IncludePath);$(WindowsSDK_IncludePath); - - - - - - Level3 - Disabled - TCC_TARGET_PE;TCC_TARGET_I386;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - EditAndContinue - - - Console - true - Debug - libtcc.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - copy $(TargetPath) $(SolutionDir).. - - - $(ProjectDir)PreBuild.bat - Generate config.h - - - - - - - Level3 - Disabled - TCC_TARGET_PE;TCC_TARGET_X86_64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - EditAndContinue - - - Console - true - libtcc.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - x64\Debug - - - copy $(TargetPath) $(SolutionDir).. - - - $(ProjectDir)PreBuild.bat - Generate config.h - - - - - Level3 - - - MaxSpeed - true - true - TCC_TARGET_PE;TCC_TARGET_I386;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - - - Console - true - true - true - Release - libtcc.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - - - copy $(TargetPath) $(SolutionDir).. - - - $(ProjectDir)PreBuild.bat - Generate config.h - - - - - Level3 - - - MaxSpeed - true - true - TCC_TARGET_PE;TCC_TARGET_X86_64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - - - Console - true - true - true - libtcc.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies) - x64\Release - - - copy $(TargetPath) $(SolutionDir).. - - - $(ProjectDir)PreBuild.bat - Generate config.h - - - - - - - - - - - - \ No newline at end of file