aboutsummaryrefslogtreecommitdiff
path: root/libtcc.c
diff options
context:
space:
mode:
authorgrischka <grischka>2017-10-11 18:13:43 +0200
committergrischka <grischka>2017-10-11 18:13:43 +0200
commitda8c62f75d893449e232944fc62566c020b4d010 (patch)
tree977fec8d53d90ceb8c718f07f47c2bc9cbd6edfc /libtcc.c
parentfaa9744f5d13c94c7298bf08e8d1eedca5db88a9 (diff)
downloadtinycc-da8c62f75d893449e232944fc62566c020b4d010.tar.gz
tinycc-da8c62f75d893449e232944fc62566c020b4d010.tar.bz2
various stuff
win32/Makefile ("for cygwin") removed - On cygwin, the normal ./configure && make can be used with either cygwin's "GCC for Win32 Toolchain" ./configure --cross-prefix=i686-w64-mingw32- or with an existing tcc: ./configure --cc=<old-tccdir>/tcc.exe tcctest.c: - exclude test_high_clobbers() on _WIN64 (does not work) tests2/95_bitfield.c: - use 'signed char' for ARM (where default 'char' is unsigned) tests: - remove -I "expr" diff option to allow tests with busybox-diff. libtcc.c, tcc.c: - removed -iwithprefix option. It is supposed to be combined with -iprefix which we don't have either. tccgen.c: - fix assignments and return of 'void', as in void f() { void *p, *q; *p = *q: return *p; } This appears to be allowed but should do nothing. tcc.h, libtcc.c, tccpp.c: - Revert "Introduce VIP sysinclude paths which are always searched first" This reverts commit 1d5e386b0a78393ac6b670c209a185849ec798a1. The patch was giving tcc's system includes priority over -I which is not how it should be. tccelf.c: - add DT_TEXTREL tag only if text relocations are actually used (which is likely not the case on x86_64) - prepare_dynamic_rel(): avoid relocation of unresolved (weak) symbols tccrun.c: - for HAVE_SELINUX, use two mappings to the same (real) file. (it was so once except the RX mapping wasn't used at all). tccpe.c: - fix relocation constant used for x86_64 (by Andrei E. Warentin) - #ifndef _WIN32 do "chmod 755 ..." to get runnable exes on cygwin. tccasm.c: - keep forward asm labels static, otherwise they will endup in dynsym eventually. configure, Makefile: - mingw32: respect ./configure options --bindir --docdir --libdir - allow overriding tcc when building libtcc1.a and libtcc.def with make XTCC=<tcc program to use> - use $(wildcard ...) for install to allow installing just a cross compiler for example make cross-arm make install - use name <target>-libtcc1.a build-tcc.bat: - add options: -clean, -b bindir
Diffstat (limited to 'libtcc.c')
-rw-r--r--libtcc.c39
1 files changed, 11 insertions, 28 deletions
diff --git a/libtcc.c b/libtcc.c
index 9ef538e..43a07ef 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -104,10 +104,8 @@ static void tcc_set_lib_path_w32(TCCState *s)
char path[1024], *p;
GetModuleFileNameA(tcc_module, path, sizeof path);
p = tcc_basename(normalize_slashes(strlwr(path)));
- if (p - 5 > path && 0 == strncmp(p - 5, "/bin/", 5))
- p -= 5;
- else if (p > path)
- p--;
+ if (p > path)
+ --p;
*p = 0;
tcc_set_lib_path(s, path);
}
@@ -440,7 +438,7 @@ static void tcc_split_path(TCCState *s, void *p_ary, int *p_nb_ary, const char *
CString str;
cstr_new(&str);
- for (p = in; c = *p, c != '\0' && c != PATHSEP; ++p) {
+ for (p = in; c = *p, c != '\0' && c != PATHSEP[0]; ++p) {
if (c == '{' && p[1] && p[2] == '}') {
c = p[1], p += 2;
if (c == 'B')
@@ -804,6 +802,8 @@ LIBTCCAPI TCCState *tcc_new(void)
#endif
#elif defined(TCC_TARGET_ARM64)
tcc_define_symbol(s, "__aarch64__", NULL);
+#elif defined TCC_TARGET_C67
+ tcc_define_symbol(s, "__C67__", NULL);
#endif
#ifdef TCC_TARGET_PE
@@ -827,13 +827,13 @@ LIBTCCAPI TCCState *tcc_new(void)
# if defined(__FreeBSD_kernel__)
tcc_define_symbol(s, "__FreeBSD_kernel__", NULL);
# endif
-#endif
# if defined(__NetBSD__)
tcc_define_symbol(s, "__NetBSD__", "__NetBSD__");
# endif
# if defined(__OpenBSD__)
tcc_define_symbol(s, "__OpenBSD__", "__OpenBSD__");
# endif
+#endif
/* TinyCC & gcc defines */
#if PTR_SIZE == 4
@@ -853,14 +853,6 @@ LIBTCCAPI TCCState *tcc_new(void)
tcc_define_symbol(s, "__LP64__", NULL);
#endif
-#if defined(TCC_MUSL)
- tcc_define_symbol(s, "__TCC_NEEDS_va_list", "");
- tcc_define_symbol(s, "__builtin_va_list", "va_list");
- tcc_define_symbol(s, "__DEFINED_va_list", "");
- tcc_define_symbol(s, "__DEFINED___isoc_va_list", "");
- tcc_define_symbol(s, "__isoc_va_list", "void *");
-#endif /* TCC_MUSL */
-
#ifdef TCC_TARGET_PE
tcc_define_symbol(s, "__WCHAR_TYPE__", "unsigned short");
tcc_define_symbol(s, "__WINT_TYPE__", "unsigned short");
@@ -887,6 +879,11 @@ LIBTCCAPI TCCState *tcc_new(void)
tcc_define_symbol(s, "__REDIRECT_NTH(name, proto, alias)",
"name proto __asm__ (#alias) __THROW");
# endif
+# if defined(TCC_MUSL)
+ tcc_define_symbol(s, "__DEFINED_va_list", "");
+ tcc_define_symbol(s, "__DEFINED___isoc_va_list", "");
+ tcc_define_symbol(s, "__isoc_va_list", "void *");
+# endif /* TCC_MUSL */
/* Some GCC builtins that are simple to express as macros. */
tcc_define_symbol(s, "__builtin_extract_return_addr(x)", "x");
#endif /* ndef TCC_TARGET_PE */
@@ -906,7 +903,6 @@ LIBTCCAPI void tcc_delete(TCCState *s1)
/* free include paths */
dynarray_reset(&s1->cached_includes, &s1->nb_cached_includes);
- dynarray_reset(&s1->tccinclude_paths, &s1->nb_tccinclude_paths);
dynarray_reset(&s1->include_paths, &s1->nb_include_paths);
dynarray_reset(&s1->sysinclude_paths, &s1->nb_sysinclude_paths);
dynarray_reset(&s1->cmd_include_files, &s1->nb_cmd_include_files);
@@ -947,7 +943,6 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type)
if (!s->nostdinc) {
/* default include paths */
/* -isystem paths have already been handled */
- tcc_add_tccinclude_path(s, CONFIG_TCC_TCCINCLUDEPATHS);
tcc_add_sysinclude_path(s, CONFIG_TCC_SYSINCLUDEPATHS);
}
@@ -985,12 +980,6 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type)
return 0;
}
-LIBTCCAPI int tcc_add_tccinclude_path(TCCState *s, const char *pathname)
-{
- tcc_split_path(s, &s->tccinclude_paths, &s->nb_tccinclude_paths, pathname);
- return 0;
-}
-
LIBTCCAPI int tcc_add_include_path(TCCState *s, const char *pathname)
{
tcc_split_path(s, &s->include_paths, &s->nb_include_paths, pathname);
@@ -1547,7 +1536,6 @@ static const TCCOption tcc_options[] = {
{ "m", TCC_OPTION_m, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
{ "f", TCC_OPTION_f, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP },
{ "isystem", TCC_OPTION_isystem, TCC_OPTION_HAS_ARG },
- { "iwithprefix", TCC_OPTION_iwithprefix, TCC_OPTION_HAS_ARG },
{ "include", TCC_OPTION_include, TCC_OPTION_HAS_ARG },
{ "nostdinc", TCC_OPTION_nostdinc, 0 },
{ "nostdlib", TCC_OPTION_nostdlib, 0 },
@@ -1682,7 +1670,6 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int *pargc, char ***pargv, int optind)
int last_o = -1;
int x;
CString linker_arg; /* collect -Wl options */
- char buf[1024];
int tool = 0, arg_start = 0, noaction = optind;
char **argv = *pargv;
int argc = *pargc;
@@ -1827,10 +1814,6 @@ reparse:
case TCC_OPTION_isystem:
tcc_add_sysinclude_path(s, optarg);
break;
- case TCC_OPTION_iwithprefix:
- snprintf(buf, sizeof buf, "{B}/%s", optarg);
- tcc_add_tccinclude_path(s, buf);
- break;
case TCC_OPTION_include:
dynarray_add(&s->cmd_include_files,
&s->nb_cmd_include_files, tcc_strdup(optarg));