271 insertions(+), 292 deletions(-), -21 lines, -5 files Also: - tccdefs.h: WIN32: less (no) __builtins - libtcc.c: simply ignore -arch
Showing the changes to libtcc.c (1 of 16 files). Show all
Unified · Split
| @@ -83,8 +83,17 @@ ST_FUNC char *normalize_slashes(char *path) · 82 unmodified lines | ||
| 83 | 83 | return path; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | −/* NULL if this is tcc.exe, HINSTANCE if this is libtcc.dll */ | |
| 86 | +#if defined LIBTCC_AS_DLL && !defined CONFIG_TCCDIR | |
| 87 | 87 | static HMODULE tcc_module; |
| 88 | +BOOL WINAPI DllMain (HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved) | |
| 89 | +{ | |
| 90 | + if (DLL_PROCESS_ATTACH == dwReason) | |
| 91 | + tcc_module = hDll; | |
| 92 | + return TRUE; | |
| 93 | +} | |
| 94 | +#else | |
| 95 | +#define tcc_module NULL /* NULL means executable itself */ | |
| 96 | +#endif | |
| 88 | 97 | |
| 89 | 98 | #ifndef CONFIG_TCCDIR |
| 90 | 99 | /* on win32, we suppose the lib and includes are at the location of 'tcc.exe' */ |
| @@ -109,15 +118,6 @@ static void tcc_add_systemdir(TCCState *s) · 18 unmodified lines | ||
| 109 | 118 | tcc_add_library_path(s, normalize_slashes(buf)); |
| 110 | 119 | } |
| 111 | 120 | #endif |
| 112 | − | |
| 113 | −#ifdef LIBTCC_AS_DLL | |
| 114 | −BOOL WINAPI DllMain (HINSTANCE hDll, DWORD dwReason, LPVOID lpReserved) | |
| 115 | −{ | |
| 116 | − if (DLL_PROCESS_ATTACH == dwReason) | |
| 117 | − tcc_module = hDll; | |
| 118 | − return TRUE; | |
| 119 | −} | |
| 120 | −#endif | |
| 121 | 121 | #endif |
| 122 | 122 | |
| 123 | 123 | /********************************************************/ |
| @@ -234,6 +234,14 @@ PUB_FUNC char *tcc_fileextension (const char *name) · 110 unmodified lines | ||
| 234 | 234 | return e ? e : strchr(b, 0); |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | +ST_FUNC char *tcc_load_text(int fd) | |
| 238 | +{ | |
| 239 | + int len = lseek(fd, 0, SEEK_END); | |
| 240 | + char *buf = load_data(fd, 0, len + 1); | |
| 241 | + buf[len] = 0; | |
| 242 | + return buf; | |
| 243 | +} | |
| 244 | + | |
| 237 | 245 | /********************************************************/ |
| 238 | 246 | /* memory management */ |
| 239 | 247 | |
| @@ -1431,6 +1439,7 @@ typedef struct TCCOption { · 1191 unmodified lines | ||
| 1431 | 1439 | } TCCOption; |
| 1432 | 1440 | |
| 1433 | 1441 | enum { |
| 1442 | + TCC_OPTION_ignored = 0, | |
| 1434 | 1443 | TCC_OPTION_HELP, |
| 1435 | 1444 | TCC_OPTION_HELP2, |
| 1436 | 1445 | TCC_OPTION_v, |
| @@ -1455,8 +1464,6 @@ enum { · 18 unmodified lines | ||
| 1455 | 1464 | TCC_OPTION_soname, |
| 1456 | 1465 | TCC_OPTION_o, |
| 1457 | 1466 | TCC_OPTION_r, |
| 1458 | − TCC_OPTION_s, | |
| 1459 | − TCC_OPTION_traditional, | |
| 1460 | 1467 | TCC_OPTION_Wl, |
| 1461 | 1468 | TCC_OPTION_Wp, |
| 1462 | 1469 | TCC_OPTION_W, |
| @@ -1471,12 +1478,9 @@ enum { · 8 unmodified lines | ||
| 1471 | 1478 | TCC_OPTION_nostdlib, |
| 1472 | 1479 | TCC_OPTION_print_search_dirs, |
| 1473 | 1480 | TCC_OPTION_rdynamic, |
| 1474 | − TCC_OPTION_param, | |
| 1475 | − TCC_OPTION_pedantic, | |
| 1476 | 1481 | TCC_OPTION_pthread, |
| 1477 | 1482 | TCC_OPTION_run, |
| 1478 | 1483 | TCC_OPTION_w, |
| 1479 | − TCC_OPTION_pipe, | |
| 1480 | 1484 | TCC_OPTION_E, |
| 1481 | 1485 | TCC_OPTION_M, |
| 1482 | 1486 | TCC_OPTION_MD, |
| @@ -1486,8 +1490,6 @@ enum { · 3 unmodified lines | ||
| 1486 | 1490 | TCC_OPTION_x, |
| 1487 | 1491 | TCC_OPTION_ar, |
| 1488 | 1492 | TCC_OPTION_impdef, |
| 1489 | − TCC_OPTION_C, | |
| 1490 | − TCC_OPTION_arch | |
| 1491 | 1493 | }; |
| 1492 | 1494 | |
| 1493 | 1495 | #define TCC_OPTION_HAS_ARG 0x0001 |
| @@ -1523,14 +1525,10 @@ static const TCCOption tcc_options[] = { · 29 unmodified lines | ||
| 1523 | 1525 | { "shared", TCC_OPTION_shared, 0 }, |
| 1524 | 1526 | { "soname", TCC_OPTION_soname, TCC_OPTION_HAS_ARG }, |
| 1525 | 1527 | { "o", TCC_OPTION_o, TCC_OPTION_HAS_ARG }, |
| 1526 | − { "-param", TCC_OPTION_param, TCC_OPTION_HAS_ARG }, | |
| 1527 | − { "pedantic", TCC_OPTION_pedantic, 0}, | |
| 1528 | 1528 | { "pthread", TCC_OPTION_pthread, 0}, |
| 1529 | 1529 | { "run", TCC_OPTION_run, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP }, |
| 1530 | 1530 | { "rdynamic", TCC_OPTION_rdynamic, 0 }, |
| 1531 | 1531 | { "r", TCC_OPTION_r, 0 }, |
| 1532 | − { "s", TCC_OPTION_s, 0 }, | |
| 1533 | − { "traditional", TCC_OPTION_traditional, 0 }, | |
| 1534 | 1532 | { "Wl,", TCC_OPTION_Wl, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP }, |
| 1535 | 1533 | { "Wp,", TCC_OPTION_Wp, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP }, |
| 1536 | 1534 | { "W", TCC_OPTION_W, TCC_OPTION_HAS_ARG | TCC_OPTION_NOSEP }, |
| @@ -1546,7 +1544,6 @@ static const TCCOption tcc_options[] = { · 9 unmodified lines | ||
| 1546 | 1544 | { "nostdlib", TCC_OPTION_nostdlib, 0 }, |
| 1547 | 1545 | { "print-search-dirs", TCC_OPTION_print_search_dirs, 0 }, |
| 1548 | 1546 | { "w", TCC_OPTION_w, 0 }, |
| 1549 | − { "pipe", TCC_OPTION_pipe, 0}, | |
| 1550 | 1547 | { "E", TCC_OPTION_E, 0}, |
| 1551 | 1548 | { "M", TCC_OPTION_M, 0}, |
| 1552 | 1549 | { "MD", TCC_OPTION_MD, 0}, |
| @@ -1558,10 +1555,14 @@ static const TCCOption tcc_options[] = { · 5 unmodified lines | ||
| 1558 | 1555 | #ifdef TCC_TARGET_PE |
| 1559 | 1556 | { "impdef", TCC_OPTION_impdef, 0}, |
| 1560 | 1557 | #endif |
| 1561 | −#ifdef TCC_TARGET_MACHO | |
| 1562 | − { "arch", TCC_OPTION_arch, TCC_OPTION_HAS_ARG }, | |
| 1563 | −#endif | |
| 1564 | − { "C", TCC_OPTION_C, 0}, | |
| 1558 | + /* ignored (silently, except after -Wunsupported) */ | |
| 1559 | + { "arch", 0, TCC_OPTION_HAS_ARG}, | |
| 1560 | + { "C", 0, 0 }, | |
| 1561 | + { "-param", 0, TCC_OPTION_HAS_ARG }, | |
| 1562 | + { "pedantic", 0, 0 }, | |
| 1563 | + { "pipe", 0, 0 }, | |
| 1564 | + { "s", 0, 0 }, | |
| 1565 | + { "traditional", 0, 0 }, | |
| 1565 | 1566 | { NULL, 0, 0 }, |
| 1566 | 1567 | }; |
| 1567 | 1568 | |
| @@ -1677,14 +1678,6 @@ static int args_parser_make_argv(const char *r, int *argc, char ***argv) · 109 unmodified lines | ||
| 1677 | 1678 | return ret; |
| 1678 | 1679 | } |
| 1679 | 1680 | |
| 1680 | −ST_FUNC char *tcc_load_text(int fd) | |
| 1681 | −{ | |
| 1682 | − int len = lseek(fd, 0, SEEK_END); | |
| 1683 | − char *buf = load_data(fd, 0, len + 1); | |
| 1684 | − buf[len] = 0; | |
| 1685 | − return buf; | |
| 1686 | −} | |
| 1687 | − | |
| 1688 | 1681 | /* read list file */ |
| 1689 | 1682 | static void args_parser_listfile(TCCState *s, |
| 1690 | 1683 | const char *filename, int optind, int *pargc, char ***pargv) |
| @@ -1991,27 +1984,6 @@ reparse: · 300 unmodified lines | ||
| 1991 | 1984 | tcc_error("cannot parse %s here", r); |
| 1992 | 1985 | tool = x; |
| 1993 | 1986 | break; |
| 1994 | −#if defined(TCC_TARGET_MACHO) | |
| 1995 | − case TCC_OPTION_arch: | |
| 1996 | −#if defined(TCC_TARGET_X86_64) | |
| 1997 | − if (strcmp(optarg, "x86_64") == 0) | |
| 1998 | − break; /* Ok, arch matches target */ | |
| 1999 | −#endif | |
| 2000 | −#if defined(TCC_TARGET_ARM64) | |
| 2001 | − if (strcmp(optarg, "arm64") == 0) | |
| 2002 | − break; /* Ok, arch matches target */ | |
| 2003 | −#endif | |
| 2004 | − tcc_error("this compiler does not support %s", optarg); | |
| 2005 | − /* ignored */ | |
| 2006 | − break; | |
| 2007 | −#endif | |
| 2008 | − case TCC_OPTION_traditional: | |
| 2009 | − case TCC_OPTION_pedantic: | |
| 2010 | − case TCC_OPTION_pipe: | |
| 2011 | − case TCC_OPTION_s: | |
| 2012 | − case TCC_OPTION_C: | |
| 2013 | − /* ignored */ | |
| 2014 | − break; | |
| 2015 | 1987 | default: |
| 2016 | 1988 | unsupported_option: |
| 2017 | 1989 | tcc_warning_c(warn_unsupported)("unsupported option '%s'", r); |