Skip to content
Snippets Groups Projects
  1. Aug 22, 2023
    • Alan Zimmerman's avatar
      EPA: Use Introduce [DeclTag] in AnnSortKey · ab40aa52
      Alan Zimmerman authored and Marge Bot's avatar Marge Bot committed
      The AnnSortKey is used to keep track of the order of declarations for
      printing when the container has split them apart.
      
      This applies to HsValBinds and ClassDecl, ClsInstDecl.
      
      When making modifications to the list of declarations, the new order
      must be captured for when it must be printed. For each list of
      declarations (binds and sigs for a HsValBind) we can just store the
      list in order.
      
      To recreate the list when printing, we must merge them, and this is
      what the AnnSortKey records. It used to be indexed by SrcSpan, we now
      simply index by a marker as to which list to take the next item from.
      ab40aa52
    • runeks's avatar
      dump-decls: fix "Ambiguous module name"-error · f861423b
      runeks authored and Marge Bot's avatar Marge Bot committed
      Fixes errors of the following kind, which happen when dump-decls is run on a package that contains a module name that clashes with that of another package.
      
      ```
      dump-decls: <no location info>: error:
          Ambiguous module name `System.Console.ANSI.Types':
            it was found in multiple packages:
            ansi-terminal-0.11.4 ansi-terminal-types-0.11.5
      ```
      f861423b
  2. Aug 16, 2023
    • Rodrigo Mesquita's avatar
      ghc-toolchain: Configure Cpp and HsCpp correctly when user specifies flags · f4c1c3a3
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      In ghc-toolchain, we were only /not/ configuring required flags when the
      user specified any flags at all for the  of the HsCpp and Cpp tools.
      
      Otherwise, the linker takes into consideration the user specified flags
      to determine whether to search for a better linker implementation, but
      already configured the remaining GHC and platform-specific flags
      regardless of the user options.
      
      Other Tools consider the user options as a baseline for further
      configuration (see `findProgram`), so #23689 is not applicable.
      
      Closes #23689
      f4c1c3a3
    • Rodrigo Mesquita's avatar
      Improve handling of Cc as a fallback · bde4b5d4
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      bde4b5d4
    • Matthew Pickering's avatar
      ghc-toolchain: Add format mode to normalise differences before diffing. · d2b63cbc
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      The "format" mode takes an "--input" and "--ouput" target file and
      formats it.
      
      This is intended to be useful on windows where the
      configure/ghc-toolchain target files can't be diffed very easily because
      the path separators are different.
      d2b63cbc
    • Matthew Pickering's avatar
      ld override: Make whitelist override user given option · 039b484f
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      039b484f
    • Matthew Pickering's avatar
      Add ldOverrideWhitelist to only default to ldOverride on windows/linux · 50df2e69
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      On some platforms - ie darwin, javascript etc we really do not want to
      allow the user to use any linker other than the default one as this
      leads to all kinds of bugs. Therefore it is a bit more prudant to add a
      whitelist which specifies on which platforms it might be possible to use
      a different linker.
      50df2e69
    • Matthew Pickering's avatar
      Add some javascript special cases to ghc-toolchain · 0283f36e
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      On javascript there isn't a choice of toolchain but some of the
      configure checks were not accurately providing the correct answer.
      
      1. The linker was reported as gnu LD because the --version output
         mentioned gnu LD.
      2. The --target flag makes no sense on javascript but it was just
         ignored by the linker, so we add a special case to stop ghc-toolchain
         thinking that emcc supports --target when used as a linker.
      0283f36e
    • Matthew Pickering's avatar
      Only check for no_compact_unwind support on darwin · bc1998b3
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      While writing ghc-toolchain we noticed that the
      FP_PROG_LD_NO_COMPACT_UNWIND check is subtly wrong. Specifically, we
      pass -Wl,-no_compact_unwind to cc. However, ld.gold interprets this as
      -n o_compact_unwind, which is a valid argument.
      
      Fixes #23676
      bc1998b3
    • Rodrigo Mesquita's avatar
      Check Link Works with -Werror · 31e9ec96
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      31e9ec96
    • Rodrigo Mesquita's avatar
      ghc-toolchain: Fix ranlib option · 8a0ae4ee
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      8a0ae4ee
    • Rodrigo Mesquita's avatar
      ghc-toolchain: Parse javascript and ghcjs as a Arch and OS · f7b3c3a0
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      f7b3c3a0
    • Rodrigo Mesquita's avatar
      Pass user-specified options to ghc-toolchain · 12d39e24
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      The current user interface to configuring target toolchains is `./configure`.
      
      In !9263 we added a new tool to configure target toolchains called
      `ghc-toolchain`, but the blessed way of creating these toolchains is
      still through configure.
      
      However, we were not passing the user-specified options given with the
      `./configure` invocation to the ghc-toolchain tool.
      
      This commit remedies that by storing the user options and environment
      variables in USER_* variables, which then get passed to GHC-toolchain.
      
      The exception to the rule is the windows bundled toolchain, which
      overrides the USER_* variables with whatever flags the windows bundled
      toolchain requires to work.
      We consider the bundled toolchain to be effectively the user specifying
      options, since the actual user delegated that configuration work.
      
      Closes #23678
      12d39e24
    • Matthew Pickering's avatar
      ghc-toolchain: Match CPP args with configure script · 662d351b
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      At the moment we need ghc-toolchain to precisely match the output as
      provided by the normal configure script. The normal configure script
      (FP_HSCPP_CMD_WITH_ARGS) branches on whether we are using clang or gcc
      so we match that logic exactly in ghc-toolchain.
      
      The old implementation (which checks if certain flags are supported) is
      better but for now we have to match to catch any potential errors in the
      configuration.
      
      Ticket: #23720
      662d351b
  3. Aug 10, 2023
  4. Aug 09, 2023
  5. Aug 07, 2023
    • sheaf's avatar
      Update Haddock submodule to fix #23368 · 6c0e2247
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This submodule update adds the following three commits:
      
      bbf1c8ae - Check for puns
      0550694e - Remove fake exports for (~), List, and Tuple<n>
      5877bceb - Fix pretty-printing of Solo and MkSolo
      
      These commits fix the issues with Haddock HTML rendering reported in
      ticket #23368.
      
      Fixes #23368
      6c0e2247
  6. Aug 04, 2023
    • Matthew Craven's avatar
      Adjust and clarify handling of primop effects · 8ba20b21
      Matthew Craven authored and Marge Bot's avatar Marge Bot committed
      Fixes #17900; fixes #20195.
      
      The existing "can_fail" and "has_side_effects" primop attributes
      that previously governed this were used in inconsistent and
      confusingly-documented ways, especially with regard to raising
      exceptions.  This patch replaces them with a single "effect"
      attribute, which has four possible values: NoEffect, CanFail,
      ThrowsException, and ReadWriteEffect.  These are described in
      Note [Classifying primop effects].
      
      A substantial amount of related documentation has been re-drafted
      for clarity and accuracy.
      
      In the process of making this attribute format change for literally
      every primop, several existing mis-classifications were detected and
      corrected.  One of these mis-classifications was tagToEnum#, which
      is now considered CanFail; this particular fix is known to cause a
      regression in performance for derived Enum instances.  (See #23782.)
      Fixing this is left as future work.
      
      New primop attributes "cheap" and "work_free" were also added,
      and used in the corresponding parts of GHC.Core.Utils.
      
      In view of their actual meaning and uses, `primOpOkForSideEffects`
      and `exprOkForSideEffects` have been renamed to `primOpOkToDiscard`
      and `exprOkToDiscard`, respectively.
      
      Metric Increase:
          T21839c
      8ba20b21
    • Ben Gamari's avatar
      base: Bump version to 4.19 · 1211112a
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Updates all boot library submodules.
      
      (cherry picked from commit 433d99a3)
      1211112a
    • Ben Gamari's avatar
      Bump deepseq submodule to 1.5. · e77a0b41
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      And bump bounds
      
      (cherry picked from commit 1228d3a4)
      e77a0b41
  7. Aug 03, 2023
  8. Aug 01, 2023
    • Bartłomiej Cieślar's avatar
      Implementation of the Deprecated Instances proposal #575 · d2bedffd
      Bartłomiej Cieślar authored and Marge Bot's avatar Marge Bot committed
      
      This commit implements the ability to deprecate certain instances,
      which causes the compiler to emit the desired deprecation message
      whenever they are instantiated. For example:
      
        module A where
        class C t where
        instance {-# DEPRECATED "dont use" #-} C Int where
      
        module B where
        import A
        f :: C t => t
        f = undefined
        g :: Int
        g = f -- "dont use" emitted here
      
      The implementation is as follows:
        - In the parser, we parse deprecations/warnings attached to instances:
      
            instance {-# DEPRECATED "msg" #-} Show X
            deriving instance {-# WARNING "msg2" #-} Eq Y
      
          (Note that non-standalone deriving instance declarations do not support
          this mechanism.)
      
        - We store the resulting warning message in `ClsInstDecl` (respectively, `DerivDecl`).
          In `GHC.Tc.TyCl.Instance.tcClsInstDecl` (respectively, `GHC.Tc.Deriv.Utils.newDerivClsInst`),
          we pass on that information to `ClsInst` (and eventually store it in `IfaceClsInst` too).
      
        - Finally, when we solve a constraint using such an instance, in
          `GHC.Tc.Instance.Class.matchInstEnv`, we emit the appropriate warning
          that was stored in `ClsInst`.
          Note that we only emit a warning when the instance is used in a different module
          than it is defined, which keeps the behaviour in line with the deprecation of
          top-level identifiers.
      
      Signed-off-by: default avatarBartłomiej Cieślar <bcieslar2001@gmail.com>
      d2bedffd
  9. Jul 24, 2023
    • Matthew Craven's avatar
      Kill off gen_bytearray_addr_access_ops.py · 32cae784
      Matthew Craven authored and Marge Bot's avatar Marge Bot committed
      The relevant primop descriptions are now
      generated directly by genprimopcode.
      
      This makes progress toward fixing #23490, but it is not
      a complete fix since there is more than one way in which
      cabal-reinstall (hadrian/build build-cabal) is broken.
      32cae784
    • Rodrigo Mesquita's avatar
      Ship ghc-toolchain in the bindist · 38e795ff
      Rodrigo Mesquita authored and Matthew Pickering's avatar Matthew Pickering committed
      Add the ghc-toolchain binary to the binary distribution we ship to
      users, and teach the bindist configure to use the existing ghc-toolchain.
      38e795ff
    • Rodrigo Mesquita's avatar
      Split ghc-toolchain executable to new packge · 61eea240
      Rodrigo Mesquita authored and Matthew Pickering's avatar Matthew Pickering committed
      In light of #23690, we split the ghc-toolchain executable out of the
      library package to be able to ship it in the bindist using Hadrian.
      
      Ideally, we eventually revert this commit.
      61eea240
    • Rodrigo Mesquita's avatar
      ghc-toolchain: Toolchain Selection · 31dcd26c
      Rodrigo Mesquita authored and Matthew Pickering's avatar Matthew Pickering committed
      This commit integrates ghc-toolchain, the brand new way of configuring
      toolchains for GHC, with the Hadrian build system, with configure, and
      extends and improves the first iteration of ghc-toolchain.
      
      The general overview is
      
      * We introduce a program invoked `ghc-toolchain --triple=...` which, when run,
        produces a file with a `Target`. A `GHC.Toolchain.Target.Target`
        describes the properties of a target and the toolchain (executables
        and configured flags) to produce code for that target
      
      * Hadrian was modified to read Target files, and will both
        * Invoke the toolchain configured in the Target file as needed
        * Produce a `settings` file for GHC based on the Target file for that stage
      
      * `./configure` will invoke ghc-toolchain to generate target files, but
        it will also generate target files based on the flags configure itself
        configured (through `.in` files that are substituted)
      
        * By default, the Targets generated by configure are still (for now) the ones used by Hadrian
      
        * But we additionally validate the Target files generated by
          ghc-toolchain against the ones generated by configure, to get a head
          start on catching configuration bugs before we transition
          completely.
      
        * When we make that transition, we will want to drop a lot of the
          toolchain configuration logic from configure, but keep it otherwise.
      
      * For each compiler stage we should have 1 target file (up to a stage compiler we can't run in our machine)
        * We just have a HOST target file, which we use as the target for stage0
        * And a TARGET target file, which we use for stage1 (and later stages, if not cross compiling)
        * Note there is no BUILD target file, because we only support cross compilation where BUILD=HOST
        * (for more details on cross-compilation see discussion on !9263)
      
      See also
      * Note [How we configure the bundled windows toolchain]
      * Note [ghc-toolchain consistency checking]
      * Note [ghc-toolchain overview]
      
      Ticket: #19877
      MR: !9263
      31dcd26c
    • Ben Gamari's avatar
      ghc-toolchain: Initial commit · 83cbc672
      Ben Gamari authored and Matthew Pickering's avatar Matthew Pickering committed
      83cbc672
  10. Jul 23, 2023
    • Vladislav Zavialov's avatar
      Visible forall in types of terms: Part 1 (#22326) · 33b6850a
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      This patch implements part 1 of GHC Proposal #281,
      introducing explicit `type` patterns and `type` arguments.
      
      Summary of the changes:
      
      1. New extension flag:
           RequiredTypeArguments
      
      2. New user-facing syntax:
           `type p` patterns    (represented by EmbTyPat)
           `type e` expressions (represented by HsEmbTy)
      
      3. Functions with required type arguments (visible forall)
         can now be defined and applied:
            idv :: forall a -> a -> a    -- signature   (relevant change: checkVdqOK in GHC/Tc/Validity.hs)
            idv (type a) (x :: a) = x    -- definition  (relevant change: tcPats in GHC/Tc/Gen/Pat.hs)
            x = idv (type Int) 42        -- usage       (relevant change: tcInstFun in GHC/Tc/Gen/App.hs)
      
      4. template-haskell support:
            TH.TypeE corresponds to HsEmbTy
            TH.TypeP corresponds to EmbTyPat
      
      5. Test cases and a new User's Guide section
      
      Changes *not* included here are the t2t (term-to-type) transformation
      and term variable capture; those belong to part 2.
      33b6850a
  11. Jul 18, 2023
    • sheaf's avatar
      Do primop rep-poly checks when instantiating · 889c2bbb
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This patch changes how we perform representation-polymorphism checking
      for primops (and other wired-in Ids such as coerce).
      When instantiating the primop, we check whether each type variable
      is required to instantiated to a concrete type, and if so we create a
      new concrete metavariable (a ConcreteTv) instead of a simple MetaTv.
      (A little subtlety is the need to apply the substitution obtained from
      instantiating to the ConcreteTvOrigins, see
      Note [substConcreteTvOrigin] in GHC.Tc.Utils.TcMType.)
      
      This allows us to prevent representation-polymorphism in non-argument
      position, as that is required for some of these primops.
      
      We can also remove the logic in tcRemainingValArgs, except for
      the part concerning representation-polymorphic unlifted newtypes.
      The function has been renamed rejectRepPolyNewtypes; all it does now
      is reject unsaturated occurrences of representation-polymorphic newtype
      constructors when the representation of its argument isn't a concrete
      RuntimeRep (i.e. still a PHASE 1 FixedRuntimeRep check).
      The Note [Eta-expanding rep-poly unlifted newtypes] in GHC.Tc.Gen.Head
      gives more explanation about a possible path to PHASE 2, which would be
      in line with the treatment for primops taken in this patch.
      
      We also update the Core Lint check to handle this new framework. This
      means Core Lint now checks representation-polymorphism in continuation
      position like needed for catch#.
      
      Fixes #21906
      
      -------------------------
      Metric Increase:
          LargeRecord
      -------------------------
      889c2bbb
    • sheaf's avatar
      Re-instate -Wincomplete-record-updates · df706de3
      sheaf authored and Marge Bot's avatar Marge Bot committed
      Commit e74fc066 refactored the handling of record updates to use
      the HsExpanded mechanism. This meant that the pattern matching inherent
      to a record update was considered to be "generated code", and thus we
      stopped emitting "incomplete record update" warnings entirely.
      
      This commit changes the "data Origin = Source | Generated" datatype,
      adding a field to the Generated constructor to indicate whether we
      still want to perform pattern-match checking. We also have to do a bit
      of plumbing with HsCase, to record that the HsCase arose from an
      HsExpansion of a RecUpd, so that the error message continues to mention
      record updates as opposed to a generic "incomplete pattern matches in case"
      error.
      
      Finally, this patch also changes the way we handle inaccessible code
      warnings. Commit e74fc066 was also a regression in this regard, as we
      were emitting "inaccessible code" warnings for case statements spuriously
      generated when desugaring a record update (remember: the desugaring mechanism
      happens before typechecking; it thus can't take into account e.g. GADT information
      in order to decide which constructors to include in the RHS of the desugaring
      of the record update).
      We fix this by changing the mechanism through which we disable inaccessible
      code warnings: we now check whether we are in generated code in
      GHC.Tc.Utils.TcMType.newImplication in order to determine whether to
      emit inaccessible code warnings.
      
      Fixes #23520
      Updates haddock submodule, to avoid incomplete record update warnings
      df706de3
    • sheaf's avatar
      exactprint: silence incomplete record update warnings · 860f6269
      sheaf authored and Marge Bot's avatar Marge Bot committed
      860f6269
  12. Jul 17, 2023
  13. Jul 16, 2023
    • Andrei Borzenkov's avatar
      Type patterns (#22478, #18986) · 2afbddb0
      Andrei Borzenkov authored
      Improved name resolution and type checking of type patterns in constructors:
      
      1. HsTyPat: a new dedicated data type that represents type patterns in
         HsConPatDetails instead of reusing HsPatSigType
      
      2. rnHsTyPat: a new function that renames a type
         pattern and collects its binders into three groups:
          - explicitly bound type variables, excluding locally bound
            variables
          - implicitly bound type variables from kind signatures
            (only if ScopedTypeVariables are enabled)
          - named wildcards (only from kind signatures)
      2a. rnHsPatSigTypeBindingVars: removed in favour of rnHsTyPat
      2b. rnImplcitTvBndrs: removed because no longer needed
      
      3. collect_pat: updated to collect type variable binders from type patterns
         (this means that types and terms use the same infrastructure to detect
         conflicting bindings, unused variables and name shadowing)
      3a. CollVarTyVarBinders: a new CollectFlag constructor that enables
          collection of type variables
      
      4. tcHsTyPat: a new function that typechecks type patterns, capable of
         handling polymorphic kinds.
         See Note [Type patterns: binders and unifiers]
      
      Examples of code that is now accepted:
      
         f = \(P @a) -> \(P @a) -> ...  -- triggers -Wname-shadowing
      
         g :: forall a. Proxy a -> ...
         g (P @a) = ...                 -- also triggers -Wname-shadowing
      
         h (P @($(TH.varT (TH.mkName "t")))) = ...
                                        -- t is bound at splice time
      
         j (P @(a :: (x,x))) = ...      -- (x,x) is no longer rejected
      
         data T where
           MkT :: forall (f :: forall k. k -> Type).
             f Int -> f Maybe -> T
         k :: T -> ()
         k (MkT @f (x :: f Int) (y :: f Maybe)) = ()
                                        -- f :: forall k. k -> Type
      
      Examples of code that is rejected with better error messages:
      
        f (Left @a @a _) = ...
        -- new message:
        --     • Conflicting definitions for ‘a’
        --       Bound at: Test.hs:1:11
        --                 Test.hs:1:14
      
      Examples of code that is now rejected:
      
        {-# OPTIONS_GHC -Werror=unused-matches #-}
        f (P @a) = ()
        -- Defined but not used: type variable ‘a’
      2afbddb0
  14. Jul 11, 2023
    • Ben Gamari's avatar
      compiler: Record original thunk info tables on stack · eb623149
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Here we introduce a new code generation option, `-forig-thunk-info`,
      which ensures that an `stg_orig_thunk_info` frame is pushed before every
      update frame. This can be invaluable when debugging thunk cycles and
      similar.
      
      See Note [Original thunk info table frames] for details.
      
      Closes #23255.
      eb623149
  15. Jul 08, 2023
  16. Jun 22, 2023
  17. Jun 21, 2023
    • Ben Gamari's avatar
      configure: Bump version to 9.8 · c1865854
      Ben Gamari authored
      Bumps Haddock submodule
      c1865854
    • Bartłomiej Cieślar's avatar
      Add support for deprecating exported items (proposal #134) · 711b1d24
      Bartłomiej Cieślar authored and Ben Gamari's avatar Ben Gamari committed
      
      This is an implementation of the deprecated exports proposal #134.
      The proposal introduces an ability to introduce warnings to exports.
      This allows for deprecating a name only when it is exported from a specific
      module, rather than always depreacting its usage. In this example:
      
          module A ({-# DEPRECATED "do not use" #-} x) where
          x = undefined
          ---
          module B where
          import A(x)
      
      `x` will emit a warning when it is explicitly imported.
      
      Like the declaration warnings, export warnings are first accumulated within
      the `Warnings` struct, then passed into the ModIface, from which they are
      then looked up and warned about in the importing module in the `lookup_ie`
      helpers of the `filterImports` function (for the explicitly imported names)
      and in the `addUsedGRE(s)` functions where they warn about regular usages
      of the imported name.
      
      In terms of the AST information, the custom warning is stored in the
      extension field of the variants of the `IE` type (see Trees that Grow for
      more information).
      
      The commit includes a bump to the haddock submodule added in MR #28
      
      Signed-off-by: default avatarBartłomiej Cieślar <bcieslar2001@gmail.com>
      711b1d24
    • Finley McIlwaine's avatar
      Fix associated data family doc structure items · 8185b1c2
      Finley McIlwaine authored and Ben Gamari's avatar Ben Gamari committed
      Associated data families were being given their own export DocStructureItems,
      which resulted in them being documented separately from their classes in
      haddocks. This commit fixes it.
      8185b1c2
    • Finley McIlwaine's avatar
      Memory usage fixes for Haddock · 3d1d42b7
      Finley McIlwaine authored and Ben Gamari's avatar Ben Gamari committed
      - Do not include `mi_globals` in the `NoBackend` backend. It was only included
        for Haddock, but Haddock does not actually need it. This causes a 200MB
        reduction in max residency when generating haddocks on the Agda codebase
        (roughly 1GB to 800MB).
      
      - Make haddock_{parser,renamer}_perf tests more accurate by forcing docs to
        be written to interface files using `-fwrite-interface`
      
      Bumps haddock submodule.
      
      Metric Decrease:
          haddock.base
      3d1d42b7
Loading