1
0
Fork 0
Commit Graph

87 Commits

Author SHA1 Message Date
grischka da0d43903b review recent commits
tccpp.c:
 - revert "Preprocessor fix + new testcase"
   Fix was not a fix and nobody could understand the test.
   This reverts 6379f2ee76
 - better fix and add new test (pp/18.c)

tccgen.c:
 - remove global variables 'in_sizeof', 'constant_p'
 - rework comma expression (gexpr())
 - merge func/data 'alias_target' codes
   (See 08c777053c)
 - move call to do_Static_assert()
 - better error: "expression expected before '%s'"
 - fix "statement after label"
    - remove unnecessary second parameter to block()
    - remove unnecessary call to decl()
    - revert changes to old C89 test file
    See 7f0a28f6ca

tccelf.c:
 - rework "...make undefined global symbol STT_NOTYPE"
   (See f44060f8fc)
 - move tccelf_add_crtbegin() from libtcc.c

tcctest:
 - unfix K&R fix (keep old look of K&R functions)

tccrun.c:
 - exit(0) returns 0

libtcc.c:
 - move #defines for -dumpmachine
 - more explicit error "file not found"
   (as opposed to error while loading file)

tccpe.c, x86_64-gen.c, i386-asm.c, tccasm.c:
 - use R_X86_64_PLT32 for functions on x86_64-win32

tccdefs.h
 - empty #defines for _Nonnull, __has_builtin(), etc.

configure:
 - Simpler "macOS .dylib ... VERSION letters."
   (See 6b967b1285)

Makefile:
 - macOS version also
 - add cross searchpaths for packages

build.yml:
 - disable codesign on macos-11 (doesn't seem to work)
2024-02-04 18:18:40 +01:00
Reimar Döffinger a473473fed stdatomic.h: Add ATOMIC_VAR_INIT macro. 2023-10-29 18:12:31 +01:00
Reimar Döffinger e9aa113240 tccdefs.h: Apple target requires __has_builtin definition.
Note: I have not been able to create working binaries on
macOS 14.1 so far, but at least tcc compiles and produces
binaries now...
2023-10-29 14:45:19 +01:00
Detlef Riekenberg 3d128041c3 include/tccdefs: Add function renaming with __REDIRECT_NTHNL (0.9.28rc testing)
Fixes a compilation break in "glob.h"
Detected during tcc 0.9.28rc testing.
Affected project: https://github.com/craigbarnes/dte

--
Regards ... Detlef
2023-09-17 12:15:28 +02:00
Sergey Sushilin 7f39b4f573 Fix typo in atomic_compare_exchange_weak() 2023-09-09 23:28:45 +03:00
grischka bb93bf8cd2 stuff & etc..
- tccpp.c: rename ... to __TCC_BCHECK__/__TCC_BACKTRACE__
- libtcc.c: correct total line count
- libtcc.c: support -run -- args... (instead of -run @ args ...)
- Makefile/build-tcc.bat: streamline GITHASH string somewhat
- bt-exe.c: avoid redef of pstrcpy() with 'tcc -bt tcc.c ...'
2023-04-25 15:22:31 +02:00
grischka 19ef024aa9 lib/armeabi.c: fix zero from/to double conversion
tccgen.c:
- allow cross-compiling 0.0L (cross-compile tcc with tcc)
tccelf.c:
- use alignment of TLS section for PT_TLS
tccpp.c:
- support long double constants on systems that do not support
  long doubles (i.e. mark them (VT_DOUBLE | VT_LONG))
tccdefs.h:
  #define __has_feature() for android
  remove _unaligned (why define a msvc extension under !_WIN32)
2023-04-25 08:59:42 +02:00
herman ten brugge 24c930a9b8 Allow _unaligned and __unaligned on WIN32 2023-04-15 15:33:14 +02:00
Detlef Riekenberg afa05caacf Ignore _unaligned and __unaligned. Required >15years ago, but still present in old code
These extensions where used by other compiler
to generate different code on old cpu's (arm and x86 before pentium/pentiumpro)
to prevent processor exceptions / very high delays when accessing an unaligned pointer.

--
Regards ... Detlef
2023-03-23 17:14:29 +01:00
grischka 19e3e10e4b small scopes cleanup etc.
tccgen.c:
- just track local_stack for small scopes (can't declare variables)
- fix a vla problem with nested scopes
- move debug N_L/RBRAC into curly braced block

Also:
- tccpp.c: move 'label_...' functions to tccgen.c
- tccpp.c: let get_tok_str() say "<no name>" for anonymous symbols
- tcctest.c: let __pa_symbol() work for memory > 2GB
- 119_random_stuff.c: revert strtoll test (no reason to test libc)
- tccdefs.h/tcctest.c: enable bit fncs for _WIN32
- Makefile:
  - use i686-linux-gnu instead of i386-linux-gnu for cross-i386
  - update 'make help'
  - revert umplicit 'make all' with 'make install' (but print warning)
2023-03-12 20:40:50 +01:00
herman ten brugge dd69143ae6 Add builtins ffs, clz, ctz, clrsb, popcount, parity
Add new file lib/builtin.c
Modify include/tccdefs.h, lib/Makefile to compile it.
Update tests/tcctest.c to test it.
2022-12-11 08:23:22 +01:00
Christian Jullien d8329c2d19 __nan() is not available on Apple M1, replaced by (0.0F/0.0F) 2022-11-25 17:08:58 +01:00
herman ten brugge 28fa4d3db6 Add strncat and strrchr to bounds checking 2022-11-25 00:31:32 -06:00
herman ten brugge f89a6f12a7 Fix atomic test_and_set and clear
The __atomic_test_and_set and __atomic_clear code was correct.
They needed locking.
Replaced to code with assembly code.
The changes are in include/stdatomic.h, lib/stdatomic.c, lib/atomic.S
Enabled tests/tests2/124_atomic_counter.c for apple again.

Also moved lib/fetch_and_add.S code to lib/atomic.S.
Removed lib/fetch_and_add.S
Adjusted lib/Makefile
2022-11-17 05:57:21 -06:00
herman ten brugge c8ef84c854 Add support for apple m1
The apple m1 uses position independent executables (pie).
I have implemented this in tccmacho.c

Apple also uses the stack different for var_args.
Also characters are signed instead of unsigned.
This is implemented in arm64-gen.c/tccdefs.h

Add bounds checking lib to lib/Makefile.

Add underscore support in lib/atomic.S and lib/fetch_and_add.S

Disable __clear_cache in lib/lib-arm64.c (Use system version).
I will try to fix this in future push.

Disable test_asm_call in tests/tcctest.c. Clang does not support @plt.
Also disable weak symbols test.
I will try to fix weak support in future push.

Disable tests/tests2/124_atomic_counter.c for 64BITS.
This is a bug in the atomic code and will be fixed in future push.

You have to use --dwarf configure option. stabs only works with -run.

tested on apple x86_64(10.5) and arm64(12.3).
2022-11-16 12:52:51 -06:00
herman ten brugge 79a8229fb5 Add atomic functions for arm/arm64/riscv
Make code more compatible with gcc. Change
__atomic_store
__atomic_load
__atomic_exchange
__atomic_compare_exchange

Also add (include/stdatomic.h, lib/stdatomic.c):
atomic_thread_fence
atomic_signal_fence
atomic_is_lock_free

And gcc extensions (tcctok.h, tccgen.c, lib/stdatomic.c):
__atomic_fetch_nand
__atomic_and_fetch
__atomic_sub_fetch
__atomic_or_fetch
__atomic_xor_fetch
__atomic_and_fetch
__atomic_nand_fetch

Add new file lib/atomic.S with assembly code for __atomic_compare_exchange_n
for arm/arm64/riscv. Also update lib/Makefile.

Update testcode in 124_atomic_counter and 125_atomic_misc to test new functions.
Also update tests/tests2/Makefile to run tests on arm/arm64/riscv.
2022-10-16 18:51:56 +02:00
grischka 09808f327f tcc android-enabled (armeabi-v7a)
On an armeabi-v7a device (phone) in the termux app with
clang & make installed this passes all the tests.

Can be used as a cross compiler to create "native apps" as well.
Example 'config-extra.mak' for the cross arm-eabi-tcc:

  SYSROOT = <path_to_android_ndk...>/sysroot/usr
  TRIPLET = arm-linux-androideabi
  ANDRVER = 32

  ROOT-arm-eabi = $(SYSROOT)

  CRT-arm-eabi = {R}/lib/$(TRIPLET)/$(ANDRVER)
  LIB-arm-eabi = {B};{R}/lib/$(TRIPLET)/$(ANDRVER);{R}/lib/$(TRIPLET)
  INC-arm-eabi = {B}/lib/include;{R}/include/$(TRIPLET);{R}/include

  DEF-arm-eabi = -DTCC_TARGET_ARM -DTCC_ARM_VFP -DTCC_ARM_EABI
  DEF-arm-eabi += -DTARGETOS_ANDROID -DCONFIG_TCC_PIE -DCONFIG_NEW_DTAGS
  DEF-arm-eabi += -DCONFIG_TCC_ELFINTERP=\"/system/bin/linker\"

  # on unix replace ';' by ':'.
  $ ./configure && make cross-arm-eabi && make install
2022-07-24 09:51:32 +02:00
illiliti d3e940c71c include/float.h: Define DECIMAL_DIG
Values were shamelessly stolen from musl libc. Needed for hare compiler.
2022-04-28 21:44:01 +03:00
herman ten brugge c1725a8f6e Only define alloca on i386/x86_64 2022-04-12 07:07:40 +02: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
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
Sam Ellicott 931a146591 tccdef.h additons for riscv64 newlib stdint 2021-07-29 22:36:53 -04:00
grischka 48df89e10e stdatomics: tidy & cleanup
- remove any error messages that were just for debugging the
  templates really
- don't use c99 in tcc (array designators etc.)
- remove memory model type (cannot be an own type really)
  and move memory model defines from built-in to stdatomics.h
- apply normal casts to non-pointer atomic_function arguments
- tidy the library support
- add some tests for errors/warnings

Also:
- Makefile: move GIT_HASH stuff from CFLAGS to DEFINES and into
  main section (away from what is included by tests for example)
- tccelf.c/tccgen.c: avoid some warnings with newer GCC
2021-04-09 10:47:35 +02:00
Dmitry Selyutin 1ff8679e79 stdatomic: refactor parser and generator 2021-03-09 12:24:08 +03:00
Dmitry Selyutin dd5b546bf7 stdatomic: atomic_init routine 2021-02-14 22:22:27 +03:00
Dmitry Selyutin 5053fd03a7 stdatomic: memory models as macros 2021-01-27 13:26:48 +03:00
Dmitry Selyutin 02ea864ad2 stdatomic: deplusification; LLVM notice 2021-01-27 13:25:12 +03:00
Dmitry Selyutin f2e7742aea stdatomic: stdatomic.h header 2021-01-27 00:48:46 +03:00
Christian Jullien 42220676d7 OpenBSD: x86 use few clang compatible C types 2021-01-11 12:19:09 +01:00
Christian Jullien b147a37c23 Remove useless [u]intN_t definitions from stddef.h 2021-01-02 11:23:26 +01:00
Christian Jullien c9fe8fe470 Yet another int64_t/uint64_t definition fix. For wine this time. 2021-01-02 05:58:46 +01:00
Christian Jullien 9a2a05ba1e *BSD: fix extra #endif 2021-01-01 16:01:03 +01:00
Christian Jullien 33257c6439 *BSD: protect against incompatible redefinitions of int64_t/uint64_t. 2021-01-01 08:50:13 +01:00
grischka ea82d0826d tccpp: cleanup target-os defines
moved target_machine defines to the <target>-gen.c files.

Also:
- c2str.c moved into conftest.c
- tccdefs.h ; defined(__TINYC__) && !defined(_LOCORE) removed
  (in tinycc __TINYC__ is always defined and _LO... is never.)
- stddef.h : too many #ifdefs, removed
- tccgen.c:stabs: support win32 long doubles aka doubles.
- win32: math.h/tcc_libm.h: fix pointer mismatch in modfl
- tccpp.c: increment include_stack_ptr after the file was
  actually found otherwise it would print
  "in file included from <itself>: file not found..."
2020-12-31 02:03:31 +01:00
Christian Jullien b9db7c90ee NetBSD: arm64 prevent use of __asm. 2020-12-24 07:31:52 +01:00
Christian Jullien b56099aeb4 NetBSD: arm64 fix int64_t/uint64_t definitions. 2020-12-24 06:50:48 +01:00
Christian Jullien 63e29113ab NetBSD: arm64 requires at least gcc 4.1 to work 2020-12-23 20:52:25 +01:00
herman ten brugge f7d2d04d96 Fix include/tccdefs.h
Remove __amd64__ for FreeBD (32 bits version did not work any more)
Add __APPLE__ at HAVE MALLOC_REDIR so bound checking works on apple
2020-12-22 18:53:29 +01:00
grischka 9f6b65230a include/tccdefs.h: moved and use it
tcc_define_symbol(): now only for -D on command line
include/tccdefs.h: converted to strings and compiled into
the tcc executable.  Can be disabled with
    ./configure --config-predefs=no
In this case include/tccdefs.h is loaded at runtime.  This is
default for other build-methods (build-tcc.bat) also (to avoid
some complexity).

Also:
- lib/Makefile: fix typo
- tcc.h : avoid _strto(u)i64 (for TCC on WIN98/2K)
- tccpp.h:cstr_printf() : workaround incompatible vsnprintf's
  (generally faster too)
2020-12-22 11:06:19 +01:00
Christian Jullien a3d5e4aa43 OpenBSD: define more internal symbols to support tcc on OpenBSD. 2020-12-07 07:15:56 +01:00
Tyge Løvset b11144d69c Overhauled WIN32 math and added missing functions:
1) Cleanup: moved function implementations from win32/include/math.h to win32/include/tcc/tcc_libm.h
2) Added missing math functions: MUSL: asinh(), acosh(), atanh(), scalbn(). My impl: log1p(), expm1(), ilogb(), scalbln(), nexttoward()
 - now only a few are missing: remquo(), remainder(), fma(), nan(), erf(), erfc(), nearbyint().
3) Added/defined all missing *f() and *l() math functions.
4) Added functions have short but accurate/fast implementations.
5) Added <tgmath.h> for all platforms. (not too useful, IMO, but is C99 standard).
2020-11-20 23:34:35 +01:00
Christian Jullien 58be11f701 Add L suffix to LDBL values. 2020-07-16 07:59:34 +02:00
Christian Jullien 92769362c7 Fix LDBL_xx values for aarch64 and riscv 2020-07-15 15:55:49 +02:00
Michael Matz 5d2f4cb403 macos: various fixes
* alloca needs to be _alloca
* int64_t and uint64_t are also defined in <sys/_types/_int64_t.h>
  but as long long, not as long, so adjust out <stddef.h> to agree
  on Darwin
* define __APPLE_CC__ so that <TargetConditionals.h> correctly defines
  various macros like TARGET_OS_MAC and TARGET_CPU_X86_64
2020-06-20 22:14:56 +02:00
grischka 781872517d tccpp.c: compile 'tcc_predefs' from string
It might have advantages in cases if tcc/libtcc does not
depend on extern files.

Also:
- apply "stray \\ ..." check to macros only. For files it
  was already checked. Add positive test.
2020-06-17 18:01:45 +02:00
Michael Matz 245f6a0d13 stdarg: always have the __builtin_va_* available
This makes available the __builtin_va_list type and __builtin variants
of va_start, va_arg, va_copy and va_end.  We do this via a header file
that's prepended to all compilations always (except if merely
preprocessing): tcc_predefs.h.  That header could also be used
for predefining other builtins in the future.

We don't need the define hacks for musl anymore with this.

Also fix x86_64 gfunc_prologue to reserve enoug space for the
full va_list structure, not just 16 bytes.
2020-04-15 22:06:52 +02:00
Michael Matz 8c6143d86f Fix stdarg on x86-64
this partly reverts 1803762e3 to fix stdarg on x86-64 again.  I've tried
to retain the apple specific changes from that commit.
Also include stdarg.h first in tcc.h, maybe that helps as well.
2020-04-15 04:49:34 +02:00