From 5462f486f0ac344b5714382b1a7498ad6d85d085 Mon Sep 17 00:00:00 2001 From: Mikhail Glushenkov Date: Fri, 12 Dec 2014 09:59:22 +0100 Subject: [PATCH] Also build profiling C objs with '-fPIC' when GHC is dynamic. --- Cabal/Distribution/Simple/GHC.hs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Cabal/Distribution/Simple/GHC.hs b/Cabal/Distribution/Simple/GHC.hs index 91a97c2cd..2af106e69 100644 --- a/Cabal/Distribution/Simple/GHC.hs +++ b/Cabal/Distribution/Simple/GHC.hs @@ -767,8 +767,13 @@ buildOrReplLib forRepl verbosity pkg_descr lbi lib clbi = do unless (null (cSources libBi)) $ do info verbosity "Building C Sources..." sequence_ - [ do let vanillaCcOpts = (componentCcGhcOptions verbosity lbi - libBi clbi libTargetDir filename) + [ do let baseCcOpts = componentCcGhcOptions verbosity lbi + libBi clbi libTargetDir filename + vanillaCcOpts = if isGhcDynamic + -- Dynamic GHC requires C sources to be built + -- with -fPIC for REPL to work. See #2207. + then baseCcOpts { ghcOptFPic = toFlag True } + else baseCcOpts profCcOpts = vanillaCcOpts `mappend` mempty { ghcOptProfilingMode = toFlag True, ghcOptObjSuffix = toFlag "p_o" @@ -780,11 +785,7 @@ buildOrReplLib forRepl verbosity pkg_descr lbi lib clbi = do } odir = fromFlag (ghcOptObjDir vanillaCcOpts) createDirectoryIfMissingVerbose verbosity True odir - runGhcProg (if isGhcDynamic - -- Dynamic GHC requires C sources to be built with - -- -fPIC for REPL to work. See #2207. - then vanillaCcOpts { ghcOptFPic = toFlag True } - else vanillaCcOpts) + runGhcProg vanillaCcOpts whenSharedLib forceSharedLib (runGhcProg sharedCcOpts) whenProfLib (runGhcProg profCcOpts) | filename <- cSources libBi] -- 2.11.4.GIT