271 insertions(+), 292 deletions(-), -21 lines, -5 files Also: - tccdefs.h: WIN32: less (no) __builtins - libtcc.c: simply ignore -arch
Unified · Split
| @@ -222,6 +222,7 @@ · 221 unmodified lines | ||
| 222 | 222 | #else |
| 223 | 223 | # define __RENAME(X) __asm__(X) |
| 224 | 224 | #endif |
| 225 | + | |
| 225 | 226 | #ifdef __BOUNDS_CHECKING_ON |
| 226 | 227 | # define __BUILTINBC(ret,name,params) ret __builtin_##name params __RENAME("__bound_"#name); |
| 227 | 228 | # define __BOUND(ret,name,params) ret name params __RENAME("__bound_"#name); |
| @@ -229,8 +230,13 @@ · 1 unmodified line | ||
| 229 | 230 | # define __BUILTINBC(ret,name,params) ret __builtin_##name params __RENAME(#name); |
| 230 | 231 | # define __BOUND(ret,name,params) |
| 231 | 232 | #endif |
| 233 | +#ifdef _WIN32 | |
| 234 | + #define __BOTH __BOUND | |
| 235 | + #define __BUILTIN(ret,name,params) | |
| 236 | +#else | |
| 232 | 237 | #define __BOTH(ret,name,params) __BUILTINBC(ret,name,params)__BOUND(ret,name,params) |
| 233 | 238 | #define __BUILTIN(ret,name,params) ret __builtin_##name params __RENAME(#name); |
| 239 | +#endif | |
| 234 | 240 | |
| 235 | 241 | __BOTH(void*, memcpy, (void *, const void*, __SIZE_TYPE__)) |
| 236 | 242 | __BOTH(void*, memmove, (void *, const void*, __SIZE_TYPE__)) |
| @@ -42,11 +42,11 @@ $(X)BT_O += tcov.o · 41 unmodified lines | ||
| 42 | 42 | |
| 43 | 43 | DSO_O = dsohandle.o |
| 44 | 44 | |
| 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) | |
| 50 | 50 | WIN_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o |
| 51 | 51 | |
| 52 | 52 | OBJ-i386 = $(I386_O) $(BCHECK_O) $(DSO_O) |
| @@ -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 | |
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* ---------------------------------------------- */ |
| 2 | −/* alloca86_64.S */ | |
| 2 | +/* alloca-bt.S */ | |
| 3 | 3 | |
| 4 | 4 | #ifdef __leading_underscore |
| 5 | 5 | # define _(s) _##s |
| @@ -7,6 +7,50 @@ · 1 unmodified line | ||
| 7 | 7 | # define _(s) s |
| 8 | 8 | #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 | |
| 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 | + | |
| 10 | 54 | .globl _(__bound_alloca) |
| 11 | 55 | _(__bound_alloca): |
| 12 | 56 | #ifdef _WIN32 |
| @@ -49,3 +93,4 @@ p3: · 36 unmodified lines | ||
| 49 | 93 | #endif |
| 50 | 94 | |
| 51 | 95 | /* ---------------------------------------------- */ |
| 96 | +#endif | |
| @@ -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 | |
| @@ -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 | −/* ---------------------------------------------- */ | |
| @@ -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 | −/* ---------------------------------------------- */ | |
| @@ -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 | −/* ---------------------------------------------- */ | |
| @@ -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 | |
| @@ -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 | |
| @@ -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 | |
| @@ -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 | |
| @@ -83,8 +83,17 @@ ST_FUNC char *normalize_slashes(char *path) · 82 unmodified lines | ||
| 83 | 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 | |
| 87 | 87 | 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 | |
| 88 | 97 | |
| 89 | 98 | #ifndef CONFIG_TCCDIR |
| 90 | 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 | 118 | tcc_add_library_path(s, normalize_slashes(buf)); |
| 110 | 119 | } |
| 111 | 120 | #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 | |
| 121 | 121 | #endif |
| 122 | 122 | |
| 123 | 123 | /********************************************************/ |
| @@ -234,6 +234,14 @@ PUB_FUNC char *tcc_fileextension (const char *name) · 110 unmodified lines | ||
| 234 | 234 | return e ? e : strchr(b, 0); |
| 235 | 235 | } |
| 236 | 236 | |
| 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 | + | |
| 237 | 245 | /********************************************************/ |
| 238 | 246 | /* memory management */ |
| 239 | 247 | |
| @@ -1431,6 +1439,7 @@ typedef struct TCCOption { · 1191 unmodified lines | ||
| 1431 | 1439 | } TCCOption; |
| 1432 | 1440 | |
| 1433 | 1441 | enum { |
| 1442 | + TCC_OPTION_ignored = 0, | |
| 1434 | 1443 | TCC_OPTION_HELP, |
| 1435 | 1444 | TCC_OPTION_HELP2, |
| 1436 | 1445 | TCC_OPTION_v, |
| @@ -1455,8 +1464,6 @@ enum { · 18 unmodified lines | ||
| 1455 | 1464 | TCC_OPTION_soname, |
| 1456 | 1465 | TCC_OPTION_o, |
| 1457 | 1466 | TCC_OPTION_r, |
| 1458 | − TCC_OPTION_s, | |
| 1459 | − TCC_OPTION_traditional, | |
| 1460 | 1467 | TCC_OPTION_Wl, |
| 1461 | 1468 | TCC_OPTION_Wp, |
| 1462 | 1469 | TCC_OPTION_W, |
| @@ -1471,12 +1478,9 @@ enum { · 8 unmodified lines | ||
| 1471 | 1478 | TCC_OPTION_nostdlib, |
| 1472 | 1479 | TCC_OPTION_print_search_dirs, |
| 1473 | 1480 | TCC_OPTION_rdynamic, |
| 1474 | − TCC_OPTION_param, | |
| 1475 | − TCC_OPTION_pedantic, | |
| 1476 | 1481 | TCC_OPTION_pthread, |
| 1477 | 1482 | TCC_OPTION_run, |
| 1478 | 1483 | TCC_OPTION_w, |
| 1479 | − TCC_OPTION_pipe, | |
| 1480 | 1484 | TCC_OPTION_E, |
| 1481 | 1485 | TCC_OPTION_M, |
| 1482 | 1486 | TCC_OPTION_MD, |
| @@ -1486,8 +1490,6 @@ enum { · 3 unmodified lines | ||
| 1486 | 1490 | TCC_OPTION_x, |
| 1487 | 1491 | TCC_OPTION_ar, |
| 1488 | 1492 | TCC_OPTION_impdef, |
| 1489 | − TCC_OPTION_C, | |
| 1490 | − TCC_OPTION_arch | |
| 1491 | 1493 | }; |
| 1492 | 1494 | |
| 1493 | 1495 | #define TCC_OPTION_HAS_ARG 0x0001 |
| @@ -1523,14 +1525,10 @@ static const TCCOption tcc_options[] = { · 29 unmodified lines | ||
| 1523 | 1525 | { "shared", TCC_OPTION_shared, 0 }, |
| 1524 | 1526 | { "soname", TCC_OPTION_soname, TCC_OPTION_HAS_ARG }, |
| 1525 | 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 | 1528 | { "pthread", TCC_OPTION_pthread, 0}, |
| 1529 | 1529 | { "run", TCC_OPTION_run, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP }, |
| 1530 | 1530 | { "rdynamic", TCC_OPTION_rdynamic, 0 }, |
| 1531 | 1531 | { "r", TCC_OPTION_r, 0 }, |
| 1532 | − { "s", TCC_OPTION_s, 0 }, | |
| 1533 | − { "traditional", TCC_OPTION_traditional, 0 }, | |
| 1534 | 1532 | { "Wl,", TCC_OPTION_Wl, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP }, |
| 1535 | 1533 | { "Wp,", TCC_OPTION_Wp, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP }, |
| 1536 | 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 | 1544 | { "nostdlib", TCC_OPTION_nostdlib, 0 }, |
| 1547 | 1545 | { "print-search-dirs", TCC_OPTION_print_search_dirs, 0 }, |
| 1548 | 1546 | { "w", TCC_OPTION_w, 0 }, |
| 1549 | − { "pipe", TCC_OPTION_pipe, 0}, | |
| 1550 | 1547 | { "E", TCC_OPTION_E, 0}, |
| 1551 | 1548 | { "M", TCC_OPTION_M, 0}, |
| 1552 | 1549 | { "MD", TCC_OPTION_MD, 0}, |
| @@ -1558,10 +1555,14 @@ static const TCCOption tcc_options[] = { · 5 unmodified lines | ||
| 1558 | 1555 | #ifdef TCC_TARGET_PE |
| 1559 | 1556 | { "impdef", TCC_OPTION_impdef, 0}, |
| 1560 | 1557 | #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 }, | |
| 1565 | 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 | 1678 | return ret; |
| 1678 | 1679 | } |
| 1679 | 1680 | |
| 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 | − | |
| 1688 | 1681 | /* read list file */ |
| 1689 | 1682 | static void args_parser_listfile(TCCState *s, |
| 1690 | 1683 | const char *filename, int optind, int *pargc, char ***pargv) |
| @@ -1991,27 +1984,6 @@ reparse: · 300 unmodified lines | ||
| 1991 | 1984 | tcc_error("cannot parse %s here", r); |
| 1992 | 1985 | tool = x; |
| 1993 | 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 | 1987 | default: |
| 2016 | 1988 | unsupported_option: |
| 2017 | 1989 | tcc_warning_c(warn_unsupported)("unsupported option '%s'", r); |
| @@ -37,7 +37,7 @@ static const char help[] = · 36 unmodified lines | ||
| 37 | 37 | " -std=c11 Conform to the ISO 2011 C standard.\n" |
| 38 | 38 | " -Wwarning set or reset (with 'no-' prefix) 'warning' (see tcc -hh)\n" |
| 39 | 39 | " -w disable all warnings\n" |
| 40 | − " --version -v show version\n" | |
| 40 | + " -v --version show version\n" | |
| 41 | 41 | " -vv show search paths or loaded files\n" |
| 42 | 42 | " -h -hh show this, show more help\n" |
| 43 | 43 | " -bench show compilation statistics\n" |
| @@ -70,16 +70,11 @@ static const char help[] = · 26 unmodified lines | ||
| 70 | 70 | " -nostdinc do not use standard system include paths\n" |
| 71 | 71 | " -nostdlib do not link with standard crt and libraries\n" |
| 72 | 72 | " -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" | |
| 77 | 75 | " -MF file specify dependency file name\n" |
| 78 | 76 | #if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64) |
| 79 | 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 | 78 | #endif |
| 84 | 79 | "Tools:\n" |
| 85 | 80 | " create library : tcc -ar [rcsv] lib.a files\n" |
| @@ -103,7 +98,7 @@ static const char help2[] = · 17 unmodified lines | ||
| 103 | 98 | " -print-search-dirs print search paths\n" |
| 104 | 99 | " -dt with -run/-E: auto-define 'test_...' macros\n" |
| 105 | 100 | "Ignored options:\n" |
| 106 | − " --param -pedantic -pipe -s -traditional\n" | |
| 101 | + " -arch -C --param -pedantic -pipe -s -traditional\n" | |
| 107 | 102 | "-W[no-]... warnings:\n" |
| 108 | 103 | " all turn on some (*) warnings\n" |
| 109 | 104 | " error[=warning] stop after warning (any or specified)\n" |
| @@ -49,6 +49,7 @@ endif · 48 unmodified lines | ||
| 49 | 49 | ifeq (-$(CONFIG_WIN32)-,-yes-) |
| 50 | 50 | SKIP += 106_versym.test # No pthread support |
| 51 | 51 | SKIP += 114_bound_signal.test # No pthread support |
| 52 | + SKIP += 117_builtins.test # win32 port doesn't define __builtins | |
| 52 | 53 | SKIP += 124_atomic_counter.test # No pthread support |
| 53 | 54 | endif |
| 54 | 55 | ifneq (,$(filter OpenBSD FreeBSD NetBSD,$(TARGETOS))) |
| @@ -8,7 +8,6 @@ if (%1)==(-clean) goto :cleanup · 7 unmodified lines | ||
| 8 | 8 | set CC=gcc |
| 9 | 9 | set /p VERSION= < ..\VERSION |
| 10 | 10 | set INST= |
| 11 | −set BIN= | |
| 12 | 11 | set DOC=no |
| 13 | 12 | set EXES_ONLY=no |
| 14 | 13 | goto :a0 |
| @@ -25,7 +24,6 @@ goto :a2 · 10 unmodified lines | ||
| 25 | 24 | if (%1)==(-t) set T=%2&& goto :a2 |
| 26 | 25 | if (%1)==(-v) set VERSION=%~2&& goto :a2 |
| 27 | 26 | if (%1)==(-i) set INST=%2&& goto :a2 |
| 28 | −if (%1)==(-b) set BIN=%2&& goto :a2 | |
| 29 | 27 | if (%1)==(-d) set DOC=yes&& goto :a3 |
| 30 | 28 | if (%1)==(-x) set EXES_ONLY=yes&& goto :a3 |
| 31 | 29 | if (%1)==() goto :p1 |
| @@ -37,7 +35,6 @@ echo -c "prog options" use prog with options to compile tcc · 5 unmodified lines | ||
| 37 | 35 | echo -t 32/64 force 32/64 bit default target |
| 38 | 36 | echo -v "version" set tcc version |
| 39 | 37 | echo -i tccdir install tcc into tccdir |
| 40 | −echo -b bindir optionally install binaries into bindir elsewhere | |
| 41 | 38 | echo -d create tcc-doc.html too (needs makeinfo) |
| 42 | 39 | echo -x just create the executables |
| 43 | 40 | echo -clean delete all previously produced files and directories |
| @@ -98,11 +95,13 @@ if %T%==64 goto :t64 · 54 unmodified lines | ||
| 98 | 95 | set D=%D32% |
| 99 | 96 | set DX=%D64% |
| 100 | 97 | set PX=%P64% |
| 98 | +set TX=64 | |
| 101 | 99 | goto :p3 |
| 102 | 100 | :t64 |
| 103 | 101 | set D=%D64% |
| 104 | 102 | set DX=%D32% |
| 105 | 103 | set PX=%P32% |
| 104 | +set TX=32 | |
| 106 | 105 | goto :p3 |
| 107 | 106 | |
| 108 | 107 | :p3 |
| @@ -118,12 +117,18 @@ echo>> ..\config.h #endif · 9 unmodified lines | ||
| 118 | 117 | |
| 119 | 118 | for %%f in (*tcc.exe *tcc.dll) do @del %%f |
| 120 | 119 | |
| 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 | |
| 123 | 128 | @if errorlevel 1 goto :the_end |
| 124 | 129 | %CC% -o tcc.exe ..\tcc.c libtcc.dll %D% -DONE_SOURCE"=0" |
| 125 | 130 | %CC% -o %PX%-tcc.exe ..\tcc.c %DX% |
| 126 | − | |
| 131 | +:compiler_done | |
| 127 | 132 | @if (%EXES_ONLY%)==(yes) goto :files_done |
| 128 | 133 | |
| 129 | 134 | if not exist libtcc mkdir libtcc |
| @@ -134,34 +139,13 @@ copy>nul ..\libtcc.h libtcc · 4 unmodified lines | ||
| 134 | 139 | copy>nul ..\tests\libtcc_test.c examples |
| 135 | 140 | copy>nul tcc-win32.txt doc |
| 136 | 141 | |
| 137 | −.\tcc -impdef libtcc.dll -o libtcc\libtcc.def | |
| 142 | +if exist libtcc.dll .\tcc -impdef libtcc.dll -o libtcc\libtcc.def | |
| 138 | 143 | @if errorlevel 1 goto :the_end |
| 139 | 144 | |
| 140 | 145 | :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% | |
| 153 | 147 | @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% | |
| 165 | 149 | @if errorlevel 1 goto :the_end |
| 166 | 150 | .\tcc -m%T% -c ../lib/bcheck.c -o lib/bcheck.o -g |
| 167 | 151 | .\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 | 164 | :copy-install |
| 181 | 165 | @if (%INST%)==() goto :the_end |
| 182 | 166 | 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 | |
| 186 | 168 | @if not exist %INST%\lib mkdir %INST%\lib |
| 187 | 169 | for %%f in (lib\*.a lib\*.o lib\*.def) do @copy>nul %%f %INST%\%%f |
| 188 | 170 | for %%f in (include examples libtcc doc) do @xcopy>nul /s/i/q/y %%f %INST%\%%f |
| 189 | 171 | |
| 190 | 172 | :the_end |
| 191 | 173 | 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% | |