Commit 574ef429 authored by Austin Seipp's avatar Austin Seipp

ghc: Do not add a space in '-U __PIC__'

GHC previously introduced a space here. However, this can in some cases
be interpreted as "-U __PIC__" - note that in shell, the -U would still
be recognized with an argument, but the argument would be " __PIC__",
with a space in front, as opposed to the single string '__PIC__'.

In practice most tools seem to handle this OK. But the Coverity Scan
analysis tool does not: it errors on the fact that ' __PIC__' is an
invalid CPP name to undefine.

With this, it seems the Coverity analysis tool can easily analyze the
entire GHC build.
Signed-off-by: default avatarAustin Seipp <>
parent 31dd5e5d
......@@ -3548,10 +3548,10 @@ picCCOpts dflags
-- Don't generate "common" symbols - these are unwanted
-- in dynamic libraries.
| gopt Opt_PIC dflags -> ["-fno-common", "-U __PIC__", "-D__PIC__"]
| gopt Opt_PIC dflags -> ["-fno-common", "-U__PIC__", "-D__PIC__"]
| otherwise -> ["-mdynamic-no-pic"]
OSMinGW32 -- no -fPIC for Windows
| gopt Opt_PIC dflags -> ["-U __PIC__", "-D__PIC__"]
| gopt Opt_PIC dflags -> ["-U__PIC__", "-D__PIC__"]
| otherwise -> []
-- we need -fPIC for C files when we are compiling with -dynamic,
......@@ -3560,12 +3560,12 @@ picCCOpts dflags
-- objects, but can't without -fPIC. See
| gopt Opt_PIC dflags || not (gopt Opt_Static dflags) ->
["-fPIC", "-U __PIC__", "-D__PIC__"]
["-fPIC", "-U__PIC__", "-D__PIC__"]
| otherwise -> []
picPOpts :: DynFlags -> [String]
picPOpts dflags
| gopt Opt_PIC dflags = ["-U __PIC__", "-D__PIC__"]
| gopt Opt_PIC dflags = ["-U__PIC__", "-D__PIC__"]
| otherwise = []
-- -----------------------------------------------------------------------------
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment