Detlef Riekenberg [Thu, 26 Oct 2023 15:51:30 +0000 (26 17:51 +0200)]
tccelf: Do not load all referenced libraries when linking a library
Recursive loading of all references can break linking of libraries
(Example: building of netbsd-curses)
Thanks grischka, Michael and Herman for the comments.
--
Regards ... Detlef
Ben C [Thu, 26 Oct 2023 02:17:35 +0000 (25 22:17 -0400)]
Fix macOS .dylib build when VERSION contains letters.
macOS builds with --disable-static fail to link if the version number
contains letters because of the -current_version and
-compatibility_version arguments (current version is 0.9.28rc).
This commit adds a new MACOS_DYLIB_VERSION variable to config.mak for
builds that target macOS. It has no impact on other targets.
Sylvain BERTRAND [Tue, 24 Oct 2023 18:13:39 +0000 (24 18:13 +0000)]
ELF Relocatable: make undefined global symbol STT_NOTYPE
If undefined global symbols in ELF Relocatable files are not of
type STT_NOTYPE, it will confuse binutils bfd and corrupt product
files.
Petr Skocik [Sun, 8 Oct 2023 16:55:04 +0000 (8 18:55 +0200)]
Support aliasing static global nonfunction objects
Enables code such as:
#undef NDEBUG
#include <assert.h>
#include <stdint.h>
static int st_x = 42;
static int st_x_ __attribute((alias("st_x")));
int main(void){ assert((uintptr_t)&st_x == (uintptr_t)&st_x_); }
which would previously fail with no compiler warnings. The limitation of
this is that the alias must be done (or redone) after an actual definition.
An alias done right after a later overridden tentative declaration won't
work (sufficient for my use case).
Eric Raible [Wed, 4 Oct 2023 05:11:59 +0000 (3 22:11 -0700)]
Produce better error message on malformed while loop
echo "void bugged() { do {} }" | tcc -run -
now produces the sensible: -:1: error: 'while' expected (got "}")
I believe (but am far from sure) that the additional use of &tokc is ok.
Detlef Riekenberg [Sun, 17 Sep 2023 10:15:28 +0000 (17 12:15 +0200)]
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
Sergey Sushilin [Sat, 9 Sep 2023 20:28:45 +0000 (9 23:28 +0300)]
Fix typo in atomic_compare_exchange_weak()
herman ten brugge [Thu, 7 Sep 2023 18:19:42 +0000 (7 20:19 +0200)]
Fix tests/tests2/Makefile for win32
herman ten brugge [Thu, 7 Sep 2023 18:05:51 +0000 (7 20:05 +0200)]
Small fixes
The testcases 22_floating_point and 24_math_library did not work with
make tcov-test
Add -lm for these in tests/tests2/Makefile
gcc -fanalyzer complains about tcc_malloc and tcc_realloc because
malloc(0) and realloc(ptr, 0) is not tested correctly.
grischka [Wed, 6 Sep 2023 20:21:15 +0000 (6 22:21 +0200)]
configury update & bump VERSION to 0.9.28rc
configure:
- option --targetos=... for cross build
- cleanup
win32/build-tcc.bat:
- option -b <bindir>
- make 'libtcc1.a' and cross-prefix-libtcc1.a
(same convention as with makefile)
Makefile:
- streamline tcov-tests, help, etc.
workflow/build.xml: simplify
- using "windows-2019" runner (instead of windows-latest)
because its msys seems more complete and has no problems
with the 96_nodata_wanted.test either.
Changelog,TODO,USES,tcc-doc.texi: update
grischka [Wed, 6 Sep 2023 20:17:03 +0000 (6 22:17 +0200)]
tcc -g1 : small debug info (lines/functions only)
grischka [Sun, 18 Jun 2023 17:58:16 +0000 (18 19:58 +0200)]
win32: pe dwarf sections & option -g.pdb
On windows, create a .pdb file with option "-g.pdb"
Such executables created by tcc can be debugged with
"ollydbg" or "x64dbg"
This currently relies on the 3rd party tool cv2pdb from
https://github.com/rainers/cv2pdb
which again relies on
mspdbsrv.exe mspdbcore.dll msobj80.dll mspdb80.dll
from a MSVC installation.
cv2pdb.exe + the ms* files may be put in the path or in the
same directory as tcc.exe.
grischka [Sat, 3 Jun 2023 19:20:48 +0000 (3 21:20 +0200)]
stuff & fixes
libtcc.c:
- revert "Small patch to allow..." (someone's personal easteregg)
(see
da3a763e977a84edf43c5ca101deae768ae8480d)
- check return value from macho_load_tbd/dylib
tcc.c:
- remove help for "not yet implemented" option
tccelf.c:
- check PIE's for "unresolved symbols"
tccgen.c:
- avoid int->double->int cast
(see
a46372e910710b9b00d4f4122ef6c1b00b2b909c)
- fix constant propagation with pseudo long doubles
(must mask out VT_LONG from type)
- cleanup find_field() (again)
tccpp.c:
- disallow strings and double constants in #if expressions
win32/include/uchar.h:
- change file mode
grischka [Wed, 30 Aug 2023 19:20:13 +0000 (30 21:20 +0200)]
bcheck: remove "tcc_location()" & x86_64 double fix
using (modified) tcc_backtrace() instead.
Also
Also fix the original bug with doubles on x86_64.
(which was not caused by incr_offset() actually).
See
598134fff6a1c85bd048ab307ff91cd24dcfbafd
Also cleanup on_exit() stuff
From
fef701b57fa75f1c387c3e6e8e7ba251a053698f
herman ten brugge [Thu, 31 Aug 2023 09:09:49 +0000 (31 11:09 +0200)]
Add tcov support in Makefile
The following targets are added:
testc / testc2.all / testc2.37 / testc2.37+ / testc2.37-
testcpp.all / make testcpp.17
This allows to check that the testcase(s) test the code modified.
See Makefile tests/pp/Makefile tests/tests2/Makefile
lib/tcov.c: Fix while loops with fgets.
tcc.h: Fix tcc_p compilation with latest gcc
tests/tests2/22_floating_point.*: Better test floating point
herman ten brugge [Wed, 30 Aug 2023 14:44:44 +0000 (30 16:44 +0200)]
Add bound checking for test 132
herman ten brugge [Wed, 30 Aug 2023 14:10:39 +0000 (30 16:10 +0200)]
Undo part of incr_offset patch.
The incr_offset offset code was not working with bounds checking.
So I reverted part of tccgen.c.
See new test code 132.
Also added some debugging code that prints location of
bounds checking calls. Needed this to find the problem.
See lib/bcheck.c, lib/bt-dll.c, lib/bt-exe.c, lib/bt-log.c, tccrun.c
noneofyourbusiness [Thu, 10 Aug 2023 14:19:49 +0000 (10 16:19 +0200)]
riscv64-asm.c: add jal/jalr
this implements the base instructions, not the pseudoinstructions
examples
jal ra, 0
jalr x0, ra, 0
noneofyourbusiness [Thu, 10 Aug 2023 11:27:11 +0000 (10 13:27 +0200)]
riscv64-tok.h: update with more instructions from the spec
defined tokens for C, M, Ziscr extensions.
separate the base RV32 instructions from the RV64, for potential future
re-use in a RV32-only assembler, from which the RV64-tok can #include
scall, sbreak have been renamed (page 7 of spec),
necessitating some renaming in riscv64-asm.c
riscv-spec-
20191213.pdf was used,
in which the "V" extension is not yet ratified.
available under https://riscv.org/technical/specifications/
Tables 16.5–16.7 do not list any "scall"
neither does the privileged spec
3 additional tokens not present in the tables were removed
note that this riscv64-asm.c still contains defects, which will
be addressed in another commit
grischka [Mon, 31 Jul 2023 09:43:15 +0000 (31 11:43 +0200)]
tccgen: update "Fix invalid load generated by gfunc_return()"
tccgen.c:
- new function incr_offset(int) to increment a lvalue
- use it in gv/vstore to load/store from/to two-word types
- use it to advance the pointer to struct fields
- use it to load/store structs passed in registers
- structs: always assume that reg-classes of registers are 2^n
- adjust stack space when regsize > sizeof the_struct
x86_64-gen.c:
- return regsize=16 for VT_QLONG/QFLOAT
i386-gen.c:
- pass structs of size(8) as two VT_INT rather than one VT_LLONG
(both should work now)
fixes
a82aff333774f3bd38841d3c167f1add8c473c1c
fixes
fd6d2180c5c801bb0b4c5dde27d61503059fc97d (slightly)
grischka [Mon, 26 Jun 2023 00:05:27 +0000 (26 02:05 +0200)]
tccpp: #pragma once normalized
In order to detect a "same file" faster, this makes one
restriction to the feature: the basenames are required to
match at least (as in "test.h" and "dir/../test.h")
Also remove obsolete 'pp_once' (cached includes do not persist
across compilations anymore anyway)
This rewrites commits
30fd24abd4e2f4223d75313909cb0c10a9c8e738
4e363a17284eb45de659ab2ca847a179938451d0
3 files changed, 38 insertions(+), 74 deletions(-)
herman ten brugge [Mon, 31 Jul 2023 07:24:06 +0000 (31 09:24 +0200)]
Align stack when returning structs.
The stack was not aligned when a returned structure was stored on stack.
This resulted in destoying of previous values stored on stack.
See testcase 119 (tst_struct_return_align) where value d is overwritten.
herman ten brugge [Wed, 5 Jul 2023 17:28:58 +0000 (5 19:28 +0200)]
Fix test 131 for 32 bits targets
Yao Zi [Sat, 1 Jul 2023 19:58:02 +0000 (2 03:58 +0800)]
Fix invalid load generated by gfunc_return()
On backends that rely on gfunc_return() to handle structures
returned in registers (like RISC-V), gfunc_return() may generate
invalid loads for structures without VT_LOCAL and VT_LVAL. This
commit fixes it and adds a regression test
(131_return_struct_in_reg)
herman ten brugge [Mon, 26 Jun 2023 09:19:41 +0000 (26 11:19 +0200)]
Update pragma once for file operations
Use open/read/close instead of fopen/fread/fclose for tcc4tcl and ziptcc
herman ten brugge [Mon, 26 Jun 2023 04:33:46 +0000 (26 06:33 +0200)]
Small update on pragma once
Update on calc_file_hash. Use xor instead of +.
Only calculate has if file name differs in search_cached_include.
herman ten brugge [Sun, 25 Jun 2023 18:23:58 +0000 (25 20:23 +0200)]
Allow different names for pragma once
pragma once can now be used with
test.h
./test.h
and other references to the same file just like gcc/clang.
On linux we can use stat and st_ino to check for the same file.
On windows the st_ino does not work so we calculate a file hash
if the size of the file differs and then compare the hash.
OldWorldOrdr [Mon, 12 Jun 2023 07:53:05 +0000 (12 03:53 -0400)]
change which to command -v
waltje [Tue, 30 May 2023 00:46:44 +0000 (29 20:46 -0400)]
Update to previous patch (remove the strcpy.)
waltje [Sat, 27 May 2023 00:16:01 +0000 (26 20:16 -0400)]
Small patch to allow for the TCC.EXE (and TCCLIB.DLL) to reside in a (directory under) a "bin/" directory at the same level where the "include/" and "lib/" directories are. This allows one to set the PATH to the (proper) binaries directory and TCC will then "find" itself there. Tested under Windows 7, Windows 8.1 (ARM) and Windows 10+11, but should also be workable for Linux and macOS.
herman ten brugge [Mon, 22 May 2023 13:09:59 +0000 (22 15:09 +0200)]
Add support for constant float compare
grischka [Sun, 12 Mar 2023 10:16:27 +0000 (12 11:16 +0100)]
about CONST_WANTED & VT_NONCONST
- integrate CONST_WANTED with nocode_wanted
- expr_const() checks VT_NONCONST
grischka [Fri, 31 Mar 2023 16:20:49 +0000 (31 18:20 +0200)]
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 ...'
grischka [Mon, 24 Apr 2023 19:58:50 +0000 (24 21:58 +0200)]
CStrings leakless
avoid memory leaks with lost CStrings on stack after errors.
tccpp.c:
- use/abuse static Cstring tokcstr where possible
tccgen.c:
- use/abuse static Cstring initstr where possible
tcc.h/libtcc.a:
- add 'stk_data' array to track memory pointer on stack
- add macros stk_push/pop() and cstr_new/free_s()
tccasm.c:
- use that
- use char[16] instead of char* for op.constraint
grischka [Sat, 15 Apr 2023 14:57:02 +0000 (15 16:57 +0200)]
MEM_DEBUG thread-safe & tccdbg leakless
libtcc.c:
- guard tcc_realloc/free_debug() with a semaphore
tccdbg.c:
- allow tcc_debug_end() to be called twice safely
grischka [Sat, 15 Apr 2023 07:54:23 +0000 (15 09:54 +0200)]
tcc_error_noabort(): always use this unless compiling
This avoids 'exit(1)' with errors outside of compilation
(nasty in particular with libtcc usage)
As a sideeffect multiple errors can be seen for linker
errors (such as undefined symbols, relocation errors, ...)
grischka [Tue, 25 Apr 2023 06:59:42 +0000 (25 08:59 +0200)]
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)
grischka [Thu, 6 Apr 2023 22:45:20 +0000 (7 00:45 +0200)]
tccpp: remove unwanted space with __VA_ARGS__
reported by "vsfos"
https://lists.gnu.org/archive/html/tinycc-devel/2023-04/msg00007.html
herman ten brugge [Sat, 15 Apr 2023 13:36:13 +0000 (15 15:36 +0200)]
Do not crach when compiling with libtcc.
herman ten brugge [Sat, 15 Apr 2023 13:33:14 +0000 (15 15:33 +0200)]
Allow _unaligned and __unaligned on WIN32
Ziyao [Sat, 8 Apr 2023 22:06:10 +0000 (9 06:06 +0800)]
Fix passing of large function arguments on riscv64
- Correct stack adjustment in gfunc_call()
- Add a regression test (130_large_argument)
Detlef Riekenberg [Thu, 23 Mar 2023 19:02:19 +0000 (23 20:02 +0100)]
Print correct values in tcc_print_stats (yarpgen v1)
Value 0 and values >2GB where printed wrong during tests with yarpgen (v1)
Starting the output with a hashtag make it compatible to TAP
--
Regards ... Detlef
Detlef Riekenberg [Thu, 23 Mar 2023 16:14:29 +0000 (23 17:14 +0100)]
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
herman ten brugge [Sat, 18 Mar 2023 13:02:52 +0000 (18 14:02 +0100)]
tests/tcctest.c: Add support for osx with clang 10
Avi Halachmi (:avih) [Sat, 18 Mar 2023 09:02:56 +0000 (18 11:02 +0200)]
configure: OSX/macos: autodetect new_macho value
Use old (=no) if autodetect succeeded and osx ver <= 10, else new.
Override is possible, and now also documented at ./configure --help.
Michael Matz [Mon, 13 Mar 2023 16:01:35 +0000 (13 17:01 +0100)]
Fix 128_run_atexit.c on linux
if we include standard headers on glibc-based systems then
we can't use '__attribute__' (those are defined away for unknown
compilers) but must use '__attribute' (or #undef that token).
grischka [Mon, 6 Mar 2023 01:04:17 +0000 (6 02:04 +0100)]
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)
grischka [Sat, 11 Mar 2023 20:35:12 +0000 (11 21:35 +0100)]
Revert ""Fix" nocode_wanted in expr_landor"
instead in vcheck_cmp(), pass the CODE_OFF_BIT to generators
unless other nocode purposes are set.
This reverts commit
cad873959410ddacfcd1a61d59755adf870dd592.
Also in 128_run_atexit.c:
avoid line output disorder which may happen on windows when
tcc itself and runned code are using two different printf
implementations and tcc would print the "[Returns 1]" above
any output from the runned test.
Detlef Riekenberg [Sat, 11 Mar 2023 13:13:23 +0000 (11 14:13 +0100)]
fix: Do not define INCLUDE_STACK_SIZE twice
We have that define already in tcc.h
and changing the define in tcc.h breaks compilation of tcc
without this fix.
--
Regards ... Detlef
herman ten brugge [Sat, 11 Mar 2023 06:51:00 +0000 (11 07:51 +0100)]
Fix nocode_wanted in expr_landor
The generated code by yarpgen failed. I traced the problem to
expr_landor. The problem was that nocode_wanted was removing
too much code.
See also testcase 33.
herman ten brugge [Sat, 11 Mar 2023 06:40:56 +0000 (11 07:40 +0100)]
Increase VSTACK_SIZE to 512.
The yarpgen test code uses very complex expressions.
herman ten brugge [Sat, 11 Mar 2023 06:35:42 +0000 (11 07:35 +0100)]
Update casted boolean expressions
The problem was that enums can also be present in vset_VT_JMP.
Also see testcode.
Michael Matz [Fri, 10 Mar 2023 16:23:55 +0000 (10 17:23 +0100)]
Fix type of cond-op
the optimization of a ternary op with two boolean operands had
the same problem (as in the last commit) of loosing the type.
Michael Matz [Fri, 10 Mar 2023 15:49:27 +0000 (10 16:49 +0100)]
Fix casted boolean expressions
the casted type was lost when a delayed bool was finally converted
to a value. See testcase, in the wrong case the '(unsigned int)' cast
was ignored, and hence the division was signed reulting in -1 instead of
the proper 0x7fffffff.
herman ten brugge [Fri, 10 Mar 2023 11:41:43 +0000 (10 12:41 +0100)]
Add attribute nodebug support and skip bitfield padding
The following code:
typedef struct {
unsigned int a __attribute__((nodebug));
unsigned int b;
unsigned int : 32;
unsigned int c;
} tst;
Supresses a and also suppresses bitfield padding.
So debugger shows only b and c in above example.
Michael Matz [Thu, 9 Mar 2023 17:18:29 +0000 (9 18:18 +0100)]
Fix more jumpopts (in ternary op)
the code in expr_cond save nocode_wanted around some parts of
expression evaluation, but at the wrong spots. If the evaluation
of the condition itself (e.g. in the testcase the first whole ternary
expression) resulted in CODE_OFF, then that was saved, and restored
before return, even if in-between codegen would have CODE_ON'ed already.
Thus the whole CODE_OFF state bled out to outside the expression
evaluation and also disabled the whole if-block. Found by yarpgen v1
(seed 64).
herman ten brugge [Thu, 9 Mar 2023 15:11:39 +0000 (9 16:11 +0100)]
Fix test90 for 32 bits targets
Should have used 'long long' instead of 'long' for 32 bits targets.
herman ten brugge [Thu, 9 Mar 2023 15:00:46 +0000 (9 16:00 +0100)]
Fix Makefile install target
Update target all before installing
herman ten brugge [Thu, 9 Mar 2023 14:53:48 +0000 (9 15:53 +0100)]
Fix init bitfield padding with size 32/64
The init code did not work for padding bitfields with size 32 and 64.
Michael Matz [Tue, 7 Mar 2023 17:10:02 +0000 (7 18:10 +0100)]
Fix code suppression during nocode_wanted
we activate code (CODE_ON) only when the target labels are used,
which doesn't happen during nocode_wanted regions. So, we cannot
just switch off code either during nocode_wanted regions, nothing
would switch it on again (except in the happy coincidences when we
outright save/restore nocode_wanted). See the testcase for one
example, reduced from code generated by yarpgen: in
ext = (xxx || 1) // #1
|| ((xxx && 1) || 1) // #2
code is first suppressed in #1 normally, then (before this commit)
was suppressed via CODE_OFF during #2 (via indirect gjmp),
then the suppression from #1 was undone, but nothing undoes the
suppression from #2 anymore as everything therein was generated
while nocode_wanted was active.
So, we would either need to save/restore nocode_wanted around
some more expressions, activate CODE_ON also with unused labels (breaks
some optimizations we want), or deactivate CODE_OFF only when not
already in nocode_wanted state. This does the latter.
Petr Skocik [Sun, 5 Mar 2023 21:31:40 +0000 (5 22:31 +0100)]
Create scopes for switches/whiles/do-whiles
The C standard has required this since at least C99.
A new scope should also be created for ifs, but that's currently
breaking tests2/122_vla_reuse.
Brian Callahan [Thu, 23 Feb 2023 22:19:37 +0000 (23 17:19 -0500)]
OpenBSD has removed the syscall() function from its libc, so we
need to use getthrid() directly in lib/bcheck.c
Michael Matz [Wed, 22 Feb 2023 16:59:31 +0000 (22 17:59 +0100)]
Fix sym_scope of typedefs
Sym.sym_scope and Sym.f (FuncAttr) share space, so blindly setting
one clobbers the other. Right now this only leads to missing errors
on incompatible typedefs (see testcase), which this commit fixes.
But it points to a larger problem:
Generally we can only manipulate Sym.f for anonymous and field symbols,
not for anything that has a top-level name (basically any proper decl),
because the latter use sym_scope. Luckily the functions type always
contains an anonymous symbol (in sym->type.ref), so we can use that.
But some of the functions attributes actually _do_ apply to the decl,
not the type (e.g. always_inline), so we still have a problem possibly,
when we update an pre-existing type that may already be shared with
another decl.
Would need untangling and perhaps using accessor functions that check
that Sym.f and Sym.sym_scope aren't used for the same symbol.
Detlef Riekenberg [Fri, 3 Feb 2023 17:04:56 +0000 (3 18:04 +0100)]
Use unsigned int to count sizes for -bench (YARPgen) (part 2)
I have a testfile created by YARPGen (seed=9), which displayed
a negative bss size without this patch.
* tcc needs also a bigger VSTACK_SIZE (i used 512)
--
bye bye ... Detlef
Detlef Riekenberg [Fri, 3 Feb 2023 00:04:38 +0000 (3 01:04 +0100)]
Use unsigned int to count sizes for -bench (YARPgen)
I have a testfile created by YARPGen (seed=9), which displayed
a negative bss size without this patch.
* tcc needs also a bigger VSTACK_SIZE (i used 512)
--
bye bye ... Detlef
herman ten brugge [Tue, 17 Jan 2023 19:08:14 +0000 (17 20:08 +0100)]
Fix preprocessor line directive update
The last commit was not a problem with macos.
The problem was that dwarf version < 5 uses different indexes for
files and directories.
They start at 1 for dwarf version < 5 and 0 for dwarf version >= 5.
Christian Jullien [Tue, 17 Jan 2023 14:29:57 +0000 (17 15:29 +0100)]
Don't forget to mention the amazing job made by Herman on native macOS.
noneofyourbusiness [Tue, 17 Jan 2023 12:35:36 +0000 (17 13:35 +0100)]
update changelog
herman ten brugge [Mon, 16 Jan 2023 19:26:44 +0000 (16 20:26 +0100)]
Fix preprocessor line directive for macos
Macos has an offset of 1 for DW_LNS_set_file.
Also rewrite dwarf_file to not scan list twice and
move check for <command line> to this function.
herman ten brugge [Mon, 16 Jan 2023 07:39:34 +0000 (16 08:39 +0100)]
Fix preprocessor line directive
The preprocessor line directive did not result in correct debug info
when -g was used.
Line directives like:
#line 1 "filename"
should now work.
herman ten brugge [Mon, 16 Jan 2023 07:37:47 +0000 (16 08:37 +0100)]
Allow const expr in builtin_frame_address/builtin_return_address
noneofyourbusiness [Sun, 1 Jan 2023 15:39:14 +0000 (1 16:39 +0100)]
Changelog: get started with the changelog since 0.9.27
noneofyourbusiness [Sun, 1 Jan 2023 15:30:57 +0000 (1 16:30 +0100)]
Makefile: remove unportable -v flag from distclean target
herman ten brugge [Wed, 28 Dec 2022 06:38:39 +0000 (28 07:38 +0100)]
Fix tcc -ar c symbol header size
tcc -ar t failed sometimes because the header size was not correct.
noneofyourbusiness [Wed, 28 Dec 2022 02:07:53 +0000 (28 03:07 +0100)]
tcc -ar: change mode to 644, use ARMAG
Per Nordlöw [Tue, 27 Dec 2022 23:31:14 +0000 (28 00:31 +0100)]
Remove _Static_assert verifying the size of CString because it breaks C99 builds with gcc-5
Per Nordlöw [Tue, 27 Dec 2022 20:50:39 +0000 (27 21:50 +0100)]
Reduce CString memory usage from 3 to two 2 words
herman ten brugge [Tue, 27 Dec 2022 13:11:18 +0000 (27 14:11 +0100)]
Allow parallel build testsuite
herman ten brugge [Tue, 27 Dec 2022 06:45:38 +0000 (27 07:45 +0100)]
Fix problem with large section size.
In tcc_load_object_file use unsigned long for size/offset.
This avoids strange sizes of sections in case of overflow.
The sections that are now larger then 4G may not work.
This avoids a hang on macos in realloc.
noneofyourbusiness [Mon, 26 Dec 2022 00:48:54 +0000 (26 01:48 +0100)]
help: also update main help with tcc -ar options and sort them
Christian Jullien [Sat, 24 Dec 2022 08:30:00 +0000 (24 09:30 +0100)]
Add -Wl,-install_name macOS clang compatible flag as clang refuses -Wl,-soname. This helps configure scripts using both clang and tcc.
herman ten brugge [Fri, 23 Dec 2022 18:48:39 +0000 (23 19:48 +0100)]
Fix multiple rpath tccmacho
If multiple rpaths are specified then output multiple LC_RPATH load
commands instead of one with : seperator.
herman ten brugge [Fri, 23 Dec 2022 11:17:55 +0000 (23 12:17 +0100)]
Update bind problem macho
Changed -1 into -2 for plt_offset,
herman ten brugge [Thu, 22 Dec 2022 19:50:37 +0000 (22 20:50 +0100)]
Fix bind problem macho
The problem occurs when a shared library creates a pointer to
a function and then the application also uses this function.
grischka [Thu, 22 Dec 2022 12:08:36 +0000 (22 13:08 +0100)]
tccgen: better find_field() not found error messages
Also: return all of 'cumofs' (no extra '+' required at caller)
herman ten brugge [Tue, 20 Dec 2022 06:34:41 +0000 (20 07:34 +0100)]
Add tcc -ar x and t options
On macos we cannot use the ar because is does not support elf files
and then does not generate a symbol table.
The solution is to use 'tcc -ar'. The problem now is that some
pacages first built an archive with 'tcc -ar c' and later extracts
the archive with 'tcc -ar x' and built with this a dylib file.
The 'tcc -ar x' failed. So I implemented it. I also added the t
option because it was simple to do,
herman ten brugge [Tue, 20 Dec 2022 06:24:48 +0000 (20 07:24 +0100)]
Add macos clang/ld compiler options
With these option I can now built several packages without problem.
There are a lot of options we can add so I tried to implement the
minumum.
Add the following options:
dynamiclib same as -shared
flat_namespace default/ignored
two_levelnamespace ignored
undefined default/ignored
install_name name of dynmic lib
compatibility_version version dynamic lib
current_version version version dynamic lib
-Wl options:
all_load same as whole-archive
force_load same as whole-archive with lib
single_module ignored
herman ten brugge [Sun, 18 Dec 2022 13:07:19 +0000 (18 14:07 +0100)]
Fix dll support for macho
Export now all global symbols in export trie instead of only text
symbols.
I wrote too much data into dylib file because I did not check
for sk_unknown/sk_discard/sk_uw_info.
Simplified code in tccrun.c
herman ten brugge [Sat, 17 Dec 2022 08:37:37 +0000 (17 09:37 +0100)]
Allow building lib with gcc/clang
Needed when using ...libtcc1-usegcc=yes in lib/Makefile.
lib/bcheck.c: Add __clang__ for pragma diagnostic
lib/bt-log.c: Add pragma diagnostic as in lib/bcheck.c
lib/builtin.c: Add a lot of alias code to allow building with gcc/clang
lib/stdatomic.c: Same as lib/builtin.c
lib/tcov.c: Avoid clang compiler warning
herman ten brugge [Sat, 17 Dec 2022 06:43:01 +0000 (17 07:43 +0100)]
Fix dll support macho for x86_64
Macho uses bind/rebase instead of dynsym so disable them for relocate_sections.
herman ten brugge [Fri, 16 Dec 2022 19:57:45 +0000 (16 20:57 +0100)]
Add dll support for macho
Update configure and remove dll=no for Darwin.
Also removed dwarf=$dwarf because this is not a config option.
In tccelf.c only add __PAGEZERO if stabs and executable.
In tccrun.c correct rt_printline_dwarf code for dll.
In tests/Makefile disable dlltest with PIC for Darwin because object
format of .o file is still in elf.
In tccmacho.c add dll support and and rpath support.
Corrected trie code. For some reason symbol 'xx' should be after 'xx1'.
Corrected weak symbol support for old macho code.
Used R_JMP_SLOT instead of R_DATA_PTR in check_relocs.
Mathias Krause [Tue, 13 Dec 2022 10:34:54 +0000 (13 11:34 +0100)]
x86asm: Add lzcnt/tzcnt support
We already support popcnt, add lzcnt and tzcnt as well.
Signed-off-by: Mathias Krause <minipli@grsecurity.net>
herman ten brugge [Sun, 11 Dec 2022 14:36:37 +0000 (11 15:36 +0100)]
Fix stab debug problem with common section
herman ten brugge [Sun, 11 Dec 2022 07:23:22 +0000 (11 08:23 +0100)]
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.
Petr Skocik [Sat, 10 Dec 2022 00:12:44 +0000 (10 01:12 +0100)]
Allow _Static_assert declarations in structs
This usage has been part of the C grammar since C11
(http://port70.net/~nsz/c/c11/n1570.html#6.7.2.1) and is
also supported by gcc and clang.
herman ten brugge [Tue, 6 Dec 2022 10:21:50 +0000 (6 11:21 +0100)]
Enable vla_test-run on all targets
Fix gen_vla_sp_save/gen_vla_sp_restore in riscv64-gen.c
herman ten brugge [Tue, 6 Dec 2022 07:09:16 +0000 (6 08:09 +0100)]
Enable testcases on apple and x86_64
Christian Jullien [Mon, 5 Dec 2022 15:28:54 +0000 (5 16:28 +0100)]
OSX is used and can't be replaced by macOS yet, revert previous change
Christian Jullien [Mon, 5 Dec 2022 14:42:38 +0000 (5 15:42 +0100)]
cosmetic: OSX is a deprecated name, macOS is the official system name for Apple Operating System since 2016.
Christian Jullien [Mon, 5 Dec 2022 14:22:46 +0000 (5 15:22 +0100)]
on macOS, configure displays the dwarf version used, currently dwarf=4