History

tcc --help -v: cleanup

from e640ed1aeb8c525f476436e561130cd73afaad0e

grischka committed 6 years ago

Commit e7a41401 parent 8fb8d886 files · +40 −105Browse files

Unified · Split

6 files
  1. Makefile +2 −1
  2. libtcc.c +28 −90
  3. tcc.c +3 −10
  4. tcc.h +4 −4
  5. tccelf.c +2 −0
  6. tccpe.c +1 −0
Makefile+2−1
@@ -236,8 +236,9 @@ libtcc.so: $(LIBTCC_OBJ) · 235 unmodified lines
236236 libtcc.so: CFLAGS+=-fPIC
237237 libtcc.so: LDFLAGS+=-fPIC
238238
239+# OSX dynamic libtcc library
239240 libtcc.dylib: $(LIBTCC_OBJ)
240− $(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
241+ $S$(CC) -shared -o $@ $^ $(LDFLAGS)
241242
242243 # windows dynamic libtcc library
243244 libtcc.dll : $(LIBTCC_OBJ)
libtcc.c+28−90
@@ -986,6 +986,27 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type) · 985 unmodified lines
986986 if (s->char_is_unsigned)
987987 tcc_define_symbol(s, "__CHAR_UNSIGNED__", NULL);
988988
989+ if (s->cversion == 201112) {
990+ tcc_undefine_symbol(s, "__STDC_VERSION__");
991+ tcc_define_symbol(s, "__STDC_VERSION__", "201112L");
992+ tcc_define_symbol(s, "__STDC_NO_ATOMICS__", NULL);
993+ tcc_define_symbol(s, "__STDC_NO_COMPLEX__", NULL);
994+ tcc_define_symbol(s, "__STDC_NO_THREADS__", NULL);
995+#ifndef TCC_TARGET_PE
996+ /* on Linux, this conflicts with a define introduced by
997+ /usr/include/stdc-predef.h included by glibc libs
998+ tcc_define_symbol(s, "__STDC_ISO_10646__", "201605L"); */
999+ tcc_define_symbol(s, "__STDC_UTF_16__", NULL);
1000+ tcc_define_symbol(s, "__STDC_UTF_32__", NULL);
1001+#endif
1002+ }
1003+
1004+ if (s->optimize > 0)
1005+ tcc_define_symbol(s, "__OPTIMIZE__", NULL);
1006+
1007+ if (s->option_pthread)
1008+ tcc_define_symbol(s, "_REENTRANT", NULL);
1009+
9891010 if (!s->nostdinc) {
9901011 /* default include paths */
9911012 /* -isystem paths have already been handled */
@@ -1719,13 +1740,11 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int *pargc, char ***pargv, int optind) · 727 unmodified lines
17191740 const TCCOption *popt;
17201741 const char *optarg, *r;
17211742 const char *run = NULL;
1722− int last_o = -1;
17231743 int x;
17241744 CString linker_arg; /* collect -Wl options */
17251745 int tool = 0, arg_start = 0, noaction = optind;
17261746 char **argv = *pargv;
17271747 int argc = *pargc;
1728− int help = 0; /* remember if -h/--help has been seen */
17291748
17301749 cstr_new(&linker_arg);
17311750
@@ -1776,13 +1795,11 @@ reparse: · 44 unmodified lines
17761795
17771796 switch(popt->index) {
17781797 case TCC_OPTION_HELP:
1779− /* help is requested, postpone return to check for -v */
1780− help = OPT_HELP;
1781− break;
1798+ x = OPT_HELP;
1799+ goto extra_action;
17821800 case TCC_OPTION_HELP2:
1783− /* help is requested, postpone return to check for -v */
1784− help = OPT_HELP2;
1785− break;
1801+ x = OPT_HELP2;
1802+ goto extra_action;
17861803 case TCC_OPTION_I:
17871804 tcc_add_include_path(s, optarg);
17881805 break;
@@ -1804,7 +1821,6 @@ reparse: · 15 unmodified lines
18041821 s->nb_libraries++;
18051822 break;
18061823 case TCC_OPTION_pthread:
1807− parse_option_D(s, "_REENTRANT");
18081824 s->option_pthread = 1;
18091825 break;
18101826 case TCC_OPTION_bench:
@@ -1850,76 +1866,8 @@ reparse: · 39 unmodified lines
18501866 s->static_link = 1;
18511867 break;
18521868 case TCC_OPTION_std:
1853− if (*optarg == '=') {
1854− if (strcmp(optarg, "=c11") == 0) {
1855− tcc_undefine_symbol(s, "__STDC_VERSION__");
1856− tcc_define_symbol(s, "__STDC_VERSION__", "201112L");
1857− /*
1858− * The integer constant 1, intended to indicate
1859− * that the implementation does not support atomic
1860− * types (including the _Atomic type qualifier) and
1861− * the <stdatomic.h> header.
1862− */
1863− tcc_define_symbol(s, "__STDC_NO_ATOMICS__", "1");
1864− /*
1865− * The integer constant 1, intended to indicate
1866− * that the implementation does not support complex
1867− * types or the <complex.h> header.
1868− */
1869− tcc_define_symbol(s, "__STDC_NO_COMPLEX__", "1");
1870− /*
1871− * The integer constant 1, intended to indicate
1872− * that the implementation does not support the
1873− * <threads.h> header.
1874− */
1875− tcc_define_symbol(s, "__STDC_NO_THREADS__", "1");
1876− /*
1877− * __STDC_NO_VLA__, tcc supports VLA.
1878− * The integer constant 1, intended to indicate
1879− * that the implementation does not support
1880− * variable length arrays or variably modified
1881− * types.
1882− */
1883−#if !defined(TCC_TARGET_PE)
1884− /*
1885− * An integer constant of the form yyyymmL (for
1886− * example, 199712L). If this symbol is defined,
1887− * then every character in the Unicode required
1888− * set, when stored in an object of type
1889− * wchar_t, has the same value as the short
1890− * identifier of that character.
1891− */
1892− #if 0
1893− /* on Linux, this conflicts with a define introduced by
1894− * /usr/include/stdc-predef.h included by glibc libs;
1895− * clang doesn't define it at all so it's probably not necessary
1896− */
1897− tcc_define_symbol(s, "__STDC_ISO_10646__", "201605L");
1898− #endif
1899− /*
1900− * The integer constant 1, intended to indicate
1901− * that values of type char16_t are UTF−16
1902− * encoded. If some other encoding is used, the
1903− * macro shall not be defined and the actual
1904− * encoding used is implementation defined.
1905− */
1906− tcc_define_symbol(s, "__STDC_UTF_16__", "1");
1907− /*
1908− * The integer constant 1, intended to indicate
1909− * that values of type char32_t are UTF−32
1910− * encoded. If some other encoding is used, the
1911− * macro shall not be defined and the actual
1912− * encoding used is implementationdefined.
1913− */
1914− tcc_define_symbol(s, "__STDC_UTF_32__", "1");
1915−#endif /* !TCC_TARGET_PE */
1916− s->cversion = 201112;
1917− }
1918− }
1919− /*
1920− * silently ignore other values, a current purpose:
1921− * allow to use a tcc as a reference compiler for "make test"
1922− */
1869+ if (strcmp(optarg, "=c11") == 0)
1870+ s->cversion = 201112;
19231871 break;
19241872 case TCC_OPTION_shared:
19251873 x = TCC_OUTPUT_DLL;
@@ -2039,7 +1987,7 @@ reparse: · 113 unmodified lines
20391987 s->filetype = x | (s->filetype & ~AFF_TYPE_MASK);
20401988 break;
20411989 case TCC_OPTION_O:
2042− last_o = atoi(optarg);
1990+ s->optimize = atoi(optarg);
20431991 break;
20441992 case TCC_OPTION_print_search_dirs:
20451993 x = OPT_PRINT_DIRS;
@@ -2068,16 +2016,6 @@ unsupported_option: · 22 unmodified lines
20682016 break;
20692017 }
20702018 }
2071−
2072− if (help) {
2073− if (s->verbose > 0)
2074− return OPT_VERBOSE_HELP;
2075− else
2076− return help;
2077− }
2078−
2079− if (last_o > 0)
2080− tcc_define_symbol(s, "__OPTIMIZE__", NULL);
20812019 if (linker_arg.size) {
20822020 r = linker_arg.data;
20832021 goto arg_err;
tcc.c+3−10
@@ -270,18 +270,14 @@ redo: · 269 unmodified lines
270270 if (n == 0) {
271271 if (opt == OPT_HELP) {
272272 fputs(help, stdout);
273− return 0;
273+ if (!s->verbose)
274+ return 0;
275+ ++opt;
274276 }
275277 if (opt == OPT_HELP2) {
276278 fputs(help2, stdout);
277279 return 0;
278280 }
279− if (opt == OPT_VERBOSE_HELP) {
280− /* simulate gcc -v --help */
281− fputs(help, stdout);
282− fputs(help2, stdout);
283− return 0;
284− }
285281 if (opt == OPT_M32 || opt == OPT_M64)
286282 tcc_tool_cross(s, argv, opt); /* never returns */
287283 if (s->verbose)
@@ -316,9 +312,6 @@ redo: · 28 unmodified lines
316312 tcc_error("cannot specify libraries with -c");
317313 if (s->nb_files > 1 && s->outfile)
318314 tcc_error("cannot specify output file with -c many files");
319− } else {
320− if (s->option_pthread)
321− tcc_set_options(s, "-lpthread");
322315 }
323316
324317 if (s->do_bench)
tcc.h+4−4
@@ -220,7 +220,7 @@ extern long double strtold (const char *__nptr, char **__endptr); · 219 unmodified lines
220220
221221 /* system include paths */
222222 #ifndef CONFIG_TCC_SYSINCLUDEPATHS
223−# ifdef TCC_TARGET_PE
223+# if defined TCC_TARGET_PE || defined _WIN32
224224 # define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include"PATHSEP"{B}/include/winapi"
225225 # else
226226 # define CONFIG_TCC_SYSINCLUDEPATHS \
@@ -697,12 +697,14 @@ struct TCCState { · 470 unmodified lines
697697 unsigned char rdynamic; /* if true, all symbols are exported */
698698 unsigned char symbolic; /* if true, resolve symbols in the current module first */
699699 unsigned char filetype; /* file type for compilation (NONE,C,ASM) */
700+ unsigned char optimize; /* only to #define __OPTIMIZE__ */
701+ unsigned char option_pthread; /* -pthread option */
702+ unsigned char enable_new_dtags; /* -Wl,--enable-new-dtags */
700703 unsigned int cversion; /* supported C ISO version, 199901 (the default), 201112, ... */
701704
702705 char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */
703706 char *soname; /* as specified on the command line (-soname) */
704707 char *rpath; /* as specified on the command line (-Wl,-rpath=) */
705− unsigned char enable_new_dtags; /* ditto, (-Wl,--enable-new-dtags) */
706708
707709 /* output type, see TCC_OUTPUT_XXX */
708710 int output_type;
@@ -918,7 +920,6 @@ struct TCCState { · 209 unmodified lines
918920 unsigned char do_bench; /* option -bench */
919921 int gen_deps; /* option -MD */
920922 char *deps_outfile; /* option -MF */
921− unsigned char option_pthread; /* -pthread option */
922923 int argc;
923924 char **argv;
924925 };
@@ -1285,7 +1286,6 @@ ST_FUNC char *normalize_slashes(char *path); · 360 unmodified lines
12851286 #define OPT_PRINT_DIRS 4
12861287 #define OPT_AR 5
12871288 #define OPT_IMPDEF 6
1288−#define OPT_VERBOSE_HELP 7
12891289 #define OPT_M32 32
12901290 #define OPT_M64 64
12911291
tccelf.c+2−0
@@ -1417,6 +1417,8 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) · 1416 unmodified lines
14171417 tcc_add_pragma_libs(s1);
14181418 /* add libc */
14191419 if (!s1->nostdlib) {
1420+ if (s1->option_pthread)
1421+ tcc_add_library_err(s1, "pthread");
14201422 tcc_add_library_err(s1, "c");
14211423 #ifdef TCC_LIBGCC
14221424 if (!s1->static_link) {
tccpe.c+1−0
@@ -1996,6 +1996,7 @@ ST_FUNC int pe_output_file(TCCState *s1, const char *filename) · 1995 unmodified lines
19961996 memset(&pe, 0, sizeof pe);
19971997 pe.filename = filename;
19981998 pe.s1 = s1;
1999+ s1->filetype = 0;
19992000
20002001 #ifdef CONFIG_TCC_BCHECK
20012002 tcc_add_bcheck(s1);

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