Commit Graph

1575 Commits (aa812e87455271d2b73e7f41832aee496fe81ee0)
 

Author SHA1 Message Date
Edmund Grimley Evans aa812e8745 Convert some lines from ISO-8859-1 to UTF-8.
perl -i -pe 'use Text::Iconv;
$c1 = Text::Iconv->new("utf-8", "utf-8");
$c2 = Text::Iconv->new("iso-8859-1", "utf-8");
if (!$c1->convert($_)) { $_ = $c2->convert($_); }' \
`find * -type f`
2015-03-11 07:30:03 +00:00
Edmund Grimley Evans 5de8b5638f .gitignore: Add lib/arm64. 2015-03-10 22:38:26 +00:00
Edmund Grimley Evans 0e79df499a tccgen.c: (!nocode_wanted) -> (nocode_wanted) in arm64 part. 2015-03-10 22:37:36 +00:00
Thomas Preud'homme 5bcc3eed7b Add some missing nocode_wanted guard
int i = i++ causes a segfault because of missing guard. Looking
recursively at all backend functions called from middle end several more
guard appeared to be missing.
2015-03-10 23:27:14 +08: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 4ba7e5dc5a A correction for the commit: revert a grischka patch: gdb refused to know "main"
keep revert (check SHF_ALLOC) only for x86 target and keep a grishka patch for
other targets
2015-03-10 14:21:14 +03: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 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
Michael Matz 25b2779c3d x86-64: Fix stdarg for large non-float structs
Some structs are passed in registers.  When they need more than
one the implementation of __va_arg on x86-64 didn't correctly account
for this.  This fixes only the cases where the structs consist of
integer types, as there the register save area is consecutive.

Fixes some tests from 73_arm64.c, but still leaves those failing
that use floating point in the large-but-regpassed structs.
2015-03-09 03:54:33 +01:00
Michael Matz 2eb4f4a3ba Remove incorrect comment
Not the code was confused, I was :)
2015-03-09 01:33:42 +01:00
Michael Matz 0ecee0072d Find libtcc1.a on arm32
The directory is called "arm", not "ARM".
2015-03-09 00:47:27 +01:00
Michael Matz 50899e30ab Fix stack overwrite on structure return
The common code to move a returned structure packed into
registers into memory on the caller side didn't take the
register size into account when allocating local storage,
so sometimes that lead to stack overwrites (e.g. in 73_arm64.c),
on x86_64.  This fixes it by generally making gfunc_sret also return
the register size.
2015-03-09 00:19:59 +01:00
Edmund Grimley Evans d73b488401 arm64: Implement __clear_cache.
__clear_cache is defined in lib-arm64.c with a single call to
__arm64_clear_cache, which is the real built-in function and is
turned into inline assembler by gen_clear_cache in arm64-gen.c
2015-03-08 00:10:44 +00:00
Edmund Grimley Evans 03303628c7 tests/Makefile: Quote to avoid: /bin/sh: 1: [: !=: unexpected operator 2015-03-07 18:10:45 +00:00
Edmund Grimley Evans d854dede03 arm64: Optimise some integer operations with a constant operand. 2015-03-07 17:42:08 +00:00
Edmund Grimley Evans ac70e6b840 tccgen.c: Optimise 0<<x, 0>>x, -1>>x, x&0, x*0, x|-1, x%1.
More precisely, treat (0 << x) and so on as constant expressions, but
not if const_wanted as we do not want to allow "case (x*0):", ...

Do not optimise (0 / x) and (0 % x) here as x might be zero, though
for an architecture that does not generate an exception for division
by zero the back end might choose to optimise those.
2015-03-07 17:32:39 +00:00
Edmund Grimley Evans 9163393476 arm64-gen.c: In load(), do not sign-extend 32-bit VT_CONST. 2015-03-07 17:32:39 +00:00
seyko 8d4c861144 fix for the array in struct initialization w/o '{', case 2
a test program:

    struct {
    int a[2], b[2];
    } cases[] = {
	{ ((int)0), (((int)0)) },
	((int)0), (((int)0)) /* error: ',' expected (got ")") */
    };
    int main() { return 0; }

This commit allow to skip ')' in the decl_initializer() and to see ','
2015-03-07 09:40:12 +03:00
Edmund Grimley Evans 238e760a29 Add __builtin_return_address.
Implementation is mostly shared with __builtin_frame_address.
It seems to work on arm64, i386 and x86_64. It may need to be
adapted for other targets.
2015-03-06 21:01:14 +00:00
seyko 8764993c0d Makefile: install tcc$(EXESUF) as symlink to the $(ARCH)-tcc 2015-03-06 17:13:45 +03:00
seyko 65a4fbd1d4 Makefile: add dependencies for $($(I386_CROSS)_LINK), ...
This is another solution for the make process.
    Commit 4b92dbf923 is reverted.
2015-03-06 16:19:10 +03:00
Roy 883aafc6bb Makefile leftover of rev 44c6e99 2015-03-06 10:25:47 +08:00
seyko d9b87c087c fixing decl_initializer() for size_only: don't eat ')'
a test program:

    struct { int c[1]; } s1[] = { (int)0       }; /* OK */
    struct { int c[1]; } s2[] = { { ((int)0) } }; /* OK */
    struct { int c[1]; } s3[] = { 0            }; /* OK */
    struct { int c[1]; } sx[] = { ((int)0)     }; /* error: ')' expected (got "}") */
    int main() { return 0; }
2015-03-05 20:18:25 +03:00
seyko 4b92dbf923 Add a dependency for a PROGS and TCCLIBS to a Makefile
Simply assume this is all *.c and *.h files in a tcc top directory.
    Now a tcc compiler is recompiled if any of this files is changed.
2015-03-05 16:39:25 +03:00
Roy 44c6e992bd Fix compiling in MinGW/MSYS 2015-03-05 09:12:42 +08:00
Edmund Grimley Evans 3fb8b14806 tccelf.c: File path component is "arm64", not "ARM64". 2015-03-04 19:43:29 +00:00
seyko 664c19ad5e partial revert of the commit 4ad186c5ef
A test program:

    /* result of the new version inroduced in 4ad186c5ef61: t2a = 44100312 */
    #include<stdio.h>
    int main() {
	int t1 = 176401255;
	float f = 0.25f;
	int t2a = (int)(t1 * f); // must be 44100313
	int t2b = (int)(t1 * (float)0.25f);
	printf("t2a=%d t2b=%d \n",t2a,t2b);
	return 0;
    }
2015-03-04 16:25:51 +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 76af948623 install-clean-tuning
* Don't use /usr/local/lib/tcc/libtcc1.a for i386 and x86_64
      A $(tccdir)/i386 directory was used to install a libtcc1.a
      but only when cross compiling. And no x86_64 directory.

    * Build/install i386-tcc/x86_64-tcc and not a tcc
    * Build/install i386-win-tcc/x86_64-win-tcc and not a i386-win-mingw32-tcc/...
    * DEFINES = -DTCC_TARGET_I386... also for i386-tcc and i386-win-tcc
    * Make a symlink tcc to the i386-tcc/x86_64-tcc for a "make test"
    * Build a $(ARCH) directory with a symlink to the libtcc1.a for a "make test"
    * Remove a /usr/local/lib/tcc directory on uninstall
    * Remove a /usr/local/share/doc/tcc directory on uninstall
    * Remove a $(ARCH) directory on "make clean"
    * Remove a *-tcc files on "make clean"
2015-03-04 11:40:33 +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
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 7ec39e2288 reverse a commit a6149c6dbb41: Set CONFIG_MULTIARCHDIR for cross compilers.
Set CONFIG_MULTIARCHDIR for cross compilers.
    Chances a cross-compiler will find a working crt*.o
    in /usr/lib are more or less 0.

This commit breaks x86 / x86_64 compilres for linux. A solution for the crt*.o
must be discussed.
must be:
    # ./x86_64-tcc -vv
    tcc version 0.9.26 (x86-64, Linux)
    install: /usr/local/lib/tcc
    crt:
      /usr/lib64
    libraries:
      /usr/lib64
      /lib64
      /usr/local/lib64
    include:
      /usr/local/include
      /usr/include
      /usr/local/lib/tcc/include
    elfinterp:
      /lib64/ld-linux-x86-64.so.2

and with MULTIARCH we have:
    # ./x86_64-tcc -vv
    tcc version 0.9.26 (x86-64 Linux)
    install: /usr/local/lib/tcc/
    crt:
      /usr/lib/x86_64-linux-gnu ???????????????????
    libraries:
      /usr/lib/x86_64-linux-gnu
      /usr/lib                  ???????????????????
      /lib/x86_64-linux-gnu
      /lib                      ???????????????????
      /usr/local/lib/x86_64-linux-gnu
      /usr/local/lib            ???????????????????
    include:
      /usr/local/include/x86_64-linux-gnu
      /usr/local/include
      /usr/include/x86_64-linux-gnu
      /usr/include
      /usr/local/lib/tcc/include
    elfinterp:
      /lib64/ld-linux-x86-64.so.2

And CONFIG_MULTIARCHDIR don't handle C67.
On Linux x86 we have:
    # ./c67-tcc -vv
    tcc version 0.9.26 (C67, Linux)
    install: /usr/local/lib/tcc
    crt:
      /usr/lib
    libraries:
      /usr/lib
      /lib
      /usr/local/lib
    include:
      /usr/local/include
      /usr/include
      /usr/local/lib/tcc/include
    elfinterp:
      /lib/ld-linux.so.2
2015-03-04 10:50:33 +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
seyko d972472c53 Disable floating-point test for ARM soft-float
From: Matteo Cypriani <mcy@lm7.fr>
    Date: Fri, 5 Sep 2014 23:22:56 -0400
    Subject: Disable floating-point test for ARM soft-float

    tcc is not yet capable of doing softfloat floating-point operations on
    ARM, therefore we disable this test for these platforms. Note that tcc
    displays a warning to warn ARM users about this limitation
    (debian)
2015-03-04 09:52:47 +03:00
seyko f1e4b2b7f3 disable-BTESTS 2015-03-04 09:49:19 +03:00
seyko b8925960ec correct a DllMain() declaration in dllcrt1.c and dllmain.c
There is a DllMain() declaration in the mingw-runtime-4.0.3.1
and it differs from a tcc one.
2015-03-03 22:51:13 +03:00
seyko 7b96ddd045 win32/include/winsock2.h (look previous commit) 2015-03-03 22:45:50 +03:00
seyko 351e2ec334 add declaration of the "double trunc (double _x)" and winsock2.h
This allow to build a windows version of the nimrod compiler.
2015-03-03 22:41:55 +03:00
seyko 4b61f7f04b A lrint functions in win32/include/math.h are rewrittem because tcc can't handle "t" constraint 2015-03-03 22:38:31 +03:00
seyko dfbb00c106 wincrt1.c: add definition of the __TRY__ if not defined
Some i686-pc-mingw32-gcc don't know about __TRY__
2015-03-03 22:35:33 +03:00
seyko 859ce5e47f Report a mingw as a execution environment instead of the
Win32, Win64, WinCE when executing "tcc -v". Example
	$ ./i386-win-tcc -v
	tcc version 0.9.26 (i386, mingw)
instead of the
	tcc version 0.9.26 (i386, Win32)

There is a cpu info already about bits of the excution environment
And display C67 for the TCC_TARGET_C67
2015-03-03 22:30:24 +03:00
seyko 2e6626a4b3 Don't add a slash to the install path of the tcc in display_info() 2015-03-03 21:41:22 +03:00
seyko d70440b406 A 32/64 bit tcc on linux: an arch specific path for libtcc1.a
Don't use /usr/local/lib/tcc/libtcc1.a for i386 and x86_64
A $(tccdir)/i386 directory was used to install a libtcc1.a
but only when cross compiling. And no x86_64 directory.
And this directory location was unknown inside tccelf.c
2015-03-03 18:34:22 +03:00
seyko 43e4a406b4 Disable floating-point test for ARM soft-float
From: Matteo Cypriani <mcy@lm7.fr>
    Date: Fri, 5 Sep 2014 23:22:56 -0400
    Subject: Disable floating-point test for ARM soft-float

    tcc is not yet capable of doing softfloat floating-point operations on
    ARM, therefore we disable this test for these platforms. Note that tcc
    displays a warning to warn ARM users about this limitation
    (debian)
2015-03-03 17:28:13 +03:00
seyko 774f0611cc arm-unused-warnings: remove problems with defined but unused wariables
arm-gen.c: In function `gfunc_call':
	arm-gen.c:1202: warning: unused variable `variadic'
	arm-gen.c: In function `gfunc_prolog':
	arm-gen.c:1258: warning: unused variable `avregs'
	arm-gen.c:1340: warning: label `from_stack' defined but not used
	arm-gen.c:222: warning: 'default_elfinterp' defined but not used
2015-03-03 17:16:52 +03:00
seyko 6cbf4fb740 tcc_add_runtime() for a CONFIG_USE_LIBGCC case: reducing a complexity 2015-03-03 17:11:18 +03:00
seyko cd4f3d962d x86_64-win-tcc elfinterp: a bug correction
./x86_64-win-tcc -vv
Before
	elfinterp:
	  /lib64/ld-linux-x86-64.so.2
After
	elfinterp:
	  -
This output is identical to the output of the i386-win-tcc
2015-03-03 17:05:44 +03:00
seyko 2d83ec7aa3 lddir-on-x86-64: let CONFIG_LDDIR=lib64 by default if TCC_TARGET_X86_64
This is done for the case when CONFIG_LDDIR is not configured. Example:
./configure --enable-cross
2015-03-03 16:37:44 +03:00