History

tcc/lib: reduce number of files

271 insertions(+), 292 deletions(-), -21 lines, -5 files Also: - tccdefs.h: WIN32: less (no) __builtins - libtcc.c: simply ignore -arch

grischka committed 5 years ago

Commit 675046b1 parent e53816016 files · +271 −292Browse files

Unified · Split

16 files
  1. include/tccdefs.h +6 −0
  2. lib/Makefile +5 −5
  3. lib/alloca-arm.S +0 −10
  4. lib/alloca-bt.S +46 −1
  5. lib/alloca.S +85 −0
  6. lib/alloca86-bt.S +0 −52
  7. lib/alloca86.S +0 −36
  8. lib/alloca86_64.S +0 −38
  9. lib/fetch_and_add.S +67 −0
  10. lib/fetch_and_add_arm.S +0 −15
  11. lib/fetch_and_add_arm64.S +0 −22
  12. lib/fetch_and_add_riscv64.S +0 −16
  13. libtcc.c +27 −55
  14. tcc.c +4 −9
  15. tests/tests2/Makefile +1 −0
  16. win32/build-tcc.bat +30 −33
include/tccdefs.h+6−0
@@ -222,6 +222,7 @@ · 221 unmodified lines
222 #else222 #else
223 # define __RENAME(X) __asm__(X)223 # define __RENAME(X) __asm__(X)
224 #endif224 #endif
225
225 #ifdef __BOUNDS_CHECKING_ON226 #ifdef __BOUNDS_CHECKING_ON
226 # define __BUILTINBC(ret,name,params) ret __builtin_##name params __RENAME("__bound_"#name);227 # define __BUILTINBC(ret,name,params) ret __builtin_##name params __RENAME("__bound_"#name);
227 # define __BOUND(ret,name,params) ret name params __RENAME("__bound_"#name);228 # define __BOUND(ret,name,params) ret name params __RENAME("__bound_"#name);
@@ -229,8 +230,13 @@ · 1 unmodified line
229 # define __BUILTINBC(ret,name,params) ret __builtin_##name params __RENAME(#name);230 # define __BUILTINBC(ret,name,params) ret __builtin_##name params __RENAME(#name);
230 # define __BOUND(ret,name,params)231 # define __BOUND(ret,name,params)
231 #endif232 #endif
233#ifdef _WIN32
234 #define __BOTH __BOUND
235 #define __BUILTIN(ret,name,params)
236#else
232 #define __BOTH(ret,name,params) __BUILTINBC(ret,name,params)__BOUND(ret,name,params)237 #define __BOTH(ret,name,params) __BUILTINBC(ret,name,params)__BOUND(ret,name,params)
233 #define __BUILTIN(ret,name,params) ret __builtin_##name params __RENAME(#name);238 #define __BUILTIN(ret,name,params) ret __builtin_##name params __RENAME(#name);
239#endif
234 240
235 __BOTH(void*, memcpy, (void *, const void*, __SIZE_TYPE__))241 __BOTH(void*, memcpy, (void *, const void*, __SIZE_TYPE__))
236 __BOTH(void*, memmove, (void *, const void*, __SIZE_TYPE__))242 __BOTH(void*, memmove, (void *, const void*, __SIZE_TYPE__))
lib/Makefile+5−5
@@ -42,11 +42,11 @@ $(X)BT_O += tcov.o · 41 unmodified lines
42 42
43DSO_O = dsohandle.o43DSO_O = dsohandle.o
44 44
45I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BT_O) stdatomic.o45I386_O = libtcc1.o alloca.o alloca-bt.o $(BT_O) stdatomic.o
46X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o $(BT_O) stdatomic.o46X86_64_O = libtcc1.o alloca.o alloca-bt.o $(BT_O) stdatomic.o
47ARM_O = libtcc1.o armeabi.o alloca-arm.o armflush.o fetch_and_add_arm.o $(BT_O)47ARM_O = libtcc1.o armeabi.o alloca.o armflush.o fetch_and_add.o $(BT_O)
48ARM64_O = lib-arm64.o fetch_and_add_arm64.o $(BT_O)48ARM64_O = lib-arm64.o fetch_and_add.o $(BT_O)
49RISCV64_O = lib-arm64.o fetch_and_add_riscv64.o $(BT_O)49RISCV64_O = lib-arm64.o fetch_and_add.o $(BT_O)
50WIN_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o50WIN_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o
51 51
52OBJ-i386 = $(I386_O) $(BCHECK_O) $(DSO_O)52OBJ-i386 = $(I386_O) $(BCHECK_O) $(DSO_O)
lib/alloca-arm.S+0−10
@@ -1,10 +0,0 @@
1 .text
2 .align 2
3 .global alloca
4 .type alloca, %function
5alloca:
6 rsb sp, r0, sp
7 bic sp, sp, #7
8 mov r0, sp
9 mov pc, lr
10 .size alloca, .-alloca
lib/alloca-bt.Srenamed from lib/alloca86_64-bt.S+46−1
@@ -1,5 +1,5 @@
1/* ---------------------------------------------- */1/* ---------------------------------------------- */
2/* alloca86_64.S */2/* alloca-bt.S */
3 3
4#ifdef __leading_underscore4#ifdef __leading_underscore
5# define _(s) _##s5# define _(s) _##s
@@ -7,6 +7,50 @@ · 1 unmodified line
7# define _(s) s7# define _(s) s
8#endif8#endif
9 9
10/* ---------------------------------------------- */
11#if defined __i386__
12
13.globl _(__bound_alloca)
14_(__bound_alloca):
15 pop %edx
16 pop %eax
17 mov %eax, %ecx
18 add $3+1,%eax
19 and $-4,%eax
20 jz p6
21
22#ifdef _WIN32
23p4:
24 cmp $4096,%eax
25 jbe p5
26 test %eax,-4096(%esp)
27 sub $4096,%esp
28 sub $4096,%eax
29 jmp p4
30
31p5:
32#endif
33
34 sub %eax,%esp
35 mov %esp,%eax
36
37 push %edx
38 push %eax
39 push %ecx
40 push %eax
41 call _(__bound_new_region)
42 add $8, %esp
43 pop %eax
44 pop %edx
45
46p6:
47 push %edx
48 push %edx
49 ret
50
51/* ---------------------------------------------- */
52#elif defined __x86_64__
53
10.globl _(__bound_alloca)54.globl _(__bound_alloca)
11_(__bound_alloca):55_(__bound_alloca):
12#ifdef _WIN3256#ifdef _WIN32
@@ -49,3 +93,4 @@ p3: · 36 unmodified lines
49#endif93#endif
50 94
51/* ---------------------------------------------- */95/* ---------------------------------------------- */
96#endif
lib/alloca.S+85−0
@@ -0,0 +1,85 @@
1/* ---------------------------------------------- */
2/* alloca.S */
3
4#ifdef __leading_underscore
5# define _(s) _##s
6#else
7# define _(s) s
8#endif
9
10/* ---------------------------------------------- */
11#if defined __i386__
12
13.globl _(alloca), _(__alloca)
14_(alloca):
15_(__alloca):
16 push %ebp
17 mov %esp,%ebp
18 mov 8(%ebp),%eax
19 add $3,%eax
20 and $-4,%eax
21#ifdef _WIN32
22 jmp .+16 #p2
23p1:
24 sub $4096,%esp
25 sub $4096,%eax
26 test %eax,(%esp)
27p2:
28 cmp $4096,%eax
29 jae p1
30#endif
31 sub %eax,%esp
32 mov 4(%ebp),%eax
33 mov 0(%ebp),%ebp
34 add $8,%esp
35 push %eax
36 lea 8(%esp),%eax
37 ret
38
39/* ---------------------------------------------- */
40#elif defined __x86_64__
41
42.globl _(alloca)
43_(alloca):
44 pop %rdx
45#ifdef _WIN32
46 mov %rcx,%rax
47#else
48 mov %rdi,%rax
49#endif
50 add $15,%rax
51 and $-16,%rax
52 jz p3
53
54#ifdef _WIN32
55p1:
56 cmp $4096,%rax
57 jbe p2
58 test %rax,-4096(%rsp)
59 sub $4096,%rsp
60 sub $4096,%rax
61 jmp p1
62p2:
63#endif
64 sub %rax,%rsp
65 mov %rsp,%rax
66p3:
67 push %rdx
68 ret
69
70/* ---------------------------------------------- */
71#elif defined __arm__
72
73 .text
74 .align 2
75 .global alloca
76 .type alloca, %function
77alloca:
78 rsb sp, r0, sp
79 bic sp, sp, #7
80 mov r0, sp
81 mov pc, lr
82 .size alloca, .-alloca
83
84/* ---------------------------------------------- */
85#endif
lib/alloca86-bt.S+0−52
@@ -1,52 +0,0 @@
1/* ---------------------------------------------- */
2/* alloca86-bt.S */
3
4#ifdef __leading_underscore
5# define _(s) _##s
6#else
7# define _(s) s
8#endif
9
10.globl _(__bound_alloca)
11_(__bound_alloca):
12 pop %edx
13 pop %eax
14 mov %eax, %ecx
15 add $3+1,%eax
16 and $-4,%eax
17 jz p6
18
19#ifdef _WIN32
20p4:
21 cmp $4096,%eax
22 jbe p5
23 test %eax,-4096(%esp)
24 sub $4096,%esp
25 sub $4096,%eax
26 jmp p4
27
28p5:
29#endif
30
31 sub %eax,%esp
32 mov %esp,%eax
33
34 push %edx
35 push %eax
36 push %ecx
37 push %eax
38 call _(__bound_new_region)
39 add $8, %esp
40 pop %eax
41 pop %edx
42
43p6:
44 push %edx
45 push %edx
46 ret
47
48/* mark stack as nonexecutable */
49#if defined __ELF__ && defined __linux__
50 .section .note.GNU-stack,"",@progbits
51#endif
52/* ---------------------------------------------- */
lib/alloca86.S+0−36
@@ -1,36 +0,0 @@
1/* ---------------------------------------------- */
2/* alloca86.S */
3
4#ifdef __leading_underscore
5# define _(s) _##s
6#else
7# define _(s) s
8#endif
9
10.globl _(alloca), _(__alloca)
11_(alloca):
12_(__alloca):
13 push %ebp
14 mov %esp,%ebp
15 mov 8(%ebp),%eax
16 add $3,%eax
17 and $-4,%eax
18#ifdef _WIN32
19 jmp .+16 #p2
20p1:
21 sub $4096,%esp
22 sub $4096,%eax
23 test %eax,(%esp)
24p2:
25 cmp $4096,%eax
26 jae p1
27#endif
28 sub %eax,%esp
29 mov 4(%ebp),%eax
30 mov 0(%ebp),%ebp
31 add $8,%esp
32 push %eax
33 lea 8(%esp),%eax
34 ret
35
36/* ---------------------------------------------- */
lib/alloca86_64.S+0−38
@@ -1,38 +0,0 @@
1/* ---------------------------------------------- */
2/* alloca86_64.S */
3
4#ifdef __leading_underscore
5# define _(s) _##s
6#else
7# define _(s) s
8#endif
9
10.globl _(alloca)
11_(alloca):
12 pop %rdx
13#ifdef _WIN32
14 mov %rcx,%rax
15#else
16 mov %rdi,%rax
17#endif
18 add $15,%rax
19 and $-16,%rax
20 jz p3
21
22#ifdef _WIN32
23p1:
24 cmp $4096,%rax
25 jbe p2
26 test %rax,-4096(%rsp)
27 sub $4096,%rsp
28 sub $4096,%rax
29 jmp p1
30p2:
31#endif
32 sub %rax,%rsp
33 mov %rsp,%rax
34p3:
35 push %rdx
36 ret
37
38/* ---------------------------------------------- */
lib/fetch_and_add.S+67−0
@@ -0,0 +1,67 @@
1/* ---------------------------------------------- */
2#if defined __arm__
3
4 .text
5 .align 2
6 .global fetch_and_add_arm
7 .type fetch_and_add_arm, %function
8fetch_and_add_arm:
9 mcr p15, #0, r0, c7, c10, #5
10.L0:
11 ldrex r3, [r0]
12 add r3, r3, r1
13 strex r2, r3, [r0]
14 cmp r2, #0
15 bne .L0
16 mcr p15, #0, r0, c7, c10, #5
17 bx lr
18 .size fetch_and_add_arm, .-fetch_and_add_arm
19
20/* ---------------------------------------------- */
21#elif defined __aarch64__
22
23 .text
24 .align 2
25 .global fetch_and_add_arm64
26 .type fetch_and_add_arm64, %function
27fetch_and_add_arm64:
28#ifdef __TINYC__
29 .int 0x885f7c02
30 .int 0x0b010042
31 .int 0x8803fc02
32 .int 0x35ffffa3
33 .int 0xd5033bbf
34 .int 0xd65f03c0
35#else
36 ldxr w2, [x0]
37 add w2, w2, w1
38 stlxr w3, w2, [x0]
39 cbnz w3, fetch_and_add_arm64
40 dmb ish
41 ret
42#endif
43
44 .size fetch_and_add_arm64, .-fetch_and_add_arm64
45
46/* ---------------------------------------------- */
47#elif defined __riscv
48
49 .text
50 .align 2
51 .global fetch_and_add_riscv64
52 .type fetch_and_add_riscv64, %function
53fetch_and_add_riscv64:
54#ifdef __TINYC__
55 .int 0x0f50000f
56 .int 0x004b5202f
57 .short 0x8082
58#else
59 fence iorw,ow
60 amoadd.w.aq zero,a1,0(a0)
61 ret
62#endif
63
64 .size fetch_and_add_riscv64, .-fetch_and_add_riscv64
65
66/* ---------------------------------------------- */
67#endif
lib/fetch_and_add_arm.S+0−15
@@ -1,15 +0,0 @@
1 .text
2 .align 2
3 .global fetch_and_add_arm
4 .type fetch_and_add_arm, %function
5fetch_and_add_arm:
6 mcr p15, #0, r0, c7, c10, #5
7.L0:
8 ldrex r3, [r0]
9 add r3, r3, r1
10 strex r2, r3, [r0]
11 cmp r2, #0
12 bne .L0
13 mcr p15, #0, r0, c7, c10, #5
14 bx lr
15 .size fetch_and_add_arm, .-fetch_and_add_arm
lib/fetch_and_add_arm64.S+0−22
@@ -1,22 +0,0 @@
1 .text
2 .align 2
3 .global fetch_and_add_arm64
4 .type fetch_and_add_arm64, %function
5fetch_and_add_arm64:
6#ifdef __TINYC__
7 .int 0x885f7c02
8 .int 0x0b010042
9 .int 0x8803fc02
10 .int 0x35ffffa3
11 .int 0xd5033bbf
12 .int 0xd65f03c0
13#else
14 ldxr w2, [x0]
15 add w2, w2, w1
16 stlxr w3, w2, [x0]
17 cbnz w3, fetch_and_add_arm64
18 dmb ish
19 ret
20#endif
21
22 .size fetch_and_add_arm64, .-fetch_and_add_arm64
lib/fetch_and_add_riscv64.S+0−16
@@ -1,16 +0,0 @@
1 .text
2 .align 2
3 .global fetch_and_add_riscv64
4 .type fetch_and_add_riscv64, %function
5fetch_and_add_riscv64:
6#ifdef __TINYC__
7 .int 0x0f50000f
8 .int 0x004b5202f
9 .short 0x8082
10#else
11 fence iorw,ow
12 amoadd.w.aq zero,a1,0(a0)
13 ret
14#endif
15
16 .size fetch_and_add_riscv64, .-fetch_and_add_riscv64
libtcc.c+27−55
@@ -83,8 +83,17 @@ ST_FUNC char *normalize_slashes(char *path) · 82 unmodified lines
83 return path;83 return path;
84}84}
85 85
86/* NULL if this is tcc.exe, HINSTANCE if this is libtcc.dll */86#if defined LIBTCC_AS_DLL && !defined CONFIG_TCCDIR
87static HMODULE tcc_module;87static HMODULE tcc_module;
88BOOL WINAPI DllMain (HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved)
89{
90 if (DLL_PROCESS_ATTACH == dwReason)
91 tcc_module = hDll;
92 return TRUE;
93}
94#else
95#define tcc_module NULL /* NULL means executable itself */
96#endif
88 97
89#ifndef CONFIG_TCCDIR98#ifndef CONFIG_TCCDIR
90/* on win32, we suppose the lib and includes are at the location of 'tcc.exe' */99/* on win32, we suppose the lib and includes are at the location of 'tcc.exe' */
@@ -109,15 +118,6 @@ static void tcc_add_systemdir(TCCState *s) · 18 unmodified lines
109 tcc_add_library_path(s, normalize_slashes(buf));118 tcc_add_library_path(s, normalize_slashes(buf));
110}119}
111#endif120#endif
112
113#ifdef LIBTCC_AS_DLL
114BOOL WINAPI DllMain (HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved)
115{
116 if (DLL_PROCESS_ATTACH == dwReason)
117 tcc_module = hDll;
118 return TRUE;
119}
120#endif
121#endif121#endif
122 122
123/********************************************************/123/********************************************************/
@@ -234,6 +234,14 @@ PUB_FUNC char *tcc_fileextension (const char *name) · 110 unmodified lines
234 return e ? e : strchr(b, 0);234 return e ? e : strchr(b, 0);
235}235}
236 236
237ST_FUNC char *tcc_load_text(int fd)
238{
239 int len = lseek(fd, 0, SEEK_END);
240 char *buf = load_data(fd, 0, len + 1);
241 buf[len] = 0;
242 return buf;
243}
244
237/********************************************************/245/********************************************************/
238/* memory management */246/* memory management */
239 247
@@ -1431,6 +1439,7 @@ typedef struct TCCOption { · 1191 unmodified lines
1431} TCCOption;1439} TCCOption;
1432 1440
1433enum {1441enum {
1442 TCC_OPTION_ignored = 0,
1434 TCC_OPTION_HELP,1443 TCC_OPTION_HELP,
1435 TCC_OPTION_HELP2,1444 TCC_OPTION_HELP2,
1436 TCC_OPTION_v,1445 TCC_OPTION_v,
@@ -1455,8 +1464,6 @@ enum { · 18 unmodified lines
1455 TCC_OPTION_soname,1464 TCC_OPTION_soname,
1456 TCC_OPTION_o,1465 TCC_OPTION_o,
1457 TCC_OPTION_r,1466 TCC_OPTION_r,
1458 TCC_OPTION_s,
1459 TCC_OPTION_traditional,
1460 TCC_OPTION_Wl,1467 TCC_OPTION_Wl,
1461 TCC_OPTION_Wp,1468 TCC_OPTION_Wp,
1462 TCC_OPTION_W,1469 TCC_OPTION_W,
@@ -1471,12 +1478,9 @@ enum { · 8 unmodified lines
1471 TCC_OPTION_nostdlib,1478 TCC_OPTION_nostdlib,
1472 TCC_OPTION_print_search_dirs,1479 TCC_OPTION_print_search_dirs,
1473 TCC_OPTION_rdynamic,1480 TCC_OPTION_rdynamic,
1474 TCC_OPTION_param,
1475 TCC_OPTION_pedantic,
1476 TCC_OPTION_pthread,1481 TCC_OPTION_pthread,
1477 TCC_OPTION_run,1482 TCC_OPTION_run,
1478 TCC_OPTION_w,1483 TCC_OPTION_w,
1479 TCC_OPTION_pipe,
1480 TCC_OPTION_E,1484 TCC_OPTION_E,
1481 TCC_OPTION_M,1485 TCC_OPTION_M,
1482 TCC_OPTION_MD,1486 TCC_OPTION_MD,
@@ -1486,8 +1490,6 @@ enum { · 3 unmodified lines
1486 TCC_OPTION_x,1490 TCC_OPTION_x,
1487 TCC_OPTION_ar,1491 TCC_OPTION_ar,
1488 TCC_OPTION_impdef,1492 TCC_OPTION_impdef,
1489 TCC_OPTION_C,
1490 TCC_OPTION_arch
1491};1493};
1492 1494
1493#define TCC_OPTION_HAS_ARG 0x00011495#define TCC_OPTION_HAS_ARG 0x0001
@@ -1523,14 +1525,10 @@ static const TCCOption tcc_options[] = { · 29 unmodified lines
1523 { "shared", TCC_OPTION_shared, 0 },1525 { "shared", TCC_OPTION_shared, 0 },
1524 { "soname", TCC_OPTION_soname, TCC_OPTION_HAS_ARG },1526 { "soname", TCC_OPTION_soname, TCC_OPTION_HAS_ARG },
1525 { "o", TCC_OPTION_o, TCC_OPTION_HAS_ARG },1527 { "o", TCC_OPTION_o, TCC_OPTION_HAS_ARG },
1526 { "-param", TCC_OPTION_param, TCC_OPTION_HAS_ARG },
1527 { "pedantic", TCC_OPTION_pedantic, 0},
1528 { "pthread", TCC_OPTION_pthread, 0},1528 { "pthread", TCC_OPTION_pthread, 0},
1529 { "run", TCC_OPTION_run, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },1529 { "run", TCC_OPTION_run, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
1530 { "rdynamic", TCC_OPTION_rdynamic, 0 },1530 { "rdynamic", TCC_OPTION_rdynamic, 0 },
1531 { "r", TCC_OPTION_r, 0 },1531 { "r", TCC_OPTION_r, 0 },
1532 { "s", TCC_OPTION_s, 0 },
1533 { "traditional", TCC_OPTION_traditional, 0 },
1534 { "Wl,", TCC_OPTION_Wl, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },1532 { "Wl,", TCC_OPTION_Wl, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
1535 { "Wp,", TCC_OPTION_Wp, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },1533 { "Wp,", TCC_OPTION_Wp, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
1536 { "W", TCC_OPTION_W, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },1534 { "W", TCC_OPTION_W, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
@@ -1546,7 +1544,6 @@ static const TCCOption tcc_options[] = { · 9 unmodified lines
1546 { "nostdlib", TCC_OPTION_nostdlib, 0 },1544 { "nostdlib", TCC_OPTION_nostdlib, 0 },
1547 { "print-search-dirs", TCC_OPTION_print_search_dirs, 0 },1545 { "print-search-dirs", TCC_OPTION_print_search_dirs, 0 },
1548 { "w", TCC_OPTION_w, 0 },1546 { "w", TCC_OPTION_w, 0 },
1549 { "pipe", TCC_OPTION_pipe, 0},
1550 { "E", TCC_OPTION_E, 0},1547 { "E", TCC_OPTION_E, 0},
1551 { "M", TCC_OPTION_M, 0},1548 { "M", TCC_OPTION_M, 0},
1552 { "MD", TCC_OPTION_MD, 0},1549 { "MD", TCC_OPTION_MD, 0},
@@ -1558,10 +1555,14 @@ static const TCCOption tcc_options[] = { · 5 unmodified lines
1558#ifdef TCC_TARGET_PE1555#ifdef TCC_TARGET_PE
1559 { "impdef", TCC_OPTION_impdef, 0},1556 { "impdef", TCC_OPTION_impdef, 0},
1560#endif1557#endif
1561#ifdef TCC_TARGET_MACHO1558 /* ignored (silently, except after -Wunsupported) */
1562 { "arch", TCC_OPTION_arch, TCC_OPTION_HAS_ARG },1559 { "arch", 0, TCC_OPTION_HAS_ARG},
1563#endif1560 { "C", 0, 0 },
1564 { "C", TCC_OPTION_C, 0},1561 { "-param", 0, TCC_OPTION_HAS_ARG },
1562 { "pedantic", 0, 0 },
1563 { "pipe", 0, 0 },
1564 { "s", 0, 0 },
1565 { "traditional", 0, 0 },
1565 { NULL, 0, 0 },1566 { NULL, 0, 0 },
1566};1567};
1567 1568
@@ -1677,14 +1678,6 @@ static int args_parser_make_argv(const char *r, int *argc, char ***argv) · 109 unmodified lines
1677 return ret;1678 return ret;
1678}1679}
1679 1680
1680ST_FUNC char *tcc_load_text(int fd)
1681{
1682 int len = lseek(fd, 0, SEEK_END);
1683 char *buf = load_data(fd, 0, len + 1);
1684 buf[len] = 0;
1685 return buf;
1686}
1687
1688/* read list file */1681/* read list file */
1689static void args_parser_listfile(TCCState *s,1682static void args_parser_listfile(TCCState *s,
1690 const char *filename, int optind, int *pargc, char ***pargv)1683 const char *filename, int optind, int *pargc, char ***pargv)
@@ -1991,27 +1984,6 @@ reparse: · 300 unmodified lines
1991 tcc_error("cannot parse %s here", r);1984 tcc_error("cannot parse %s here", r);
1992 tool = x;1985 tool = x;
1993 break;1986 break;
1994#if defined(TCC_TARGET_MACHO)
1995 case TCC_OPTION_arch:
1996#if defined(TCC_TARGET_X86_64)
1997 if (strcmp(optarg, "x86_64") == 0)
1998 break; /* Ok, arch matches target */
1999#endif
2000#if defined(TCC_TARGET_ARM64)
2001 if (strcmp(optarg, "arm64") == 0)
2002 break; /* Ok, arch matches target */
2003#endif
2004 tcc_error("this compiler does not support %s", optarg);
2005 /* ignored */
2006 break;
2007#endif
2008 case TCC_OPTION_traditional:
2009 case TCC_OPTION_pedantic:
2010 case TCC_OPTION_pipe:
2011 case TCC_OPTION_s:
2012 case TCC_OPTION_C:
2013 /* ignored */
2014 break;
2015 default:1987 default:
2016unsupported_option:1988unsupported_option:
2017 tcc_warning_c(warn_unsupported)("unsupported option '%s'", r);1989 tcc_warning_c(warn_unsupported)("unsupported option '%s'", r);
tcc.c+4−9
@@ -37,7 +37,7 @@ static const char help[] = · 36 unmodified lines
37 " -std=c11 Conform to the ISO 2011 C standard.\n"37 " -std=c11 Conform to the ISO 2011 C standard.\n"
38 " -Wwarning set or reset (with 'no-' prefix) 'warning' (see tcc -hh)\n"38 " -Wwarning set or reset (with 'no-' prefix) 'warning' (see tcc -hh)\n"
39 " -w disable all warnings\n"39 " -w disable all warnings\n"
40 " --version -v show version\n"40 " -v --version show version\n"
41 " -vv show search paths or loaded files\n"41 " -vv show search paths or loaded files\n"
42 " -h -hh show this, show more help\n"42 " -h -hh show this, show more help\n"
43 " -bench show compilation statistics\n"43 " -bench show compilation statistics\n"
@@ -70,16 +70,11 @@ static const char help[] = · 26 unmodified lines
70 " -nostdinc do not use standard system include paths\n"70 " -nostdinc do not use standard system include paths\n"
71 " -nostdlib do not link with standard crt and libraries\n"71 " -nostdlib do not link with standard crt and libraries\n"
72 " -Bdir set tcc's private include/library dir\n"72 " -Bdir set tcc's private include/library dir\n"
73 " -M just output makefile fragment with dependencies\n"73 " -M[M]D generate make dependency file [ignore system files]\n"
74 " -MM like -M but ignore system libs\n"74 " -M[M] as above but no other output\n"
75 " -MD generate dependency file for make\n"
76 " -MMD like -MMD but ignore system libs\n"
77 " -MF file specify dependency file name\n"75 " -MF file specify dependency file name\n"
78#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)76#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)
79 " -m32/64 defer to i386/x86_64 cross compiler\n"77 " -m32/64 defer to i386/x86_64 cross compiler\n"
80#endif
81#if defined(TCC_TARGET_MACHO) || defined(TCC_TARGET_X86_64)
82 " -arch set macos target achitecture (ignored, always x86_64)\n"
83#endif78#endif
84 "Tools:\n"79 "Tools:\n"
85 " create library : tcc -ar [rcsv] lib.a files\n"80 " create library : tcc -ar [rcsv] lib.a files\n"
@@ -103,7 +98,7 @@ static const char help2[] = · 17 unmodified lines
103 " -print-search-dirs print search paths\n"98 " -print-search-dirs print search paths\n"
104 " -dt with -run/-E: auto-define 'test_...' macros\n"99 " -dt with -run/-E: auto-define 'test_...' macros\n"
105 "Ignored options:\n"100 "Ignored options:\n"
106 " --param -pedantic -pipe -s -traditional\n"101 " -arch -C --param -pedantic -pipe -s -traditional\n"
107 "-W[no-]... warnings:\n"102 "-W[no-]... warnings:\n"
108 " all turn on some (*) warnings\n"103 " all turn on some (*) warnings\n"
109 " error[=warning] stop after warning (any or specified)\n"104 " error[=warning] stop after warning (any or specified)\n"
tests/tests2/Makefile+1−0
@@ -49,6 +49,7 @@ endif · 48 unmodified lines
49ifeq (-$(CONFIG_WIN32)-,-yes-)49ifeq (-$(CONFIG_WIN32)-,-yes-)
50 SKIP += 106_versym.test # No pthread support50 SKIP += 106_versym.test # No pthread support
51 SKIP += 114_bound_signal.test # No pthread support51 SKIP += 114_bound_signal.test # No pthread support
52 SKIP += 117_builtins.test # win32 port doesn't define __builtins
52 SKIP += 124_atomic_counter.test # No pthread support53 SKIP += 124_atomic_counter.test # No pthread support
53endif54endif
54ifneq (,$(filter OpenBSD FreeBSD NetBSD,$(TARGETOS)))55ifneq (,$(filter OpenBSD FreeBSD NetBSD,$(TARGETOS)))
win32/build-tcc.bat+30−33
@@ -8,7 +8,6 @@ if (%1)==(-clean) goto :cleanup · 7 unmodified lines
8set CC=gcc8set CC=gcc
9set /p VERSION= < ..\VERSION9set /p VERSION= < ..\VERSION
10set INST=10set INST=
11set BIN=
12set DOC=no11set DOC=no
13set EXES_ONLY=no12set EXES_ONLY=no
14goto :a013goto :a0
@@ -25,7 +24,6 @@ goto :a2 · 10 unmodified lines
25if (%1)==(-t) set T=%2&& goto :a224if (%1)==(-t) set T=%2&& goto :a2
26if (%1)==(-v) set VERSION=%~2&& goto :a225if (%1)==(-v) set VERSION=%~2&& goto :a2
27if (%1)==(-i) set INST=%2&& goto :a226if (%1)==(-i) set INST=%2&& goto :a2
28if (%1)==(-b) set BIN=%2&& goto :a2
29if (%1)==(-d) set DOC=yes&& goto :a327if (%1)==(-d) set DOC=yes&& goto :a3
30if (%1)==(-x) set EXES_ONLY=yes&& goto :a328if (%1)==(-x) set EXES_ONLY=yes&& goto :a3
31if (%1)==() goto :p129if (%1)==() goto :p1
@@ -37,7 +35,6 @@ echo -c "prog options" use prog with options to compile tcc · 5 unmodified lines
37echo -t 32/64 force 32/64 bit default target35echo -t 32/64 force 32/64 bit default target
38echo -v "version" set tcc version36echo -v "version" set tcc version
39echo -i tccdir install tcc into tccdir37echo -i tccdir install tcc into tccdir
40echo -b bindir optionally install binaries into bindir elsewhere
41echo -d create tcc-doc.html too (needs makeinfo)38echo -d create tcc-doc.html too (needs makeinfo)
42echo -x just create the executables39echo -x just create the executables
43echo -clean delete all previously produced files and directories40echo -clean delete all previously produced files and directories
@@ -98,11 +95,13 @@ if %T%==64 goto :t64 · 54 unmodified lines
98set D=%D32%95set D=%D32%
99set DX=%D64%96set DX=%D64%
100set PX=%P64%97set PX=%P64%
98set TX=64
101goto :p399goto :p3
102:t64100:t64
103set D=%D64%101set D=%D64%
104set DX=%D32%102set DX=%D32%
105set PX=%P32%103set PX=%P32%
104set TX=32
106goto :p3105goto :p3
107 106
108:p3107:p3
@@ -118,12 +117,18 @@ echo>> ..\config.h #endif · 9 unmodified lines
118 117
119for %%f in (*tcc.exe *tcc.dll) do @del %%f118for %%f in (*tcc.exe *tcc.dll) do @del %%f
120 119
121:compiler120@if _%TCC_C%_==__ goto compiler_2parts
122%CC% -o libtcc.dll -shared ..\libtcc.c %D% -DLIBTCC_AS_DLL121@rem if TCC_C was defined then build only tcc.exe
122%CC% -o tcc.exe %TCC_C% %D%
123@goto :compiler_done
124
125:compiler_2parts
126@if _%LIBTCC_C%_==__ set LIBTCC_C=..\libtcc.c
127%CC% -o libtcc.dll -shared %LIBTCC_C% %D% -DLIBTCC_AS_DLL
123@if errorlevel 1 goto :the_end128@if errorlevel 1 goto :the_end
124%CC% -o tcc.exe ..\tcc.c libtcc.dll %D% -DONE_SOURCE"=0"129%CC% -o tcc.exe ..\tcc.c libtcc.dll %D% -DONE_SOURCE"=0"
125%CC% -o %PX%-tcc.exe ..\tcc.c %DX%130%CC% -o %PX%-tcc.exe ..\tcc.c %DX%
126 131:compiler_done
127@if (%EXES_ONLY%)==(yes) goto :files_done132@if (%EXES_ONLY%)==(yes) goto :files_done
128 133
129if not exist libtcc mkdir libtcc134if not exist libtcc mkdir libtcc
@@ -134,34 +139,13 @@ copy>nul ..\libtcc.h libtcc · 4 unmodified lines
134copy>nul ..\tests\libtcc_test.c examples139copy>nul ..\tests\libtcc_test.c examples
135copy>nul tcc-win32.txt doc140copy>nul tcc-win32.txt doc
136 141
137.\tcc -impdef libtcc.dll -o libtcc\libtcc.def142if exist libtcc.dll .\tcc -impdef libtcc.dll -o libtcc\libtcc.def
138@if errorlevel 1 goto :the_end143@if errorlevel 1 goto :the_end
139 144
140:libtcc1.a145:libtcc1.a
141@set O1=libtcc1.o crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o chkstk.o146call :makelib %T%
142.\tcc -m32 -c ../lib/libtcc1.c
143.\tcc -m32 -c lib/crt1.c
144.\tcc -m32 -c lib/crt1w.c
145.\tcc -m32 -c lib/wincrt1.c
146.\tcc -m32 -c lib/wincrt1w.c
147.\tcc -m32 -c lib/dllcrt1.c
148.\tcc -m32 -c lib/dllmain.c
149.\tcc -m32 -c lib/chkstk.S
150.\tcc -m32 -c ../lib/alloca86.S
151.\tcc -m32 -c ../lib/alloca86-bt.S
152.\tcc -m32 -ar lib/libtcc1-32.a %O1% alloca86.o alloca86-bt.o
153@if errorlevel 1 goto :the_end147@if errorlevel 1 goto :the_end
154.\tcc -m64 -c ../lib/libtcc1.c148@if exist %PX%-tcc.exe call :makelib %TX%
155.\tcc -m64 -c lib/crt1.c
156.\tcc -m64 -c lib/crt1w.c
157.\tcc -m64 -c lib/wincrt1.c
158.\tcc -m64 -c lib/wincrt1w.c
159.\tcc -m64 -c lib/dllcrt1.c
160.\tcc -m64 -c lib/dllmain.c
161.\tcc -m64 -c lib/chkstk.S
162.\tcc -m64 -c ../lib/alloca86_64.S
163.\tcc -m64 -c ../lib/alloca86_64-bt.S
164.\tcc -m64 -ar lib/libtcc1-64.a %O1% alloca86_64.o alloca86_64-bt.o
165@if errorlevel 1 goto :the_end149@if errorlevel 1 goto :the_end
166.\tcc -m%T% -c ../lib/bcheck.c -o lib/bcheck.o -g150.\tcc -m%T% -c ../lib/bcheck.c -o lib/bcheck.o -g
167.\tcc -m%T% -c ../lib/bt-exe.c -o lib/bt-exe.o151.\tcc -m%T% -c ../lib/bt-exe.c -o lib/bt-exe.o
@@ -180,12 +164,25 @@ for %%f in (*.o *.def) do @del %%f · 12 unmodified lines
180:copy-install164:copy-install
181@if (%INST%)==() goto :the_end165@if (%INST%)==() goto :the_end
182if not exist %INST% mkdir %INST%166if not exist %INST% mkdir %INST%
183@if (%BIN%)==() set BIN=%INST%167for %%f in (*tcc.exe *tcc.dll) do @copy>nul %%f %INST%\%%f
184if not exist %BIN% mkdir %BIN%
185for %%f in (*tcc.exe *tcc.dll) do @copy>nul %%f %BIN%\%%f
186@if not exist %INST%\lib mkdir %INST%\lib168@if not exist %INST%\lib mkdir %INST%\lib
187for %%f in (lib\*.a lib\*.o lib\*.def) do @copy>nul %%f %INST%\%%f169for %%f in (lib\*.a lib\*.o lib\*.def) do @copy>nul %%f %INST%\%%f
188for %%f in (include examples libtcc doc) do @xcopy>nul /s/i/q/y %%f %INST%\%%f170for %%f in (include examples libtcc doc) do @xcopy>nul /s/i/q/y %%f %INST%\%%f
189 171
190:the_end172:the_end
191exit /B %ERRORLEVEL%173exit /B %ERRORLEVEL%
174
175:makelib
176.\tcc -m%1 -c ../lib/libtcc1.c
177.\tcc -m%1 -c lib/crt1.c
178.\tcc -m%1 -c lib/crt1w.c
179.\tcc -m%1 -c lib/wincrt1.c
180.\tcc -m%1 -c lib/wincrt1w.c
181.\tcc -m%1 -c lib/dllcrt1.c
182.\tcc -m%1 -c lib/dllmain.c
183.\tcc -m%1 -c lib/chkstk.S
184.\tcc -m%1 -c ../lib/alloca.S
185.\tcc -m%1 -c ../lib/alloca-bt.S
186.\tcc -m%1 -c ../lib/stdatomic.c
187.\tcc -m%1 -ar lib/libtcc1-%1.a libtcc1.o crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o chkstk.o alloca.o alloca-bt.o stdatomic.o
188exit /B %ERRORLEVEL%

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t