Skip to content
Snippets Groups Projects
  1. Mar 19, 2024
    • Matthew Craven's avatar
      CorePrep: Rework lowering of BigNat# literals · b56d2761
      Matthew Craven authored and Marge Bot's avatar Marge Bot committed
      Don't use bigNatFromWord#, because that's terrible:
       * We shouldn't have to traverse a linked list at run-time
         to build a BigNat# literal. That's just silly!
       * The static List object we have to create is much larger
         than the actual BigNat#'s contents, bloating code size.
       * We have to read the corresponding interface file,
         which causes un-tracked implicit dependencies. (#23942)
      
      Instead, encode them into the appropriate platform-dependent
      sequence of bytes, and generate code that copies these bytes
      at run-time from an Addr# literal into a new ByteArray#.
      A ByteArray# literal would be the correct thing to generate,
      but these are not yet supported; see also #17747.
      
      Somewhat surprisingly, this change results in a slight
      reduction in compiler allocations, averaging around 0.5%
      on ghc's compiler performance tests, including when compiling
      programs that contain no bignum literals to begin with.
      The specific cause of this has not been investigated.
      
      Since this lowering no longer reads the interface file for
      GHC.Num.BigNat, the reasoning in Note [Depend on GHC.Num.Integer]
      is obsoleted.  But the story of un-tracked built-in dependencies
      remains complex, and Note [Tracking dependencies on primitives]
      now exists to explain this complexity.
      
      Additionally, many empty imports have been modified to refer to
      this new note and comply with its guidance.  Several empty imports
      necessary for other reasons have also been given brief explanations.
      
      Metric Decrease:
          MultiLayerModulesTH_OneShot
      b56d2761
    • Matthew Craven's avatar
      Remove unused ghc-internal module "GHC.Internal.Constants" · da0d8ba5
      Matthew Craven authored and Marge Bot's avatar Marge Bot committed
      da0d8ba5
    • Matthew Pickering's avatar
      hadrian: Remove stage1 testsuite wrappers logic · 4c8f1794
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      Now instead of producing wrappers which pass the global package database
      argument to ghc and ghc-pkg, we write the location of the correct
      package database into the settings file so you can just use the intree
      compiler directly.
      4c8f1794
    • Matthew Pickering's avatar
      Read global package database from settings file · f45f700e
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      Before this patch, the global package database was always assumed to be
      in libdir </> package.conf.d.
      
      This causes issues in GHC's build system because there are sometimes
      situations where the package database you need to use is not located in
      the same place as the settings file.
      
      * The stage1 compiler needs to use stage1 libraries, so we should set
        "Global Package DB" for the stage1 compiler to the stage1 package
        database.
      * Stage 2 cross compilers need to use stage2 libraries, so likewise, we
        should set the package database path to `_build/stage2/lib/`
      
      * The normal situation is where the stage2 compiler uses stage1
        libraries. Then everything lines up.
      
      * When installing we have rearranged everything so that the settings
        file and package database line up properly, so then everything should
        continue to work as before. In this case we set the relative package
        db path to `package.conf.d`, so it resolves the same as before.
      
      * ghc-pkg needs to be modified as well to look in the settings file fo
        the package database rather than assuming the global package database
        location relative to the lib folder.
      
      * Cabal/cabal-install will work correctly because they query the global
        package database using `--print-global-package-db`.
      
      A reasonable question is why not generate the "right" settings files in
      the right places in GHC's build system. In order to do this you would
      need to engineer wrappers for all executables to point to a specific
      libdir. There are also situations where the same package db is used by
      two different compilers with two different settings files (think stage2
      cross compiler and stage3 compiler).
      
      In short, this 10 line patch allows for some reasonable simplifications
      in Hadrian at very little cost to anything else.
      
      Fixes #24502
      f45f700e
    • Hannes Siebenhandl's avatar
      Escape multiple arguments in the settings file · 31bf85ee
      Hannes Siebenhandl authored and Marge Bot's avatar Marge Bot committed
      Uses responseFile syntax.
      
      The issue arises when GHC is installed on windows into a location that
      has a space, for example the user name is 'Fake User'.
      The $topdir will also contain a space, consequentially.
      When we resolve the top dir in the string `-I$topdir/mingw/include`,
      then `words` will turn this single argument into `-I/C/Users/Fake` and
      `User/.../mingw/include` which trips up the flag argument parser of
      various tools such as gcc or clang.
      We avoid this by escaping the $topdir before replacing it in
      `initSettngs`.
      Additionally, we allow to escape spaces and quotation marks for
      arguments in `settings` file.
      
      Add regression test case to count the number of options after variable
      expansion and argument escaping took place.
      Additionally, we check that escaped spaces and double quotation marks are
      correctly parsed.
      31bf85ee
    • Alan Zimmerman's avatar
      EPA: Address more 9.10.1-alpha1 regressions from recent changes · bd8209eb
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      Closes #24533
      Hopefully for good this time
      bd8209eb
    • Hannes Siebenhandl's avatar
      Fix sharing of 'IfaceTyConInfo' during core to iface type translation · 73be65ab
      Hannes Siebenhandl authored and Marge Bot's avatar Marge Bot committed
      During heap analysis, we noticed that during generation of
      'mi_extra_decls' we have lots of duplicates for the instances:
      
      * `IfaceTyConInfo NotPromoted IfaceNormalTyCon`
      * `IfaceTyConInfo IsPromoted IfaceNormalTyCon`
      
      which should be shared instead of duplicated. This duplication increased
      the number of live bytes by around 200MB while loading the agda codebase
      into GHCi.
      
      These instances are created during `CoreToIface` translation, in
      particular `toIfaceTyCon`.
      
      The generated core looks like:
      
          toIfaceTyCon
            = \ tc_sjJw ->
                case $wtoIfaceTyCon tc_sjJw of
                { (# ww_sjJz, ww1_sjNL, ww2_sjNM #) ->
                IfaceTyCon ww_sjJz (IfaceTyConInfo ww1_sjNL ww2_sjNM)
                }
      
      whichs removes causes the sharing to work propery.
      
      Adding explicit sharing, with NOINLINE annotations, changes the core to:
      
          toIfaceTyCon
            = \ tc_sjJq ->
                case $wtoIfaceTyCon tc_sjJq of { (# ww_sjNB, ww1_sjNC #) ->
                IfaceTyCon ww_sjNB ww1_sjNC
                }
      
      which looks much more like sharing is happening.
      We confirmed via ghc-debug that all duplications were eliminated and the
      number of live bytes are noticeably reduced.
      73be65ab
  2. Mar 14, 2024
  3. Mar 12, 2024
  4. Mar 11, 2024
  5. Mar 10, 2024
  6. Mar 09, 2024
Loading