Lassi Pulkkinen: 2
driver: Make stage selection flags order-independent
driver: Pass default -MT and -MF explicitly to cpp when -o is used
2 files changed, 47 insertions(+), 11 deletions(-)
When multiple of -E, -M, -emit-qbe, -S and -c are specified, always
select the one corresponding to the earliest build stage. This matches
GCC and Clang behavior, and makes it impossible to get the driver to
pass -M output to the compiler. Well, except for -MD -MF -, but the only
thing that could reasonably be done about that is displaying a better
error message, and cproc will eventually stop using an external
preprocessor anyway.
---
driver.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/driver.c b/driver.c
index 853c20e..4f82644 100644
--- a/driver.c+++ b/driver.c
@@ -431,7 +431,8 @@ main(int argc, char *argv[])
} else if (strcmp(arg, "-static") == 0) {
arrayaddptr(&stages[LINK].cmd, arg);
} else if (strcmp(arg, "-emit-qbe") == 0) {
- last = COMPILE;+ if (last > COMPILE)+ last = COMPILE; } else if (strcmp(arg, "-include") == 0 || strcmp(arg, "-idirafter") == 0 || strcmp(arg, "-isystem") == 0 || strcmp(arg, "-iquote") == 0) {
if (!--argc)
usage(NULL);
@@ -455,14 +456,16 @@ main(int argc, char *argv[])
usage(NULL);
switch (arg[1]) {
case 'c':
- last = ASSEMBLE;+ if (last > ASSEMBLE)+ last = ASSEMBLE; break;
case 'D':
arrayaddptr(&stages[PREPROCESS].cmd, "-D");
arrayaddptr(&stages[PREPROCESS].cmd, nextarg(&argv));
break;
case 'E':
- last = PREPROCESS;+ if (last > PREPROCESS)+ last = PREPROCESS; break;
case 'g':
/* ignore */
@@ -485,7 +488,8 @@ main(int argc, char *argv[])
case 'M':
if (strcmp(arg, "-M") == 0 || strcmp(arg, "-MM") == 0) {
arrayaddptr(&stages[PREPROCESS].cmd, arg);
- last = PREPROCESS;+ if (last > PREPROCESS)+ last = PREPROCESS; } else if (strcmp(arg, "-MD") == 0 || strcmp(arg, "-MMD") == 0) {
arrayaddptr(&stages[PREPROCESS].cmd, arg);
} else if (strcmp(arg, "-MT") == 0 || strcmp(arg, "-MF") == 0) {
@@ -507,7 +511,8 @@ main(int argc, char *argv[])
arrayaddptr(&stages[PREPROCESS].cmd, "-P");
break;
case 'S':
- last = CODEGEN;+ if (last > CODEGEN)+ last = CODEGEN; break;
case 's':
arrayaddptr(&stages[LINK].cmd, "-s");
--
2.45.0
[PATCH 2/2] driver: Pass default -MT and -MF explicitly to cpp when -o is used
Export this patch