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
16571657 int optind = 0;
16581658 int run = 0;
16591659 int x;
1660+ int last_o = -1;
16601661 CString linker_arg; /* collect -Wl options */
16611662 char buf[1024];
16621663
@@ -1887,9 +1888,7 @@ reparse: · 224 unmodified lines
18871888 tcc_warning("unsupported language '%s'", optarg);
18881889 break;
18891890 case TCC_OPTION_O:
1890− x = atoi(optarg);
1891− if (x > 0)
1892− tcc_define_symbol(s, "__OPTIMIZE__", NULL);
1891+ last_o = atoi(optarg);
18931892 break;
18941893 case TCC_OPTION_mms_bitfields:
18951894 s->ms_bitfields = 1;
@@ -1908,6 +1907,9 @@ unsupported_option: · 12 unmodified lines
19081907 }
19091908 }
19101909
1910+ if (last_o > 0)
1911+ tcc_define_symbol(s, "__OPTIMIZE__", NULL);
1912+
19111913 if (linker_arg.size) {
19121914 r = linker_arg.data;
19131915 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