Skip to content

Commit 8e2ba0e

Browse files
committed
Merge remote-tracking branch 'upstream/mob'
2 parents 394937f + 9670d10 commit 8e2ba0e

20 files changed

+838
-620
lines changed

.github/workflows/build.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,25 +29,37 @@ jobs:
2929
- name: make & test tcc (aarch64-osx)
3030
run: ./configure && make && make test -k
3131

32-
test-x86-win32:
33-
runs-on: windows-2019
34-
timeout-minutes: 6
32+
test-x86_64-win32:
33+
runs-on: windows-2025
34+
timeout-minutes: 4
3535
steps:
3636
- uses: actions/checkout@v4
3737
- name: make & test tcc (x86_64-win32)
3838
shell: cmd
3939
run: |
40+
echo ::group:: setup msys mingw64-gcc
4041
set MSYS2_PATH_TYPE=inherit
4142
set MSYSTEM=MINGW64
4243
set CHERE_INVOKING=yes
44+
C:\msys64\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-x86_64-gcc"
45+
echo ::endgroup::
4346
C:\msys64\usr\bin\bash -l -c "./configure && make && make test -k"
47+
48+
test-i386-win32:
49+
runs-on: windows-2025
50+
timeout-minutes: 4
51+
steps:
52+
- uses: actions/checkout@v4
4453
- name: make & test tcc (i386-win32)
4554
shell: cmd
4655
run: |
56+
echo ::group:: setup msys mingw32-gcc
4757
set MSYS2_PATH_TYPE=inherit
4858
set MSYSTEM=MINGW32
4959
set CHERE_INVOKING=yes
50-
C:\msys64\usr\bin\bash -l -c "./configure && make clean all && make test -k"
60+
C:\msys64\usr\bin\bash -l -c "pacman -S --noconfirm mingw-w64-i686-gcc"
61+
echo ::endgroup::
62+
C:\msys64\usr\bin\bash -l -c "./configure && make all && make test -k"
5163
5264
test-x86_64-centos:
5365
runs-on: ubuntu-latest
@@ -70,7 +82,7 @@ jobs:
7082
7183
test-armv7-linux:
7284
runs-on: ubuntu-22.04
73-
timeout-minutes: 6
85+
timeout-minutes: 8
7486
steps:
7587
- uses: actions/checkout@v4
7688
- uses: uraimo/run-on-arch-action@v3
@@ -88,14 +100,14 @@ jobs:
88100
89101
test-aarch64-linux:
90102
runs-on: ubuntu-22.04
91-
timeout-minutes: 6
103+
timeout-minutes: 8
92104
steps:
93105
- uses: actions/checkout@v4
94106
- uses: uraimo/run-on-arch-action@v3
95107
name: make & test tcc (aarch64-linux)
96108
with:
97109
arch: aarch64
98-
distro: ubuntu22.04
110+
distro: ubuntu24.04
99111
githubToken: ${{ github.token }}
100112
install: |
101113
apt-get update -q -y
@@ -106,7 +118,7 @@ jobs:
106118
107119
test-riscv64-linux:
108120
runs-on: ubuntu-22.04
109-
timeout-minutes: 6
121+
timeout-minutes: 8
110122
steps:
111123
- uses: actions/checkout@v4
112124
- uses: uraimo/run-on-arch-action@v3

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,11 @@ LDFLAGS += -g
252252
endif
253253

254254
# convert "include/tccdefs.h" to "tccdefs_.h"
255-
%_.h : include/%.h conftest.c
256-
$S$(CC) -DC2STR $(filter %.c,$^) -o c2str.exe && ./c2str.exe $< $@
255+
%_.h : include/%.h c2str.exe
256+
$S./c2str.exe $< $@
257+
258+
c2str.exe : conftest.c
259+
$S$(CC) -DC2STR $< -o $@
257260

258261
# target specific object rule
259262
$(X)%.o : %.c $(LIBTCC_INC)

arm-gen.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,10 +1311,6 @@ static int copy_params(int nb_args, struct plan *plan, int todo)
13111311
if (++pass < 2)
13121312
goto again;
13131313

1314-
/* Manually free remaining registers since next parameters are loaded
1315-
* manually, without the help of gv(int). */
1316-
save_regs(nb_args);
1317-
13181314
if(todo) {
13191315
o(0xE8BD0000|todo); /* pop {todo} */
13201316
for(pplan = plan->clsplans[CORE_STRUCT_CLASS]; pplan; pplan = pplan->prev) {
@@ -1354,6 +1350,8 @@ void gfunc_call(int nb_args)
13541350
gbound_args(nb_args);
13551351
#endif
13561352

1353+
save_regs(nb_args + 1);
1354+
13571355
#ifdef TCC_ARM_EABI
13581356
if (float_abi == ARM_HARD_FLOAT) {
13591357
variadic = (vtop[-nb_args].type.ref->f.func_type == FUNC_ELLIPSIS);

arm64-gen.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,8 @@ ST_FUNC void gfunc_call(int nb_args)
997997
int variadic = (vtop[-nb_args].type.ref->f.func_type == FUNC_ELLIPSIS);
998998
int var_nb_arg = n_func_args(&vtop[-nb_args].type);
999999

1000+
save_regs(nb_args + 1);
1001+
10001002
#ifdef CONFIG_TCC_BCHECK
10011003
if (tcc_state->do_bounds_check)
10021004
gbound_args(nb_args);
@@ -1101,9 +1103,6 @@ ST_FUNC void gfunc_call(int nb_args)
11011103
// value in floating-point registers
11021104
if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) {
11031105
uint32_t j, sz, n = arm64_hfa(&vtop->type, &sz);
1104-
// save regs because struct may overwrite previous func call result
1105-
save_regs(0);
1106-
11071106
vtop->type.t = VT_PTR;
11081107
gaddrof();
11091108
gv(RC_R30);
@@ -1129,7 +1128,6 @@ ST_FUNC void gfunc_call(int nb_args)
11291128
vswap();
11301129
}
11311130

1132-
save_regs(0);
11331131
arm64_gen_bl_or_b(0);
11341132
--vtop;
11351133
if (stack & 0xfff)

i386-asm.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,21 +1002,24 @@ ST_FUNC void asm_opcode(TCCState *s1, int opcode)
10021002
modrm_index = -1;
10031003
modreg_index = -1;
10041004
if (pa->instr_type & OPC_MODRM) {
1005-
#ifdef TCC_TARGET_X86_64
10061005
if (!nb_ops) {
10071006
/* A modrm opcode without operands is a special case (e.g. mfence).
10081007
It has a group and acts as if there's an register operand 0 */
10091008
i = 0;
10101009
ops[i].type = OP_REG;
1010+
#ifdef TCC_TARGET_X86_64
10111011
if (pa->sym == TOK_ASM_endbr64)
10121012
ops[i].reg = 2; // dx
10131013
else if (pa->sym >= TOK_ASM_lfence && pa->sym <= TOK_ASM_sfence)
10141014
ops[i].reg = 0; // ax
1015+
#else
1016+
if (pa->sym == TOK_ASM_endbr32)
1017+
ops[i].reg = 3; // bx
1018+
#endif
10151019
else
10161020
tcc_error("bad MODR/M opcode without operands");
10171021
goto modrm_found;
10181022
}
1019-
#endif
10201023
/* first look for an ea operand */
10211024
for(i = 0;i < nb_ops; i++) {
10221025
if (op_type[i] & OP_EA)

i386-asm.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@
3737
DEF_ASM_OP0(pause, 0xf390)
3838
DEF_ASM_OP0(xlat, 0xd7)
3939

40-
/* strings */
40+
/* Control-Flow Enforcement */
41+
DEF_ASM_OP0L(endbr32, 0xf30f1e, 7, OPC_MODRM)
42+
43+
/* strings */
4144
ALT(DEF_ASM_OP0L(cmpsb, 0xa6, 0, OPC_BWLX))
4245
ALT(DEF_ASM_OP0L(scmpb, 0xa6, 0, OPC_BWLX))
4346

i386-gen.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ ST_FUNC void gfunc_call(int nb_args)
406406
gbound_args(nb_args);
407407
#endif
408408

409+
save_regs(nb_args + 1);
410+
409411
args_size = 0;
410412
for(i = 0;i < nb_args; i++) {
411413
if ((vtop->type.t & VT_BTYPE) == VT_STRUCT) {
@@ -463,7 +465,7 @@ ST_FUNC void gfunc_call(int nb_args)
463465
}
464466
vtop--;
465467
}
466-
save_regs(0); /* save used temporary registers */
468+
467469
func_sym = vtop->type.ref;
468470
func_call = func_sym->f.func_call;
469471
/* fast call case */

0 commit comments

Comments
 (0)