Commit Graph

50 Commits (4b3c6e74aba07d61e91b2e0ba7190483a0f9f000)

Author SHA1 Message Date
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 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
grischka 44abffe33a more minor fixes
* tccgen: re-allow long double constants for x87 cross
  sizeof (long double) may be 12 or 16 depending on host platform
  (i386/x86_64 on unix/windows).
  Except that it's 8 if the host is on windows and not gcc
  was used to compile tcc.

* win64: fix builtin_va_start after VT_REF removal
  See also a8b83ce43a

* tcctest.c: remove outdated limitation for ll-bitfield test
  It always worked, there is no reason why it should not work
  in future.

* libtcc1.c: exclude long double conversion on ARM

* Makefile: remove CFLAGS from link recipes

* lib/Makefile: use target DEFINES as passed from main Makefile

* lib/armflush.c lib/va_list.c: factor out from libtcc1.c

* arm-gen.c: disable "depreciated" warnings for now
2017-05-07 12:41:29 +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 bb93064d78 makefile: unify cross with native builds
supports building cross compilers on the fly without need
for configure --enable-cross

   $ make cross          # all compilers
   $ make cross-TARGET   # only TARGET-compiler & its libtcc1.a

with TARGET one from
   i386 x86_64 i386-win32 x86_64-win32 arm arm64 arm-wince c67

Type 'make help' for more information
2017-02-25 12:51:04 +01:00
grischka 569255e6c4 cross-compilers: allow individual configuration
since configure supports only native configuration
a file 'cross-tcc.mak' needs to be created manually.
It is included in the Makefile if present.

# ----------------------------------------------------
# Example config-cross.mak:
#
# windows -> i386-linux cross-compiler
# (it expects the linux files in <prefix>/i386-linux)

ROOT-i386 = {B}/i386-linux
CRT-i386 = $(ROOT-i386)/usr/lib
LIB-i386 = $(ROOT-i386)/lib:$(ROOT-i386)/usr/lib
INC-i386 = {B}/lib/include:$(ROOT-i386)/usr/include
DEF-i386 += -D__linux__

# ----------------------------------------------------

Also:
- use libtcc1-<target>.a instead of directories
- add dummy arm assembler
- remove include dependencies from armeabi.c/lib-arm64.c
- tccelf/ld_add_file: add SYSROOT (when defined) to absolute
  filenames coming from ld-scripts
2017-02-23 08:41:57 +01:00
grischka 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 2d3b9559bf tcctools.c: integrate tiny_libmaker/_impdef
usage:
    tcc -ar [rcsv] lib files...
    tcc -impdef lib.dll [-v] [-o lib.def]

also:
- support more files with -c: tcc -c f1.c f2.c ...
- fix a bug which caused tcc f1.c f2.S to produce no asm
- allow tcc -ar @listfile too
- change prototype: _void_ tcc_set_options(...)
- apply -Wl,-whole-archive when a librariy is given
  as libxxx.a also (not just for -lxxx)
2017-02-18 09:55:34 +01:00
grischka 096125d963 win32: adjust new unicode support
- lib/Makefile: add (win)crt1_w.o

- crt1.c/_runtmain: return to tcc & only use for UNICODE
  (because it might be not 100% reliable with for example
  wildcards (tcc *.c -run ...)

- tccrun.c/tccpe.c: load -run startup_code only if called
  from tcc_run(). Otherwise main may not be defined.  See
  libtcc_test.c

- tests2/Makefile: pass extra options in FLAGS to allow
  overriding TCC

Also:
- tccpe.c: support weak attribute.  (I first tried to solve
  the problem above by using it but then didn't)
2017-02-18 09:51:23 +01:00
grischka 362cafb471 arm: libtcc1.a needs gcc with -fPIC 2017-02-11 09:30:20 +01:00
grischka 71c5ce5ced tests: OOT build fixes etc.
tests/Makefile: fix out-of-tree build issues

Also:

- win64: align(16) MEM_DEBUG user memory
  on win64 the struct jmp_buf in the TCCState structure which we
  allocate by tcc_malloc needs alignment 16 because the msvcrt
  setjmp uses MMX instructions.

- libtcc_test.c: win32/64 need __attribute__((dllimport)) for
  extern data objects

- tcctest.c: exclude stuff that gcc does not compile
  except for relocation_test() the other issues are mostly ASM
  related.  We should probably check GCC versions but I have
  no idea which mingw/gcc versions support what and which don't.

- lib/Makefile: use tcc to compile libtcc1.a (except on arm
  which needs arm-asm
2016-12-20 18:05:33 +01:00
grischka 02919cd275 configure: --triplet= option, Makefile: cleanup 2016-10-17 23:24:10 +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 d0e48c51c7 [avih] a custom build dir fix for lib/Makefile
mkdir build; cd build
    ../configure && make
    ../../lib/libtcc1.c:31: error: include file 'stddef.h' not found

    Author: Avi Halachmi
    Date:   Sat Nov 14 18:40:36 2015 +0200
    When building from the root tcc dir, $TOP and $top_srcdir
    are the same, but with a custom build dir, we need top_srcdir
2016-05-20 15:55:36 +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 37e815eee1 lib/Makefile: filter-out -b flag from XFLAGS
to build tcc with bound checking
    ./configure --cc=tcc --extra-cflags-b
2015-11-08 12:26:17 +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
seyko 559675b90a a bounds checking code for the ARCH=x86_64 2015-04-10 15:17:22 +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 cfaa165e62 libtcc1.a while "configure --enable-cross"
build and install libtcc1.a for i386, x86_64 and arm64
    (libtcc1.a for x86_64 was not installed on i386)
2015-03-20 08:52:01 +03:00
seyko 3dba9cc13d "configure --enable-cross" on x86: build a libtcc1.a for x86_64 2015-03-19 13:07:02 +03:00
Edmund Grimley Evans 68605ab4d4 lib/Makefile: Partial revert of 896a0c881a.
lib/lib-arm64.c must be compiled by tcc.
2015-03-10 14:08:42 +00:00
seyko 896a0c881a don't use a *-tcc to compile *.S files for ARM*
A tcc for ARM* don't have an assembler. This is partial reverse of the commit
  build-libtcc1-by-tcc: use a new tcc to compile a libtcc1.c and alloca.S
2015-03-10 13:54:12 +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 54fc439e9e an unification of the tcc cross names for a windows
produce a
      i386-win-mingw32-tcc
      i386-win-tcc
      x86_64-win-mingw32-tcc
      x86_64-win-tcc
      arm-win-mingw32ce-tcc
      arm-win-tcc

    instead of the
      i386-w64-mingw32-tcc
      i386-win32-tcc
      x86_64-w64-mingw32-tcc
      x86_64-win32-tcc
      arm-wince-mingw32ce-tcc
      arm-win32-tcc

    Replacing a *-win32 directory names with a *-win names
    because this names are based on the names of the tcc
    	x86_64-win32-tcc, i386-win32-tcc
2015-03-04 11:19:39 +03:00
seyko 1cbb4d322b build-libtcc1-by-tcc: use a new tcc to compile a libtcc1.c and alloca.S
This will allow to build a libtcc1.a even if a bootstrap compiler
don't support a target arch.

There was alrady this feature but only for OS Darwin.
2015-03-04 11:08:16 +03:00
Edmund Grimley Evans b14ef0e24b Add arm64 (AArch64) as a target architecture. 2015-02-23 22:51:03 +00:00
Matteo Cypriani 178275dc0c Don't build libtcc1 with -fstack-protector-strong
Prevent libtcc1.a to be compiled with -fstack-protector-strong, so that
linking with tcc doesn't fail because symbol '__stack_chk_fail_local' is
not present in libtcc1.a. This is useful only if the CFLAGS passed from
the main Makefile contain this flag.
2014-09-07 10:56:03 -04:00
grischka 76accfb8d5 win32: libtcc1.a needs to be built with tcc
gcc/mingw produces msvc compatible pecoff objects, tcc only
knows ELF.
2014-04-07 11:16:06 +02:00
Michael Matz c4427747e6 arm: Provide alloca()
This provides a simple implementation of alloca for ARM (and enables
the associated testcase).  As tcc for ARM doesn't contain an assembler,
we'll have to resort using gcc for compiling it.
2014-04-05 22:54:11 +02:00
Michael Matz ea2805f097 shared libs: Build libtcc1.a with -fPIC
TCCs runtime library must be compiled as position independend code,
so it can be linked into shared libraries.
2014-04-02 21:27:22 +02:00
grischka 2bd0daabbe misc. fixes
- tccgen: error out for cast to void, as in
      void foo(void) { return 1; }
  This avoids an assertion failure in x86_64-gen.c, also.
  also fix tests2/03_struct.c accordingly

- Error: "memory full" - be more specific

- Makefiles: remove circular dependencies, lookup tcctest.c from VPATH

- tcc.h: cleanup lib, include, crt and libgcc search paths"
  avoid duplication or trailing slashes with no CONFIG_MULTIARCHDIR
  (as from 9382d6f1a0)

- tcc.h: remove ";{B}" from PE search path
  in ce5e12c2f9 James Lyon wrote:
  "... I'm not sure this is the right way to fix this problem."
  And the answer is: No, please. (copying libtcc1.a for tests instead)

- win32/build_tcc.bat: do not move away a versioned file
2014-01-06 19:56:26 +01:00
Thomas Preud'homme f2dbcf7594 Add ARM aeabi functions needed to run tcctest
Add implementation for float / integer conversion functions:
  __aeabi_d2lz, __aeabi_d2ulz, __aeabi_f2lz, __aeabi_f2ulz, __aeabi_l2d,
  __aeabi_l2f, __aeabi_ul2d, __aeabi_ul2f

Add implementation for long long helper functions:
  __aeabi_ldivmod, __aeabi_uldivmod, __aeabi_llsl, __aeabi_llsr, __aeabi_lasr

Add implementation for integer division functions:
  __aeabi_uidiv, __aeabi_uidivmod, __aeabi_idiv, __aeabi_idivmod,
2013-12-11 10:15:30 +08:00
Thomas Preud'homme fbb4841606 Add __clear_cache implementation in libtcc1
Add __clear_cache function for flushing caches to libtcc1.
2013-11-05 19:29:43 +08:00
James Lyon e31579b076 Fixed tests on Windows (including out-of-tree problems)
Modified tcctest.c so that it uses 'double' in place of 'long double'
with MinGW since this is what TCC does, and what Visual C++ does. Added
an option -norunsrc to tcc to allow argv[0] to be set independently of
the compiled source when using tcc -run, which allows tests that rely on
the value of argv[0] to work in out-of-tree builds.

Also added Makefile rules to automatically update out-of-tree build
Makefiles when in-tree Makefiles have changed.
2013-04-17 20:32:07 +01:00
grischka 762a43877b configure: pass CONFIG_xxxDIR/PATH options via commandline
- except for CONFIG_SYSROOT and CONFIG_TCCDIR

Strictly neccessary it is only for CONFIG_MULTIARCHDIR
because otherwise if it's in config.h it is impossible to
leave it undefined.

But it is also nicer not to use these definitions for
cross-compilers.

- Also:
lib/Makefile : include ../Makefile for CFLAGS
lib/libtcc1.c : fix an issue compiling tcc with tcc on x64
2013-02-14 17:43:24 +01:00
grischka 8042121d74 tcc -vv/--print-search-dirs: print more info
tests/Makefile:
- print-search-dirs when 'hello' fails
- split off hello-run

win32/include/_mingw.h:
- fix for compatibility with mingw headers
  (While our headers in win32 are from mingw-64 and don't have
  the problem)

tiny_libmaker:
- don't use "dangerous" mktemp
2013-02-10 00:38:40 +01:00
grischka d6d7686b60 tcc.h: declare CValue.tab[LDOUBLE_SIZE/4]
Should fix some warnings wrt. access out of array bounds.

tccelf.c: fix "static function unused" warning
x86_64-gen.c: fix "ctype.ref uninitialzed" warning and cleanup
tcc-win32.txt: remove obsolete limitation notes.
2013-02-08 19:07:11 +01:00
grischka 7a477d70ca lib/Makefile: use CC, add bcheck to libtcc1.a
Also:
- fix "make tcc_p" (profiling version)
- remove old gcc flags:
  -mpreferred-stack-boundary=2 -march=i386 -falign-functions=0
- remove test "hello" for Darwin (cannot compile to file)
2013-02-06 19:01:07 +01:00
grischka 17cf0dcf70 configure: use relative paths for in-tree build
Also
- move CPPFLAGS to Makefile
- Use top_srcdir in lib/Makefile
2013-01-30 18:39:09 +01:00
Akim Demaille 3f09b90d21 build: fix VPATH builds
* configure (fn_dirname): New.
Use it to ensure the creation of proper symlinks to Makefiles.
(config.mak): Define top_builddir and top_srcdir.
(CPPFLAGS): Be sure to find the headers.
* Makefile, lib/Makefile, tests/Makefile, tests2/Makefile: Adjust
to set VPATH properly.
Fix confusion between top_builddir and top_srcdir.
2012-12-18 10:06:20 +01:00
Thomas Preud'homme a7f010ee8a Honour *FLAGS everywhere
Add CPPFLAGS, CFLAGS and LDFLAGS everywhere it's missing.
2012-11-06 15:20:53 +01:00
Milutin Jovanovic de54586d5b Further changes improving the OSX build. Everything builds. libtest passes.
Other tests still have issues, currently with weak linking.

One of the primary stumbling blocks on OSX is the lack of support for
mach-o binaries. Therefore all tcc usage on OSX has to be limited to elf
binaries, presumably produced by tcc itself.

Therefore I had to enable building of tiny_libmaker for OSX. Then changed
the make to use tcc and tiny_libmaker to compile the tcclib1.

In order to compile the tests, specifically the parts that use weak linking,
I have had to define MACOSX_DEPLOYMENT_TARGET to 10.2, which seems like a
hack, but extensive searching seems to indicate that this is the only way
to make apple gcc allow weak linking. Using any other value, bigger or smaller
breaks weak linking.

Also added _ANSI_SOURCE define required by some OSX headers, and some cosmetic
gitignore changes. I believe these changes should not impact other platforms.
2012-03-06 13:26:36 -05:00
Milutin Jovanovic 6e13c35334 Attempt to fix 32 bit OSX build. The fix consists of adding -m32 and -m64
to the appropriate CFLAGS. In addition, memory hooks are very different
on OSX, so build of bcheck.c had to be disabled for now.

Change of the CFLAGS does affect builds on other platforms, and this needs
to be tested.
2012-02-16 11:24:14 -05:00
grischka 86ffc48129 make: new lib/Makefile for libtcc1.a on more platforms
win32/64 cross-compilers now build libtcc1.a and install it
together with the windows headers in a 'win32' sub-directory
of TCCDIR.
2010-12-04 16:47:08 +01:00