the last one wins, i.e. "-O2 -O0" does _not_ set __OPTIMIZ__.
Unified · Split
| @@ -1657,6 +1657,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 1656 unmodified lines | ||
| 1657 | 1657 | int optind = 0; |
| 1658 | 1658 | int run = 0; |
| 1659 | 1659 | int x; |
| 1660 | + int last_o = -1; | |
| 1660 | 1661 | CString linker_arg; /* collect -Wl options */ |
| 1661 | 1662 | char buf[1024]; |
| 1662 | 1663 | |
| @@ -1887,9 +1888,7 @@ reparse: · 224 unmodified lines | ||
| 1887 | 1888 | tcc_warning("unsupported language '%s'", optarg); |
| 1888 | 1889 | break; |
| 1889 | 1890 | case TCC_OPTION_O: |
| 1890 | − x = atoi(optarg); | |
| 1891 | − if (x > 0) | |
| 1892 | − tcc_define_symbol(s, "__OPTIMIZE__", NULL); | |
| 1891 | + last_o = atoi(optarg); | |
| 1893 | 1892 | break; |
| 1894 | 1893 | case TCC_OPTION_mms_bitfields: |
| 1895 | 1894 | s->ms_bitfields = 1; |
| @@ -1908,6 +1907,9 @@ unsupported_option: · 12 unmodified lines | ||
| 1908 | 1907 | } |
| 1909 | 1908 | } |
| 1910 | 1909 | |
| 1910 | + if (last_o > 0) | |
| 1911 | + tcc_define_symbol(s, "__OPTIMIZE__", NULL); | |
| 1912 | + | |
| 1911 | 1913 | if (linker_arg.size) { |
| 1912 | 1914 | r = linker_arg.data; |
| 1913 | 1915 | goto arg_err; |