Skip to content

Commit f57cc34

Browse files
author
grischka
committed
Revert "Fix tcc -run on Windows" (almost)
Oviously what the patch wants is... on Windows, with "tcc c:/dir/xyz.dll -run file"... pass the absolute path of the dll to LoadLibrary() which can make sense in situations. Other changes in the patch to other platfurms seem to have no effect. This reverts 52a9a54 except 2 lines in tccpe.c. Also revert _Float16 patch a06c608 As long as tcc does not really handle _Float16, we can just define it in tccdefs.h. Also move uint128_t to tccdefs.h for same reason. Update github action (might fix random arm64 crashes)
1 parent 5527ca6 commit f57cc34

File tree

9 files changed

+34
-67
lines changed

9 files changed

+34
-67
lines changed

.github/workflows/build.yml

+13-13
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66

77
jobs:
88
test-x86_64-linux:
9-
runs-on: ubuntu-20.04
9+
runs-on: ubuntu-22.04
1010
timeout-minutes: 2
1111
steps:
1212
- uses: actions/checkout@v4
@@ -50,55 +50,55 @@ jobs:
5050
C:\msys64\usr\bin\bash -l -c "./configure && make clean all && make test -k"
5151
5252
test-armv7-linux:
53-
runs-on: ubuntu-20.04
53+
runs-on: ubuntu-22.04
5454
timeout-minutes: 6
5555
steps:
5656
- uses: actions/checkout@v4
57-
- uses: uraimo/run-on-arch-action@v2
57+
- uses: uraimo/run-on-arch-action@v3
5858
name: make & test tcc (armv7-linux)
5959
with:
6060
arch: armv7
61-
distro: ubuntu20.04
61+
distro: ubuntu22.04
6262
githubToken: ${{ github.token }}
6363
install: |
6464
apt-get update -q -y
6565
apt-get install -q -y gcc make
6666
run: |
67-
echo "::endgroup::" && echo "::endgroup::" # missing in 'run-on-arch-action'
67+
echo "::endgroup::" # flatten 'run container'
6868
./configure && make && make test -k
6969
7070
test-aarch64-linux:
71-
runs-on: ubuntu-20.04
71+
runs-on: ubuntu-22.04
7272
timeout-minutes: 6
7373
steps:
7474
- uses: actions/checkout@v4
75-
- uses: uraimo/run-on-arch-action@v2
75+
- uses: uraimo/run-on-arch-action@v3
7676
name: make & test tcc (aarch64-linux)
7777
with:
7878
arch: aarch64
79-
distro: ubuntu20.04
79+
distro: ubuntu22.04
8080
githubToken: ${{ github.token }}
8181
install: |
8282
apt-get update -q -y
8383
apt-get install -q -y gcc make
8484
run: |
85-
echo "::endgroup::" && echo "::endgroup::" # missing in 'run-on-arch-action'
85+
echo "::endgroup::" # flatten 'run container'
8686
./configure && make && make test -k
8787
8888
test-riscv64-linux:
89-
runs-on: ubuntu-20.04
89+
runs-on: ubuntu-22.04
9090
timeout-minutes: 6
9191
steps:
9292
- uses: actions/checkout@v4
93-
- uses: uraimo/run-on-arch-action@v2
93+
- uses: uraimo/run-on-arch-action@v3
9494
name: make & test tcc (riscv64-linux)
9595
with:
9696
arch: riscv64
97-
distro: ubuntu20.04
97+
distro: ubuntu22.04
9898
githubToken: ${{ github.token }}
9999
install: |
100100
apt-get update -q -y
101101
apt-get install -q -y gcc make
102102
run: |
103-
echo "::endgroup::" && echo "::endgroup::" # missing in 'run-on-arch-action'
103+
echo "::endgroup::" # flatten 'run container'
104104
./configure && make && make test -k

include/tccdefs.h

+7
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
#define __FINITE_MATH_ONLY__ 1
126126
#define _FORTIFY_SOURCE 0
127127
//#define __has_builtin(x) 0
128+
#define _Float16 short unsigned int /* fake type just for size & alignment (macOS Sequoia) */
128129

129130
#elif defined __ANDROID__
130131
#define BIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD
@@ -141,6 +142,12 @@
141142
#endif
142143
#define __INT32_TYPE__ int
143144

145+
#if defined __aarch64__
146+
/* GCC's __uint128_t appears in some Linux/OSX header files. Make it a
147+
synonym for long double to get the size and alignment right. */
148+
#define __uint128_t long double
149+
#endif
150+
144151
#if !defined _WIN32
145152
/* glibc defines. We do not support __USER_NAME_PREFIX__ */
146153
#define __REDIRECT(name, proto, alias) name proto __asm__ (#alias)

libtcc.c

+5-10
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ ST_DATA int nb_stk_data;
7878
/* option -d<num> (for general development purposes) */
7979
ST_DATA int g_debug;
8080

81-
8281
/********************************************************/
8382
#ifdef _WIN32
8483
ST_FUNC char *normalize_slashes(char *path)
@@ -964,19 +963,15 @@ LIBTCCAPI int tcc_add_sysinclude_path(TCCState *s, const char *pathname)
964963
}
965964

966965
/* add/update a 'DLLReference', Just find if level == -1 */
967-
ST_FUNC DLLReference *tcc_add_dllref(TCCState *s1, const char *dllpath, int level)
966+
ST_FUNC DLLReference *tcc_add_dllref(TCCState *s1, const char *dllname, int level)
968967
{
969968
DLLReference *ref = NULL;
970969
int i;
971-
const char *dllname = tcc_basename(dllpath);
972-
const char *name;
973-
for (i = 0; i < s1->nb_loaded_dlls; i++) {
974-
name = tcc_basename(s1->loaded_dlls[i]->path);
975-
if (0 == strcmp(name, dllname)) {
970+
for (i = 0; i < s1->nb_loaded_dlls; i++)
971+
if (0 == strcmp(s1->loaded_dlls[i]->name, dllname)) {
976972
ref = s1->loaded_dlls[i];
977973
break;
978974
}
979-
}
980975
if (level == -1)
981976
return ref;
982977
if (ref) {
@@ -985,8 +980,8 @@ ST_FUNC DLLReference *tcc_add_dllref(TCCState *s1, const char *dllpath, int leve
985980
ref->found = 1;
986981
return ref;
987982
}
988-
ref = tcc_mallocz(sizeof(DLLReference) + strlen(dllpath));
989-
strcpy(ref->path, dllpath);
983+
ref = tcc_mallocz(sizeof(DLLReference) + strlen(dllname));
984+
strcpy(ref->name, dllname);
990985
dynarray_add(&s1->loaded_dlls, &s1->nb_loaded_dlls, ref);
991986
ref->level = level;
992987
ref->index = s1->nb_loaded_dlls;

tcc.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ typedef struct DLLReference {
583583
int level;
584584
void *handle;
585585
unsigned char found, index;
586-
char path[1];
586+
char name[1];
587587
} DLLReference;
588588

589589
/* -------------------------------------------------- */
@@ -1293,7 +1293,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int *argc, char ***argv, int optind);
12931293
#ifdef _WIN32
12941294
ST_FUNC char *normalize_slashes(char *path);
12951295
#endif
1296-
ST_FUNC DLLReference *tcc_add_dllref(TCCState *s1, const char *dllpath, int level);
1296+
ST_FUNC DLLReference *tcc_add_dllref(TCCState *s1, const char *dllname, int level);
12971297
ST_FUNC char *tcc_load_text(int fd);
12981298
/* for #pragma once */
12991299
ST_FUNC int normalized_PATHCMP(const char *f1, const char *f2);

tccelf.c

+4-13
Original file line numberDiff line numberDiff line change
@@ -1056,25 +1056,16 @@ ST_FUNC void relocate_syms(TCCState *s1, Section *symtab, int do_resolve)
10561056
name = (char *) s1->symtab->link->data + sym->st_name;
10571057
/* Use ld.so to resolve symbol for us (for tcc -run) */
10581058
if (do_resolve) {
1059-
void *addr = NULL;
1060-
#if defined(TCC_IS_NATIVE)
1061-
#if defined(TCC_TARGET_PE)
1062-
int i;
1063-
for (i = 0; i < s1->nb_loaded_dlls; i++) {
1064-
if ((addr = GetProcAddress(s1->loaded_dlls[i]->handle, name)))
1065-
break;
1066-
}
1067-
#else
1059+
#if defined TCC_IS_NATIVE && !defined TCC_TARGET_PE
10681060
/* dlsym() needs the undecorated name. */
1069-
addr = dlsym(RTLD_DEFAULT, &name[s1->leading_underscore]);
1061+
void *addr = dlsym(RTLD_DEFAULT, &name[s1->leading_underscore]);
10701062
#if TARGETOS_OpenBSD || TARGETOS_FreeBSD || TARGETOS_NetBSD || TARGETOS_ANDROID
10711063
if (addr == NULL) {
10721064
int i;
10731065
for (i = 0; i < s1->nb_loaded_dlls; i++)
10741066
if ((addr = dlsym(s1->loaded_dlls[i]->handle, name)))
10751067
break;
10761068
}
1077-
#endif
10781069
#endif
10791070
if (addr) {
10801071
sym->st_value = (addr_t) addr;
@@ -2910,7 +2901,7 @@ static int elf_output_file(TCCState *s1, const char *filename)
29102901
for(i = 0; i < s1->nb_loaded_dlls; i++) {
29112902
DLLReference *dllref = s1->loaded_dlls[i];
29122903
if (dllref->level == 0)
2913-
put_dt(dynamic, DT_NEEDED, put_elf_str(dynstr, tcc_basename(dllref->path)));
2904+
put_dt(dynamic, DT_NEEDED, put_elf_str(dynstr, dllref->name));
29142905
}
29152906

29162907
if (s1->rpath)
@@ -3732,7 +3723,7 @@ ST_FUNC int tcc_load_dll(TCCState *s1, int fd, const char *filename, int level)
37323723
soname = dynstr + dt->d_un.d_val;
37333724

37343725
/* if the dll is already loaded, do not load it */
3735-
if (tcc_add_dllref(s1, filename, level)->found)
3726+
if (tcc_add_dllref(s1, soname, level)->found)
37363727
goto ret_success;
37373728

37383729
if (v.nb_versyms != nb_syms)

tccgen.c

-15
Original file line numberDiff line numberDiff line change
@@ -4696,29 +4696,14 @@ static int parse_btype(CType *type, AttributeDef *ad, int ignore_label)
46964696
}
46974697
next();
46984698
break;
4699-
#ifdef TCC_TARGET_ARM64
4700-
case TOK_UINT128:
4701-
/* GCC's __uint128_t appears in some Linux header files. Make it a
4702-
synonym for long double to get the size and alignment right. */
4703-
u = VT_LDOUBLE;
4704-
goto basic_type;
4705-
#endif
47064699
case TOK_BOOL:
47074700
u = VT_BOOL;
47084701
goto basic_type;
47094702
case TOK_COMPLEX:
47104703
tcc_error("_Complex is not yet supported");
47114704
case TOK_FLOAT:
4712-
/* macOS SDK uses it in math.h
4713-
fake the size and alignment
4714-
*/
47154705
u = VT_FLOAT;
4716-
/* tcc_warning("_Float16 is not yet supported. Skipped.");
4717-
I hope no one really uses it in the wild. */
47184706
goto basic_type;
4719-
case TOK_FLOAT16:
4720-
u = VT_SHORT;
4721-
47224707
case TOK_DOUBLE:
47234708
if ((t & (VT_BTYPE|VT_LONG)) == VT_LONG) {
47244709
t = (t & ~(VT_BTYPE|VT_LONG)) | VT_LDOUBLE;

tccmacho.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@ static void collect_sections(TCCState *s1, struct macho *mo, const char *filenam
17701770
for(i = 0; i < s1->nb_loaded_dlls; i++) {
17711771
DLLReference *dllref = s1->loaded_dlls[i];
17721772
if (dllref->level == 0)
1773-
add_dylib(mo, tcc_basename(dllref->path));
1773+
add_dylib(mo, dllref->name);
17741774
}
17751775

17761776
if (s1->rpath) {

tccpe.c

+2-4
Original file line numberDiff line numberDiff line change
@@ -848,9 +848,7 @@ static void pe_build_imports(struct pe_info *pe)
848848

849849
dllindex = p->dll_index;
850850
if (dllindex)
851-
name = tcc_basename(
852-
(dllref = pe->s1->loaded_dlls[dllindex-1])
853-
->path);
851+
name = tcc_basename((dllref = pe->s1->loaded_dlls[dllindex-1])->name);
854852
else
855853
name = "", dllref = NULL;
856854

@@ -886,7 +884,7 @@ static void pe_build_imports(struct pe_info *pe)
886884
if (pe->type == PE_RUN) {
887885
if (dllref) {
888886
if ( !dllref->handle )
889-
dllref->handle = LoadLibraryA(dllref->path);
887+
dllref->handle = LoadLibraryA(dllref->name);
890888
v = (ADDR3264)GetProcAddress(dllref->handle, ordinal?(char*)0+ordinal:name);
891889
}
892890
if (!v)

tcctok.h

-9
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,6 @@
6767
DEF(TOK_TYPEOF2, "__typeof")
6868
DEF(TOK_TYPEOF3, "__typeof__")
6969
DEF(TOK_LABEL, "__label__")
70-
DEF(TOK_FLOAT16, "_Float16")
71-
72-
#ifdef TCC_TARGET_ARM64
73-
DEF(TOK_UINT128, "__uint128_t")
74-
#endif
7570

7671
/*********************************************************************/
7772
/* the following are not keywords. They are included to ease parsing */
@@ -106,10 +101,6 @@
106101
DEF(TOK___NAN__, "__nan__")
107102
DEF(TOK___SNAN__, "__snan__")
108103
DEF(TOK___INF__, "__inf__")
109-
#if defined TCC_TARGET_X86_64
110-
DEF(TOK___mzerosf, "__mzerosf") /* -0.0 */
111-
DEF(TOK___mzerodf, "__mzerodf") /* -0.0 */
112-
#endif
113104

114105
/* attribute identifiers */
115106
/* XXX: handle all tokens generically since speed is not critical */

0 commit comments

Comments
 (0)