mirror of
https://github.com/mirror/tinycc.git
synced 2025-01-29 06:10:09 +08:00
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
This commit is contained in:
parent
e538160a32
commit
675046bd59
@ -222,6 +222,7 @@
|
||||
#else
|
||||
# define __RENAME(X) __asm__(X)
|
||||
#endif
|
||||
|
||||
#ifdef __BOUNDS_CHECKING_ON
|
||||
# define __BUILTINBC(ret,name,params) ret __builtin_##name params __RENAME("__bound_"#name);
|
||||
# define __BOUND(ret,name,params) ret name params __RENAME("__bound_"#name);
|
||||
@ -229,8 +230,13 @@
|
||||
# define __BUILTINBC(ret,name,params) ret __builtin_##name params __RENAME(#name);
|
||||
# define __BOUND(ret,name,params)
|
||||
#endif
|
||||
#ifdef _WIN32
|
||||
#define __BOTH __BOUND
|
||||
#define __BUILTIN(ret,name,params)
|
||||
#else
|
||||
#define __BOTH(ret,name,params) __BUILTINBC(ret,name,params)__BOUND(ret,name,params)
|
||||
#define __BUILTIN(ret,name,params) ret __builtin_##name params __RENAME(#name);
|
||||
#endif
|
||||
|
||||
__BOTH(void*, memcpy, (void *, const void*, __SIZE_TYPE__))
|
||||
__BOTH(void*, memmove, (void *, const void*, __SIZE_TYPE__))
|
||||
|
10
lib/Makefile
10
lib/Makefile
@ -42,11 +42,11 @@ $(X)BT_O += tcov.o
|
||||
|
||||
DSO_O = dsohandle.o
|
||||
|
||||
I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BT_O) stdatomic.o
|
||||
X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o $(BT_O) stdatomic.o
|
||||
ARM_O = libtcc1.o armeabi.o alloca-arm.o armflush.o fetch_and_add_arm.o $(BT_O)
|
||||
ARM64_O = lib-arm64.o fetch_and_add_arm64.o $(BT_O)
|
||||
RISCV64_O = lib-arm64.o fetch_and_add_riscv64.o $(BT_O)
|
||||
I386_O = libtcc1.o alloca.o alloca-bt.o $(BT_O) stdatomic.o
|
||||
X86_64_O = libtcc1.o alloca.o alloca-bt.o $(BT_O) stdatomic.o
|
||||
ARM_O = libtcc1.o armeabi.o alloca.o armflush.o fetch_and_add.o $(BT_O)
|
||||
ARM64_O = lib-arm64.o fetch_and_add.o $(BT_O)
|
||||
RISCV64_O = lib-arm64.o fetch_and_add.o $(BT_O)
|
||||
WIN_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o
|
||||
|
||||
OBJ-i386 = $(I386_O) $(BCHECK_O) $(DSO_O)
|
||||
|
@ -1,10 +0,0 @@
|
||||
.text
|
||||
.align 2
|
||||
.global alloca
|
||||
.type alloca, %function
|
||||
alloca:
|
||||
rsb sp, r0, sp
|
||||
bic sp, sp, #7
|
||||
mov r0, sp
|
||||
mov pc, lr
|
||||
.size alloca, .-alloca
|
@ -1,5 +1,5 @@
|
||||
/* ---------------------------------------------- */
|
||||
/* alloca86_64.S */
|
||||
/* alloca-bt.S */
|
||||
|
||||
#ifdef __leading_underscore
|
||||
# define _(s) _##s
|
||||
@ -7,6 +7,50 @@
|
||||
# define _(s) s
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------- */
|
||||
#if defined __i386__
|
||||
|
||||
.globl _(__bound_alloca)
|
||||
_(__bound_alloca):
|
||||
pop %edx
|
||||
pop %eax
|
||||
mov %eax, %ecx
|
||||
add $3+1,%eax
|
||||
and $-4,%eax
|
||||
jz p6
|
||||
|
||||
#ifdef _WIN32
|
||||
p4:
|
||||
cmp $4096,%eax
|
||||
jbe p5
|
||||
test %eax,-4096(%esp)
|
||||
sub $4096,%esp
|
||||
sub $4096,%eax
|
||||
jmp p4
|
||||
|
||||
p5:
|
||||
#endif
|
||||
|
||||
sub %eax,%esp
|
||||
mov %esp,%eax
|
||||
|
||||
push %edx
|
||||
push %eax
|
||||
push %ecx
|
||||
push %eax
|
||||
call _(__bound_new_region)
|
||||
add $8, %esp
|
||||
pop %eax
|
||||
pop %edx
|
||||
|
||||
p6:
|
||||
push %edx
|
||||
push %edx
|
||||
ret
|
||||
|
||||
/* ---------------------------------------------- */
|
||||
#elif defined __x86_64__
|
||||
|
||||
.globl _(__bound_alloca)
|
||||
_(__bound_alloca):
|
||||
#ifdef _WIN32
|
||||
@ -49,3 +93,4 @@ p3:
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------- */
|
||||
#endif
|
85
lib/alloca.S
Normal file
85
lib/alloca.S
Normal file
@ -0,0 +1,85 @@
|
||||
/* ---------------------------------------------- */
|
||||
/* alloca.S */
|
||||
|
||||
#ifdef __leading_underscore
|
||||
# define _(s) _##s
|
||||
#else
|
||||
# define _(s) s
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------- */
|
||||
#if defined __i386__
|
||||
|
||||
.globl _(alloca), _(__alloca)
|
||||
_(alloca):
|
||||
_(__alloca):
|
||||
push %ebp
|
||||
mov %esp,%ebp
|
||||
mov 8(%ebp),%eax
|
||||
add $3,%eax
|
||||
and $-4,%eax
|
||||
#ifdef _WIN32
|
||||
jmp .+16 #p2
|
||||
p1:
|
||||
sub $4096,%esp
|
||||
sub $4096,%eax
|
||||
test %eax,(%esp)
|
||||
p2:
|
||||
cmp $4096,%eax
|
||||
jae p1
|
||||
#endif
|
||||
sub %eax,%esp
|
||||
mov 4(%ebp),%eax
|
||||
mov 0(%ebp),%ebp
|
||||
add $8,%esp
|
||||
push %eax
|
||||
lea 8(%esp),%eax
|
||||
ret
|
||||
|
||||
/* ---------------------------------------------- */
|
||||
#elif defined __x86_64__
|
||||
|
||||
.globl _(alloca)
|
||||
_(alloca):
|
||||
pop %rdx
|
||||
#ifdef _WIN32
|
||||
mov %rcx,%rax
|
||||
#else
|
||||
mov %rdi,%rax
|
||||
#endif
|
||||
add $15,%rax
|
||||
and $-16,%rax
|
||||
jz p3
|
||||
|
||||
#ifdef _WIN32
|
||||
p1:
|
||||
cmp $4096,%rax
|
||||
jbe p2
|
||||
test %rax,-4096(%rsp)
|
||||
sub $4096,%rsp
|
||||
sub $4096,%rax
|
||||
jmp p1
|
||||
p2:
|
||||
#endif
|
||||
sub %rax,%rsp
|
||||
mov %rsp,%rax
|
||||
p3:
|
||||
push %rdx
|
||||
ret
|
||||
|
||||
/* ---------------------------------------------- */
|
||||
#elif defined __arm__
|
||||
|
||||
.text
|
||||
.align 2
|
||||
.global alloca
|
||||
.type alloca, %function
|
||||
alloca:
|
||||
rsb sp, r0, sp
|
||||
bic sp, sp, #7
|
||||
mov r0, sp
|
||||
mov pc, lr
|
||||
.size alloca, .-alloca
|
||||
|
||||
/* ---------------------------------------------- */
|
||||
#endif
|
@ -1,52 +0,0 @@
|
||||
/* ---------------------------------------------- */
|
||||
/* alloca86-bt.S */
|
||||
|
||||
#ifdef __leading_underscore
|
||||
# define _(s) _##s
|
||||
#else
|
||||
# define _(s) s
|
||||
#endif
|
||||
|
||||
.globl _(__bound_alloca)
|
||||
_(__bound_alloca):
|
||||
pop %edx
|
||||
pop %eax
|
||||
mov %eax, %ecx
|
||||
add $3+1,%eax
|
||||
and $-4,%eax
|
||||
jz p6
|
||||
|
||||
#ifdef _WIN32
|
||||
p4:
|
||||
cmp $4096,%eax
|
||||
jbe p5
|
||||
test %eax,-4096(%esp)
|
||||
sub $4096,%esp
|
||||
sub $4096,%eax
|
||||
jmp p4
|
||||
|
||||
p5:
|
||||
#endif
|
||||
|
||||
sub %eax,%esp
|
||||
mov %esp,%eax
|
||||
|
||||
push %edx
|
||||
push %eax
|
||||
push %ecx
|
||||
push %eax
|
||||
call _(__bound_new_region)
|
||||
add $8, %esp
|
||||
pop %eax
|
||||
pop %edx
|
||||
|
||||
p6:
|
||||
push %edx
|
||||
push %edx
|
||||
ret
|
||||
|
||||
/* mark stack as nonexecutable */
|
||||
#if defined __ELF__ && defined __linux__
|
||||
.section .note.GNU-stack,"",@progbits
|
||||
#endif
|
||||
/* ---------------------------------------------- */
|
@ -1,36 +0,0 @@
|
||||
/* ---------------------------------------------- */
|
||||
/* alloca86.S */
|
||||
|
||||
#ifdef __leading_underscore
|
||||
# define _(s) _##s
|
||||
#else
|
||||
# define _(s) s
|
||||
#endif
|
||||
|
||||
.globl _(alloca), _(__alloca)
|
||||
_(alloca):
|
||||
_(__alloca):
|
||||
push %ebp
|
||||
mov %esp,%ebp
|
||||
mov 8(%ebp),%eax
|
||||
add $3,%eax
|
||||
and $-4,%eax
|
||||
#ifdef _WIN32
|
||||
jmp .+16 #p2
|
||||
p1:
|
||||
sub $4096,%esp
|
||||
sub $4096,%eax
|
||||
test %eax,(%esp)
|
||||
p2:
|
||||
cmp $4096,%eax
|
||||
jae p1
|
||||
#endif
|
||||
sub %eax,%esp
|
||||
mov 4(%ebp),%eax
|
||||
mov 0(%ebp),%ebp
|
||||
add $8,%esp
|
||||
push %eax
|
||||
lea 8(%esp),%eax
|
||||
ret
|
||||
|
||||
/* ---------------------------------------------- */
|
@ -1,38 +0,0 @@
|
||||
/* ---------------------------------------------- */
|
||||
/* alloca86_64.S */
|
||||
|
||||
#ifdef __leading_underscore
|
||||
# define _(s) _##s
|
||||
#else
|
||||
# define _(s) s
|
||||
#endif
|
||||
|
||||
.globl _(alloca)
|
||||
_(alloca):
|
||||
pop %rdx
|
||||
#ifdef _WIN32
|
||||
mov %rcx,%rax
|
||||
#else
|
||||
mov %rdi,%rax
|
||||
#endif
|
||||
add $15,%rax
|
||||
and $-16,%rax
|
||||
jz p3
|
||||
|
||||
#ifdef _WIN32
|
||||
p1:
|
||||
cmp $4096,%rax
|
||||
jbe p2
|
||||
test %rax,-4096(%rsp)
|
||||
sub $4096,%rsp
|
||||
sub $4096,%rax
|
||||
jmp p1
|
||||
p2:
|
||||
#endif
|
||||
sub %rax,%rsp
|
||||
mov %rsp,%rax
|
||||
p3:
|
||||
push %rdx
|
||||
ret
|
||||
|
||||
/* ---------------------------------------------- */
|
67
lib/fetch_and_add.S
Normal file
67
lib/fetch_and_add.S
Normal file
@ -0,0 +1,67 @@
|
||||
/* ---------------------------------------------- */
|
||||
#if defined __arm__
|
||||
|
||||
.text
|
||||
.align 2
|
||||
.global fetch_and_add_arm
|
||||
.type fetch_and_add_arm, %function
|
||||
fetch_and_add_arm:
|
||||
mcr p15, #0, r0, c7, c10, #5
|
||||
.L0:
|
||||
ldrex r3, [r0]
|
||||
add r3, r3, r1
|
||||
strex r2, r3, [r0]
|
||||
cmp r2, #0
|
||||
bne .L0
|
||||
mcr p15, #0, r0, c7, c10, #5
|
||||
bx lr
|
||||
.size fetch_and_add_arm, .-fetch_and_add_arm
|
||||
|
||||
/* ---------------------------------------------- */
|
||||
#elif defined __aarch64__
|
||||
|
||||
.text
|
||||
.align 2
|
||||
.global fetch_and_add_arm64
|
||||
.type fetch_and_add_arm64, %function
|
||||
fetch_and_add_arm64:
|
||||
#ifdef __TINYC__
|
||||
.int 0x885f7c02
|
||||
.int 0x0b010042
|
||||
.int 0x8803fc02
|
||||
.int 0x35ffffa3
|
||||
.int 0xd5033bbf
|
||||
.int 0xd65f03c0
|
||||
#else
|
||||
ldxr w2, [x0]
|
||||
add w2, w2, w1
|
||||
stlxr w3, w2, [x0]
|
||||
cbnz w3, fetch_and_add_arm64
|
||||
dmb ish
|
||||
ret
|
||||
#endif
|
||||
|
||||
.size fetch_and_add_arm64, .-fetch_and_add_arm64
|
||||
|
||||
/* ---------------------------------------------- */
|
||||
#elif defined __riscv
|
||||
|
||||
.text
|
||||
.align 2
|
||||
.global fetch_and_add_riscv64
|
||||
.type fetch_and_add_riscv64, %function
|
||||
fetch_and_add_riscv64:
|
||||
#ifdef __TINYC__
|
||||
.int 0x0f50000f
|
||||
.int 0x004b5202f
|
||||
.short 0x8082
|
||||
#else
|
||||
fence iorw,ow
|
||||
amoadd.w.aq zero,a1,0(a0)
|
||||
ret
|
||||
#endif
|
||||
|
||||
.size fetch_and_add_riscv64, .-fetch_and_add_riscv64
|
||||
|
||||
/* ---------------------------------------------- */
|
||||
#endif
|
@ -1,15 +0,0 @@
|
||||
.text
|
||||
.align 2
|
||||
.global fetch_and_add_arm
|
||||
.type fetch_and_add_arm, %function
|
||||
fetch_and_add_arm:
|
||||
mcr p15, #0, r0, c7, c10, #5
|
||||
.L0:
|
||||
ldrex r3, [r0]
|
||||
add r3, r3, r1
|
||||
strex r2, r3, [r0]
|
||||
cmp r2, #0
|
||||
bne .L0
|
||||
mcr p15, #0, r0, c7, c10, #5
|
||||
bx lr
|
||||
.size fetch_and_add_arm, .-fetch_and_add_arm
|
@ -1,22 +0,0 @@
|
||||
.text
|
||||
.align 2
|
||||
.global fetch_and_add_arm64
|
||||
.type fetch_and_add_arm64, %function
|
||||
fetch_and_add_arm64:
|
||||
#ifdef __TINYC__
|
||||
.int 0x885f7c02
|
||||
.int 0x0b010042
|
||||
.int 0x8803fc02
|
||||
.int 0x35ffffa3
|
||||
.int 0xd5033bbf
|
||||
.int 0xd65f03c0
|
||||
#else
|
||||
ldxr w2, [x0]
|
||||
add w2, w2, w1
|
||||
stlxr w3, w2, [x0]
|
||||
cbnz w3, fetch_and_add_arm64
|
||||
dmb ish
|
||||
ret
|
||||
#endif
|
||||
|
||||
.size fetch_and_add_arm64, .-fetch_and_add_arm64
|
@ -1,16 +0,0 @@
|
||||
.text
|
||||
.align 2
|
||||
.global fetch_and_add_riscv64
|
||||
.type fetch_and_add_riscv64, %function
|
||||
fetch_and_add_riscv64:
|
||||
#ifdef __TINYC__
|
||||
.int 0x0f50000f
|
||||
.int 0x004b5202f
|
||||
.short 0x8082
|
||||
#else
|
||||
fence iorw,ow
|
||||
amoadd.w.aq zero,a1,0(a0)
|
||||
ret
|
||||
#endif
|
||||
|
||||
.size fetch_and_add_riscv64, .-fetch_and_add_riscv64
|
82
libtcc.c
82
libtcc.c
@ -83,8 +83,17 @@ ST_FUNC char *normalize_slashes(char *path)
|
||||
return path;
|
||||
}
|
||||
|
||||
/* NULL if this is tcc.exe, HINSTANCE if this is libtcc.dll */
|
||||
#if defined LIBTCC_AS_DLL && !defined CONFIG_TCCDIR
|
||||
static HMODULE tcc_module;
|
||||
BOOL WINAPI DllMain (HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
if (DLL_PROCESS_ATTACH == dwReason)
|
||||
tcc_module = hDll;
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
#define tcc_module NULL /* NULL means executable itself */
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_TCCDIR
|
||||
/* 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)
|
||||
tcc_add_library_path(s, normalize_slashes(buf));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef LIBTCC_AS_DLL
|
||||
BOOL WINAPI DllMain (HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved)
|
||||
{
|
||||
if (DLL_PROCESS_ATTACH == dwReason)
|
||||
tcc_module = hDll;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/********************************************************/
|
||||
@ -234,6 +234,14 @@ PUB_FUNC char *tcc_fileextension (const char *name)
|
||||
return e ? e : strchr(b, 0);
|
||||
}
|
||||
|
||||
ST_FUNC char *tcc_load_text(int fd)
|
||||
{
|
||||
int len = lseek(fd, 0, SEEK_END);
|
||||
char *buf = load_data(fd, 0, len + 1);
|
||||
buf[len] = 0;
|
||||
return buf;
|
||||
}
|
||||
|
||||
/********************************************************/
|
||||
/* memory management */
|
||||
|
||||
@ -1431,6 +1439,7 @@ typedef struct TCCOption {
|
||||
} TCCOption;
|
||||
|
||||
enum {
|
||||
TCC_OPTION_ignored = 0,
|
||||
TCC_OPTION_HELP,
|
||||
TCC_OPTION_HELP2,
|
||||
TCC_OPTION_v,
|
||||
@ -1455,8 +1464,6 @@ enum {
|
||||
TCC_OPTION_soname,
|
||||
TCC_OPTION_o,
|
||||
TCC_OPTION_r,
|
||||
TCC_OPTION_s,
|
||||
TCC_OPTION_traditional,
|
||||
TCC_OPTION_Wl,
|
||||
TCC_OPTION_Wp,
|
||||
TCC_OPTION_W,
|
||||
@ -1471,12 +1478,9 @@ enum {
|
||||
TCC_OPTION_nostdlib,
|
||||
TCC_OPTION_print_search_dirs,
|
||||
TCC_OPTION_rdynamic,
|
||||
TCC_OPTION_param,
|
||||
TCC_OPTION_pedantic,
|
||||
TCC_OPTION_pthread,
|
||||
TCC_OPTION_run,
|
||||
TCC_OPTION_w,
|
||||
TCC_OPTION_pipe,
|
||||
TCC_OPTION_E,
|
||||
TCC_OPTION_M,
|
||||
TCC_OPTION_MD,
|
||||
@ -1486,8 +1490,6 @@ enum {
|
||||
TCC_OPTION_x,
|
||||
TCC_OPTION_ar,
|
||||
TCC_OPTION_impdef,
|
||||
TCC_OPTION_C,
|
||||
TCC_OPTION_arch
|
||||
};
|
||||
|
||||
#define TCC_OPTION_HAS_ARG 0x0001
|
||||
@ -1523,14 +1525,10 @@ static const TCCOption tcc_options[] = {
|
||||
{ "shared", TCC_OPTION_shared, 0 },
|
||||
{ "soname", TCC_OPTION_soname, TCC_OPTION_HAS_ARG },
|
||||
{ "o", TCC_OPTION_o, TCC_OPTION_HAS_ARG },
|
||||
{ "-param", TCC_OPTION_param, TCC_OPTION_HAS_ARG },
|
||||
{ "pedantic", TCC_OPTION_pedantic, 0},
|
||||
{ "pthread", TCC_OPTION_pthread, 0},
|
||||
{ "run", TCC_OPTION_run, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
|
||||
{ "rdynamic", TCC_OPTION_rdynamic, 0 },
|
||||
{ "r", TCC_OPTION_r, 0 },
|
||||
{ "s", TCC_OPTION_s, 0 },
|
||||
{ "traditional", TCC_OPTION_traditional, 0 },
|
||||
{ "Wl,", TCC_OPTION_Wl, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
|
||||
{ "Wp,", TCC_OPTION_Wp, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
|
||||
{ "W", TCC_OPTION_W, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
|
||||
@ -1546,7 +1544,6 @@ static const TCCOption tcc_options[] = {
|
||||
{ "nostdlib", TCC_OPTION_nostdlib, 0 },
|
||||
{ "print-search-dirs", TCC_OPTION_print_search_dirs, 0 },
|
||||
{ "w", TCC_OPTION_w, 0 },
|
||||
{ "pipe", TCC_OPTION_pipe, 0},
|
||||
{ "E", TCC_OPTION_E, 0},
|
||||
{ "M", TCC_OPTION_M, 0},
|
||||
{ "MD", TCC_OPTION_MD, 0},
|
||||
@ -1558,10 +1555,14 @@ static const TCCOption tcc_options[] = {
|
||||
#ifdef TCC_TARGET_PE
|
||||
{ "impdef", TCC_OPTION_impdef, 0},
|
||||
#endif
|
||||
#ifdef TCC_TARGET_MACHO
|
||||
{ "arch", TCC_OPTION_arch, TCC_OPTION_HAS_ARG },
|
||||
#endif
|
||||
{ "C", TCC_OPTION_C, 0},
|
||||
/* ignored (silently, except after -Wunsupported) */
|
||||
{ "arch", 0, TCC_OPTION_HAS_ARG},
|
||||
{ "C", 0, 0 },
|
||||
{ "-param", 0, TCC_OPTION_HAS_ARG },
|
||||
{ "pedantic", 0, 0 },
|
||||
{ "pipe", 0, 0 },
|
||||
{ "s", 0, 0 },
|
||||
{ "traditional", 0, 0 },
|
||||
{ NULL, 0, 0 },
|
||||
};
|
||||
|
||||
@ -1677,14 +1678,6 @@ static int args_parser_make_argv(const char *r, int *argc, char ***argv)
|
||||
return ret;
|
||||
}
|
||||
|
||||
ST_FUNC char *tcc_load_text(int fd)
|
||||
{
|
||||
int len = lseek(fd, 0, SEEK_END);
|
||||
char *buf = load_data(fd, 0, len + 1);
|
||||
buf[len] = 0;
|
||||
return buf;
|
||||
}
|
||||
|
||||
/* read list file */
|
||||
static void args_parser_listfile(TCCState *s,
|
||||
const char *filename, int optind, int *pargc, char ***pargv)
|
||||
@ -1991,27 +1984,6 @@ reparse:
|
||||
tcc_error("cannot parse %s here", r);
|
||||
tool = x;
|
||||
break;
|
||||
#if defined(TCC_TARGET_MACHO)
|
||||
case TCC_OPTION_arch:
|
||||
#if defined(TCC_TARGET_X86_64)
|
||||
if (strcmp(optarg, "x86_64") == 0)
|
||||
break; /* Ok, arch matches target */
|
||||
#endif
|
||||
#if defined(TCC_TARGET_ARM64)
|
||||
if (strcmp(optarg, "arm64") == 0)
|
||||
break; /* Ok, arch matches target */
|
||||
#endif
|
||||
tcc_error("this compiler does not support %s", optarg);
|
||||
/* ignored */
|
||||
break;
|
||||
#endif
|
||||
case TCC_OPTION_traditional:
|
||||
case TCC_OPTION_pedantic:
|
||||
case TCC_OPTION_pipe:
|
||||
case TCC_OPTION_s:
|
||||
case TCC_OPTION_C:
|
||||
/* ignored */
|
||||
break;
|
||||
default:
|
||||
unsupported_option:
|
||||
tcc_warning_c(warn_unsupported)("unsupported option '%s'", r);
|
||||
|
13
tcc.c
13
tcc.c
@ -37,7 +37,7 @@ static const char help[] =
|
||||
" -std=c11 Conform to the ISO 2011 C standard.\n"
|
||||
" -Wwarning set or reset (with 'no-' prefix) 'warning' (see tcc -hh)\n"
|
||||
" -w disable all warnings\n"
|
||||
" --version -v show version\n"
|
||||
" -v --version show version\n"
|
||||
" -vv show search paths or loaded files\n"
|
||||
" -h -hh show this, show more help\n"
|
||||
" -bench show compilation statistics\n"
|
||||
@ -70,16 +70,11 @@ static const char help[] =
|
||||
" -nostdinc do not use standard system include paths\n"
|
||||
" -nostdlib do not link with standard crt and libraries\n"
|
||||
" -Bdir set tcc's private include/library dir\n"
|
||||
" -M just output makefile fragment with dependencies\n"
|
||||
" -MM like -M but ignore system libs\n"
|
||||
" -MD generate dependency file for make\n"
|
||||
" -MMD like -MMD but ignore system libs\n"
|
||||
" -M[M]D generate make dependency file [ignore system files]\n"
|
||||
" -M[M] as above but no other output\n"
|
||||
" -MF file specify dependency file name\n"
|
||||
#if defined(TCC_TARGET_I386) || defined(TCC_TARGET_X86_64)
|
||||
" -m32/64 defer to i386/x86_64 cross compiler\n"
|
||||
#endif
|
||||
#if defined(TCC_TARGET_MACHO) || defined(TCC_TARGET_X86_64)
|
||||
" -arch set macos target achitecture (ignored, always x86_64)\n"
|
||||
#endif
|
||||
"Tools:\n"
|
||||
" create library : tcc -ar [rcsv] lib.a files\n"
|
||||
@ -103,7 +98,7 @@ static const char help2[] =
|
||||
" -print-search-dirs print search paths\n"
|
||||
" -dt with -run/-E: auto-define 'test_...' macros\n"
|
||||
"Ignored options:\n"
|
||||
" --param -pedantic -pipe -s -traditional\n"
|
||||
" -arch -C --param -pedantic -pipe -s -traditional\n"
|
||||
"-W[no-]... warnings:\n"
|
||||
" all turn on some (*) warnings\n"
|
||||
" error[=warning] stop after warning (any or specified)\n"
|
||||
|
@ -49,6 +49,7 @@ endif
|
||||
ifeq (-$(CONFIG_WIN32)-,-yes-)
|
||||
SKIP += 106_versym.test # No pthread support
|
||||
SKIP += 114_bound_signal.test # No pthread support
|
||||
SKIP += 117_builtins.test # win32 port doesn't define __builtins
|
||||
SKIP += 124_atomic_counter.test # No pthread support
|
||||
endif
|
||||
ifneq (,$(filter OpenBSD FreeBSD NetBSD,$(TARGETOS)))
|
||||
|
@ -8,7 +8,6 @@ if (%1)==(-clean) goto :cleanup
|
||||
set CC=gcc
|
||||
set /p VERSION= < ..\VERSION
|
||||
set INST=
|
||||
set BIN=
|
||||
set DOC=no
|
||||
set EXES_ONLY=no
|
||||
goto :a0
|
||||
@ -25,7 +24,6 @@ goto :a2
|
||||
if (%1)==(-t) set T=%2&& goto :a2
|
||||
if (%1)==(-v) set VERSION=%~2&& goto :a2
|
||||
if (%1)==(-i) set INST=%2&& goto :a2
|
||||
if (%1)==(-b) set BIN=%2&& goto :a2
|
||||
if (%1)==(-d) set DOC=yes&& goto :a3
|
||||
if (%1)==(-x) set EXES_ONLY=yes&& goto :a3
|
||||
if (%1)==() goto :p1
|
||||
@ -37,7 +35,6 @@ echo -c "prog options" use prog with options to compile tcc
|
||||
echo -t 32/64 force 32/64 bit default target
|
||||
echo -v "version" set tcc version
|
||||
echo -i tccdir install tcc into tccdir
|
||||
echo -b bindir optionally install binaries into bindir elsewhere
|
||||
echo -d create tcc-doc.html too (needs makeinfo)
|
||||
echo -x just create the executables
|
||||
echo -clean delete all previously produced files and directories
|
||||
@ -98,11 +95,13 @@ if %T%==64 goto :t64
|
||||
set D=%D32%
|
||||
set DX=%D64%
|
||||
set PX=%P64%
|
||||
set TX=64
|
||||
goto :p3
|
||||
:t64
|
||||
set D=%D64%
|
||||
set DX=%D32%
|
||||
set PX=%P32%
|
||||
set TX=32
|
||||
goto :p3
|
||||
|
||||
:p3
|
||||
@ -118,12 +117,18 @@ echo>> ..\config.h #endif
|
||||
|
||||
for %%f in (*tcc.exe *tcc.dll) do @del %%f
|
||||
|
||||
:compiler
|
||||
%CC% -o libtcc.dll -shared ..\libtcc.c %D% -DLIBTCC_AS_DLL
|
||||
@if _%TCC_C%_==__ goto compiler_2parts
|
||||
@rem if TCC_C was defined then build only tcc.exe
|
||||
%CC% -o tcc.exe %TCC_C% %D%
|
||||
@goto :compiler_done
|
||||
|
||||
:compiler_2parts
|
||||
@if _%LIBTCC_C%_==__ set LIBTCC_C=..\libtcc.c
|
||||
%CC% -o libtcc.dll -shared %LIBTCC_C% %D% -DLIBTCC_AS_DLL
|
||||
@if errorlevel 1 goto :the_end
|
||||
%CC% -o tcc.exe ..\tcc.c libtcc.dll %D% -DONE_SOURCE"=0"
|
||||
%CC% -o %PX%-tcc.exe ..\tcc.c %DX%
|
||||
|
||||
:compiler_done
|
||||
@if (%EXES_ONLY%)==(yes) goto :files_done
|
||||
|
||||
if not exist libtcc mkdir libtcc
|
||||
@ -134,34 +139,13 @@ copy>nul ..\libtcc.h libtcc
|
||||
copy>nul ..\tests\libtcc_test.c examples
|
||||
copy>nul tcc-win32.txt doc
|
||||
|
||||
.\tcc -impdef libtcc.dll -o libtcc\libtcc.def
|
||||
if exist libtcc.dll .\tcc -impdef libtcc.dll -o libtcc\libtcc.def
|
||||
@if errorlevel 1 goto :the_end
|
||||
|
||||
:libtcc1.a
|
||||
@set O1=libtcc1.o crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o chkstk.o
|
||||
.\tcc -m32 -c ../lib/libtcc1.c
|
||||
.\tcc -m32 -c lib/crt1.c
|
||||
.\tcc -m32 -c lib/crt1w.c
|
||||
.\tcc -m32 -c lib/wincrt1.c
|
||||
.\tcc -m32 -c lib/wincrt1w.c
|
||||
.\tcc -m32 -c lib/dllcrt1.c
|
||||
.\tcc -m32 -c lib/dllmain.c
|
||||
.\tcc -m32 -c lib/chkstk.S
|
||||
.\tcc -m32 -c ../lib/alloca86.S
|
||||
.\tcc -m32 -c ../lib/alloca86-bt.S
|
||||
.\tcc -m32 -ar lib/libtcc1-32.a %O1% alloca86.o alloca86-bt.o
|
||||
call :makelib %T%
|
||||
@if errorlevel 1 goto :the_end
|
||||
.\tcc -m64 -c ../lib/libtcc1.c
|
||||
.\tcc -m64 -c lib/crt1.c
|
||||
.\tcc -m64 -c lib/crt1w.c
|
||||
.\tcc -m64 -c lib/wincrt1.c
|
||||
.\tcc -m64 -c lib/wincrt1w.c
|
||||
.\tcc -m64 -c lib/dllcrt1.c
|
||||
.\tcc -m64 -c lib/dllmain.c
|
||||
.\tcc -m64 -c lib/chkstk.S
|
||||
.\tcc -m64 -c ../lib/alloca86_64.S
|
||||
.\tcc -m64 -c ../lib/alloca86_64-bt.S
|
||||
.\tcc -m64 -ar lib/libtcc1-64.a %O1% alloca86_64.o alloca86_64-bt.o
|
||||
@if exist %PX%-tcc.exe call :makelib %TX%
|
||||
@if errorlevel 1 goto :the_end
|
||||
.\tcc -m%T% -c ../lib/bcheck.c -o lib/bcheck.o -g
|
||||
.\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
|
||||
:copy-install
|
||||
@if (%INST%)==() goto :the_end
|
||||
if not exist %INST% mkdir %INST%
|
||||
@if (%BIN%)==() set BIN=%INST%
|
||||
if not exist %BIN% mkdir %BIN%
|
||||
for %%f in (*tcc.exe *tcc.dll) do @copy>nul %%f %BIN%\%%f
|
||||
for %%f in (*tcc.exe *tcc.dll) do @copy>nul %%f %INST%\%%f
|
||||
@if not exist %INST%\lib mkdir %INST%\lib
|
||||
for %%f in (lib\*.a lib\*.o lib\*.def) do @copy>nul %%f %INST%\%%f
|
||||
for %%f in (include examples libtcc doc) do @xcopy>nul /s/i/q/y %%f %INST%\%%f
|
||||
|
||||
:the_end
|
||||
exit /B %ERRORLEVEL%
|
||||
|
||||
:makelib
|
||||
.\tcc -m%1 -c ../lib/libtcc1.c
|
||||
.\tcc -m%1 -c lib/crt1.c
|
||||
.\tcc -m%1 -c lib/crt1w.c
|
||||
.\tcc -m%1 -c lib/wincrt1.c
|
||||
.\tcc -m%1 -c lib/wincrt1w.c
|
||||
.\tcc -m%1 -c lib/dllcrt1.c
|
||||
.\tcc -m%1 -c lib/dllmain.c
|
||||
.\tcc -m%1 -c lib/chkstk.S
|
||||
.\tcc -m%1 -c ../lib/alloca.S
|
||||
.\tcc -m%1 -c ../lib/alloca-bt.S
|
||||
.\tcc -m%1 -c ../lib/stdatomic.c
|
||||
.\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
|
||||
exit /B %ERRORLEVEL%
|
||||
|
Loading…
Reference in New Issue
Block a user