Commit 9ea8dcea authored by Zejun Wu's avatar Zejun Wu Committed by Ben Gamari

Hadrian: merge sections in profiling _p.a to .p_o for ghci

This is the hadrain version of {D5169}

* We build squashed .o and .p_o for ghci when `dynamicGhcPrograms` is
`False`
* We no longer build them for rts as ghci never loads it

we need https://github.com/haskell/cabal/pull/5592 for cabal to copy
the built `.p_o` file.

Test Plan:
```
$ grep dynamicGhc hadrian/UserSettings.hs
  , dynamicGhcPrograms = return False
$ touch ...
$ hadrian/build.sh --flavour=user -j --digest-or
$ find _build/stage1/libraries/ -name 'HS*-*.*o' | wc
     62      62    3664
```

```
$ grep -C3 dynamicGhc hadrian/UserSettings.hs
userFlavour :: Flavour
userFlavour = performanceFlavour
  { name = "user"
  , dynamicGhcPrograms = return False
  }
$ hadrian/build.sh -j --flavour=user test --verbose
Unexpected results from:
TEST="T3807 T9208 T9293 annth_make ghci057 haddock.Cabal haddock.base
haddock.compiler"

SUMMARY for test run started at Wed Dec  5 17:45:39 2018 PST
 0:03:16 spent to go through
    6708 total tests, which gave rise to
   26015 test cases, of which
   19290 were skipped

      29 had missing libraries
    6600 expected passes
      88 expected failures

       3 caused framework failures
       0 caused framework warnings
       1 unexpected passes
       7 unexpected failures
       0 unexpected stat failures
$ find _build -name 'HSbase*.*o'
_build/stage1/lib/x86_64-linux-ghc-8.7.20181204/base-4.12.0.0/HSbase-4.1
2.0.0.o
_build/stage1/lib/x86_64-linux-ghc-8.7.20181204/base-4.12.0.0/HSbase-4.1
2.0.0.p_o
_build/stage1/libraries/base/build/HSbase-4.12.0.0.o
_build/stage1/libraries/base/build/HSbase-4.12.0.0.p_o
```

Reviewers: bgamari, simonmar, snowleopard

Reviewed By: snowleopard

Subscribers: alpmestan, rwbarton, carter

GHC Trac Issues: #15779

Differential Revision: https://phabricator.haskell.org/D5270
parent bbd58fb5
Pipeline #888 passed with stages
in 256 minutes and 1 second
......@@ -96,7 +96,9 @@ pkgLibraryFile context@Context {..} = do
-- | Path to the GHCi library file of a given 'Context', e.g.:
-- @_build/stage1/libraries/array/build/HSarray-0.5.1.0.o@.
pkgGhciLibraryFile :: Context -> Action FilePath
pkgGhciLibraryFile context = pkgFile context "HS" ".o"
pkgGhciLibraryFile context@Context {..} = do
let extension = "" <.> osuf way
pkgFile context "HS" extension
-- | Path to the configuration file of a given 'Context'.
pkgConfFile :: Context -> Action FilePath
......
......@@ -25,7 +25,9 @@ libraryRules = do
root -/- "//libHS*-*.dylib" %> buildDynamicLibUnix root "dylib"
root -/- "//libHS*-*.so" %> buildDynamicLibUnix root "so"
root -/- "//*.a" %> buildStaticLib root
priority 2 $ root -/- "//HS*-*.o" %> buildGhciLibO root
priority 2 $ do
root -/- "//HS*-*.o" %> buildGhciLibO root
root -/- "//HS*-*.p_o" %> buildGhciLibO root
-- * 'Action's for building libraries
......@@ -193,8 +195,9 @@ parseLibGhciFilename :: Parsec.Parsec String () LibGhci
parseLibGhciFilename = do
_ <- Parsec.string "HS"
(pkgname, pkgver) <- parsePkgId
way <- parseWaySuffix vanilla
_ <- Parsec.string ".o"
_ <- Parsec.string "."
way <- parseWayPrefix vanilla
_ <- Parsec.string "o"
return (LibGhci pkgname pkgver way)
-- | Parse the filename of a dynamic library to be built into a 'LibDyn' value.
......
......@@ -57,19 +57,24 @@ libraryArgs :: Args
libraryArgs = do
flavourWays <- getLibraryWays
contextWay <- getWay
package <- getPackage
withGhci <- expr ghcWithInterpreter
dynPrograms <- expr (flavour >>= dynamicGhcPrograms)
let ways = flavourWays ++ [contextWay]
pure [ if vanilla `elem` ways
hasVanilla = vanilla `elem` ways
hasProfiling = any (wayUnit Profiling) ways
hasDynamic = any (wayUnit Dynamic) ways
pure [ if hasVanilla
then "--enable-library-vanilla"
else "--disable-library-vanilla"
, if vanilla `elem` ways && withGhci && not dynPrograms
then "--enable-library-for-ghci"
else "--disable-library-for-ghci"
, if or [Profiling `wayUnit` way | way <- ways]
, if hasProfiling
then "--enable-library-profiling"
else "--disable-library-profiling"
, if or [Dynamic `wayUnit` way | way <- ways]
, if (hasVanilla || hasProfiling) &&
package /= rts && withGhci && not dynPrograms
then "--enable-library-for-ghci"
else "--disable-library-for-ghci"
, if hasDynamic
then "--enable-shared"
else "--disable-shared" ]
......
......@@ -61,10 +61,10 @@ stage1Dependencies =
-- | Given a library 'Package' this action computes all of its targets. See
-- 'packageTargets' for the explanation of the @includeGhciLib@ parameter.
libraryTargets :: Bool -> Context -> Action [FilePath]
libraryTargets includeGhciLib context = do
libraryTargets includeGhciLib context@Context {..} = do
libFile <- pkgLibraryFile context
ghciLib <- pkgGhciLibraryFile context
ghci <- if includeGhciLib
ghci <- if includeGhciLib && not (wayUnit Dynamic way)
then interpretInContext context $ getContextData buildGhciLib
else return False
return $ [ libFile ] ++ [ ghciLib | ghci ]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment