diff options
| author | Austin Seipp <aseipp@pobox.com> | 2013-06-17 06:12:08 -0500 |
|---|---|---|
| committer | Austin Seipp <aseipp@pobox.com> | 2013-06-18 21:26:21 -0500 |
| commit | 7b0695a887c13a431f898d89938e127faa3f4585 (patch) | |
| tree | 96ebd63f7473fc8de25c6c3d831993bd11d1e1dd /compiler | |
| parent | 73991d61642a3a7dc1305bfac773ee3f59920d09 (diff) | |
| download | haskell-7b0695a887c13a431f898d89938e127faa3f4585.tar.gz | |
Use assembler-with-cpp mode when running CPP.
This is needed because Clang is very strict about C99 macro rules, which
dictate that '#' in a body must have a token immediately following it for
string-ification. In practice we break this all the time, because we do
very weird stuff like:
#define FOOBAR(xyz) \
{-# SOME PRAGMA #-} \
baz :: (xyz) \
baz = ...
where the leading '#' in in the macro body clearly breaks this rule.
Signed-off-by: Austin Seipp <aseipp@pobox.com>
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/main/DriverPipeline.hs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index 7df823c27d..958bc9b0bf 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -1140,10 +1140,10 @@ runPhase (RealPhase cc_phase) input_fn dflags -- very weakly typed, being derived from C--. ["-fno-strict-aliasing"] - let gcc_lang_opt | cc_phase `eqPhase` Ccpp = "c++" - | cc_phase `eqPhase` Cobjc = "objective-c" + let gcc_lang_opt | cc_phase `eqPhase` Ccpp = "c++" + | cc_phase `eqPhase` Cobjc = "objective-c" | cc_phase `eqPhase` Cobjcpp = "objective-c++" - | otherwise = "c" + | otherwise = "c" liftIO $ SysTools.runCc dflags ( -- force the C compiler to interpret this file as C when -- compiling .hc files, by adding the -x c option. @@ -2042,8 +2042,12 @@ doCpp dflags raw input_fn output_fn = do ++ map SysTools.Option backend_defs ++ map SysTools.Option hscpp_opts ++ map SysTools.Option sse_defs + -- Set the language mode to assembler-with-cpp when preprocessing. This + -- alleviates some of the C99 macro rules relating to whitespace and the hash + -- operator, which we tend to abuse. Clang in particular is not very happy + -- about this. ++ [ SysTools.Option "-x" - , SysTools.Option "c" + , SysTools.Option "assembler-with-cpp" , SysTools.Option input_fn -- We hackily use Option instead of FileOption here, so that the file -- name is not back-slashed on Windows. cpp is capable of |
