Closed Kleidukos closed 4 years ago
Perhaps adding --cpp-define x86_64_HOST_ARCH
to the hlint invocation will help here?
Perfect! I still get a rather peculiar message from hlint, but other than that, no problem whatsoever!
Warning: unknown directive #-}
in libraries/base/Unsafe/Coerce.hs at line 311 col 1
No hints
This is the file in question: https://gitlab.haskell.org/ghc/ghc/-/blob/master/libraries/base/Unsafe/Coerce.hs#L303-311
Perfect! I still get a rather peculiar message from hlint, but other than that, no problem whatsoever!
Awesome.
Warning: unknown directive #-} in libraries/base/Unsafe/Coerce.hs at line 311 col 1 No hints
This is the file in question: https://gitlab.haskell.org/ghc/ghc/-/blob/master/libraries/base/Unsafe/Coerce.hs#L303-311
Ha. That's a genuine problem. The C-preprocessor is being run over the file and it doesn't know what to make of a line that reads,
#-}
and that's where the warning is coming from. This is because the C-preprocessor interprets lines beginning with a #
as being those with directives meant for it. Putting a space in front of the leading #
will fix it.
If this were purely a language extension issue then potential fixes would include:
{-# LANGUAGE NoCPP #-}
to the extensions;-XNoCPP
to hlint so that the extension is disabled by default.However, I'm not sure in this instance those things alone will do. I don't know if/how HLint can be told to not run CPP in general. @ndmitchell can you advise please?
@shayne-fletcher Thanks for the fix! I'll be sure to document the hows and whys on the GHC side. Cheers!
-XNoCpp
turns off CPP entirely, --cpp-simple
just strips lines with a leading #
but otherwise ignores CPP markup. But in this case, with complex CPP, passing a valid set of CPP options as Shayne suggests is the right thing to do.
HLint v3.1.6, (C) Neil Mitchell 2006-2020
$ hlint -j --cpp-include="./libraries/base/include/" --cpp-include=includes --cpp-include=./_build/stage1/lib/ -h libraries/base/.hlint.yaml libraries/base
The CPP code block is :