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
236libtcc.so: CFLAGS+=-fPIC236libtcc.so: CFLAGS+=-fPIC
237libtcc.so: LDFLAGS+=-fPIC237libtcc.so: LDFLAGS+=-fPIC
238 238
239# OSX dynamic libtcc library
239libtcc.dylib: $(LIBTCC_OBJ)240libtcc.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_namespace241 $S$(CC) -shared -o $@ $^ $(LDFLAGS)
241 242
242# windows dynamic libtcc library243# windows dynamic libtcc library
243libtcc.dll : $(LIBTCC_OBJ)244libtcc.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
986 if (s->char_is_unsigned)986 if (s->char_is_unsigned)
987 tcc_define_symbol(s, "__CHAR_UNSIGNED__", NULL);987 tcc_define_symbol(s, "__CHAR_UNSIGNED__", NULL);
988 988
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
989 if (!s->nostdinc) {1010 if (!s->nostdinc) {
990 /* default include paths */1011 /* default include paths */
991 /* -isystem paths have already been handled */1012 /* -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
1719 const TCCOption *popt;1740 const TCCOption *popt;
1720 const char *optarg, *r;1741 const char *optarg, *r;
1721 const char *run = NULL;1742 const char *run = NULL;
1722 int last_o = -1;
1723 int x;1743 int x;
1724 CString linker_arg; /* collect -Wl options */1744 CString linker_arg; /* collect -Wl options */
1725 int tool = 0, arg_start = 0, noaction = optind;1745 int tool = 0, arg_start = 0, noaction = optind;
1726 char **argv = *pargv;1746 char **argv = *pargv;
1727 int argc = *pargc;1747 int argc = *pargc;
1728 int help = 0; /* remember if -h/--help has been seen */
1729 1748
1730 cstr_new(&linker_arg);1749 cstr_new(&linker_arg);
1731 1750
@@ -1776,13 +1795,11 @@ reparse: · 44 unmodified lines
1776 1795
1777 switch(popt->index) {1796 switch(popt->index) {
1778 case TCC_OPTION_HELP:1797 case TCC_OPTION_HELP:
1779 /* help is requested, postpone return to check for -v */1798 x = OPT_HELP;
1780 help = OPT_HELP;1799 goto extra_action;
1781 break;
1782 case TCC_OPTION_HELP2:1800 case TCC_OPTION_HELP2:
1783 /* help is requested, postpone return to check for -v */1801 x = OPT_HELP2;
1784 help = OPT_HELP2;1802 goto extra_action;
1785 break;
1786 case TCC_OPTION_I:1803 case TCC_OPTION_I:
1787 tcc_add_include_path(s, optarg);1804 tcc_add_include_path(s, optarg);
1788 break;1805 break;
@@ -1804,7 +1821,6 @@ reparse: · 15 unmodified lines
1804 s->nb_libraries++;1821 s->nb_libraries++;
1805 break;1822 break;
1806 case TCC_OPTION_pthread:1823 case TCC_OPTION_pthread:
1807 parse_option_D(s, "_REENTRANT");
1808 s->option_pthread = 1;1824 s->option_pthread = 1;
1809 break;1825 break;
1810 case TCC_OPTION_bench:1826 case TCC_OPTION_bench:
@@ -1850,76 +1866,8 @@ reparse: · 39 unmodified lines
1850 s->static_link = 1;1866 s->static_link = 1;
1851 break;1867 break;
1852 case TCC_OPTION_std:1868 case TCC_OPTION_std:
1853 if (*optarg == '=') {1869 if (strcmp(optarg, "=c11") == 0)
1854 if (strcmp(optarg, "=c11") == 0) {1870 s->cversion = 201112;
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 */
1923 break;1871 break;
1924 case TCC_OPTION_shared:1872 case TCC_OPTION_shared:
1925 x = TCC_OUTPUT_DLL;1873 x = TCC_OUTPUT_DLL;
@@ -2039,7 +1987,7 @@ reparse: · 113 unmodified lines
2039 s->filetype = x | (s->filetype & ~AFF_TYPE_MASK);1987 s->filetype = x | (s->filetype & ~AFF_TYPE_MASK);
2040 break;1988 break;
2041 case TCC_OPTION_O:1989 case TCC_OPTION_O:
2042 last_o = atoi(optarg);1990 s->optimize = atoi(optarg);
2043 break;1991 break;
2044 case TCC_OPTION_print_search_dirs:1992 case TCC_OPTION_print_search_dirs:
2045 x = OPT_PRINT_DIRS;1993 x = OPT_PRINT_DIRS;
@@ -2068,16 +2016,6 @@ unsupported_option: · 22 unmodified lines
2068 break;2016 break;
2069 }2017 }
2070 }2018 }
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);
2081 if (linker_arg.size) {2019 if (linker_arg.size) {
2082 r = linker_arg.data;2020 r = linker_arg.data;
2083 goto arg_err;2021 goto arg_err;
tcc.c+3−10
@@ -270,18 +270,14 @@ redo: · 269 unmodified lines
270 if (n == 0) {270 if (n == 0) {
271 if (opt == OPT_HELP) {271 if (opt == OPT_HELP) {
272 fputs(help, stdout);272 fputs(help, stdout);
273 return 0;273 if (!s->verbose)
274 return 0;
275 ++opt;
274 }276 }
275 if (opt == OPT_HELP2) {277 if (opt == OPT_HELP2) {
276 fputs(help2, stdout);278 fputs(help2, stdout);
277 return 0;279 return 0;
278 }280 }
279 if (opt == OPT_VERBOSE_HELP) {
280 /* simulate gcc -v --help */
281 fputs(help, stdout);
282 fputs(help2, stdout);
283 return 0;
284 }
285 if (opt == OPT_M32 || opt == OPT_M64)281 if (opt == OPT_M32 || opt == OPT_M64)
286 tcc_tool_cross(s, argv, opt); /* never returns */282 tcc_tool_cross(s, argv, opt); /* never returns */
287 if (s->verbose)283 if (s->verbose)
@@ -316,9 +312,6 @@ redo: · 28 unmodified lines
316 tcc_error("cannot specify libraries with -c");312 tcc_error("cannot specify libraries with -c");
317 if (s->nb_files > 1 && s->outfile)313 if (s->nb_files > 1 && s->outfile)
318 tcc_error("cannot specify output file with -c many files");314 tcc_error("cannot specify output file with -c many files");
319 } else {
320 if (s->option_pthread)
321 tcc_set_options(s, "-lpthread");
322 }315 }
323 316
324 if (s->do_bench)317 if (s->do_bench)
tcc.h+4−4
@@ -220,7 +220,7 @@ extern long double strtold (const char *__nptr, char **__endptr); · 219 unmodified lines
220 220
221/* system include paths */221/* system include paths */
222#ifndef CONFIG_TCC_SYSINCLUDEPATHS222#ifndef CONFIG_TCC_SYSINCLUDEPATHS
223# ifdef TCC_TARGET_PE223# if defined TCC_TARGET_PE || defined _WIN32
224# define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include"PATHSEP"{B}/include/winapi"224# define CONFIG_TCC_SYSINCLUDEPATHS "{B}/include"PATHSEP"{B}/include/winapi"
225# else225# else
226# define CONFIG_TCC_SYSINCLUDEPATHS \226# define CONFIG_TCC_SYSINCLUDEPATHS \
@@ -697,12 +697,14 @@ struct TCCState { · 470 unmodified lines
697 unsigned char rdynamic; /* if true, all symbols are exported */697 unsigned char rdynamic; /* if true, all symbols are exported */
698 unsigned char symbolic; /* if true, resolve symbols in the current module first */698 unsigned char symbolic; /* if true, resolve symbols in the current module first */
699 unsigned char filetype; /* file type for compilation (NONE,C,ASM) */699 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 */
700 unsigned int cversion; /* supported C ISO version, 199901 (the default), 201112, ... */703 unsigned int cversion; /* supported C ISO version, 199901 (the default), 201112, ... */
701 704
702 char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */705 char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */
703 char *soname; /* as specified on the command line (-soname) */706 char *soname; /* as specified on the command line (-soname) */
704 char *rpath; /* as specified on the command line (-Wl,-rpath=) */707 char *rpath; /* as specified on the command line (-Wl,-rpath=) */
705 unsigned char enable_new_dtags; /* ditto, (-Wl,--enable-new-dtags) */
706 708
707 /* output type, see TCC_OUTPUT_XXX */709 /* output type, see TCC_OUTPUT_XXX */
708 int output_type;710 int output_type;
@@ -918,7 +920,6 @@ struct TCCState { · 209 unmodified lines
918 unsigned char do_bench; /* option -bench */920 unsigned char do_bench; /* option -bench */
919 int gen_deps; /* option -MD */921 int gen_deps; /* option -MD */
920 char *deps_outfile; /* option -MF */922 char *deps_outfile; /* option -MF */
921 unsigned char option_pthread; /* -pthread option */
922 int argc;923 int argc;
923 char **argv;924 char **argv;
924};925};
@@ -1285,7 +1286,6 @@ ST_FUNC char *normalize_slashes(char *path); · 360 unmodified lines
1285#define OPT_PRINT_DIRS 41286#define OPT_PRINT_DIRS 4
1286#define OPT_AR 51287#define OPT_AR 5
1287#define OPT_IMPDEF 61288#define OPT_IMPDEF 6
1288#define OPT_VERBOSE_HELP 7
1289#define OPT_M32 321289#define OPT_M32 32
1290#define OPT_M64 641290#define OPT_M64 64
1291 1291
tccelf.c+2−0
@@ -1417,6 +1417,8 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) · 1416 unmodified lines
1417 tcc_add_pragma_libs(s1);1417 tcc_add_pragma_libs(s1);
1418 /* add libc */1418 /* add libc */
1419 if (!s1->nostdlib) {1419 if (!s1->nostdlib) {
1420 if (s1->option_pthread)
1421 tcc_add_library_err(s1, "pthread");
1420 tcc_add_library_err(s1, "c");1422 tcc_add_library_err(s1, "c");
1421#ifdef TCC_LIBGCC1423#ifdef TCC_LIBGCC
1422 if (!s1->static_link) {1424 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
1996 memset(&pe, 0, sizeof pe);1996 memset(&pe, 0, sizeof pe);
1997 pe.filename = filename;1997 pe.filename = filename;
1998 pe.s1 = s1;1998 pe.s1 = s1;
1999 s1->filetype = 0;
1999 2000
2000#ifdef CONFIG_TCC_BCHECK2001#ifdef CONFIG_TCC_BCHECK
2001 tcc_add_bcheck(s1);2002 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