Skip to content
Snippets Groups Projects
This project is mirrored from https://*****:*****@gitlab.haskell.org/ghc/ghc.git. Pull mirroring updated .
  1. Mar 13, 2025
    • Matthew Craven's avatar
      Add interface-stability test for ghc-prim · 24d373a6
      Matthew Craven authored and Marge Bot's avatar Marge Bot committed
      24d373a6
    • Matthew Pickering's avatar
      interfaces: Ensure that forceModIface deeply forces a ModIface · 915a6781
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      A ModIface is the result of compilation that we keep for a long time in
      memory. Therefore, it's very important to manage what we are going to
      retain and remove any external references to things which we might have
      captured compilation.
      
      If storing your ModIface in memory uses too much space, then store
      less things or make it use a more efficient representation.
      
      In the past there have been many space leak bugs by not sufficiently
      forcing a ModIface (#15111)
      
      This patch adds all the missing NFData instances for all the places I
      could find where we weren't deeply forcing the structure.
      915a6781
  2. Mar 12, 2025
  3. Mar 11, 2025
    • Matthew Pickering's avatar
      Remove mi_hpc field from interface files · 6bb0e261
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      The `mi_hpc` field is not used for anything as far as I can discern so
      there is no reason to record in the private interface of a module that
      there are modules in the transitive closure which use `hpc`.
      
      You can freely mix modules which use `-fhpc` and ones which don't.
      
      Whether to recompile a module due to `-fhpc` being passed to the module
      itself is determined in `fingerprintDynFlags`.
      6bb0e261
    • Matthew Pickering's avatar
      Remove mi_used_th field from interface files · 03c72f01
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      In the distant past, recompilation checking was disabled for interfaces which used
      TemplateHaskell, but for several years now recompilation checking has
      been more fine-grained. This has rendered this field unused and
      lingering in an interface file.
      03c72f01
    • Matthew Pickering's avatar
      Pass -fPIC to dynamicToo001 test to avoid platform dependence issues · 48b8f110
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      On darwin platforms, `-fPIC` is always enabled but on linux it is only
      enabled in the dynamic flavour. This can cause a difference in
      interface files (see #25836).
      
      The purpose of this test isn't to test module A recompilation, so we
      avoid this platform dependency by always passing `-fPIC`.
      48b8f110
    • Matthew Pickering's avatar
      Take into account all flags when computing iface_hash · 77df05d0
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      The "interface hash" should contain a hash of everything in the
      interface file. We are not doing that yet but at least a start is to
      include a hash of everything in `mi_self_recomp`, rather than just
      `mi_src_hash` and `mi_usages`.
      
      In particular, this fixes #25837, a bug where we should recompile a
      `dyn_hi` file but fail to do so.
      77df05d0
    • sheaf's avatar
      user's guide: NamedDefaults vs ExtendedDefaultRules · 2df171d4
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This commit clarifies the defaulting rules with NamedDefaults,
      in particular in situations where a type variable appears in other
      constraints than standard/unary constraints.
      2df171d4
    • sheaf's avatar
      user's guide: flesh out XOverloadedStrings docs · 0c9fd8d4
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This commit extends the documentation of the OverloadedStrings extension
      with some usage information, in particular suggestions to:
      
        - use default declarations, such as `default (Text)` or
          `default IsString(Text)` (with the NamedDefaults extension),
      
        - enable the ExtendedDefaultRules extension to relax the requirement
          that a defaultable type variable must only appear in unary standard
          classes
      
      Fixes #23388
      0c9fd8d4
    • sheaf's avatar
      user's guide: consolidate defaulting documentation · 37d8b50b
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This commit adds a new section on defaulting, which consolidates various
      parts of documentation surrounding defaulting into one central place.
      
      It explains type class defaulting in detail, extensions to it with
      OverloadedStrings, NamedDefaults and ExtendedDefaultRules, as well
      as other defaulting mechanisms (e.g. kind-based defaulting such as
      RuntimeRep defaulting, and defaulting of equalities).
      37d8b50b
    • Vladislav Zavialov's avatar
      Error message with EmptyCase and RequiredTypeArguments (#25004) · cce869ea
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      Fix a panic triggered by a combination of \case{} and forall t ->
      
        ghci> let f :: forall (xs :: Type) -> (); f = \case {}
        panic! (the 'impossible' happened)
          GHC version 9.10.1:
                Util: only
      
      The new error message looks like this:
      
        ghci> let f :: forall (xs :: Type) -> (); f = \case {}
        <interactive>:5:41: error: [GHC-48010]
            • Empty list of alternatives in \case expression
              checked against a forall-type: forall xs -> ...
      
      This is achieved as follows:
      
      * A new data type, BadEmptyCaseReason, is now used to describe
        why an empty case has been rejected. Used in TcRnEmptyCase.
      
      * HsMatchContextRn is passed to tcMatches, so that the type checker
        can attach the syntactic context to the error message.
      
      * tcMatches now rejects type arguments if the list of alternatives is
        empty. This is what fixes the bug.
      cce869ea
    • Vladislav Zavialov's avatar
      One list in ConPat (part of #25127) · 7b84c588
      Vladislav Zavialov authored and Marge Bot's avatar Marge Bot committed
      This patch changes PrefixCon to use one list instead of two:
      
      	-data HsConDetails tyarg arg rec
      	-  = PrefixCon [tyarg] [arg]
      	+data HsConDetails arg rec
      	+  = PrefixCon [arg]
      	   | RecCon    rec
      	   | InfixCon  arg arg
      
      The [tyarg] list is now gone. To understand the effect of this change,
      recall that there are three instantiations of HsConDetails:
      
      1. type HsConPatDetails p =
            HsConDetails (HsConPatTyArg (NoGhcTc p))  -- tyarg
                         (LPat p)                     -- arg
                         (HsRecFields p (LPat p))     -- rec
      
      2. type HsConDeclH98Details pass =
            HsConDetails Void                              -- tyarg
                         (HsScaled pass (LBangType pass))  -- arg
                         (XRec pass [LConDeclField pass])  -- rec
      
      3. type HsPatSynDetails pass =
            HsConDetails Void                     -- tyarg
                         (LIdP pass)              -- arg
                         [RecordPatSynField pass] -- rec
      
      In cases (2) and (3), tyarg was instantiated to Void, so the [tyarg]
      list was always empty. Its removal is basically a no-op.
      
      The interesting case is (1), which is used in ConPat to represent
      pattern matching of the form (MkE @tp1 @tp2 p1 p2).
      With this patch, its representation is changed as follows:
      
        ConPat "MkE" [tp1, tp2] [p1, p2]               -- old
        ConPat "MkE" [InvisP tp1, InvisP tp2, p1, p2]  -- new
      
      The new mixed-list representation is consintent with lambdas, where
      InvisP is already used to deal with \ @tp1 @tp2 p1 p2 -> body.
      
      The immediate effect of the new representation is an improvement to
      error messages. Consider the pattern (Con x @t y). Previously it
      resulted in a parse error because @t could not occur after x. Now it is
      reported as [GHC-14964]. Test case: TyAppPat_MisplacedApplication.
      
      In the long term, this is intended as preparation for #18389 and #25127,
      which would make (Con x @t y) potentially valid, e.g. if its type is
        Con :: forall a -> forall b. (a, b) -> T
      
      The TH AST is left unchanged for the moment to avoid breakage.
      7b84c588
    • Ben Gamari's avatar
      rts/linker/MachO: Account for internal GOT references in GOT construction · 8c96bcb4
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      Previously we failed to give GOT slots to symbols which were referred to
      by GOT relocations in the same module. This lead to #25577.
      
      Fix this by explicitly traversing relocation lists and maintaining a
      `needs_got` flag for each symbol.
      
      Fixes #25577.
      8c96bcb4
    • Ben Gamari's avatar
      rts/linker/MachO: Assert that GOT relocations have GOT entries · 2275b642
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      In #25577 we found that some GOT relocation types were not being given
      relocation entries. Add assertions to catch this sort of failure in the
      future.
      2275b642
    • Ben Gamari's avatar
      testsuite/ghc-api: Eliminate Makefile usage from various GHC API tests · d2ffb0ce
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      These tests can be expressed perfectly well using the testsuite driver
      itself.
      d2ffb0ce
    • Ben Gamari's avatar
      testsuite: Add testcase for #25577 · 48daaf53
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      48daaf53
    • sheaf's avatar
      Solve Wanted quantified constraints from Givens · d450e88e
      sheaf authored and Marge Bot's avatar Marge Bot committed
      This commit ensures we directly solve Wanted quantified constraints from
      matching inert Given quantified constraints,instead of going through the
      trouble of emitting an implication constraint and processing that.
      
      This is not just an optimisation; it makes our lives easier when
      generating RULEs for specialisation.
      See Note [Solving Wanted QCs from Given QCs] for details
      
      Fixes #25758
      d450e88e
    • Matthew Pickering's avatar
      Use panic rather than error in expectJust · 589f40b9
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      Otherwise, we would not get a callstack printed out when the exception
      occurs.
      
      Fixes #25829
      589f40b9
    • Ben Gamari's avatar
      testsuite: Don't count fragile passes as failures in JUnit output · 1951eb7a
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      As noted in #25806, the testsuite driver's JUnit output
      previously considered passes of fragile tests to be failures. Fix this.
      
      Closes #25806.
      1951eb7a
    • Ben Gamari's avatar
      users guide: Fix typo · cbae3708
      Ben Gamari authored and Marge Bot's avatar Marge Bot committed
      cbae3708
  4. Mar 09, 2025
    • Cheng Shao's avatar
      wasm: revamp JSFFI internal implementation and documentation · fd40eaa1
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This patch revamps the wasm backend's JSFFI internal implementation
      and documentation:
      
      - `JSValManager` logic to allocate a key is simplified to simple
        bumping. According to experiments with all major browsers, the
        internal `Map` would overflow the heap much earlier before we really
        exhaust the 32-bit key space, so there's no point in the extra
        complexity.
      - `freeJSVal` is now idempotent and safe to call more than once. This
        is achieved by attaching the `StablePtr#` to the `JSVal#` closure
        and nullifying it when calling `freeJSVal`, so the same stable
        pointer cannot be double freed.
      - `mkWeakJSVal` no longer exposes the internal `Weak#` pointer and
        always creates a new `Weak#` on the fly. Otherwise by finalizing
        that `Weak#`, user could accidentally drop the `JSVal`, but
        `mkWeakJSVal` is only supposed to create a `Weak` that observes the
        `JSVal`'s liveliness without actually interfering it.
      - `PromisePendingException` is no longer exported since it's never
        meant to be caught by user code; it's a severe bug if it's actually
        raised at runtime.
      - Everything exported by user-facing `GHC.Wasm.Prim` now has proper
        haddock documentation.
      - Note [JSVal representation for wasm] has been updated to reflect the
        new JSVal# memory layout.
      fd40eaa1
    • Cheng Shao's avatar
      wasm: don't create a wasm global for dyld poison · 75fcc5c9
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      There's a much more efficient way to convert an unsigned i32 to a
      signed one. Thanks, o3-mini-high.
      75fcc5c9
    • Cheng Shao's avatar
      wasm: do not use wasm type reflection in dyld · cca68421
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      The wasm dynamic linker used to depend on v8's experimental wasm type
      reflection support to generate stub functions when treating GOT.func
      items that aren't exported by any loaded library yet. However, as we
      work towards wasm ghci browser mode (#25399), we need to ensure the
      wasm dyld logic is portable across browsers. So this commit removes
      the usage of wasm type reflection in wasm dyld, and it shall only be
      added many months later when this feature is widely available in
      browsers.
      cca68421
  5. Mar 08, 2025
  6. Mar 07, 2025
    • Matthew Pickering's avatar
      iface: Store flags in interface files · 44bf5fa1
      Matthew Pickering authored
      When reporting the reason why a module is recompiled (using
      `-dump-hi-diffs`), it is much more informative to inform the user about
      which flag exactly has changed, rather than just an opaque reference to
      a hash.
      
      Now, when the user enables `-fwrite-if-self-recomp-flags`
      there is a difference the precise part of the flags is
      reported:
      
      ```
      codegen flags changed:
      before: [Opt_NoTypeableBinds, Opt_OmitYields]
      after: [Opt_NoTypeableBinds, Opt_OmitYields, Opt_DictsStrict]
      ```
      
      Fixes #25571
      44bf5fa1
  7. Mar 06, 2025
    • Matthew Craven's avatar
      Add tests for #25771 · 30bdea67
      Matthew Craven authored and Marge Bot's avatar Marge Bot committed
      30bdea67
    • Matthew Craven's avatar
      Cmm: Add constant-folding for Word->Float bitcasts · 25c4a2a2
      Matthew Craven authored and Marge Bot's avatar Marge Bot committed
      25c4a2a2
    • Matthew Craven's avatar
      Cmm: Add surface syntax for Word/Float bitcast ops · 1d4c9824
      Matthew Craven authored and Marge Bot's avatar Marge Bot committed
      1d4c9824
    • Matthew Pickering's avatar
      Disable self recomp in release flavour · 5b05c27b
      Matthew Pickering authored
      The interface files that we distribute should not contain any
      information which is used by the recompilation checking logic since
      source file will never be compiled again.
      
      I am not 100% sure this won't cause unexpected issues, there many be
      downstream consumers which are incorrectly using the information from
      interfaces, but this commit can be reverted if we detect issues.
      5b05c27b
    • Matthew Pickering's avatar
      Add flag to control whether self-recompilation information is written to interface · a510b861
      Matthew Pickering authored
      This patch adds the flag -fwrite-if-self-recomp which controls whether
      interface files contain the information necessary to answer the
      question:
      
        Do I need to recompile myself or is this current interface file
        suitable?
      
      Why? Most packages are only built once either by a distribution or cabal
      and then placed into an immutable store, after which we will never ask
      this question. Therefore we can derive two benefits from omitting this
      information.
      
      * Primary motivation: It vastly reduces the surface area for creating
        non-deterministic interface files. See issue #10424 which motivated a
        proper fix to that issue. Distributions have long contained versions
        of GHC which just have broken self-recompilation checking (in order to
        get deterministic interface files).
      
      * Secondary motivation: This reduces the size of interface files
        slightly.. the `mi_usages` field can be quite big but probably this
        isn't such a great benefit.
      
      * Third motivation: Conceptually clarity about which parts of an
        interface file are used in order to **communicate** with subsequent
        packages about the **interface** for a module. And which parts are
        used to self-communicate during recompilation checking.
      
      The main tracking issue is #22188 but fixes issues such as #10424 in a
      proper way.
      a510b861
  8. Mar 05, 2025
    • Rodrigo Mesquita's avatar
      docs: Fix ghci :doc documentation · 07fe6d1d
      Rodrigo Mesquita authored and Marge Bot's avatar Marge Bot committed
      Fixes #25799
      07fe6d1d
    • Matthew Pickering's avatar
      simplifier: Zap Id unfoldings before constructing InScopeSet in simpleOptExpr · 8273d7d1
      Matthew Pickering authored and Marge Bot's avatar Marge Bot committed
      Care must be taken to remove unfoldings from `Var`s collected by exprFreeVars
      before using them to construct an in-scope set hence `zapIdUnfolding` in `init_subst`.
      Consider calling `simpleOptExpr` on an expression like
      
      ```
       case x of (a,b) -> (x,a)
      ```
      
      * One of those two occurrences of x has an unfolding (the one in (x,a), with
      unfolding x = (a,b)) and the other does not. (Inside a case GHC adds
      unfolding-info to the scrutinee's Id.)
      * But exprFreeVars just builds a set, so it's a bit random which occurrence is collected.
      * Then simpleOptExpr replaces each occurrence of x with the one in the in-scope set.
      * Bad bad bad: then the x in  case x of ... may be replaced with a version that has an unfolding.
      
      Fixes #25790
      8273d7d1
    • Cheng Shao's avatar
      ghc-experimental: add mkWeakJSVal · 55af20e6
      Cheng Shao authored and Marge Bot's avatar Marge Bot committed
      This commit adds a mkWeakJSVal function that can be used to set up a
      Weak pointer with a JSVal key to observe the key's lifetime and
      optionally attach a finalizer.
      55af20e6
Loading