Commit Graph

3138 Commits

Author SHA1 Message Date
herman ten brugge
4efcada291 Fix when bound checking and test coverage is used at the same time 2022-03-17 18:06:02 +01:00
herman ten brugge
184d845838 Fix riscv64 test 90 after struct init commit 2022-03-17 17:16:24 +01:00
herman ten brugge
291eccc154 Vla fix for 64 bits targets 2022-03-17 10:06:24 +01:00
grischka
719d96665e tccgen: Allow struct init from struct
Example:
    struct S {int x,y;}
        a = {1, 2},
        b = {3, 4},
        c[] = {a, b}, // new
        d[] = {b, (struct S){5,6}}; // new
2022-03-16 19:18:16 +01:00
grischka
0c6adcbe53 tccgen: multi-dimensional vla: bug fixes
fixes these cases:
   ptr - ptr             (-> ptrdiff_t)
   ptr +/- num           (-> ptr)
   sizeof (ptr+/-num)    (-> size_t)

Also some cleanups
2022-03-16 19:18:16 +01:00
grischka
ec5d94291c tccgen: accept array-size expressions in function paramters
Modify function parameter parser such that symbols are
put into token-table temporarily.  Benefits are:
- detects redefinitions, as with
    int foo(int a, int a);
- detects reserved symbols, as with
    int foo(int if);
- can parse expressions like
    int main(int argc, char *argv[argc + 1]);
- doesn't fix this one
    int main(int argc, char *argv[++argc]);

Also: fix unexpected "function might return no value"
with statement expression
    int f() { ({ return 0; }); }
2022-03-16 19:16:29 +01:00
Steffen Nurpmeso
917aad3bcf Add some missing fdopen(3) checks (Domingo Alvarez Duarte) 2022-02-28 21:19:41 +01:00
herman ten brugge
308d8d17dc Fix get thread id in lib/bcheck.c for freebsd
The api for getting the thread id is different for freebsd.
2022-02-21 09:15:43 +01:00
Christian Jullien
7225282ea5 Small patch from collective work to better support FreeBSD. 2022-02-20 15:45:24 +01:00
herman ten brugge
e9f59c804d Update for freebsd 13.0
Add __RUNETYPE_INTERNAL define in include/tccdefs.h
2022-02-08 18:53:16 +01:00
Christian Jullien
4e0e9b8f21 Add '#define __LITTLE_ENDIAN__ 1' which was missing for macOS port 2022-01-11 07:06:09 +01:00
herman ten brugge
d33b189427 Fix vla bug
This fixes a vla bug. Probably more fixes are needed.
Add testcode for bug.
2021-12-27 11:39:52 +01:00
herman ten brugge
1692060fb0 Fix cross compiling tcc on freebsd 2021-12-27 11:32:35 +01:00
herman ten brugge
6c0e0b998b Fix memcpy1/memcpy2 asm testcode on x86_64 2021-12-27 11:24:33 +01:00
Riccardo Schirone
027b8fb9b8 Add rpath to the library paths instead of state->rpath 2021-12-15 17:45:16 +01:00
Riccardo Schirone
d88857b210 If the DLL has a RPATH, use it when looking for NEEDED libraries 2021-12-15 17:30:25 +01:00
Alexander Sosedkin
da11cf6515 Don't skip weak symbols during ar creation
```
$ echo 'int __attribute__((__weak__)) f(void) { return 4; }' > w.c
$ tcc -c w.c -o w.o

$ tcc-old -ar rc w.a w.o; nm -s w.a  # previous behaviour, not indexed
w.o:
0000000000000000 W f

$ ar rc w.a w.o; nm -s w.a           # GNU binutils behaviour, indexed
Archive index:
f in w.o

0000000000000000 W f

$ tcc-new rc w.a w.o; nm -s w.a      # new behaviour, indexed
Archive index:
f in w.o

0000000000000000 W f
```
2021-10-30 16:07:00 +02:00
mingodad
1645616843 Revert "Move almost all global variables to TCCState, actually all tests pass on Ubuntu 18.04 x86_64"
This reverts commit af686a796b.
2021-10-22 07:39:54 +02:00
mingodad
2ce2dbcb09 Revert "Fix some errors on arm64-asm.c, rename some variables, fix several code style declarations"
This reverts commit 61537d899a.
2021-10-22 07:39:26 +02:00
mingodad
d33f582e25 Revert "Fix missing parameter"
This reverts commit 1a8fb94350.
2021-10-22 07:37:39 +02:00
mingodad
1a8fb94350 Fix missing parameter 2021-10-22 07:37:15 +02:00
mingodad
61537d899a Fix some errors on arm64-asm.c, rename some variables, fix several code style declarations 2021-10-22 07:20:00 +02:00
mingodad
af686a796b Move almost all global variables to TCCState, actually all tests pass on Ubuntu 18.04 x86_64 2021-10-21 20:09:42 +02:00
Ryan Burns
ca11849ebb Permit '=' character in configure options
By replacing the `-f 2` field selection with `-f 2-`, we select fields
2 and beyond, so that arguments containing the '=' character are not
truncated.

This option qualifier list format is POSIX standard and tested
to work with the `cut` program from:
* GNU coreutils
* macOS (FreeBSD)
* NetBSD
* toybox
* busybox
* uutils-coreutils

In my case, this is useful because I'm trying to use an installation
prefix which contains an equals sign.
2021-10-09 17:28:42 -07:00
coltrane
15e9b7384e Add few Windows API that can be used to detect the exact Windows version we are running on. 2021-09-16 08:52:35 +02:00
grischka
e97e108d0b tccpe: #pragma pack(push) - support this form 2021-09-01 19:36:24 +02:00
Tyge Løvset
c7a57bf1fa Prepended branch name to githash (tcc -v). WIN32: added githash support.
- E.g. "tcc version 0.9.27 mob:675046b (x86_64 Windows)"
- WIN32: Replaced compiler opt -O1 and -Os with -O2 (only 1% larger executable).
2021-08-21 09:10:56 +02:00
grischka
675046bd59 tcc/lib: reduce number of files
271 insertions(+), 292 deletions(-), -21 lines, -5 files
Also:
- tccdefs.h: WIN32: less (no) __builtins
- libtcc.c: simply ignore -arch
2021-08-03 22:49:18 +02:00
herman ten brugge
e538160a32 Fix netbsd build
Netbsd uses __UINTPTR_TYPE__ to detect gcc in machine/int_types.h
2021-08-03 11:32:54 +02:00
Christian Jullien
e449db5f1d macOS: if used, -arch option must match target 2021-08-02 14:21:28 +02:00
Christian Jullien
a951dc026f macOS: add -arch option to allow to bootstrap tcc with tcc on macOS. 2021-08-02 09:22:46 +02:00
grischka
dda95e9b0b WAIT/POST_SEM(): generalize interface (and more)
Currently used only with 'tcc_compile_sem' to protect
tcc_compile(),  but can be used with other semaphores

Also fix deadlock when tcc_enter_state() is called
recursively for the same state, for example with
tcc_warning() from #pragma comment(option,"...")

Also:
- libtcc.c: error1(): use cstr_[v]printf()
- tcc.h: set TCC_USING_DOUBLE_FOR_LDOUBLE for macho-arm64
  (rather than for macho-X86_64)
- tcc.h: define TCC_TARGET_MACHO on __APPLE__ by default
- tcc.h: cleanup TCCState, move DEFASM token stuff to tcctok.h
- tccgen.c: more static
- Makefile/tcc.c: review githash
- tccpe/tcctools: use read() instead of fgets() in pe_load_def()
  (all files opened by tcc for reading are now read via 'int fd')
- configure/win32: don't preset CONFIG_TCCDIR (to allow to override it)
- tcc.c -bench: do not include output/run-time
2021-08-01 20:33:31 +02:00
grischka
4b2c6cf3a4 -W[no-]error...: features by shrinkage
136 insertions(+), 226 deletions(-), less 90 lines (except tests)
only one set_flag() function required
* can now turn off specific errors: -Werror -Wno-error=option
* new interface: tcc_warning_c(warn_option)("format", args...);
* new warning: -Wdiscarded-qualifiers (on by default)
* new variable 'warn_all' for conditional warnings with -Wall
see also the tests
2021-07-31 21:45:33 +02:00
Sam Ellicott
931a146591 tccdef.h additons for riscv64 newlib stdint 2021-07-29 22:36:53 -04:00
Steffen Nurpmeso
2709b7ab03 -W[no-]error: fix previous (sigh) 2021-07-27 23:19:36 +02:00
Steffen Nurpmeso
49cd6f59b2 -W[no-]error: rid of TCCState.warn_none, too; and adjust -h/-hh output 2021-07-27 20:55:58 +02:00
Steffen Nurpmeso
0d59ac4817 -W[no-]error: fix previous 2021-07-27 20:00:20 +02:00
Steffen Nurpmeso
0c16762418 -W[no-]error=X: gcc compat: when disabling X again, do not unset the warning 2021-07-27 19:48:29 +02:00
Christian Jullien
b1d9de6794 [macOS] fix format warning 2021-07-27 07:54:46 +02:00
Steffen Nurpmeso
a7a13896b3 Add -W[no-]error=OPTION specific abortions 2021-07-27 00:37:22 +02:00
grischka
eadcee6501 macos: yet another tbd adjustment
configure:
- re-enable apple M1-arm64
- however, with --cpu=x86_64,  set -arch in CFLAGS/LDFLAGS too
  (assume rosetta)

Makefile:
- re-enable osx cross-test (Please do not disable tests)

tcc.h
- set TCC_IS_NATIVE for TCC_TARGET_MACHO on __APPLE__
- apply TCC_USING_DOUBLE_FOR_LDOUBLE for x86_64-osx

libtcc.c:
- cleanup tcc_add_file_internal()
- new function char *tcc_load_text(int fd); and use it for tbd files
2021-07-25 20:55:05 +02:00
Sushant Pandurangi
ecb384ac0c Fix 'unused function' warning on non-macOS targets 2021-07-17 13:42:54 +02:00
Brian Callahan
46bf3f940c Add register definitions for OpenBSD/riscv64 2021-07-09 12:16:18 -04:00
Christian Jullien
ab13f1a25a On Big Sur M1, force a x86_64 native build and count on Rosetta to make job as arm64 is not yet supported. 2021-07-08 09:37:37 +02:00
herman ten brugge
6e76d894fe Fix macOS memcheck problems 2021-07-07 10:05:23 +02:00
Christian Jullien
91a956823e [macOS] Add VT_LDOUBLE special case for Rosetta to handle --cpu=x86_64. 2021-07-07 09:50:20 +02:00
Christian Jullien
592cf7fb25 Temporary remove osx cross build which is broken, at least on Windows. 2021-07-07 09:09:12 +02:00
Christian Jullien
b964fc6922 dlopen does not exist on Windows, recent macOS adds a dlopen call which is skipped on Windows. 2021-07-07 09:08:15 +02:00
Sushant Pandurangi
588d64c538 (merge) macOS11+ dynamic linker support 2021-07-06 22:54:28 +02:00
Sushant Pandurangi
cca4ece0a8 macOS: get active SDK path from xcode-select 2021-07-06 22:48:38 +02:00