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
222222 #else
223223 # define __RENAME(X) __asm__(X)
224224 #endif
225+
225226 #ifdef __BOUNDS_CHECKING_ON
226227 # define __BUILTINBC(ret,name,params) ret __builtin_##name params __RENAME("__bound_"#name);
227228 # define __BOUND(ret,name,params) ret name params __RENAME("__bound_"#name);
@@ -229,8 +230,13 @@ · 1 unmodified line
229230 # define __BUILTINBC(ret,name,params) ret __builtin_##name params __RENAME(#name);
230231 # define __BOUND(ret,name,params)
231232 #endif
233+#ifdef _WIN32
234+ #define __BOTH __BOUND
235+ #define __BUILTIN(ret,name,params)
236+#else
232237 #define __BOTH(ret,name,params) __BUILTINBC(ret,name,params)__BOUND(ret,name,params)
233238 #define __BUILTIN(ret,name,params) ret __builtin_##name params __RENAME(#name);
239+#endif
234240
235241 __BOTH(void*, memcpy, (void *, const void*, __SIZE_TYPE__))
236242 __BOTH(void*, memmove, (void *, const void*, __SIZE_TYPE__))
lib/Makefile+5−5
@@ -42,11 +42,11 @@ $(X)BT_O += tcov.o · 41 unmodified lines
4242
4343 DSO_O = dsohandle.o
4444
45−I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BT_O) stdatomic.o
46−X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o $(BT_O) stdatomic.o
47−ARM_O = libtcc1.o armeabi.o alloca-arm.o armflush.o fetch_and_add_arm.o $(BT_O)
48−ARM64_O = lib-arm64.o fetch_and_add_arm64.o $(BT_O)
49−RISCV64_O = lib-arm64.o fetch_and_add_riscv64.o $(BT_O)
45+I386_O = libtcc1.o alloca.o alloca-bt.o $(BT_O) stdatomic.o
46+X86_64_O = libtcc1.o alloca.o alloca-bt.o $(BT_O) stdatomic.o
47+ARM_O = libtcc1.o armeabi.o alloca.o armflush.o fetch_and_add.o $(BT_O)
48+ARM64_O = lib-arm64.o fetch_and_add.o $(BT_O)
49+RISCV64_O = lib-arm64.o fetch_and_add.o $(BT_O)
5050 WIN_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o
5151
5252 OBJ-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
5−alloca:
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 @@
11 /* ---------------------------------------------- */
2−/* alloca86_64.S */
2+/* alloca-bt.S */
33
44 #ifdef __leading_underscore
55 # define _(s) _##s
@@ -7,6 +7,50 @@ · 1 unmodified line
77 # define _(s) s
88 #endif
99
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
23+p4:
24+ cmp $4096,%eax
25+ jbe p5
26+ test %eax,-4096(%esp)
27+ sub $4096,%esp
28+ sub $4096,%eax
29+ jmp p4
30+
31+p5:
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+
46+p6:
47+ push %edx
48+ push %edx
49+ ret
50+
51+/* ---------------------------------------------- */
52+#elif defined __x86_64__
53+
1054 .globl _(__bound_alloca)
1155 _(__bound_alloca):
1256 #ifdef _WIN32
@@ -49,3 +93,4 @@ p3: · 36 unmodified lines
4993 #endif
5094
5195 /* ---------------------------------------------- */
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
23+p1:
24+ sub $4096,%esp
25+ sub $4096,%eax
26+ test %eax,(%esp)
27+p2:
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
55+p1:
56+ cmp $4096,%rax
57+ jbe p2
58+ test %rax,-4096(%rsp)
59+ sub $4096,%rsp
60+ sub $4096,%rax
61+ jmp p1
62+p2:
63+#endif
64+ sub %rax,%rsp
65+ mov %rsp,%rax
66+p3:
67+ push %rdx
68+ ret
69+
70+/* ---------------------------------------------- */
71+#elif defined __arm__
72+
73+ .text
74+ .align 2
75+ .global alloca
76+ .type alloca, %function
77+alloca:
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
20−p4:
21− cmp $4096,%eax
22− jbe p5
23− test %eax,-4096(%esp)
24− sub $4096,%esp
25− sub $4096,%eax
26− jmp p4
27−
28−p5:
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−
43−p6:
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
20−p1:
21− sub $4096,%esp
22− sub $4096,%eax
23− test %eax,(%esp)
24−p2:
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
23−p1:
24− cmp $4096,%rax
25− jbe p2
26− test %rax,-4096(%rsp)
27− sub $4096,%rsp
28− sub $4096,%rax
29− jmp p1
30−p2:
31−#endif
32− sub %rax,%rsp
33− mov %rsp,%rax
34−p3:
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
8+fetch_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
27+fetch_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
53+fetch_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
5−fetch_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
5−fetch_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
5−fetch_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
8383 return path;
8484 }
8585
86−/* NULL if this is tcc.exe, HINSTANCE if this is libtcc.dll */
86+#if defined LIBTCC_AS_DLL && !defined CONFIG_TCCDIR
8787 static HMODULE tcc_module;
88+BOOL 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
8897
8998 #ifndef CONFIG_TCCDIR
9099 /* 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
109118 tcc_add_library_path(s, normalize_slashes(buf));
110119 }
111120 #endif
112−
113−#ifdef LIBTCC_AS_DLL
114−BOOL 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
121121 #endif
122122
123123 /********************************************************/
@@ -234,6 +234,14 @@ PUB_FUNC char *tcc_fileextension (const char *name) · 110 unmodified lines
234234 return e ? e : strchr(b, 0);
235235 }
236236
237+ST_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+
237245 /********************************************************/
238246 /* memory management */
239247
@@ -1431,6 +1439,7 @@ typedef struct TCCOption { · 1191 unmodified lines
14311439 } TCCOption;
14321440
14331441 enum {
1442+ TCC_OPTION_ignored = 0,
14341443 TCC_OPTION_HELP,
14351444 TCC_OPTION_HELP2,
14361445 TCC_OPTION_v,
@@ -1455,8 +1464,6 @@ enum { · 18 unmodified lines
14551464 TCC_OPTION_soname,
14561465 TCC_OPTION_o,
14571466 TCC_OPTION_r,
1458− TCC_OPTION_s,
1459− TCC_OPTION_traditional,
14601467 TCC_OPTION_Wl,
14611468 TCC_OPTION_Wp,
14621469 TCC_OPTION_W,
@@ -1471,12 +1478,9 @@ enum { · 8 unmodified lines
14711478 TCC_OPTION_nostdlib,
14721479 TCC_OPTION_print_search_dirs,
14731480 TCC_OPTION_rdynamic,
1474− TCC_OPTION_param,
1475− TCC_OPTION_pedantic,
14761481 TCC_OPTION_pthread,
14771482 TCC_OPTION_run,
14781483 TCC_OPTION_w,
1479− TCC_OPTION_pipe,
14801484 TCC_OPTION_E,
14811485 TCC_OPTION_M,
14821486 TCC_OPTION_MD,
@@ -1486,8 +1490,6 @@ enum { · 3 unmodified lines
14861490 TCC_OPTION_x,
14871491 TCC_OPTION_ar,
14881492 TCC_OPTION_impdef,
1489− TCC_OPTION_C,
1490− TCC_OPTION_arch
14911493 };
14921494
14931495 #define TCC_OPTION_HAS_ARG 0x0001
@@ -1523,14 +1525,10 @@ static const TCCOption tcc_options[] = { · 29 unmodified lines
15231525 { "shared", TCC_OPTION_shared, 0 },
15241526 { "soname", TCC_OPTION_soname, TCC_OPTION_HAS_ARG },
15251527 { "o", TCC_OPTION_o, TCC_OPTION_HAS_ARG },
1526− { "-param", TCC_OPTION_param, TCC_OPTION_HAS_ARG },
1527− { "pedantic", TCC_OPTION_pedantic, 0},
15281528 { "pthread", TCC_OPTION_pthread, 0},
15291529 { "run", TCC_OPTION_run, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
15301530 { "rdynamic", TCC_OPTION_rdynamic, 0 },
15311531 { "r", TCC_OPTION_r, 0 },
1532− { "s", TCC_OPTION_s, 0 },
1533− { "traditional", TCC_OPTION_traditional, 0 },
15341532 { "Wl,", TCC_OPTION_Wl, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
15351533 { "Wp,", TCC_OPTION_Wp, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
15361534 { "W", TCC_OPTION_W, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
@@ -1546,7 +1544,6 @@ static const TCCOption tcc_options[] = { · 9 unmodified lines
15461544 { "nostdlib", TCC_OPTION_nostdlib, 0 },
15471545 { "print-search-dirs", TCC_OPTION_print_search_dirs, 0 },
15481546 { "w", TCC_OPTION_w, 0 },
1549− { "pipe", TCC_OPTION_pipe, 0},
15501547 { "E", TCC_OPTION_E, 0},
15511548 { "M", TCC_OPTION_M, 0},
15521549 { "MD", TCC_OPTION_MD, 0},
@@ -1558,10 +1555,14 @@ static const TCCOption tcc_options[] = { · 5 unmodified lines
15581555 #ifdef TCC_TARGET_PE
15591556 { "impdef", TCC_OPTION_impdef, 0},
15601557 #endif
1561−#ifdef TCC_TARGET_MACHO
1562− { "arch", TCC_OPTION_arch, TCC_OPTION_HAS_ARG },
1563−#endif
1564− { "C", TCC_OPTION_C, 0},
1558+ /* ignored (silently, except after -Wunsupported) */
1559+ { "arch", 0, TCC_OPTION_HAS_ARG},
1560+ { "C", 0, 0 },
1561+ { "-param", 0, TCC_OPTION_HAS_ARG },
1562+ { "pedantic", 0, 0 },
1563+ { "pipe", 0, 0 },
1564+ { "s", 0, 0 },
1565+ { "traditional", 0, 0 },
15651566 { NULL, 0, 0 },
15661567 };
15671568
@@ -1677,14 +1678,6 @@ static int args_parser_make_argv(const char *r, int *argc, char ***argv) · 109 unmodified lines
16771678 return ret;
16781679 }
16791680
1680−ST_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−
16881681 /* read list file */
16891682 static void args_parser_listfile(TCCState *s,
16901683 const char *filename, int optind, int *pargc, char ***pargv)
@@ -1991,27 +1984,6 @@ reparse: · 300 unmodified lines
19911984 tcc_error("cannot parse %s here", r);
19921985 tool = x;
19931986 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;
20151987 default:
20161988 unsupported_option:
20171989 tcc_warning_c(warn_unsupported)("unsupported option '%s'", r);
tcc.c+4−9
@@ -37,7 +37,7 @@ static const char help[] = · 36 unmodified lines
3737 " -std=c11 Conform to the ISO 2011 C standard.\n"
3838 " -Wwarning set or reset (with 'no-' prefix) 'warning' (see tcc -hh)\n"
3939 " -w disable all warnings\n"
40− " --version -v show version\n"
40+ " -v --version show version\n"
4141 " -vv show search paths or loaded files\n"
4242 " -h -hh show this, show more help\n"
4343 " -bench show compilation statistics\n"
@@ -70,16 +70,11 @@ static const char help[] = · 26 unmodified lines
7070 " -nostdinc do not use standard system include paths\n"
7171 " -nostdlib do not link with standard crt and libraries\n"
7272 " -Bdir set tcc's private include/library dir\n"
73− " -M just output makefile fragment with dependencies\n"
74− " -MM like -M but ignore system libs\n"
75− " -MD generate dependency file for make\n"
76− " -MMD like -MMD but ignore system libs\n"
73+ " -M[M]D generate make dependency file [ignore system files]\n"
74+ " -M[M] as above but no other output\n"
7775 " -MF file specify dependency file name\n"
7876 #if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)
7977 " -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"
8378 #endif
8479 "Tools:\n"
8580 " create library : tcc -ar [rcsv] lib.a files\n"
@@ -103,7 +98,7 @@ static const char help2[] = · 17 unmodified lines
10398 " -print-search-dirs print search paths\n"
10499 " -dt with -run/-E: auto-define 'test_...' macros\n"
105100 "Ignored options:\n"
106− " --param -pedantic -pipe -s -traditional\n"
101+ " -arch -C --param -pedantic -pipe -s -traditional\n"
107102 "-W[no-]... warnings:\n"
108103 " all turn on some (*) warnings\n"
109104 " error[=warning] stop after warning (any or specified)\n"
tests/tests2/Makefile+1−0
@@ -49,6 +49,7 @@ endif · 48 unmodified lines
4949 ifeq (-$(CONFIG_WIN32)-,-yes-)
5050 SKIP += 106_versym.test # No pthread support
5151 SKIP += 114_bound_signal.test # No pthread support
52+ SKIP += 117_builtins.test # win32 port doesn't define __builtins
5253 SKIP += 124_atomic_counter.test # No pthread support
5354 endif
5455 ifneq (,$(filter OpenBSD FreeBSD NetBSD,$(TARGETOS)))
win32/build-tcc.bat+30−33
@@ -8,7 +8,6 @@ if (%1)==(-clean) goto :cleanup · 7 unmodified lines
88 set CC=gcc
99 set /p VERSION= < ..\VERSION
1010 set INST=
11−set BIN=
1211 set DOC=no
1312 set EXES_ONLY=no
1413 goto :a0
@@ -25,7 +24,6 @@ goto :a2 · 10 unmodified lines
2524 if (%1)==(-t) set T=%2&& goto :a2
2625 if (%1)==(-v) set VERSION=%~2&& goto :a2
2726 if (%1)==(-i) set INST=%2&& goto :a2
28−if (%1)==(-b) set BIN=%2&& goto :a2
2927 if (%1)==(-d) set DOC=yes&& goto :a3
3028 if (%1)==(-x) set EXES_ONLY=yes&& goto :a3
3129 if (%1)==() goto :p1
@@ -37,7 +35,6 @@ echo -c "prog options" use prog with options to compile tcc · 5 unmodified lines
3735 echo -t 32/64 force 32/64 bit default target
3836 echo -v "version" set tcc version
3937 echo -i tccdir install tcc into tccdir
40−echo -b bindir optionally install binaries into bindir elsewhere
4138 echo -d create tcc-doc.html too (needs makeinfo)
4239 echo -x just create the executables
4340 echo -clean delete all previously produced files and directories
@@ -98,11 +95,13 @@ if %T%==64 goto :t64 · 54 unmodified lines
9895 set D=%D32%
9996 set DX=%D64%
10097 set PX=%P64%
98+set TX=64
10199 goto :p3
102100 :t64
103101 set D=%D64%
104102 set DX=%D32%
105103 set PX=%P32%
104+set TX=32
106105 goto :p3
107106
108107 :p3
@@ -118,12 +117,18 @@ echo>> ..\config.h #endif · 9 unmodified lines
118117
119118 for %%f in (*tcc.exe *tcc.dll) do @del %%f
120119
121−:compiler
122−%CC% -o libtcc.dll -shared ..\libtcc.c %D% -DLIBTCC_AS_DLL
120+@if _%TCC_C%_==__ goto compiler_2parts
121+@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
123128 @if errorlevel 1 goto :the_end
124129 %CC% -o tcc.exe ..\tcc.c libtcc.dll %D% -DONE_SOURCE"=0"
125130 %CC% -o %PX%-tcc.exe ..\tcc.c %DX%
126−
131+:compiler_done
127132 @if (%EXES_ONLY%)==(yes) goto :files_done
128133
129134 if not exist libtcc mkdir libtcc
@@ -134,34 +139,13 @@ copy>nul ..\libtcc.h libtcc · 4 unmodified lines
134139 copy>nul ..\tests\libtcc_test.c examples
135140 copy>nul tcc-win32.txt doc
136141
137−.\tcc -impdef libtcc.dll -o libtcc\libtcc.def
142+if exist libtcc.dll .\tcc -impdef libtcc.dll -o libtcc\libtcc.def
138143 @if errorlevel 1 goto :the_end
139144
140145 :libtcc1.a
141−@set O1=libtcc1.o crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o chkstk.o
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
146+call :makelib %T%
153147 @if errorlevel 1 goto :the_end
154−.\tcc -m64 -c ../lib/libtcc1.c
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
148+@if exist %PX%-tcc.exe call :makelib %TX%
165149 @if errorlevel 1 goto :the_end
166150 .\tcc -m%T% -c ../lib/bcheck.c -o lib/bcheck.o -g
167151 .\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
180164 :copy-install
181165 @if (%INST%)==() goto :the_end
182166 if not exist %INST% mkdir %INST%
183−@if (%BIN%)==() set BIN=%INST%
184−if not exist %BIN% mkdir %BIN%
185−for %%f in (*tcc.exe *tcc.dll) do @copy>nul %%f %BIN%\%%f
167+for %%f in (*tcc.exe *tcc.dll) do @copy>nul %%f %INST%\%%f
186168 @if not exist %INST%\lib mkdir %INST%\lib
187169 for %%f in (lib\*.a lib\*.o lib\*.def) do @copy>nul %%f %INST%\%%f
188170 for %%f in (include examples libtcc doc) do @xcopy>nul /s/i/q/y %%f %INST%\%%f
189171
190172 :the_end
191173 exit /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
188+exit /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