cpp is not run when building .c or .cpp files
Summary
C pre-processor is not run and -D or -optP flags are not respected when building .c or .cpp files.
Steps to reproduce
$ cat test.c
#ifndef TEST
#define TEST 0
#endif
#include <stdio.h>
int main(void) {
printf("%d\n", TEST);
return 0;
}
$ ghc -DTEST=9 test.c -no-hs-main && ./a.out
0
or
$ mkdir -p x && touch x/x.h
$ echo '#include "x.h"' > y.c
$ ghc -Ix -c y.c
$ ghc -optP=-Ix -c y.c
y.c:1:10: error:
fatal error: x.h: No such file or directory
#include "x.h"
^~~~~
|
1 | #include "x.h"
| ^
compilation terminated.
`gcc' failed in phase `C Compiler'. (Exit code: 1)
Expected behavior
Output 9 for the first example.
Both ghc -Ix -c y.c and ghc -optP=-Ix -c y.c work in the second example.
This is because we don't run cpp for Cc, Ccxx, Cobjc and Cobjcxx phase and we probably should do so.
For HCc phase, we usually run cpp in previous phase and probably don't want to run it again.