History

Handle multiple -O options

the last one wins, i.e. "-O2 -O0" does _not_ set __OPTIMIZ__.

Michael Matz committed 10 years ago

Commit 7ae35bf1 parent a1582601 file · +5 −3Browse files

Unified · Split

libtcc.c+5−3
@@ -1657,6 +1657,7 @@ PUB_FUNC int tcc_parse_args(TCCState *s, int argc, char **argv) · 1656 unmodified lines
1657 int optind = 0;1657 int optind = 0;
1658 int run = 0;1658 int run = 0;
1659 int x;1659 int x;
1660 int last_o = -1;
1660 CString linker_arg; /* collect -Wl options */1661 CString linker_arg; /* collect -Wl options */
1661 char buf[1024];1662 char buf[1024];
1662 1663
@@ -1887,9 +1888,7 @@ reparse: · 224 unmodified lines
1887 tcc_warning("unsupported language '%s'", optarg);1888 tcc_warning("unsupported language '%s'", optarg);
1888 break;1889 break;
1889 case TCC_OPTION_O:1890 case TCC_OPTION_O:
1890 x = atoi(optarg);1891 last_o = atoi(optarg);
1891 if (x > 0)
1892 tcc_define_symbol(s, "__OPTIMIZE__", NULL);
1893 break;1892 break;
1894 case TCC_OPTION_mms_bitfields:1893 case TCC_OPTION_mms_bitfields:
1895 s->ms_bitfields = 1;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 if (linker_arg.size) {1913 if (linker_arg.size) {
1912 r = linker_arg.data;1914 r = linker_arg.data;
1913 goto arg_err;1915 goto arg_err;

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