herman ten brugge
5a370d8a6b
Relocation updates
...
build and test / test-x86_64-linux (push) Waiting to run
build and test / test-x86_64-osx (push) Waiting to run
build and test / test-aarch64-osx (push) Waiting to run
build and test / test-x86_64-win32 (push) Waiting to run
build and test / test-i386-win32 (push) Waiting to run
build and test / test-armv7-linux (push) Waiting to run
build and test / test-aarch64-linux (push) Waiting to run
build and test / test-riscv64-linux (push) Waiting to run
x86_64-link.c:
Check relocations R_X86_64_32/R_X86_64_32S. These relocations
can become to large if not configured with '--disable-static'
or '--config-pie' and code is run with -run -ltcc.
This only happens on x86_64.
tccdbg.c:
1) Add some .debug (dummy) sections when dwarf is used. These
sections are otherwise not relocated correctly for R_DATA_32DW.
2) Fix stab problem when reloc is applied twice.
2025-12-23 06:46:22 +01:00
herman ten brugge
64cf0b816b
undo x86_64-link.c commmit
...
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
The relocation check does not work with stabs enabled on some targets.
It works fine on fedora with and without stabs.
So remove check.
2025-12-21 18:49:21 +01:00
herman ten brugge
96119149fe
Problems solved on for libtcc, pie, riscv64, arm64
...
build and test / test-x86_64-linux (push) Waiting to run
build and test / test-x86_64-osx (push) Waiting to run
build and test / test-aarch64-osx (push) Waiting to run
build and test / test-x86_64-win32 (push) Waiting to run
build and test / test-i386-win32 (push) Waiting to run
build and test / test-armv7-linux (push) Waiting to run
build and test / test-aarch64-linux (push) Waiting to run
build and test / test-riscv64-linux (push) Waiting to run
I found some problems with a testcase from mailing list.
On x86_64 an overflow on reloc R_X86_64_32 occurred that was
not reported when using -run -ltcc.
The problem could be solved by compiling tcc with -fPIE, -pie
or --disable-static.
Makefile, configure, libtcc.c, x86_64-link.c:
- add --config-pie to configure help. Ignore -pie in libtcc.c
and check reloc overflow in x86_64-link.c
arm64-gen.c:
- Fix reading from constant like '*(int *)0x7fffb7f1280c'
elf.h, riscv64-link.c:
- fix for -run -ltcc. Ignore reloc R_RISCV_SET_ULEB128 and
R_RISCV_SUB_ULEB128 that are used in .debug_loclists section.
2025-12-21 07:05:55 +01:00
herman ten brugge
34eed88a70
Small updates
...
build and test / test-x86_64-linux (push) Waiting to run
build and test / test-x86_64-osx (push) Waiting to run
build and test / test-aarch64-osx (push) Waiting to run
build and test / test-x86_64-win32 (push) Waiting to run
build and test / test-i386-win32 (push) Waiting to run
build and test / test-armv7-linux (push) Waiting to run
build and test / test-aarch64-linux (push) Waiting to run
build and test / test-riscv64-linux (push) Waiting to run
Allow 'make speedtest' in tests directory
Fix compiler warning tccpp.c
2025-12-17 20:22:08 +01:00
herman ten brugge
3c18df610d
Fix clang macos 15 bug on arm64 in tests/tcctest.c
2025-12-17 19:54:22 +01:00
herman ten brugge
f3de8b5307
Use macos 15 in build.yml
2025-12-17 18:21:01 +01:00
herman ten brugge
8569427459
Move -run -nostdlib code to lib directory
...
tcc.h, arm-gen.c, arm64-gen.c, i386-gen.c, riscv64-gen.c, x86_64-gen.c:
- remove old code
tccrun.c:
- update to use lib/run_nostdlib.c
Makefile, lib/Makefile, lib/run_nostdlib.c:
- new code
tests/nostdlib_test.c:
- testcode
2025-12-15 14:45:11 +01:00
Stefan
829c848520
tccpp.c: Configurable integer literal overflow handling
...
Add the define TCC_CUT_ON_INTEGER_LITERAL_OVERFLOW to use the most
significant digits of an integer literal before its parsing led to an
overflow.
When compiling tcc with another compiler, which is not able to handle
64 bit arithmetic, it is beneficial to use the last value before an
integer literal overflows. Parsing 0x1000000000000000 then results in
0x10000000. The mescc from GNU Mes is able to compile a first tcc on a
32 bit system without 64 bit arithmetic. This change allows this first
tcc to compile a second tcc with complete 64 bit arithmetic.
2025-12-13 18:53:15 +01:00
Aleksi Hannula
cb41cbfe71
x86-64: Fix cvts*2si
...
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
Co-authored-by: Herman ten Brugge <hermantenbrugge@home.nl>
2025-12-03 17:21:00 +02:00
Reini Urban
831c3fa184
github CI: pinact run -u
...
for security
2025-12-02 16:31:13 +01:00
Aleksi Hannula
0fcd46f364
rv64: Generate VT_CMP output from float comparison
2025-12-02 07:30:31 +02:00
Aleksi Hannula
b4569233cb
Set TYPE_PARAM parsing mode in old-style param lists
2025-12-02 07:30:27 +02:00
herman ten brugge
f5f544f436
allow cross compiling for alloca on arm64
2025-12-01 18:09:04 +01:00
Aleksi Hannula
7479a5c21a
elf: Set ph sizes only if ph was allocated
2025-11-29 22:28:36 +02:00
Aleksi Hannula
78e5e690a2
rv64: Implement some pseudo-ops from Zicsr
2025-11-29 21:11:46 +02:00
herman ten brugge
6da45946ae
Add bound check support for alloca on all targets
...
stddef.h, tccdefs.h, tccgen.c, tests/boundtest.c, tests/tcctest.c:
- remove ifdef arround alloca
lib/Makefile:
- move alloca-bt.o to COMMON_O
lib/alloca-bt.S:
- add alloca bound check code for arm, arm64, riscv64
lib/alloca.S:
- check for leading underscore
tcc.h, libtcc.c:
- include arm64-asm.c instead of arm-asm.c for arm64
tcctok.h, tccasm.c:
- add simple reloc support (only for R_AARCH64_CALL26)
2025-11-29 07:54:28 +01:00
Aleksi Hannula
fc424c9f7b
Reorder "pure" attribute
...
Placing the definition of "pure" prior to TOK_DEFINE would cause it to
be treated as a keyword by tccgen. This breaks building gcc, in which
"pure" is used as a struct field name.
2025-11-28 16:07:24 +02:00
Aleksi Hannula
5b96aeb7fc
Implement some SSE/2 instructions
...
This patch implements some instructions required by musl 1.1.24.
2025-11-28 15:23:09 +02:00
Aleksi Hannula
06e24e7eed
Implement some RV64F/D instructions
...
This patch implements some instructions required by musl 1.1.24.
2025-11-28 15:23:07 +02:00
Aleksi Hannula
3c631fdb6d
Implement alloca for RV64
2025-11-28 15:17:06 +02:00
Aleksi Hannula
e7be7b192d
Simplify RV64 function epilogue
...
Previous sp can be computed based from only frame pointer and short
offset. ra and s0 can be restored from stack with constant fp offset.
2025-11-28 15:17:06 +02:00
H-language
3327327e5d
Add WM_MOUSEHWHEEL to winuser.h
2025-11-26 11:10:10 +13:00
herman ten brugge
7e4fc3a0d0
Fix alloca for arm
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
2025-11-19 11:20:50 +01:00
kbkpbot
264229a0d4
Add arm64 alloca() support.
2025-11-19 17:17:05 +08:00
herman ten brugge
fa6a6bfbbd
Move lib/va_list.c into include/tccdefs.h
...
This makes code with va_arg work with -nostdlib on x86_64.
2025-11-19 08:31:15 +01:00
herman ten brugge
3e8f1da9c5
Change asm into __asm__ in previous commit
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
2025-11-17 19:17:53 +01:00
herman ten brugge
c52b96cf85
Allow -nostdlib -run
...
build and test / test-x86_64-linux (push) Waiting to run
build and test / test-x86_64-osx (push) Waiting to run
build and test / test-aarch64-osx (push) Waiting to run
build and test / test-x86_64-win32 (push) Waiting to run
build and test / test-i386-win32 (push) Waiting to run
build and test / test-armv7-linux (push) Waiting to run
build and test / test-aarch64-linux (push) Waiting to run
build and test / test-riscv64-linux (push) Waiting to run
The -run option did not support -nostdlib correctly.
The argc/argc/envp are now passed on stack according to sysv.
This implementation does not work for TCC_TARGET_PE.
Also arm64 does not work when running tcc compiled with itself.
This is because arm64 assembly is not implemented yet.
The following test code is used to check the code:
#include <unistd.h>
#include <sys/syscall.h>
void _start() {
syscall(SYS_write, 1, "hello world\n", 12);
syscall(SYS_exit, 0);
}
Run this with:
./tcc -nostdlib -lc -run a.c
make tcc_c
./tcc_c -nostdlib -lc -run a.c
2025-11-17 14:00:15 +01:00
DFP
d9ec17d334
Relaxed the 'incompatible pointer type' warning a bit
...
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
Do not emit that warning when the source struct (recursively) contains destination struct as the first member. For example, in this case the warning would have been emitted before, and is not anymore:
struct base {
int a;
};
struct derived {
struct base base;
int b;
};
struct derived derived;
struct base *base = &derived;
I personally use that pattern in my code (in a bit more elaborate form) and so this change removes the warnings for those use cases, while still retaining it for everything else. Feel free to CC me on the mailing list if you have questions, suggestions or complaints.
2025-11-14 08:55:55 +01:00
herman ten brugge
ab2ce3b13a
Ignore some more attributes
...
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
Detected when using -Wunsupported
2025-11-04 15:03:19 +01:00
Detlef Riekenberg
cdebce3079
tccpp: Add the define __STDC_HOSTED__ [C99]
...
build and test / test-x86_64-linux (push) Waiting to run
build and test / test-x86_64-osx (push) Waiting to run
build and test / test-aarch64-osx (push) Waiting to run
build and test / test-x86_64-win32 (push) Waiting to run
build and test / test-i386-win32 (push) Waiting to run
build and test / test-armv7-linux (push) Waiting to run
build and test / test-aarch64-linux (push) Waiting to run
build and test / test-riscv64-linux (push) Waiting to run
Usually defined to 1, but when using "-nostdlib", the value is 0
(required for C99)
--
Regards ... Detlef
2025-11-01 18:11:49 +01:00
Avi Halachmi (:avih)
f4e01bfcab
tcc -run: support custom stdin with -rstdin FILE
...
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
When tcc -run is used with input file from stdin, then run_main's
stdin (which is tcc's stdin) is already EOF after we've read it.
If the program operates exclusively on stdin, then it cannot be used.
This commit adds an option -rstdin FILE which sets run_main's stdin.
Can also be used in such case to set run_main's stdin to the tty,
using -rstdin /dev/tty (posix) or -rstdin con (windows).
2025-10-27 14:50:56 +02:00
Avi Halachmi (:avih)
234e2dd2bf
tcc options: document behavior and clashes (no-op)
...
The tcc options behavior is non trivial, and it's also susceptible
to ambiguities - which do exist (but currently are not painful).
- Add a script 'optclash' which detects clashes/ambiguities.
- Document the parsing behaviour and current clashes/resolutions
as comments in libtcc.c .
2025-10-27 14:50:54 +02:00
Aleksi Hannula
01d1b7bc76
Add support for f{l,s}d in riscv64-gen
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
2025-10-17 15:40:08 +03:00
herman ten brugge
19589288cb
Some fixes and cleanups
...
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
tcc.h, tccgen.c:
Add and use IS_BT_ARRAY
tccpp.c:
free memory when size is 0 in realloc code
tccdbg.c:
move common code to seperate function remove_type_info
2025-10-16 07:35:27 +02:00
herman ten brugge
edcd228214
Init global_expr variable
...
build and test / test-x86_64-linux (push) Waiting to run
build and test / test-x86_64-osx (push) Waiting to run
build and test / test-aarch64-osx (push) Waiting to run
build and test / test-x86_64-win32 (push) Waiting to run
build and test / test-i386-win32 (push) Waiting to run
build and test / test-armv7-linux (push) Waiting to run
build and test / test-aarch64-linux (push) Waiting to run
build and test / test-riscv64-linux (push) Waiting to run
This is needed when errors occur when compiling with libtcc.
A next compile with libtcc results in undefined symbol.
2025-10-15 10:02:09 +02:00
herman ten brugge
96229004c4
Fix debugging after commit tccgen: more of scope hacks
...
The commit added some extra defines that where not
handled in debugging code.
2025-10-15 09:01:54 +02:00
herman ten brugge
c96f0cad61
Free all preprocessor memmory in case of error.
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
2025-10-13 15:57:31 +02:00
grischka
34b45a69ff
Reverts & cleanups
...
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
- include/stddef.h, tcctest.c
Revert "tests/tcctest.c: include stdint.h"
This reverts commit 8f23997ca7
We don't want tcctest.c to rely on system include files
- libtcc.c:
Revert "libtcc.c: Remove unused defines free and realloc"
To be unused is the point why they do exist
This reverts commit 2f88764100 .
- tcc.c:
fix formatting of commit e73529865d
- tccpp.c:
parse_include(): print skipped include files too (with tcc -vv[v] file)
next_nomacro(): faster L"str" parsing
- tccgen.c: fix c2y if declaration:
* accept like GCC: if (int a = 0, b, c = x; c)
* accept as "TCC extension": if (int a = 0, b, c = x)
* "speak tcc" with symbol/function names
- README:
cleanup
2025-10-09 13:08:33 +02:00
herman ten brugge
ce8b3432bf
Allow gcc 16 for build
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
2025-10-07 14:32:13 +02:00
Stefan
bcfb872fd0
Makefile: Add space behind 'install -m'
...
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
There are install shell scripts around, often derived from X11 like
contained in glibc or Gash sources, which require to separate -m from
its value. Therefore add a space behind 'install -m' in the Makefile.
2025-10-03 17:58:45 +02:00
Stefan
ba0899d909
tccasm.c: Make .init and .fini sections executable
...
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
GAS selects default attributes for a section based on its name and makes
the sections .text, .init, .fini executable. The crti.s and crtn.s files
of musl rely on these defaults and don't set the "x" flag for the .init
and .fini sections. Unfortunately TCC does not care for .init and .fini
section defaults in assembler or C code. Fix this for assembler code.
2025-09-21 14:06:59 +02:00
Stefan
2f88764100
libtcc.c: Remove unused defines free and realloc
...
These defines are not used in the code below their definition. They are
defined in tcc.h as well.
2025-09-21 13:30:15 +02:00
Stefan
95d184cba1
i386-asm.c: Optional % for variables in specific registers
...
Handle 'register long r10 __asm__("%r10")' without %, too. Using GCC
the % is optional. The musl source code does not use the % prefix.
The GCC source code uses both variants.
2025-09-21 13:18:37 +02:00
Stefan
5aebf106e8
i386-asm.c: Use NB_ASM_REGS instead of 8
...
For x86_64 there are more than just 8 registers.
2025-09-21 12:21:27 +02:00
Stefan
9dc59f9c23
i386-asm.c: Do bit-check for OP_SEG in asm_opcode
...
Fix a bug with "call *%%gs:16", which sets the two flags OP_INDIR and
OP_SEG in pop->type.
2025-09-21 12:18:11 +02:00
grischka
de8c19e1da
tccgen: globalize function return type too
...
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
Commit 38ab5f65b3 was missing
to move the function return type to the global stack too.
Also, check redefinition in sym_push(), as before.
2025-09-18 19:32:19 +02:00
noneofyourbusiness
47106ce103
tccgen.c: silence logical op warning
...
build and test / test-x86_64-linux (push) Waiting to run
build and test / test-x86_64-osx (push) Waiting to run
build and test / test-aarch64-osx (push) Waiting to run
build and test / test-x86_64-win32 (push) Waiting to run
build and test / test-i386-win32 (push) Waiting to run
build and test / test-armv7-linux (push) Waiting to run
build and test / test-aarch64-linux (push) Waiting to run
build and test / test-riscv64-linux (push) Waiting to run
behavior is unchanged
2025-09-18 11:42:58 +02:00
noneofyourbusiness
8f23997ca7
tests/tcctest.c: include stdint.h
...
despite being defined in tcc's own stddef.h, intended to be included by
libtcc.h, libtcc.h actually included the libc's standard include
tested on musl
2025-09-18 11:17:55 +02:00
noneofyourbusiness
e73529865d
tcc.c: add information about reporting bugs to the mailing list
2025-09-18 09:58:21 +02:00
grischka
38ab5f65b3
tccgen: more of scope hacks
...
build and test / test-x86_64-linux (push) Has been cancelled
build and test / test-x86_64-osx (push) Has been cancelled
build and test / test-aarch64-osx (push) Has been cancelled
build and test / test-x86_64-win32 (push) Has been cancelled
build and test / test-i386-win32 (push) Has been cancelled
build and test / test-armv7-linux (push) Has been cancelled
build and test / test-aarch64-linux (push) Has been cancelled
build and test / test-riscv64-linux (push) Has been cancelled
* case 1: local scope of 'ff'
int main() {
int ff = 123;
{
int ff(int):
ff(456)
}}
* case 2: linkage of a static extern symbol
(older gcc did allow that)
static int ff(int);
int main() {
int ff(int):
ff(456)
}
Also:
- cleanup enum, let sym_push() handle redefinition
- just mark incomplete array base types, unshare only
when needed (in decl_initializer_alloc())
- fix sizeof empty array (= 0) : int ii[] = {};
- rename 'Sym' members used by __attribute__((cleanup(f)))
2025-09-08 17:23:18 +02:00