Commit Graph

313 Commits

Author SHA1 Message Date
grischka
2caaff20fb tccdbg.c: new file
Better avoid global variables, at least in new code.

tccdbg.c hopefully should be logically identical to the
former parts in tccgen/elf.c (s1 tccstate added in some
places)

tccelf.c: dwarf linkage seems special per dwarf rather
than special per target.
2022-05-09 22:37:25 +02:00
grischka
56481d554f bored...
/* Use "-g" as alias for "-g1". Use "-g0" to disable debug */

So not using -g is now the alias for -g0 ?!?

This reverts commit 8759b2581d.
This reverts commit 3ce7bc6efc.
This reverts commit 5fb582ab7f.
This reverts commit aea68dbb40.
This reverts commit fa9c31c3db.
This reverts commit b3bebdb20a.
This reverts commit ecf8e5a00e.
This reverts commit fe6b5c08dc.
This reverts commit e2e5377e7b.
This reverts commit 1cd7998905.
2022-05-09 22:19:15 +02:00
Detlef Riekenberg
9ac128c0bd Makefile: Add a comment with an option to debug the Makefile 2022-04-27 20:25:23 +02:00
Detlef Riekenberg
8759b2581d Makefile: Use the .exe extension only on Windows for the c2str helper program
Signed-off-by: Detlef Riekenberg <wine.dev@web.de>
2022-04-07 02:18:19 +02:00
Detlef Riekenberg
e2e5377e7b Makefile: Add a doc target.
"make help" already documents a "doc" target,
but it was not present.

Signed-off-by: Detlef Riekenberg <wine.dev@web.de>
2022-04-01 21:26:55 +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
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
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
Arthur Williams
24d35faed2 Use grep -q instead of grep --quiet to be more portable 2021-07-01 01:44:23 -05:00
Christian Jullien
035ae7d735 Fix Makefile as suggested by Urs Janßen 2021-04-09 14:21:36 +02: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
Christian Jullien
affd736f19 Add 'modified' before hash when tcc is built from a patched mob version. 2021-04-02 08:00:31 +02:00
Christian Jullien
f68b39b922 Surround hash code with double quotes 2021-03-31 23:15:47 +02:00
Christian Jullien
65d00b13d5 tcc -v displays short hash to ease detection of source version used to compile tcc 2021-03-31 22:24:29 +02:00
Christian Jullien
e8bff295f9 [macOS]: arm64, very early stage of Big Sur M1 native port. 2021-02-21 08:38:39 +01:00
herman ten brugge
3658c29b43 Add config pie option
Allow configure --config-pie for netbsd arm
2021-02-15 19:14:48 +01:00
grischka
557b4a1f6d configure chmod 755 etc.
lib/tcov.c:
- can't be cross-compiled (needs stdio.h)
- can be included in libtcc1.a

Reason why bt-xxx.o/bcheck.o are linked separatly is because we
don't want then to linked into exe's and dlls at the same time.
2021-01-26 18:44:37 +01:00
grischka
1ed4b6ba1a debug_modes, re-unalign, cleanups
tccgen.c: debug_modes
- don't waste debug function calls during normal execution.
libtcc.c:
- mem_debug: no C99 features in tcc please, for example
  ({compound expressions}): do not use.
tccgen.c: struct_layout:
- unaligned access is completely ok for most targets.
- Moreover the patch was triggering single byte mode even
  for normal aligned access (as with tcc's SymAttr)

static Sym label: don't do this

arm-gen.c:
- use some #ifdefs to explain some code
tccpp.c:
- cleanup UCN chars
libtcc.c:
- replace openbsd library search
configure:
- cleanup strip fallouts
tccgen.c:
- expr_cond(): remove an exotic optimization that eventually
  got fixed to do the contrary by a gv(RC_InT)
- pop_local_syms(): remove some args
- init_putv() : use write##le functions to avoid cross-compiler
  unaligned access
- __bt_init(): remove unused param 'mode'
2021-01-24 18:00:33 +01:00
herman ten brugge
bc6c0c34c1 implement test coverage
I have implemented the -ftest-coverage option. It works a bit different
from the gcc version. It output .tcov text file which looks almost the
same as a gcov file after a executable/so file is run.

Add lib/tcov.c file
Modify Makefiles to compile/install it
Add -ftest-coverage option in tcc.c/tcc.h/tcc-doc.texi
Add code to tccelf.c/tccgen.c/tccpe.c
Add gen_increment_tcov to tcc.h/*gen.c

unrelated changes:
Add sigemptyset in tccrun.c
Fix riscv64-gen.c tok_alloc label size
2021-01-23 18:17:38 +01:00
Christian Jullien
593bed9b52 Fix arm NetBSD cross compilation 2021-01-19 08:58:24 +01:00
Christian Jullien
f5f8326531 FreeBSD: arm port is fully supported and added to cross list 2021-01-16 16:25:22 +01:00
Christian Jullien
1d7b233562 Remove strip logic form configure script, keep a deprecated warning message when --strip-binaries is still used. 2021-01-14 07:10:41 +01:00
Christian Jullien
d5c78ce655 Add more supported systems for cross test 2021-01-13 09:34:37 +01:00
grischka
62c0c4c77a tccelf.c: factor out elf_output_obj()
The small common parts within elf_output_file() aren't
worth the many #ifdefs.  Also, set section sizes and
allocate section names in 2 separate functions.
2021-01-12 18:39:35 +01:00
Christian Jullien
64d5db7635 *BSD: fix broken Makefile on all BSD systems. 2021-01-12 07:08:39 +01:00
grischka
bbc7070c82 make test: run cross-test always
To see inconsistencies when they happen.
2021-01-11 15:17:26 +01:00
Christian Jullien
0e74965d7f make install always strips, only install-strip target should do 2021-01-10 05:57:52 +01:00
Danny Milosavljevic
9539f51369
Makefile: Split arm64-asm from arm-asm 2021-01-03 15:49:17 +01:00
Danny Milosavljevic
f88ded6c2d
arm-asm: Implement asm_parse_regvar and asm_clobber 2021-01-03 02:34:10 +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
Michael Matz
cc40305a12 Fix errors with parallel make
seen when doing 'make -j i386-tcc tcc', as explained in the comment.
2020-12-25 02:10:43 +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
grischka
e2e62fcb8b replace native platform macros in the compiler
- The compiler should not use these
- However tccrun.c & libtcc1.a files should use these
Also:
- use s1->loaded_dlls for loaded dlls instead of dlopens
- alpine musl: fully supported now and tested
- ./configure ...
   --config-backtrace=no : disable backtraces
   --config-bcheck=no : disable bcheck
- tests:dlltest: enable by default
- tccrun.c : simplify mmaps
- __builtin_alloca : always use asm-alias (instead of #define)
- tccpe.c : use write32le
2020-12-17 12:39:16 +01:00
grischka
cf8d9cf072 win64: fix pe_isafunc()
- tccpe.c: commit "tidy support for helper function" created
  STT_NOTYPE symbols and hence relied on ad-hoc detection which
  didn't work for x86_64 (as reported by Christian Jullien)

- tccgen.c: However to be more safe the helper symbols are
  now made STT_FUNC anyway (via new VT_ASM_FUNC).

Also:
- tcc.h: minor reorder
- riscv64-*, arm64-*, tccmacho.c: avoid some gcc format-warnings
  (mingw-gcc complains about "%llx" being "unknown conversion",
  although it does work since Vista or so)
2020-11-26 16:11:17 +01:00
Christian Jullien
60c1f70bb9 Revert commit 55f8963dfa from wanjochan until better tested on all platforms 2020-09-10 05:49:15 +02:00
wanjochan
55f8963dfa ignore symbol main for .dylib; skip libtcc1 for tccrun mode; 2020-09-08 22:05:00 +08:00
wanjochan
9085b38a71 add "libtcc.osx" entry to Makefile, for programs who need more pure libtcc.dylib without "@rpath/" config 2020-08-07 21:10:39 +08:00
Christian Jullien
28e9fc1913 macos: 'make uninstall' also removes *.dylib 2020-07-10 10:38:36 +02:00
Avi Halachmi (:avih)
c69290fb0c macos: support arbitrary configure --libdir
Previously, after installation, only ../lib relative to the binary was
supported for finding libtcc.dylib, now any custom libdir.
2020-07-10 00:03:48 +03:00
Christian Jullien
6c94df6e2d macos: add path relative ../lib 2020-07-09 19:37:37 +02:00
Christian Jullien
af0370a75d macos: add tcc version to libtcc.dylib. It can be shown with 'otool -L'. 2020-07-09 14:25:19 +02:00
Christian Jullien
b5a89c8c93 macos: tcc searches for libtcc.dyln in the same directory as its executable 2020-07-09 12:04:57 +02:00
grischka
72277967ff some cleanups related to recent commits
- configure/Makefile : cleanup, really use CC_NAME
- tccasm.c : remove C99 construct that MSVC doesn't compile
- arm-gen.c, x86_64-gen.c, riscv64-gen.c, tccmacho.c : ditto
- arm64-gen.c: commit 383acf8eff wrote:
  "Instead of a cast, it would be better to pass the exact type."
  It is true that there are better solutions but it is not
  passing the exact type (I think).
- tcctest.c: revert "fix cast test for clang" 03646ad46f
  this obviously wants to test non-portable conversions
- 114_bound_signal.test: clock_nanosleep is too new for older
  linuxes, just use sleep() instead
2020-07-06 13:00:47 +02:00
Christian Jullien
f635de709e macos: clang -s option is obsolete - at least on macOS. 2020-06-24 07:06:48 +02:00
Christian Jullien
9617ea6a3a macos: workaround to build tcc using tcc until .o object files generated by tcc are fully compatible with ar. Instead of ar, use 'tcc -ar' 2020-06-23 06:51:51 +02:00
Michael Matz
4eff2b5f6a macos: more adjustments for OSX systems
* instead of /usr/include use the current SDK path as system
  include directory (/usr/include is empty with current tools)
  (this also removes the need to add these paths in individual
  Makefiles)
* define _DARWIN_C_SOURCE in tcc.h to get the full set of decls
  from system headers (e.g. vsnprintf), similar to _GNU_SOURCE
  (and don't define _ANSI_SOURCE in the main Makefile anymore)
* tests/tests2/Makefile: remove the -w flag, it's added when necessary
  in the rules generating the .expect files
2020-06-20 22:17:06 +02:00
Michael Matz
94066765ed macos: First cut at generating Mach-O executables
this does generate a working executable for a very simple
example input, e.g. this:

% cat simple.c
int main(void)
{
  return 0;
}
% ./tcc -B. -c simple.c
% ./tcc -nostdlib -B. simple.o -lc
% ./a.out && echo okay
okay

(the -lc is actually not necessary right now, see below).  This
has many limitations:

* no symbol table, hence no calls to external functions from
  e.g. libc, aka libSystemB
* no proper entry point (should be main, but is hardcoded to first
  real .text address)
* libSystemB is hardcoded, no other libs are supported (but again
  no external calls anyway)
* generated Mach-O executable is in old format: neither LC_DYLD_INFO
  no export tries for symbols are created (no symbol table at all!)
* the __LINKEDIT segment is faked and empty, as dyld doesn't like
  it empty even if no symbols point into it
* same with __DATA, dyld wants a non-empty writable segment which
  we enforce with useless data
* no relocations, hence no function call stubs (lazy or not) are
  generated
* hardcodes some other constants as well
2020-06-20 22:09:21 +02:00
Michael Matz
4cc27b816f macos: Use newer MACOSX_DEPLOYMENT_TARGET
10.6 seems to still be supported on Mojave, but not 10.4
anymore.
2020-06-20 22:07:24 +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
grischka
e7a4140d28 tcc --help -v: cleanup
from e640ed1aeb

Also:
- cleanup -std, -O, -pthread
- tcc.h:win32: use win32-type include paths even for cross
  compilers (needed for loading tcc_predefs.h in cases)
- Makefile: simplify OSX .dylib clause
2020-06-17 17:41:46 +02:00