CPP usage in GHC.

Karel Gardas karel.gardas at centrum.cz
Sun Aug 10 21:06:25 UTC 2014


in my attempt to lower number of failing tests on Solaris I've found 
several tests which fail on just difference in file name report. My ghc 
reports warning/error in /tmp/ghc<something>/<some different thing> 
while expected is clear T<something>.hs.

See http://haskell.inf.elte.hu/builders/solaris-x86-head/125/21.html and 
search for T7145b as an example of this behavior.

The reason why this happen is that Solaris GNU C 4.x does not emit line 
markers in preprocessed file when it's preprocessed with -x 
assembler-with-cpp. The reason behind this is documented in this 
thread[1] on GCC mailing list. Simply speaking Sun's assembler in the 
past chokes on some linemarkers generated. This was apparently case of 
as on older Solaris then 10 version and perhaps this will be fixed in 
future major GCC release as Solaris 9 is not supported anymore. Anyway, 
we still do have a case with GNU C compilers provided by Solaris 10 and 
Solaris 11. FYI: Solaris' 10 GNU C 3.4.x is OK, Solaris 11's GNU C 4.5.2 
is broken and with this all more modern 4.x releases so probably also 
all 4.x release provided by Solaris 11.1/11.2.

So far I've solved the issue of those failing tests by passing 
--with-hs-cpp=/usr/sfw/bin/gcc -- so configured this way GHC will use 
old not-buggy GNU C 3.4.x on my Solaris 11 builder as CPP and otherwise 
it'll use /usr/bin/gcc (GNU C 4.5.2) and everything will pass fine 

Anyway, the thread[1] also contains a question which also rings in my 
head and that is: why we use -x assembler-with-cpp at all? Isn't simple 
-E enough. Or isn't simple usage of system provided CPP enough 
/usr/lib/cpp on Solaris)? Or what will happen if we for example change 
-x assembler-with-cpp to -x c or -x c-header or something like that? 
Please note that the testcase is OK with -x c/c-header even using this 
"buggy" GNU C 4.5.2 since the compiler/cpp is really buggy just for the 
case of -x assembler-with-cpp.


[1]: https://gcc.gnu.org/ml/gcc/2014-08/msg00114.html

More information about the ghc-devs mailing list