Commit Graph

123 Commits (meesbs)

Author SHA1 Message Date
grischka da8c62f75d various stuff
win32/Makefile ("for cygwin") removed
- On cygwin, the normal ./configure && make can be used with either
  cygwin's "GCC for Win32 Toolchain"
      ./configure --cross-prefix=i686-w64-mingw32-
  or with an existing tcc:
      ./configure --cc=<old-tccdir>/tcc.exe

tcctest.c:
- exclude test_high_clobbers() on _WIN64 (does not work)

tests2/95_bitfield.c:
- use 'signed char' for ARM (where default 'char' is unsigned)

tests:
- remove -I "expr" diff option to allow tests with
  busybox-diff.

libtcc.c, tcc.c:
- removed -iwithprefix option.  It is supposed to be
  combined with -iprefix which we don't have either.

tccgen.c:
- fix assignments and return of 'void', as in
     void f() {
         void *p, *q;
         *p = *q:
         return *p;
     }
  This appears to be allowed but should do nothing.

tcc.h, libtcc.c, tccpp.c:
- Revert "Introduce VIP sysinclude paths which are always searched first"
  This reverts commit 1d5e386b0a.

  The patch was giving tcc's system includes priority over -I which
  is not how it should be.

tccelf.c:
- add DT_TEXTREL tag only if text relocations are actually
  used (which is likely not the case on x86_64)
- prepare_dynamic_rel(): avoid relocation of unresolved
  (weak) symbols

tccrun.c:
- for HAVE_SELINUX, use two mappings to the same (real) file.
  (it was so once except the RX mapping wasn't used at all).

tccpe.c:
- fix relocation constant used for x86_64 (by Andrei E. Warentin)
- #ifndef _WIN32 do "chmod 755 ..." to get runnable exes on cygwin.

tccasm.c:
- keep forward asm labels static, otherwise they will endup
  in dynsym eventually.

configure, Makefile:
- mingw32: respect ./configure options --bindir --docdir --libdir
- allow overriding tcc when building libtcc1.a and libtcc.def with
      make XTCC=<tcc program to use>
- use $(wildcard ...) for install to allow installing just
  a cross compiler for example
      make cross-arm
      make install
- use name <target>-libtcc1.a

build-tcc.bat:
- add  options: -clean, -b bindir
2017-10-11 18:13:43 +02:00
grischka 4b3c6e74ab tccgen: nodata_wanted fix, default ONE_SOURCE, etc...
tccgen.c:
  doubles need to be aligned, on ARM.  The section_reserve()
  in init_putv does not do that.
-D ONE_SOURCE: is now the default and not longer needed. Also,
  tcc.h now sets the default native target.  These both make
  compiling tcc simple as "gcc tcc.c -o tcc -ldl" again.
arm-asm.c:
  enable pseudo asm also for inline asm
tests/tests2/Makefile:
  disable bitfield tests except on windows and x86_64
  and don't generate-always
tcc.c:
  fix a loop with -dt on errors
configure:
  print compiler version (as recognized)
tccpp.c:
  actually define symbols for tcc -dt
  clear static variables (needed for -dt or libtcc usage)
96_nodata_wanted.c:
  use __label__ instead of asm
lib/files:
  use native symbols (__i386__ etc.) instead of TCC_TARGET_...
2017-07-23 21:24:11 +02:00
grischka 9f79b62ec4 unsorted adjustments
- configure
  * use aarch64 instead of arm64

- Makefile
  * rename the custom include file to "config-extra.mak"
  * Also avoid "rm -r /*" if $(tccdir) is empty

- pp/Makefile
  * fix .expect generation with gcc

- tcc.h
  * cleanup #defines for _MSC_VER

- tccgen.c:
  * fix const-propagation for &,|
  * fix anonymous named struct (ms-extension) and enable
    -fms-extension by default

- i386-gen.c
  * clear VT_DEFSIGN

- x86_64-gen.c/win64:
  * fix passing structs in registers
  * fix alloca (need to keep "func_scratch" below each alloca area on stack)
    (This allows to compile a working gnu-make on win64)

- tccpp.c
  * alternative approach to 37999a4fbf
    This is to avoid some slowdown with ## token pasting.
  * get_tok_str() : return <eof> for TOK_EOF
  * -funsigned-char: apply to "string" literals as well

- tccpe/tools.c: -impdef: support both 32 and 64 bit dlls anyway
2017-07-09 12:07:40 +02:00
grischka 28435ec58c configure: --config-musl/-uClibc switch & misc cleanups
- configure:
  - add --config-uClibc,-musl switch and suggest to use
    it if uClibc/musl is detected
  - make warning options magic clang compatible
  - simplify (use $confvars instead of individual options)
- Revert "Remove some unused-parameter lint"
  7443db0d5f
  rather use -Wno-unused-parameter (or just not -Wextra)
- #ifdef functions that are unused on some targets
- tccgen.c: use PTR_SIZE==8 instead of (X86_64 || ARM64)
- tccpe.c: fix some warnings
- integrate dummy arm-asm better
2017-05-13 08:59:06 +02:00
Marc Vertes 1094891e67 Improve musl and uclibc detection
Do not enable musl or uclibc native support if a GNU linker is
already present. This avoids interference for example on a
Debian platform with musl-dev installed. More work is required
to select musl libc in that case, with additional configure flags.
2017-05-08 16:14:35 +00:00
Larry Doolittle 1b9935cf36 Add missing const and add warning flags 2017-05-07 21:28:05 -07:00
grischka a35752d233 configure: fix permissions
There must be something with git on windows that it
messes up x permissions sometimes.
2017-04-26 00:01:23 +02: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
Andrei Warkentin 91cd148a05 tcc: early OSX native support
- build scripts
- working '-run' mode, e.g.:

./tcc -B. -I./include -I. -I.. -D_ANSI_SOURCE -run examples/ex1.c

Note: we don't bother parsing Mach-O/Fat images yet. We blindly
dlopen the image.

Signed-off-by: Andrei Warkentin <andrey.warkentin@gmail.com>
2017-04-25 13:55:18 +03:00
Marc Vertes 0ac29b53dc Add support of musl-libc
The port is functional. Bound checking is not supported yet.
2017-04-20 22:01:50 +02:00
grischka 5f33d313c8 tcc: re-enable correct option -r support
Forgot about it.  It allows to compile several
sources (and other .o's) to one single .o file;

    tcc -r -o all.o f1.c f2.c f3.S o4.o ...

Also:
- option -fold-struct-init-code removed, no effect anymore
- (tcc_)set_environment() moved to tcc.c
- win32/lib/(win)crt1 minor fix & add dependency
- debug line output for asm (tcc -c -g xxx.S) enabled
- configure/Makefiles: x86-64 -> x86_64 changes
- README: cleanup
2017-02-20 18:58:08 +01:00
grischka 43d9a7de9b updates & cleanups (tcc-doc/Changelog/TODO ...)
- tcc-doc.texi: commandline option info update
- Changelog/TODO: update
- tests/tcctest.py: removed
- tests/Makefile: weaktest fixed
- tests/tests2: some files renamed and/or converted to unix LF
- configure/Makefile: --enable-static option (no dll on win32)
- win32/build-tcc.bat: msvc support
- win32/tcc-win32.txt: build info update
- win32/vs2015/: VS solution removed
- win32/include/tcc/tcc_libm.h: #include statement fixed
- tcc.c: -include <file> option help info
- .gitignore: cleanup
2017-02-13 19:03:29 +01:00
grischka 2b7ee000cd tests: add .so/.dll creation test
Also remove bitfield test from tcctest.c because gcc
versions don't agree among each other.
2016-12-15 17:04:07 +01:00
grischka 0d14e7e698 configure: prefer lib64 on 64-bit platforms
use lib64 if
- "/usr/lib/multi-arch-triplet" does not work and
- we are on a 64-bit platform and
- lib64 exists and does contain crti.o
2016-11-28 14:48:54 +01:00
grischka 02919cd275 configure: --triplet= option, Makefile: cleanup 2016-10-17 23:24:10 +02:00
Avi Halachmi (:avih) 35b7bf9382 build: win: detect also mingw64 in msys2 setup
MSYS2 installs 3 environments, with uname (e.g. on win8.1 64) as follows:
- MINGW32_NT-6.3  gcc -> stand-alone native i686 binaries
- MINGW64_NT-6.3  gcc -> stand-alone native x86_64 binaries
- MSYS_NT-6.3     gcc -> posix-ish binaries which can only run in this env

Therefore 'MINGW' is more generic and detects both 32/64 native
environments, where previously 'MINGW32' detected only the 32 one.
2016-10-10 14:55:34 +03:00
Avi Halachmi (:avih) 61894e17cd build: win32: don't use mklink - use ln or fallback to cp
For the following reasons:
- Native windows links are rarely used in general.
- Require elevated privileges even if the current user has administrator
  privileges (needs further "run as administrator").
- Most/all windows shell environments capable of running configure already
  support ln (msys[1], msys2, most probably cygwin too).
- If cross building tcc on linux for windows then native mklink is not
  available, as well as 'cmd' (in this scenario the build later fails
  for other reasons, but at least configures succeeds now).
- cp is good enough as fallback since we only copy 5 makefiles anyway.
- The only environment I'm aware of which doesn't support ln -s is busybox
  for windows, and with this patch it falls back to cp and completes
  configure successfully (and the build later succeeds, assuming valid
  $CC and $AR).
2016-10-10 14:50:48 +03:00
grischka 78f1c10e0f configure: fix tcc_lddir, cpu
... and other minor cosmetic fixes
2016-10-03 12:33:40 +02:00
grischka f350487e1e win32/64: msys2 support
Support ./configure && make under msys2 (a new msys fork)
on win32 and win64.

Get rid of CONFIG_WIN64 make-var. (On windows, WIN32 in
general is used for both 32 and 64 bit platforms)

Also:
- cleanup win32/build-tcc.bat
- adjust win32/(doc/)tcc-win32.tx
2016-10-02 01:39:07 +02:00
grischka afdbc5b815 build: restore out-of-tree support 2016-10-01 21:06:53 +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
seyko bab4519617 Allow to perform tests from the custom build dir:
mkdir build; cd build
    ../configure --prefix=./package
    make
    make test
    make install
2016-05-20 16:02:42 +03:00
seyko 18cbe62e69 fix a mingw64 build on Linux with --enable-tcc64-mingw
* define CONFIG_WIN64=yes when ARCH=x86-64 (not CONFIG_WIN32=yes)
    * CONFIG_WIN64 now use a windows install part (not a Linux one)
2016-05-20 15:48:02 +03:00
seyko 778ec44adc [avih] configure: support custom ar with --ar=
Author: Avi Halachmi (:avih)
    Date:   Mon Nov 2 18:46:32 2015 +0200

    configure: support custom ar with --ar=
2016-05-20 15:27:22 +03:00
seyko 4e7a8906a1 configure: docdir fix
was /usr/local/share/doc/usr/local/lib/tcc
    now /usr/local/share/doc
2016-05-20 15:21:26 +03: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 41031221c8 Trim trailing spaces everywhere. 2015-07-27 12:43:40 -04:00
seyko 87a0109604 restore "./configure --enable-tcc32-mingw" on linux
commit "tccpp: fix issues, add tests" also include
        - configure/Makefile : build on windows (MSYS) was broken
    which breaks a cross compilation on linux
2015-05-10 09:57:11 +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
Philip 2e51f0ee63 warn about declarations after statements when compiling with gcc. 2015-04-27 13:28:03 +00: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
Raphael Cohn 2ba7542e4b Adjusted configure host_os to use uname for Darwin
Adjusted Makefile to make it Darwin (Mac OS X 10.10)-friendly for cross-compilers
by removing the creation of arm64 cross-compilers on this platform.
2015-04-07 15:44:54 +01:00
Raphael Cohn fa0eff949d Adjusted configure to be more BSD friendly 2015-04-07 15:18:34 +01:00
seyko b5d25654d8 configure: don't output CONFIG_LDDIR when build_cross = "yes"
This fixes i386-tcc on CentOS 7. After patch
    [root@centos7 tinycc]# ./i386-tcc -vv
    tcc version 0.9.26 (i386, Linux)
    install: /usr/local/lib/tcc
    crt:
      /usr/lib
    libraries:
      /usr/lib
      /lib
      /usr/local/lib

Before patch:
    [root@centos7 tinycc]# ./i386-tcc -vv
    tcc version 0.9.26 (i386, Linux)
    install: /usr/local/lib/tcc
    crt:
      /usr/lib64
    libraries:
      /usr/lib64
      /lib64
      /usr/local/lib64
2015-03-21 07:16:33 +03:00
seyko 87ec08ecc8 A native tcc for MSYS (Windows) must be i386-win-tcc.exe and not i386-tcc.exe
i386-tcc.exe is a compiler for i386 Linux. A HOST_OS variable in Makefile is
introduced and used to select a native compiler (which one to name as tcc.exe)
2015-03-10 13:39:26 +03:00
seyko bfb7b0d959 --enable-tcc32-mingw option: build windows version on linux with i386-win-tcc
--enable-tcc64-mingw option: build windows version on linux with x86_64-win-tcc
2015-03-04 12:02:13 +03:00
seyko 48d12e42ad gcc options and mingw: move a gcc options detection from a makefile to the configure
+ define XCC and XAR if mingw32 defined
    + use XCC and XAR in lib/Makefile if defined
    Try "./configure --enable-mingw32; make". This must work
2015-03-04 11:47:52 +03:00
seyko 7ed4341538 a libraries paths
* x86_64-tcc: use /usr/lib64,.. instead of /usr/lib,..
    * don't set tcc_lddir="lib64" if cpu="x86"
    * put a definition of the CONFIG_LDDIR into config.h instead
      of the config.mak  Otherwise a "lib" string may be used by default.
      This is a usual case when building a x86_64-tcc (there was
      no -DCONFIG_LDDIR building this binary).

    * suppress -Wdeprecated-declarations for gcc which complain on malloc hooks
      in bcheck.c if glibc is quite new.
2015-03-04 10:57:13 +03:00
seyko 149c2a9cc9 a cpu option of the configure script as a method to specify a target cpu
* don't setup a cpu before scanning for --cpu=
    * --cpu= option sets a 'cpu' variable, not a 'build_cpu', 'build_cpu' was not used anywhere.
    * if cpu="" and ARCH != "" then cpu=$ARCH else cpu=`uname -m`
    * replace "Build CPU" with "Target CPU" in the output of the configure script.
      output this value only when not builing a cross compilers.
    * remove a HOST_I386, ... defines from a config.h file.
      thise defines are not used anywhere and cpu is now used to define a target cpu
2015-03-04 10:03:40 +03:00
Edmund Grimley Evans b14ef0e24b Add arm64 (AArch64) as a target architecture. 2015-02-23 22:51:03 +00:00
Thomas Preud'homme 0e3d2e0bea Make build CPU detection a tad more flexible 2014-04-12 16:20:12 +08:00
minux 9714d2e75f build: add initial NetBSD support.
Not able to generate ELF files on NetBSD yet (lacks the note and crt1.o
is actually named crt0.o on NetBSD), but -run works with these extra
defines:
-D__lint__ -D"__symbolrename(x)=asm(#x)" -D__NetBSD__

The -D__lint__ is an ugly hack, TCC should be able to emulate GCC just
fine, but it seems TCC doesn't support __builtin_va_list yet?
	typedef __builtin_va_list __va_list;
/usr/include/sys/ansi.h:72: error: ';' expected (got "__va_list")
2014-04-12 01:42:46 -04:00
grischka 3fe2a95d7f be stricter with aliasing
Refactoring (no logical changes):
- use memcpy in tccgen.c:ieee_finite(double d)
- use union to store attribute flags in Sym
Makefile: "CFLAGS+=-fno-strict-aliasing" basically not necessary
anymore but I left it for now because gcc sometimes behaves
unexpectedly without.

Also:
- configure: back to mode 100755
- tcc.h: remove unused variables tdata/tbss_section
- x86_64-gen.c: adjust gfunc_sret for prototype
2014-01-07 14:57:07 +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
Thomas Preud'homme 9e79b18bca Use libtcc.a for static link even with USE_LIBGCC
When statically linking, runtime library should be static as well. tcc
could link with libgcc.a but it's in a gcc version specific directory.
Another solution, followed by this patch, is to use libtcc.a when
statically linking, even if USE_LIBGCC was configured.
2014-01-03 18:20:51 +08:00
Thomas Preud'homme 9382d6f1a0 Fix lib, include, crt and libgcc search paths 2013-09-07 19:28:06 +02:00
James Lyon 41b3c7a507 Improved variable length array support.
VLA storage is now freed when it goes out of scope. This makes it
possible to use a VLA inside a loop without consuming an unlimited
amount of memory.

Combining VLAs with alloca() should work as in GCC - when a VLA is
freed, memory allocated by alloca() after the VLA was created is also
freed. There are some exceptions to this rule when using goto: if a VLA
is in scope at the goto, jumping to a label will reset the stack pointer
to where it was immediately after the last VLA was created prior to the
label, or to what it was before the first VLA was created if the label
is outside the scope of any VLA. This means that in some cases combining
alloca() and VLAs will free alloca() memory where GCC would not.
2013-04-27 22:58:52 +01:00
Thomas Preud'homme d9dfd9cded Fix configure script on FreeBSD
* x86-64 architectures are reported as amd64 by uname -r
* FreeBSD platform don't need -ldl for linking
2013-03-14 18:15:32 +01:00
grischka c4397b2b02 configure: detect ARM variants
Using gnu make's variable variable-names.
2013-02-14 21:15:56 +01:00