mirror of
https://github.com/mirror/tinycc.git
synced 2024-12-26 03:50:07 +08:00
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
3
Makefile
3
Makefile
@ -236,8 +236,9 @@ libtcc.so: $(LIBTCC_OBJ)
|
||||
libtcc.so: CFLAGS+=-fPIC
|
||||
libtcc.so: LDFLAGS+=-fPIC
|
||||
|
||||
# OSX dynamic libtcc library
|
||||
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
|
||||
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)
|
||||
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) {
|
||||
/* default include paths */
|
||||
/* -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 char *optarg, *r;
|
||||
const char *run = NULL;
|
||||
int last_o = -1;
|
||||
int x;
|
||||
CString linker_arg; /* collect -Wl options */
|
||||
int tool = 0, arg_start = 0, noaction = optind;
|
||||
char **argv = *pargv;
|
||||
int argc = *pargc;
|
||||
int help = 0; /* remember if -h/--help has been seen */
|
||||
|
||||
cstr_new(&linker_arg);
|
||||
|
||||
@ -1776,13 +1795,11 @@ reparse:
|
||||
|
||||
switch(popt->index) {
|
||||
case TCC_OPTION_HELP:
|
||||
/* help is requested, postpone return to check for -v */
|
||||
help = OPT_HELP;
|
||||
break;
|
||||
x = OPT_HELP;
|
||||
goto extra_action;
|
||||
case TCC_OPTION_HELP2:
|
||||
/* help is requested, postpone return to check for -v */
|
||||
help = OPT_HELP2;
|
||||
break;
|
||||
x = OPT_HELP2;
|
||||
goto extra_action;
|
||||
case TCC_OPTION_I:
|
||||
tcc_add_include_path(s, optarg);
|
||||
break;
|
||||
@ -1804,7 +1821,6 @@ reparse:
|
||||
s->nb_libraries++;
|
||||
break;
|
||||
case TCC_OPTION_pthread:
|
||||
parse_option_D(s, "_REENTRANT");
|
||||
s->option_pthread = 1;
|
||||
break;
|
||||
case TCC_OPTION_bench:
|
||||
@ -1850,76 +1866,8 @@ reparse:
|
||||
s->static_link = 1;
|
||||
break;
|
||||
case TCC_OPTION_std:
|
||||
if (*optarg == '=') {
|
||||
if (strcmp(optarg, "=c11") == 0) {
|
||||
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"
|
||||
*/
|
||||
if (strcmp(optarg, "=c11") == 0)
|
||||
s->cversion = 201112;
|
||||
break;
|
||||
case TCC_OPTION_shared:
|
||||
x = TCC_OUTPUT_DLL;
|
||||
@ -2039,7 +1987,7 @@ reparse:
|
||||
s->filetype = x | (s->filetype & ~AFF_TYPE_MASK);
|
||||
break;
|
||||
case TCC_OPTION_O:
|
||||
last_o = atoi(optarg);
|
||||
s->optimize = atoi(optarg);
|
||||
break;
|
||||
case TCC_OPTION_print_search_dirs:
|
||||
x = OPT_PRINT_DIRS;
|
||||
@ -2068,16 +2016,6 @@ unsupported_option:
|
||||
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) {
|
||||
r = linker_arg.data;
|
||||
goto arg_err;
|
||||
|
13
tcc.c
13
tcc.c
@ -270,18 +270,14 @@ redo:
|
||||
if (n == 0) {
|
||||
if (opt == OPT_HELP) {
|
||||
fputs(help, stdout);
|
||||
return 0;
|
||||
if (!s->verbose)
|
||||
return 0;
|
||||
++opt;
|
||||
}
|
||||
if (opt == OPT_HELP2) {
|
||||
fputs(help2, stdout);
|
||||
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)
|
||||
tcc_tool_cross(s, argv, opt); /* never returns */
|
||||
if (s->verbose)
|
||||
@ -316,9 +312,6 @@ redo:
|
||||
tcc_error("cannot specify libraries with -c");
|
||||
if (s->nb_files > 1 && s->outfile)
|
||||
tcc_error("cannot specify output file with -c many files");
|
||||
} else {
|
||||
if (s->option_pthread)
|
||||
tcc_set_options(s, "-lpthread");
|
||||
}
|
||||
|
||||
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 */
|
||||
#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"
|
||||
# else
|
||||
# define CONFIG_TCC_SYSINCLUDEPATHS \
|
||||
@ -697,12 +697,14 @@ struct TCCState {
|
||||
unsigned char rdynamic; /* if true, all symbols are exported */
|
||||
unsigned char symbolic; /* if true, resolve symbols in the current module first */
|
||||
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, ... */
|
||||
|
||||
char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */
|
||||
char *soname; /* as specified on the command line (-soname) */
|
||||
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 */
|
||||
int output_type;
|
||||
@ -918,7 +920,6 @@ struct TCCState {
|
||||
unsigned char do_bench; /* option -bench */
|
||||
int gen_deps; /* option -MD */
|
||||
char *deps_outfile; /* option -MF */
|
||||
unsigned char option_pthread; /* -pthread option */
|
||||
int argc;
|
||||
char **argv;
|
||||
};
|
||||
@ -1285,7 +1286,6 @@ ST_FUNC char *normalize_slashes(char *path);
|
||||
#define OPT_PRINT_DIRS 4
|
||||
#define OPT_AR 5
|
||||
#define OPT_IMPDEF 6
|
||||
#define OPT_VERBOSE_HELP 7
|
||||
#define OPT_M32 32
|
||||
#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);
|
||||
/* add libc */
|
||||
if (!s1->nostdlib) {
|
||||
if (s1->option_pthread)
|
||||
tcc_add_library_err(s1, "pthread");
|
||||
tcc_add_library_err(s1, "c");
|
||||
#ifdef TCC_LIBGCC
|
||||
if (!s1->static_link) {
|
||||
|
Loading…
Reference in New Issue
Block a user