Skip to content
Snippets Groups Projects
  1. Apr 01, 2022
  2. Jan 03, 2022
  3. Dec 28, 2021
    • Matthew Pickering's avatar
      Multiple Home Units · fd42ab5f
      Matthew Pickering authored
      
      Multiple home units allows you to load different packages which may depend on
      each other into one GHC session. This will allow both GHCi and HLS to support
      multi component projects more naturally.
      
      Public Interface
      ~~~~~~~~~~~~~~~~
      
      In order to specify multiple units, the -unit @⟨filename⟩ flag
      is given multiple times with a response file containing the arguments for each unit.
      The response file contains a newline separated list of arguments.
      
      ```
      ghc -unit @unitLibCore -unit @unitLib
      ```
      
      where the `unitLibCore` response file contains the normal arguments that cabal would pass to `--make` mode.
      
      ```
      -this-unit-id lib-core-0.1.0.0
      -i
      -isrc
      LibCore.Utils
      LibCore.Types
      ```
      
      The response file for lib, can specify a dependency on lib-core, so then modules in lib can use modules from lib-core.
      
      ```
      -this-unit-id lib-0.1.0.0
      -package-id lib-core-0.1.0.0
      -i
      -isrc
      Lib.Parse
      Lib.Render
      ```
      
      Then when the compiler starts in --make mode it will compile both units lib and lib-core.
      
      There is also very basic support for multiple home units in GHCi, at the
      moment you can start a GHCi session with multiple units but only the
      :reload is supported. Most commands in GHCi assume a single home unit,
      and so it is additional work to work out how to modify the interface to
      support multiple loaded home units.
      
      Options used when working with Multiple Home Units
      
      There are a few extra flags which have been introduced specifically for
      working with multiple home units. The flags allow a home unit to pretend
      it’s more like an installed package, for example, specifying the package
      name, module visibility and reexported modules.
      
      -working-dir ⟨dir⟩
      
          It is common to assume that a package is compiled in the directory
          where its cabal file resides. Thus, all paths used in the compiler
          are assumed to be relative to this directory. When there are
          multiple home units the compiler is often not operating in the
          standard directory and instead where the cabal.project file is
          located. In this case the -working-dir option can be passed which
          specifies the path from the current directory to the directory the
          unit assumes to be it’s root, normally the directory which contains
          the cabal file.
      
          When the flag is passed, any relative paths used by the compiler are
          offset by the working directory. Notably this includes -i and
          -I⟨dir⟩ flags.
      
      -this-package-name ⟨name⟩
      
          This flag papers over the awkward interaction of the PackageImports
          and multiple home units. When using PackageImports you can specify
          the name of the package in an import to disambiguate between modules
          which appear in multiple packages with the same name.
      
          This flag allows a home unit to be given a package name so that you
          can also disambiguate between multiple home units which provide
          modules with the same name.
      
      -hidden-module ⟨module name⟩
      
          This flag can be supplied multiple times in order to specify which
          modules in a home unit should not be visible outside of the unit it
          belongs to.
      
          The main use of this flag is to be able to recreate the difference
          between an exposed and hidden module for installed packages.
      
      -reexported-module ⟨module name⟩
      
          This flag can be supplied multiple times in order to specify which
          modules are not defined in a unit but should be reexported. The
          effect is that other units will see this module as if it was defined
          in this unit.
      
          The use of this flag is to be able to replicate the reexported
          modules feature of packages with multiple home units.
      
      Offsetting Paths in Template Haskell splices
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      When using Template Haskell to embed files into your program,
      traditionally the paths have been interpreted relative to the directory
      where the .cabal file resides. This causes problems for multiple home
      units as we are compiling many different libraries at once which have
      .cabal files in different directories.
      
      For this purpose we have introduced a way to query the value of the
      -working-dir flag to the Template Haskell API. By using this function we
      can implement a makeRelativeToProject function which offsets a path
      which is relative to the original project root by the value of
      -working-dir.
      
      ```
      import Language.Haskell.TH.Syntax ( makeRelativeToProject )
      
      foo = $(makeRelativeToProject "./relative/path" >>= embedFile)
      ```
      
      > If you write a relative path in a Template Haskell splice you should use the makeRelativeToProject function so that your library works correctly with multiple home units.
      
      A similar function already exists in the file-embed library. The
      function in template-haskell implements this function in a more robust
      manner by honouring the -working-dir flag rather than searching the file
      system.
      
      Closure Property for Home Units
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      For tools or libraries using the API there is one very important closure
      property which must be adhered to:
      
      > Any dependency which is not a home unit must not (transitively) depend
        on a home unit.
      
      For example, if you have three packages p, q and r, then if p depends on
      q which depends on r then it is illegal to load both p and r as home
      units but not q, because q is a dependency of the home unit p which
      depends on another home unit r.
      
      If you are using GHC by the command line then this property is checked,
      but if you are using the API then you need to check this property
      yourself. If you get it wrong you will probably get some very confusing
      errors about overlapping instances.
      
      Limitations of Multiple Home Units
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      There are a few limitations of the initial implementation which will be smoothed out on user demand.
      
          * Package thinning/renaming syntax is not supported
          * More complicated reexports/renaming are not yet supported.
          * It’s more common to run into existing linker bugs when loading a
            large number of packages in a session (for example #20674, #20689)
          * Backpack is not yet supported when using multiple home units.
          * Dependency chasing can be quite slow with a large number of
            modules and packages.
          * Loading wired-in packages as home units is currently not supported
            (this only really affects GHC developers attempting to load
            template-haskell).
          * Barely any normal GHCi features are supported, it would be good to
            support enough for ghcid to work correctly.
      
      Despite these limitations, the implementation works already for nearly
      all packages. It has been testing on large dependency closures,
      including the whole of head.hackage which is a total of 4784 modules
      from 452 packages.
      
      Internal Changes
      ~~~~~~~~~~~~~~~~
      
      * The biggest change is that the HomePackageTable is replaced with the
        HomeUnitGraph. The HomeUnitGraph is a map from UnitId to HomeUnitEnv,
        which contains information specific to each home unit.
      * The HomeUnitEnv contains:
          - A unit state, each home unit can have different package db flags
          - A set of dynflags, each home unit can have different flags
          - A HomePackageTable
      * LinkNode: A new node type is added to the ModuleGraph, this is used to
        place the linking step into the build plan so linking can proceed in
        parralel with other packages being built.
      * New invariant: Dependencies of a ModuleGraphNode can be completely
        determined by looking at the value of the node. In order to achieve
        this, downsweep now performs a more complete job of downsweeping and
        then the dependenices are recorded forever in the node rather than
        being computed again from the ModSummary.
      * Some transitive module calculations are rewritten to use the
        ModuleGraph which is more efficient.
      * There is always an active home unit, which simplifies modifying a lot
        of the existing API code which is unit agnostic (for example, in the
        driver).
      
      The road may be bumpy for a little while after this change but the
      basics are well-tested.
      
      One small metric increase, which we accept and also submodule update to
      haddock which removes ExtendedModSummary.
      
      Closes #10827
      
      -------------------------
      Metric Increase:
          MultiLayerModules
      -------------------------
      
      Co-authored-by: default avatarFendor <power.walross@gmail.com>
      fd42ab5f
  4. Dec 22, 2021
    • Matthew Pickering's avatar
      testsuite: Remove reqlib modifier · 3ed90911
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      The reqlib modifer was supposed to indicate that a test needed a certain
      library in order to work. If the library happened to be installed then
      the test would run as normal.
      
      However, CI has never run these tests as the packages have not been
      installed and we don't want out tests to depend on things which might
      get externally broken by updating the compiler.
      
      The new strategy is to run these tests in head.hackage, where the tests
      have been cabalised as well as possible. Some tests couldn't be
      transferred into the normal style testsuite but it's better than never
      running any of the reqlib tests. head.hackage!169
      
      A few submodules also had reqlib tests and have been updated to remove
      it.
      
      Closes #16264 #20032 #17764 #16561
      3ed90911
  5. Aug 09, 2021
    • John Ericson's avatar
      Move `/includes` to `/rts/include`, sort per package better · d5de970d
      John Ericson authored and Marge Bot's avatar Marge Bot committed
      In order to make the packages in this repo "reinstallable", we need to
      associate source code with a specific packages. Having a top level
      `/includes` dir that mixes concerns (which packages' includes?) gets in
      the way of this.
      
      To start, I have moved everything to `rts/`, which is mostly correct.
      There are a few things however that really don't belong in the rts (like
      the generated constants haskell type, `CodeGen.Platform.h`). Those
      needed to be manually adjusted.
      
      Things of note:
      
       - No symlinking for sake of windows, so we hard-link at configure time.
      
       - `CodeGen.Platform.h` no longer as `.hs` extension (in addition to
         being moved to `compiler/`) so as not to confuse anyone, since it is
         next to Haskell files.
      
       - Blanket `-Iincludes` is gone in both build systems, include paths now
         more strictly respect per-package dependencies.
      
       - `deriveConstants` has been taught to not require a `--target-os` flag
         when generating the platform-agnostic Haskell type. Make takes
         advantage of this, but Hadrian has yet to.
      d5de970d
  6. Jun 05, 2021
    • Moritz Angermann's avatar
      Adds AArch64 Native Code Generator · 3b1aa7db
      Moritz Angermann authored and Marge Bot's avatar Marge Bot committed
      In which we add a new code generator to the Glasgow Haskell
      Compiler. This codegen supports ELF and Mach-O targets, thus covering
      Linux, macOS, and BSDs in principle.  It was tested only on macOS and
      Linux.  The NCG follows a similar structure as the other native code
      generators we already have, and should therfore be realtively easy to
      follow.
      
      It supports most of the features required for a proper native code
      generator, but does not claim to be perfect or fully optimised.  There
      are still opportunities for optimisations.
      
      Metric Decrease:
          ManyAlternatives
          ManyConstructors
          MultiLayerModules
          PmSeriesG
          PmSeriesS
          PmSeriesT
          PmSeriesV
          T10421
          T10421a
          T10858
          T11195
          T11276
          T11303b
          T11374
          T11822
          T12227
          T12545
          T12707
          T13035
          T13253
          T13253-spj
          T13379
          T13701
          T13719
          T14683
          T14697
          T15164
          T15630
          T16577
          T17096
          T17516
          T17836
          T17836b
          T17977
          T17977b
          T18140
          T18282
          T18304
          T18478
          T18698a
          T18698b
          T18923
          T1969
          T3064
          T5030
          T5321FD
          T5321Fun
          T5631
          T5642
          T5837
          T783
          T9198
          T9233
          T9630
          T9872d
          T9961
          WWRec
      Metric Increase:
          T4801
      3b1aa7db
  7. Mar 29, 2021
  8. Mar 10, 2021
  9. Jun 24, 2020
  10. Jun 17, 2020
    • Sylvain Henry's avatar
      Update testsuite · f817d816
      Sylvain Henry authored
      * support detection of slow ghc-bignum backend (to replace the detection
        of integer-simple use). There are still some test cases that the
        native backend doesn't handle efficiently enough.
      
      * remove tests for GMP only functions that have been removed from
        ghc-bignum
      
      * fix test results showing dependent packages (e.g. integer-gmp) or
        showing suggested instances
      
      * fix test using Integer/Natural API or showing internal names
      f817d816
  11. Oct 17, 2019
    • Ben Gamari's avatar
      testsuite: Ensure that makefile tests get run · b15a7fb8
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Previously `makefile_test` and `run_command` tests could easily end up
      in a situation where they wouldn't be run if the user used the
      `only_ways` modifier. The reason is to build the set of a ways to run
      the test in we first start with a candidate set determined by the test
      type (e.g. `makefile_test`, `compile_run`, etc.) and then filter that
      set with the constraints given by the test's modifiers.
      
      `makefile_test` and `run_command` tests' candidate sets were simply
      `{normal}`, and consequently most uses of `only_ways` would result in
      the test being never run.
      
      To avoid this we rather use all ways as the candidate sets for these
      test types. This may result in a few more testcases than we would like
      (given that some `run_command` tests are insensitive to way) but this
      can be fixed by adding modifiers and we would much rather run too many
      tests than too few.
      
      This fixes #16042 and a number of other tests afflicted by the same issue.
      However, there were a few cases that required special attention:
      
       * `T14028` is currently failing and is therefore marked as broken due
         to #17300
      
       * `T-signals-child` is fragile in the `threaded1` and `threaded2` ways
         (tracked in #17307)
      b15a7fb8
  12. Mar 15, 2019
  13. Jan 30, 2019
  14. Jan 22, 2017
  15. Apr 28, 2016
  16. Mar 12, 2016
    • Erik de Castro Lopo's avatar
      LlvmCodeGen: Fix generation of malformed LLVM blocks · 92821ec9
      Erik de Castro Lopo authored and Ben Gamari's avatar Ben Gamari committed
      Commit 673efccb uncovered a bug in LLVM code generation that produced
      LLVM code that the LLVM compiler refused to compile:
      
          {
          clpH:
            br label %clpH
          }
      
      This may well be a bug in LLVM itself. The solution is to keep the
      existing entry label and rewrite the function as:
      
          {
          clpH:
            br label %nPV
          nPV:
            br label %nPV
          }
      
      Thanks to Ben Gamari for pointing me in the right direction on this
      one.
      
      Test Plan: Build GHC with BuildFlavour=quick-llvm
      
      Reviewers: hvr, austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D1996
      
      GHC Trac Issues: #11649
      92821ec9
  17. Feb 25, 2016
  18. Jun 20, 2015
  19. Jun 16, 2015
  20. Dec 10, 2014
  21. Nov 19, 2014
  22. Nov 12, 2014
    • Herbert Valerio Riedel's avatar
      Implement new integer-gmp2 from scratch (re #9281) · c774b28f
      Herbert Valerio Riedel authored
      This is done as a separate `integer-gmp2` backend library because it
      turned out to become a complete rewrite from scratch.
      
      Due to the different (over)allocation scheme and potentially different
      accounting (via the new `{shrink,resize}MutableByteArray#` primitives),
      some of the nofib benchmarks actually results in increased allocation
      numbers (but not necessarily an increase in runtime!).  I believe the
      allocation numbers could improve if `{resize,shrink}MutableByteArray#`
      could be optimised to reallocate in-place more efficiently.
      
      Here are the more apparent changes in the latest nofib comparision
      between `integer-gmp` and `integer-gmp2`:
      
        ------------------------------------------------------------------
                Program     Size    Allocs   Runtime   Elapsed  TotalMem
        ------------------------------------------------------------------
                    ...
             bernouilli    +1.6%    +15.3%     0.132     0.132      0.0%
                    ...
           cryptarithm1    -2.2%      0.0%     -9.7%     -9.7%      0.0%
                    ...
                  fasta    -0.7%     -0.0%    +10.9%    +10.9%      0.0%
                    ...
                  kahan    +0.6%    +38.9%     0.169     0.169      0.0%
                    ...
                   lcss    -0.7%     -0.0%     -6.4%     -6.4%      0.0%
                    ...
                 mandel    +1.6%    +33.6%     0.049     0.049      0.0%
                    ...
               pidigits    +0.8%     +8.5%     +3.9%     +3.9%      0.0%
                  power    +1.4%    -23.8%    -18.6%    -18.6%    -16.7%
                    ...
              primetest    +1.3%    +50.1%     0.085     0.085      0.0%
                    ...
                    rsa    +1.6%    +53.4%     0.026     0.026      0.0%
                    ...
                    scs    +1.2%     +6.6%     +6.5%     +6.6%    +14.3%
                    ...
                 symalg    +1.0%     +9.5%     0.010     0.010      0.0%
                    ...
              transform    -0.6%     -0.0%     -5.9%     -5.9%      0.0%
                    ...
        ------------------------------------------------------------------
                    Min    -2.3%    -23.8%    -18.6%    -18.6%    -16.7%
                    Max    +1.6%    +53.4%    +10.9%    +10.9%    +14.3%
         Geometric Mean    -0.3%     +1.9%     -0.8%     -0.8%     +0.0%
      
      (see P35 / https://phabricator.haskell.org/P35 for full report)
      
      By default, `INTEGER_LIBRARY=integer-gmp2` is active now, which results
      in the package `integer-gmp-1.0.0.0` being registered in the package db.
      The previous `integer-gmp-0.5.1.0` can be restored by setting
      `INTEGER_LIBRARY=integer-gmp` (but will probably be removed altogether
      for GHC 7.12). In-tree GMP support has been stolen from the old
      `integer-gmp` (while unpatching the custom memory-allocators, as well as
      forcing `-fPIC`)
      
      A minor hack to `ghc-cabal` was necessary in order to support two different
      `integer-gmp` packages (in different folders) with the same package key.
      
      There will be a couple of follow-up commits re-implementing some features
      that were dropped to keep D82 minimal, as well as further
      clean-ups/improvements.
      
      More information can be found via #9281 and
      https://ghc.haskell.org/trac/ghc/wiki/Design/IntegerGmp2
      
      Reviewed By: austin, rwbarton, simonmar
      
      Differential Revision: https://phabricator.haskell.org/D82
      c774b28f
  23. Oct 07, 2014
  24. Aug 14, 2013
  25. Feb 07, 2013
    • Ian Lynagh's avatar
      Pass the test name to the test options · effc8af9
      Ian Lynagh authored
      This allows them to give framework failures.
      
      I also had to change how setTestOpts works. Now, rather than applying
      the options to the directory's "default options", it just stores the
      options to be applied for each test (i.e. once we know the test name).
      effc8af9
    • Ian Lynagh's avatar
      Define 'when' and 'unless' helpers · 86df0f32
      Ian Lynagh authored
      This will reduce the number of helper functions that we need
      86df0f32
  26. Jan 25, 2013
  27. Jan 23, 2013
  28. Jan 22, 2013
  29. Jun 25, 2012
  30. Dec 06, 2011
  31. Nov 15, 2011
  32. Nov 10, 2011
Loading