@@ -707,33 +707,36 @@ buildOrReplLib mReplFlags verbosity numJobs pkg_descr lbi lib clbi = do
707707 -- build any C sources
708708 unless (not has_code || null (cSources libBi)) $ do
709709 info verbosity " Building C Sources..."
710- sequence_
711- [ do let baseCcOpts = Internal. componentCcGhcOptions verbosity implInfo
712- lbi libBi clbi relLibTargetDir filename
713- vanillaCcOpts = if isGhcDynamic
714- -- Dynamic GHC requires C sources to be built
715- -- with -fPIC for REPL to work. See #2207.
716- then baseCcOpts { ghcOptFPic = toFlag True }
717- else baseCcOpts
718- profCcOpts = vanillaCcOpts `mappend` mempty {
719- ghcOptProfilingMode = toFlag True ,
720- ghcOptObjSuffix = toFlag " p_o"
721- }
722- sharedCcOpts = vanillaCcOpts `mappend` mempty {
723- ghcOptFPic = toFlag True ,
724- ghcOptDynLinkMode = toFlag GhcDynamicOnly ,
725- ghcOptObjSuffix = toFlag " dyn_o"
726- }
727- odir = fromFlag (ghcOptObjDir vanillaCcOpts)
728- createDirectoryIfMissingVerbose verbosity True odir
729- let runGhcProgIfNeeded ccOpts = do
730- needsRecomp <- checkNeedsRecompilation filename ccOpts
731- when needsRecomp $ runGhcProg ccOpts
732- runGhcProgIfNeeded vanillaCcOpts
733- unless forRepl $
734- whenSharedLib forceSharedLib (runGhcProgIfNeeded sharedCcOpts)
735- unless forRepl $ whenProfLib (runGhcProgIfNeeded profCcOpts)
736- | filename <- cSources libBi]
710+ let (cSrcs', others) = partition (\ filepath -> " .c" `isSuffixOf` filepath) (cSources libBi)
711+ unless (null others) $ do
712+ let files = intercalate " , " others
713+ warn verbosity $ " The following files listed in c-sources will not be used: " <> files
714+ forM_ cSrcs' $ \ filename -> do
715+ let baseCcOpts = Internal. componentCcGhcOptions verbosity implInfo
716+ lbi libBi clbi relLibTargetDir filename
717+ vanillaCcOpts = if isGhcDynamic
718+ -- Dynamic GHC requires C sources to be built
719+ -- with -fPIC for REPL to work. See #2207.
720+ then baseCcOpts { ghcOptFPic = toFlag True }
721+ else baseCcOpts
722+ profCcOpts = vanillaCcOpts `mappend` mempty {
723+ ghcOptProfilingMode = toFlag True ,
724+ ghcOptObjSuffix = toFlag " p_o"
725+ }
726+ sharedCcOpts = vanillaCcOpts `mappend` mempty {
727+ ghcOptFPic = toFlag True ,
728+ ghcOptDynLinkMode = toFlag GhcDynamicOnly ,
729+ ghcOptObjSuffix = toFlag " dyn_o"
730+ }
731+ odir = fromFlag (ghcOptObjDir vanillaCcOpts)
732+ createDirectoryIfMissingVerbose verbosity True odir
733+ let runGhcProgIfNeeded ccOpts = do
734+ needsRecomp <- checkNeedsRecompilation filename ccOpts
735+ when needsRecomp $ runGhcProg ccOpts
736+ runGhcProgIfNeeded vanillaCcOpts
737+ unless forRepl $
738+ whenSharedLib forceSharedLib (runGhcProgIfNeeded sharedCcOpts)
739+ unless forRepl $ whenProfLib (runGhcProgIfNeeded profCcOpts)
737740
738741 -- build any JS sources
739742 unless (not has_code || not hasJsSupport || null (jsSources libBi)) $ do
@@ -1528,31 +1531,34 @@ gbuild verbosity numJobs pkg_descr lbi bm clbi = do
15281531
15291532 -- build any C sources
15301533 unless (null cSrcs) $ do
1531- info verbosity " Building C Sources..."
1532- sequence_
1533- [ do let baseCcOpts = Internal. componentCcGhcOptions verbosity implInfo
1534+ info verbosity " Building C Sources..."
1535+ let (cSrcs', others) = partition (\ filepath -> " .c" `isSuffixOf` filepath) cSrcs
1536+ unless (null others) $ do
1537+ let files = intercalate " , " others
1538+ warn verbosity $ " The following files listed in c-sources will not be used: " <> files
1539+ forM_ cSrcs' $ \ filename -> do
1540+ let baseCcOpts = Internal. componentCcGhcOptions verbosity implInfo
15341541 lbi bnfo clbi tmpDir filename
1535- vanillaCcOpts = if isGhcDynamic
1536- -- Dynamic GHC requires C sources to be built
1537- -- with -fPIC for REPL to work. See #2207.
1538- then baseCcOpts { ghcOptFPic = toFlag True }
1539- else baseCcOpts
1540- profCcOpts = vanillaCcOpts `mappend` mempty {
1541- ghcOptProfilingMode = toFlag True
1542- }
1543- sharedCcOpts = vanillaCcOpts `mappend` mempty {
1544- ghcOptFPic = toFlag True ,
1545- ghcOptDynLinkMode = toFlag GhcDynamicOnly
1546- }
1547- opts | needProfiling = profCcOpts
1548- | needDynamic = sharedCcOpts
1549- | otherwise = vanillaCcOpts
1550- odir = fromFlag (ghcOptObjDir opts)
1551- createDirectoryIfMissingVerbose verbosity True odir
1552- needsRecomp <- checkNeedsRecompilation filename opts
1553- when needsRecomp $
1554- runGhcProg opts
1555- | filename <- cSrcs ]
1542+ let vanillaCcOpts = if isGhcDynamic
1543+ -- Dynamic GHC requires C sources to be built
1544+ -- with -fPIC for REPL to work. See #2207.
1545+ then baseCcOpts { ghcOptFPic = toFlag True }
1546+ else baseCcOpts
1547+ let profCcOpts = vanillaCcOpts `mappend` mempty {
1548+ ghcOptProfilingMode = toFlag True
1549+ }
1550+ let sharedCcOpts = vanillaCcOpts `mappend` mempty {
1551+ ghcOptFPic = toFlag True ,
1552+ ghcOptDynLinkMode = toFlag GhcDynamicOnly
1553+ }
1554+ let opts | needProfiling = profCcOpts
1555+ | needDynamic = sharedCcOpts
1556+ | otherwise = vanillaCcOpts
1557+ let odir = fromFlag (ghcOptObjDir opts)
1558+ createDirectoryIfMissingVerbose verbosity True odir
1559+ needsRecomp <- checkNeedsRecompilation filename opts
1560+ when needsRecomp $
1561+ runGhcProg opts
15561562
15571563 -- TODO: problem here is we need the .c files built first, so we can load them
15581564 -- with ghci, but .c files can depend on .h files generated by ghc by ffi
0 commit comments