tcc --help -v: cleanup
from e640ed1aeb
Also:
- cleanup -std, -O, -pthread
- tcc.h:win32: use win32-type include paths even for cross
compilers (needed for loading tcc_predefs.h in cases)
- Makefile: simplify OSX .dylib clause
This commit is contained in:
parent
8fb8d88ea6
commit
e7a4140d28
6 changed files with 40 additions and 105 deletions
3
Makefile
3
Makefile
|
@ -236,8 +236,9 @@ libtcc.so: $(LIBTCC_OBJ)
|
||||||
libtcc.so: CFLAGS+=-fPIC
|
libtcc.so: CFLAGS+=-fPIC
|
||||||
libtcc.so: LDFLAGS+=-fPIC
|
libtcc.so: LDFLAGS+=-fPIC
|
||||||
|
|
||||||
|
# OSX dynamic libtcc library
|
||||||
libtcc.dylib: $(LIBTCC_OBJ)
|
libtcc.dylib: $(LIBTCC_OBJ)
|
||||||
$(CC) -shared -o libtcc.dylib libtcc.o tccpp.o tccgen.o tccelf.o tccasm.o tccrun.o x86_64-gen.o x86_64-link.o i386-asm.o -flat_namespace
|
$S$(CC) -shared -o $@ $^ $(LDFLAGS)
|
||||||
|
|
||||||
# windows dynamic libtcc library
|
# windows dynamic libtcc library
|
||||||
libtcc.dll : $(LIBTCC_OBJ)
|
libtcc.dll : $(LIBTCC_OBJ)
|
||||||
|
|
118
libtcc.c
118
libtcc.c
|
@ -986,6 +986,27 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type)
|
||||||
if (s->char_is_unsigned)
|
if (s->char_is_unsigned)
|
||||||
tcc_define_symbol(s, "__CHAR_UNSIGNED__", NULL);
|
tcc_define_symbol(s, "__CHAR_UNSIGNED__", NULL);
|
||||||
|
|
||||||
|
if (s->cversion == 201112) {
|
||||||
|
tcc_undefine_symbol(s, "__STDC_VERSION__");
|
||||||
|
tcc_define_symbol(s, "__STDC_VERSION__", "201112L");
|
||||||
|
tcc_define_symbol(s, "__STDC_NO_ATOMICS__", NULL);
|
||||||
|
tcc_define_symbol(s, "__STDC_NO_COMPLEX__", NULL);
|
||||||
|
tcc_define_symbol(s, "__STDC_NO_THREADS__", NULL);
|
||||||
|
#ifndef TCC_TARGET_PE
|
||||||
|
/* on Linux, this conflicts with a define introduced by
|
||||||
|
/usr/include/stdc-predef.h included by glibc libs
|
||||||
|
tcc_define_symbol(s, "__STDC_ISO_10646__", "201605L"); */
|
||||||
|
tcc_define_symbol(s, "__STDC_UTF_16__", NULL);
|
||||||
|
tcc_define_symbol(s, "__STDC_UTF_32__", NULL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s->optimize > 0)
|
||||||
|
tcc_define_symbol(s, "__OPTIMIZE__", NULL);
|
||||||
|
|
||||||
|
if (s->option_pthread)
|
||||||
|
tcc_define_symbol(s, "_REENTRANT", NULL);
|
||||||
|
|
||||||
if (!s->nostdinc) {
|
if (!s->nostdinc) {
|
||||||
/* default include paths */
|
/* default include paths */
|
||||||
/* -isystem paths have already been handled */
|
/* -isystem paths have already been handled */
|
||||||
|
@ -1719,13 +1740,11 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int *pargc, char ***pargv, int optind)
|
||||||
const TCCOption *popt;
|
const TCCOption *popt;
|
||||||
const char *optarg, *r;
|
const char *optarg, *r;
|
||||||
const char *run = NULL;
|
const char *run = NULL;
|
||||||
int last_o = -1;
|
|
||||||
int x;
|
int x;
|
||||||
CString linker_arg; /* collect -Wl options */
|
CString linker_arg; /* collect -Wl options */
|
||||||
int tool = 0, arg_start = 0, noaction = optind;
|
int tool = 0, arg_start = 0, noaction = optind;
|
||||||
char **argv = *pargv;
|
char **argv = *pargv;
|
||||||
int argc = *pargc;
|
int argc = *pargc;
|
||||||
int help = 0; /* remember if -h/--help has been seen */
|
|
||||||
|
|
||||||
cstr_new(&linker_arg);
|
cstr_new(&linker_arg);
|
||||||
|
|
||||||
|
@ -1776,13 +1795,11 @@ reparse:
|
||||||
|
|
||||||
switch(popt->index) {
|
switch(popt->index) {
|
||||||
case TCC_OPTION_HELP:
|
case TCC_OPTION_HELP:
|
||||||
/* help is requested, postpone return to check for -v */
|
x = OPT_HELP;
|
||||||
help = OPT_HELP;
|
goto extra_action;
|
||||||
break;
|
|
||||||
case TCC_OPTION_HELP2:
|
case TCC_OPTION_HELP2:
|
||||||
/* help is requested, postpone return to check for -v */
|
x = OPT_HELP2;
|
||||||
help = OPT_HELP2;
|
goto extra_action;
|
||||||
break;
|
|
||||||
case TCC_OPTION_I:
|
case TCC_OPTION_I:
|
||||||
tcc_add_include_path(s, optarg);
|
tcc_add_include_path(s, optarg);
|
||||||
break;
|
break;
|
||||||
|
@ -1804,7 +1821,6 @@ reparse:
|
||||||
s->nb_libraries++;
|
s->nb_libraries++;
|
||||||
break;
|
break;
|
||||||
case TCC_OPTION_pthread:
|
case TCC_OPTION_pthread:
|
||||||
parse_option_D(s, "_REENTRANT");
|
|
||||||
s->option_pthread = 1;
|
s->option_pthread = 1;
|
||||||
break;
|
break;
|
||||||
case TCC_OPTION_bench:
|
case TCC_OPTION_bench:
|
||||||
|
@ -1850,76 +1866,8 @@ reparse:
|
||||||
s->static_link = 1;
|
s->static_link = 1;
|
||||||
break;
|
break;
|
||||||
case TCC_OPTION_std:
|
case TCC_OPTION_std:
|
||||||
if (*optarg == '=') {
|
if (strcmp(optarg, "=c11") == 0)
|
||||||
if (strcmp(optarg, "=c11") == 0) {
|
s->cversion = 201112;
|
||||||
tcc_undefine_symbol(s, "__STDC_VERSION__");
|
|
||||||
tcc_define_symbol(s, "__STDC_VERSION__", "201112L");
|
|
||||||
/*
|
|
||||||
* The integer constant 1, intended to indicate
|
|
||||||
* that the implementation does not support atomic
|
|
||||||
* types (including the _Atomic type qualifier) and
|
|
||||||
* the <stdatomic.h> header.
|
|
||||||
*/
|
|
||||||
tcc_define_symbol(s, "__STDC_NO_ATOMICS__", "1");
|
|
||||||
/*
|
|
||||||
* The integer constant 1, intended to indicate
|
|
||||||
* that the implementation does not support complex
|
|
||||||
* types or the <complex.h> header.
|
|
||||||
*/
|
|
||||||
tcc_define_symbol(s, "__STDC_NO_COMPLEX__", "1");
|
|
||||||
/*
|
|
||||||
* The integer constant 1, intended to indicate
|
|
||||||
* that the implementation does not support the
|
|
||||||
* <threads.h> header.
|
|
||||||
*/
|
|
||||||
tcc_define_symbol(s, "__STDC_NO_THREADS__", "1");
|
|
||||||
/*
|
|
||||||
* __STDC_NO_VLA__, tcc supports VLA.
|
|
||||||
* The integer constant 1, intended to indicate
|
|
||||||
* that the implementation does not support
|
|
||||||
* variable length arrays or variably modified
|
|
||||||
* types.
|
|
||||||
*/
|
|
||||||
#if !defined(TCC_TARGET_PE)
|
|
||||||
/*
|
|
||||||
* An integer constant of the form yyyymmL (for
|
|
||||||
* example, 199712L). If this symbol is defined,
|
|
||||||
* then every character in the Unicode required
|
|
||||||
* set, when stored in an object of type
|
|
||||||
* wchar_t, has the same value as the short
|
|
||||||
* identifier of that character.
|
|
||||||
*/
|
|
||||||
#if 0
|
|
||||||
/* on Linux, this conflicts with a define introduced by
|
|
||||||
* /usr/include/stdc-predef.h included by glibc libs;
|
|
||||||
* clang doesn't define it at all so it's probably not necessary
|
|
||||||
*/
|
|
||||||
tcc_define_symbol(s, "__STDC_ISO_10646__", "201605L");
|
|
||||||
#endif
|
|
||||||
/*
|
|
||||||
* The integer constant 1, intended to indicate
|
|
||||||
* that values of type char16_t are UTF−16
|
|
||||||
* encoded. If some other encoding is used, the
|
|
||||||
* macro shall not be defined and the actual
|
|
||||||
* encoding used is implementation defined.
|
|
||||||
*/
|
|
||||||
tcc_define_symbol(s, "__STDC_UTF_16__", "1");
|
|
||||||
/*
|
|
||||||
* The integer constant 1, intended to indicate
|
|
||||||
* that values of type char32_t are UTF−32
|
|
||||||
* encoded. If some other encoding is used, the
|
|
||||||
* macro shall not be defined and the actual
|
|
||||||
* encoding used is implementationdefined.
|
|
||||||
*/
|
|
||||||
tcc_define_symbol(s, "__STDC_UTF_32__", "1");
|
|
||||||
#endif /* !TCC_TARGET_PE */
|
|
||||||
s->cversion = 201112;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* silently ignore other values, a current purpose:
|
|
||||||
* allow to use a tcc as a reference compiler for "make test"
|
|
||||||
*/
|
|
||||||
break;
|
break;
|
||||||
case TCC_OPTION_shared:
|
case TCC_OPTION_shared:
|
||||||
x = TCC_OUTPUT_DLL;
|
x = TCC_OUTPUT_DLL;
|
||||||
|
@ -2039,7 +1987,7 @@ reparse:
|
||||||
s->filetype = x | (s->filetype & ~AFF_TYPE_MASK);
|
s->filetype = x | (s->filetype & ~AFF_TYPE_MASK);
|
||||||
break;
|
break;
|
||||||
case TCC_OPTION_O:
|
case TCC_OPTION_O:
|
||||||
last_o = atoi(optarg);
|
s->optimize = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case TCC_OPTION_print_search_dirs:
|
case TCC_OPTION_print_search_dirs:
|
||||||
x = OPT_PRINT_DIRS;
|
x = OPT_PRINT_DIRS;
|
||||||
|
@ -2068,16 +2016,6 @@ unsupported_option:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (help) {
|
|
||||||
if (s->verbose > 0)
|
|
||||||
return OPT_VERBOSE_HELP;
|
|
||||||
else
|
|
||||||
return help;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (last_o > 0)
|
|
||||||
tcc_define_symbol(s, "__OPTIMIZE__", NULL);
|
|
||||||
if (linker_arg.size) {
|
if (linker_arg.size) {
|
||||||
r = linker_arg.data;
|
r = linker_arg.data;
|
||||||
goto arg_err;
|
goto arg_err;
|
||||||
|
|
13
tcc.c
13
tcc.c
|
@ -270,18 +270,14 @@ redo:
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
if (opt == OPT_HELP) {
|
if (opt == OPT_HELP) {
|
||||||
fputs(help, stdout);
|
fputs(help, stdout);
|
||||||
return 0;
|
if (!s->verbose)
|
||||||
|
return 0;
|
||||||
|
++opt;
|
||||||
}
|
}
|
||||||
if (opt == OPT_HELP2) {
|
if (opt == OPT_HELP2) {
|
||||||
fputs(help2, stdout);
|
fputs(help2, stdout);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (opt == OPT_VERBOSE_HELP) {
|
|
||||||
/* simulate gcc -v --help */
|
|
||||||
fputs(help, stdout);
|
|
||||||
fputs(help2, stdout);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if (opt == OPT_M32 || opt == OPT_M64)
|
if (opt == OPT_M32 || opt == OPT_M64)
|
||||||
tcc_tool_cross(s, argv, opt); /* never returns */
|
tcc_tool_cross(s, argv, opt); /* never returns */
|
||||||
if (s->verbose)
|
if (s->verbose)
|
||||||
|
@ -316,9 +312,6 @@ redo:
|
||||||
tcc_error("cannot specify libraries with -c");
|
tcc_error("cannot specify libraries with -c");
|
||||||
if (s->nb_files > 1 && s->outfile)
|
if (s->nb_files > 1 && s->outfile)
|
||||||
tcc_error("cannot specify output file with -c many files");
|
tcc_error("cannot specify output file with -c many files");
|
||||||
} else {
|
|
||||||
if (s->option_pthread)
|
|
||||||
tcc_set_options(s, "-lpthread");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->do_bench)
|
if (s->do_bench)
|
||||||
|
|
8
tcc.h
8
tcc.h
|
@ -220,7 +220,7 @@ extern long double strtold (const char *__nptr, char **__endptr);
|
||||||
|
|
||||||
/* system include paths */
|
/* system include paths */
|
||||||
#ifndef CONFIG_TCC_SYSINCLUDEPATHS
|
#ifndef CONFIG_TCC_SYSINCLUDEPATHS
|
||||||
# ifdef TCC_TARGET_PE
|
# if defined TCC_TARGET_PE || defined _WIN32
|
||||||
# define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include"PATHSEP"{B}/include/winapi"
|
# define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include"PATHSEP"{B}/include/winapi"
|
||||||
# else
|
# else
|
||||||
# define CONFIG_TCC_SYSINCLUDEPATHS \
|
# define CONFIG_TCC_SYSINCLUDEPATHS \
|
||||||
|
@ -697,12 +697,14 @@ struct TCCState {
|
||||||
unsigned char rdynamic; /* if true, all symbols are exported */
|
unsigned char rdynamic; /* if true, all symbols are exported */
|
||||||
unsigned char symbolic; /* if true, resolve symbols in the current module first */
|
unsigned char symbolic; /* if true, resolve symbols in the current module first */
|
||||||
unsigned char filetype; /* file type for compilation (NONE,C,ASM) */
|
unsigned char filetype; /* file type for compilation (NONE,C,ASM) */
|
||||||
|
unsigned char optimize; /* only to #define __OPTIMIZE__ */
|
||||||
|
unsigned char option_pthread; /* -pthread option */
|
||||||
|
unsigned char enable_new_dtags; /* -Wl,--enable-new-dtags */
|
||||||
unsigned int cversion; /* supported C ISO version, 199901 (the default), 201112, ... */
|
unsigned int cversion; /* supported C ISO version, 199901 (the default), 201112, ... */
|
||||||
|
|
||||||
char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */
|
char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */
|
||||||
char *soname; /* as specified on the command line (-soname) */
|
char *soname; /* as specified on the command line (-soname) */
|
||||||
char *rpath; /* as specified on the command line (-Wl,-rpath=) */
|
char *rpath; /* as specified on the command line (-Wl,-rpath=) */
|
||||||
unsigned char enable_new_dtags; /* ditto, (-Wl,--enable-new-dtags) */
|
|
||||||
|
|
||||||
/* output type, see TCC_OUTPUT_XXX */
|
/* output type, see TCC_OUTPUT_XXX */
|
||||||
int output_type;
|
int output_type;
|
||||||
|
@ -918,7 +920,6 @@ struct TCCState {
|
||||||
unsigned char do_bench; /* option -bench */
|
unsigned char do_bench; /* option -bench */
|
||||||
int gen_deps; /* option -MD */
|
int gen_deps; /* option -MD */
|
||||||
char *deps_outfile; /* option -MF */
|
char *deps_outfile; /* option -MF */
|
||||||
unsigned char option_pthread; /* -pthread option */
|
|
||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
};
|
};
|
||||||
|
@ -1285,7 +1286,6 @@ ST_FUNC char *normalize_slashes(char *path);
|
||||||
#define OPT_PRINT_DIRS 4
|
#define OPT_PRINT_DIRS 4
|
||||||
#define OPT_AR 5
|
#define OPT_AR 5
|
||||||
#define OPT_IMPDEF 6
|
#define OPT_IMPDEF 6
|
||||||
#define OPT_VERBOSE_HELP 7
|
|
||||||
#define OPT_M32 32
|
#define OPT_M32 32
|
||||||
#define OPT_M64 64
|
#define OPT_M64 64
|
||||||
|
|
||||||
|
|
2
tccelf.c
2
tccelf.c
|
@ -1417,6 +1417,8 @@ ST_FUNC void tcc_add_runtime(TCCState *s1)
|
||||||
tcc_add_pragma_libs(s1);
|
tcc_add_pragma_libs(s1);
|
||||||
/* add libc */
|
/* add libc */
|
||||||
if (!s1->nostdlib) {
|
if (!s1->nostdlib) {
|
||||||
|
if (s1->option_pthread)
|
||||||
|
tcc_add_library_err(s1, "pthread");
|
||||||
tcc_add_library_err(s1, "c");
|
tcc_add_library_err(s1, "c");
|
||||||
#ifdef TCC_LIBGCC
|
#ifdef TCC_LIBGCC
|
||||||
if (!s1->static_link) {
|
if (!s1->static_link) {
|
||||||
|
|
1
tccpe.c
1
tccpe.c
|
@ -1996,6 +1996,7 @@ ST_FUNC int pe_output_file(TCCState *s1, const char *filename)
|
||||||
memset(&pe, 0, sizeof pe);
|
memset(&pe, 0, sizeof pe);
|
||||||
pe.filename = filename;
|
pe.filename = filename;
|
||||||
pe.s1 = s1;
|
pe.s1 = s1;
|
||||||
|
s1->filetype = 0;
|
||||||
|
|
||||||
#ifdef CONFIG_TCC_BCHECK
|
#ifdef CONFIG_TCC_BCHECK
|
||||||
tcc_add_bcheck(s1);
|
tcc_add_bcheck(s1);
|
||||||
|
|
Loading…
Reference in a new issue