1. 20 Sep, 2019 1 commit
    • Alp Mestanogullari's avatar
      ErrUtils: split withTiming into withTiming and withTimingSilent · b3e5c731
      Alp Mestanogullari authored
      'withTiming' becomes a function that, when passed '-vN' (N >= 2) or
      '-ddump-timings', will print timing (and possibly allocations) related
      information. When additionally built with '-eventlog' and executed with
      '+RTS -l', 'withTiming' will also emit both 'traceMarker' and 'traceEvent'
      events to the eventlog.
      
      'withTimingSilent' on the other hand will never print any timing information,
      under any circumstance, and will only emit 'traceEvent' events to the eventlog.
      As pointed out in !1672, 'traceMarker' is better suited for things that we
      might want to visualize in tools like eventlog2html, while 'traceEvent'
      is better suited for internal events that occur a lot more often and that we
      don't necessarily want to visualize.
      
      This addresses #17138 by using 'withTimingSilent' for all the codegen bits
      that are expressed as a bunch of small computations over streams of codegen
      ASTs.
      b3e5c731
  2. 03 Aug, 2019 1 commit
  3. 01 May, 2019 2 commits
  4. 15 Mar, 2019 1 commit
  5. 18 Feb, 2019 1 commit
  6. 29 Nov, 2018 1 commit
    • Chaitanya Koparkar's avatar
      Fix #15953 by consistently using dumpIfSet_dyn to print debug output · dcf1f926
      Chaitanya Koparkar authored
      Summary:
      In some modules we directly dump the debugging output to STDOUT
      via 'putLogMsg', 'printInfoForUser' etc. However, if `-ddump-to-file`
      is enabled, that output should be written to a file. Easily fixed.
      
      Certain tests (T3017, Roles3, T12763 etc.) expect part of the
      output generated by `-ddump-types` to be in 'PprUser' style. However,
      generally we want all other debugging output to use 'PprDump'
      style. `traceTcRn` and `traceTcRnForUser` help us accomplish this.
      
      This patch also documents some missing flags in the users guide.
      
      Reviewers: RyanGlScott, bgamari, hvr
      
      Reviewed By: RyanGlScott
      
      Subscribers: rwbarton, carter
      
      GHC Trac Issues: #15953
      
      Differential Revision: https://phabricator.haskell.org/D5382
      dcf1f926
  7. 25 Feb, 2018 1 commit
  8. 22 Nov, 2017 2 commits
  9. 15 Nov, 2017 1 commit
  10. 02 Nov, 2017 1 commit
  11. 19 Sep, 2017 1 commit
    • Herbert Valerio Riedel's avatar
      compiler: introduce custom "GhcPrelude" Prelude · f63bc730
      Herbert Valerio Riedel authored
      This switches the compiler/ component to get compiled with
      -XNoImplicitPrelude and a `import GhcPrelude` is inserted in all
      modules.
      
      This is motivated by the upcoming "Prelude" re-export of
      `Semigroup((<>))` which would cause lots of name clashes in every
      modulewhich imports also `Outputable`
      
      Reviewers: austin, goldfire, bgamari, alanz, simonmar
      
      Reviewed By: bgamari
      
      Subscribers: goldfire, rwbarton, thomie, mpickering, bgamari
      
      Differential Revision: https://phabricator.haskell.org/D3989
      f63bc730
  12. 11 Jul, 2017 1 commit
    • Ömer Sinan Ağacan's avatar
      Mention which -Werror promoted a warning to an error · 4befb415
      Ömer Sinan Ağacan authored
      Previously -Werror or -Werror=flag printed warnings as usual and then
      printed
      these two lines:
      
          <no location info>: error:
          Failing due to -Werror.
      
      This is not ideal: first, it's not clear which flag made one of the
      warnings an
      error. Second, warning messages are not modified in any way, so there's
      no way
      to know which warnings caused this error.
      
      With this patch we (1) promote warning messages to error messages if a
      relevant
      -Werror is enabled (2) mention which -Werror is used during this
      promotion.
      
      Previously:
      
          [1 of 1] Compiling Main             ( test.hs, test.o )
      
          test.hs:9:10: warning: [-Wincomplete-patterns]
              Pattern match(es) are non-exhaustive
              In a case alternative: Patterns not matched: (C2 _)
            |
          9 | sInt s = case s of
            |          ^^^^^^^^^...
      
          test.hs:12:14: warning: [-Wmissing-fields]
              • Fields of ‘Rec’ not initialised: f2
              • In the first argument of ‘print’, namely ‘Rec {f1 =
      1}’
                In the expression: print Rec {f1 = 1}
                In an equation for ‘main’: main = print Rec {f1 = 1}
             |
          12 | main = print Rec{ f1 = 1 }
             |              ^^^^^^^^^^^^^
      
          <no location info>: error:
          Failing due to -Werror.
      
      Now:
      
          [1 of 1] Compiling Main             ( test.hs, test.o )
      
          test.hs:9:10: error: [-Wincomplete-patterns,
      -Werror=incomplete-patterns]
              Pattern match(es) are non-exhaustive
              In a case alternative: Patterns not matched: (C2 _)
            |
          9 | sInt s = case s of
            |          ^^^^^^^^^...
      
          test.hs:12:14: error: [-Wmissing-fields, -Werror=missing-fields]
              • Fields of ‘Rec’ not initialised: f2
              • In the first argument of ‘print’, namely ‘Rec {f1 =
      1}’
                In the expression: print Rec {f1 = 1}
                In an equation for ‘main’: main = print Rec {f1 = 1}
             |
          12 | main = print Rec{ f1 = 1 }
             |              ^^^^^^^^^^^^^
      
      Test Plan: - Update old tests, add new tests if there aren't any
      relevant tests
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3709
      4befb415
  13. 08 Jun, 2017 1 commit
    • duog's avatar
      Refactor temp files cleanup · 3ee3822c
      duog authored
      Remove filesToNotIntermediateClean from DynFlags, create a data type
      FilesToClean, and change filesToClean in DynFlags to be a FilesToClean.
      
      Modify SysTools.newTempName and the Temporary constructor of
      PipelineMonad.PipelineOutput to take a TempFileLifetime, which specifies
      whether a temp file should live until the end of GhcMonad.withSession,
      or until the next time cleanIntermediateTempFiles is called.
      
      These changes allow the cleaning of intermediate files in GhcMake to be
      much more efficient.
      
      HscTypes.hptObjs is removed as it is no longer used.
      
      A new performance test T13701 is added, which passes both with and
      without -keep-tmp-files.  The test fails by 25% without the patch, and
      passes when -keep-tmp-files is added.
      
      Note that there are still at two hotspots caused by
      algorithms quadratic in the number of modules, however neither of them
      allocate. They are:
      
      * DriverPipeline.compileOne'.needsLinker
      * GhcMake.getModLoop
      
      DriverPipeline.compileOne'.needsLinker is changed slightly to improve
      the situation.
      
      I don't like adding these Types to DynFlags, but they need to be seen by
      Dynflags, SysTools and PipelineMonad. The alternative seems to be to
      create a new module.
      
      Reviewers: austin, hvr, bgamari, dfeuer, niteria, simonmar, erikd
      
      Reviewed By: simonmar
      
      Subscribers: rwbarton, thomie
      
      GHC Trac Issues: #13701
      
      Differential Revision: https://phabricator.haskell.org/D3620
      3ee3822c
  14. 26 May, 2017 1 commit
  15. 22 May, 2017 1 commit
  16. 20 May, 2017 1 commit
    • Rufflewind's avatar
      Correctly expand lines with multiple tabs · 86466489
      Rufflewind authored
      rwbarton pointed out that tab expansions can affect the column numbers
      of subsequent characters, so a unstateful map + zip won't do.  This
      commit hopefully fixes that.  It also adds a test for this particular
      case.
      
      Test Plan: validate
      
      Reviewers: bgamari, rwbarton, austin
      
      Reviewed By: bgamari
      
      Subscribers: dfeuer, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3578
      86466489
  17. 12 May, 2017 1 commit
  18. 18 Apr, 2017 1 commit
  19. 24 Mar, 2017 1 commit
    • Rufflewind's avatar
      Allow colors to be customized · adf27d61
      Rufflewind authored
      Allow customization of diagnostic colors through the GHC_COLORS
      environment variable.  Some color-related code have been refactored to
      PprColour to reduce the circular dependence between DynFlags,
      Outputable, ErrUtils.  Some color functions that were part of Outputable
      but were never used have been deleted.
      
      Test Plan: validate
      
      Reviewers: austin, hvr, bgamari, dfeuer
      
      Reviewed By: bgamari, dfeuer
      
      Subscribers: dfeuer, rwbarton, thomie, snowleopard
      
      Differential Revision: https://phabricator.haskell.org/D3364
      adf27d61
  20. 15 Mar, 2017 1 commit
    • Ben Gamari's avatar
      Introduce putLogMsg · 086b514b
      Ben Gamari authored
      This factors out the repetition of (log_action dflags dflags) and will
      hopefully allow us to someday better abstract log output.
      
      Test Plan: Validate
      
      Reviewers: austin, hvr, goldfire
      
      Subscribers: rwbarton, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3334
      086b514b
  21. 13 Mar, 2017 1 commit
  22. 13 Feb, 2017 1 commit
  23. 03 Feb, 2017 1 commit
    • Sylvain Henry's avatar
      Ditch static flags · bbd3c399
      Sylvain Henry authored
      This patch converts the 4 lasting static flags (read from the command
      line and unsafely stored in immutable global variables) into dynamic
      flags. Most use cases have been converted into reading them from a DynFlags.
      
      In cases for which we don't have easy access to a DynFlags, we read from
      'unsafeGlobalDynFlags' that is set at the beginning of each 'runGhc'.
      It's not perfect (not thread-safe) but it is still better as we can
      set/unset these 4 flags before each run when using GHC API.
      
      Updates haddock submodule.
      
      Rebased and finished by: bgamari
      
      Test Plan: validate
      
      Reviewers: goldfire, erikd, hvr, austin, simonmar, bgamari
      
      Reviewed By: simonmar
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2839
      
      GHC Trac Issues: #8440
      bbd3c399
  24. 30 Jan, 2017 1 commit
    • Matthew Pickering's avatar
      Add a flag to emit error messages as JSON · 91691117
      Matthew Pickering authored
      This patch adds the flag `-ddump-json` which dumps all the compiler
      output as a JSON array. This allows tooling to more easily parse GHC's
      output to display to users.
      
      The flag is currently experimental and will hopefully be refined for the
      next release.  In particular I have avoided any changes which involve
      significant refactoring and provided what is easy given the current
      infrastructure.
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: DanielG, gracjan, thomie
      
      Differential Revision: https://phabricator.haskell.org/D3010
      
      GHC Trac Issues: #13190
      91691117
  25. 23 Dec, 2016 1 commit
    • Rufflewind's avatar
      Add caret diagnostics · 158530a5
      Rufflewind authored
      This is controlled by -f[no-]diagnostics-show-caret.
      
      Example of what it looks like:
      ```
          |
       42 |     x = 1 + ()
          |         ^^^^^^
      ```
      This is appended to each diagnostic message.
      
      Test Plan:
      testsuite/tests/warnings/should_fail/CaretDiagnostics1
      testsuite/tests/warnings/should_fail/CaretDiagnostics2
      
      Reviewers: simonpj, austin, bgamari
      
      Reviewed By: simonpj, bgamari
      
      Subscribers: joehillen, mpickering, Phyx, simonpj, alanz, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2718
      
      GHC Trac Issues: #8809
      158530a5
  26. 09 Dec, 2016 1 commit
  27. 29 Nov, 2016 1 commit
    • Rufflewind's avatar
      Make diagnostics slightly more colorful · f1fc8cbf
      Rufflewind authored
      This is a preliminary commit to add colors to diagnostics (warning and
      error messages).  The aesthetic changes are:
      
        - 'warning', 'error', and 'fatal' are all colored magenta, red, and
          red respectively.
        - The warning annotation [-Wsomething] shares the same color.
        - Warnings and errors are also bolded (this is consistent with what
          other compilers do).
      
      A new flag has been added to control the behavior:
      
          -fdiagnostics-color=(always|auto|never)
      
      This flag is 'auto' by default.  However, auto-detection is not
      implemented yet, so it effectively it defaults to off.
      
      Test Plan: validate
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: thomie
      
      Differential Revision: https://phabricator.haskell.org/D2716
      
      GHC Trac Issues: #8809
      f1fc8cbf
  28. 21 Nov, 2016 1 commit
    • Maciej Bielecki's avatar
      Implement fine-grained `-Werror=...` facility · 514acfe4
      Maciej Bielecki authored
      This patch add new options `-Werror=...`, `-Wwarn=...` and
      `-Wno-error=...` (synonym for `-Wwarn=...`).
      
      Semantics:
      
        - `-Werror` marks all warnings as fatal, including those that don't
          have a warning flag, and CPP warnings.
        - `-Werror=...` enables a warning and marks it as fatal
        - `-Wwarn=...` marks a warning as non-fatal, but doesn't disable it
      
      Test Plan: validate
      
      Reviewers: austin, bgamari
      
      Reviewed By: bgamari
      
      Subscribers: mpickering, svenpanne, RyanGlScott, thomie
      
      Differential Revision: https://phabricator.haskell.org/D2706
      
      GHC Trac Issues: #11219
      514acfe4
  29. 22 Oct, 2016 1 commit
  30. 31 Aug, 2016 1 commit
  31. 24 Mar, 2016 1 commit
    • Ben Gamari's avatar
      ErrUtils: Add timings to compiler phases · 8048d51b
      Ben Gamari authored
      This adds timings and allocation figures to the compiler's output when
      run with `-v2` in an effort to ease performance analysis.
      
      Todo:
        * Documentation
        * Where else should we add these?
        * Perhaps we should remove some of the now-arguably-redundant
          `showPass` occurrences where they are
        * Must we force more?
        * Perhaps we should place this behind a `-ftimings` instead of `-v2`
      
      Test Plan: `ghc -v2 Test.hs`, look at the output
      
      Reviewers: hvr, goldfire, simonmar, austin
      
      Reviewed By: simonmar
      
      Subscribers: angerman, michalt, niteria, ezyang, thomie
      
      Differential Revision: https://phabricator.haskell.org/D1959
      8048d51b
  32. 25 Feb, 2016 1 commit
    • barrucadu's avatar
      Print which warning-flag controls an emitted warning · bb5afd3c
      barrucadu authored
      Both gcc and clang tell which warning flag a reported warning can be
      controlled with, this patch makes ghc do the same. More generally, this
      allows for annotated compiler output, where an optional annotation is
      displayed in brackets after the severity.
      
      This also adds a new flag `-f(no-)show-warning-groups` to control
      whether to show which warning-group (such as `-Wall` or `-Wcompat`)
      a warning belongs to. This flag is on by default.
      
      This implements #10752
      
      Reviewed By: quchen, bgamari, hvr
      
      Differential Revision: https://phabricator.haskell.org/D1943
      bb5afd3c
  33. 18 Jan, 2016 1 commit
    • Jan Stolarek's avatar
      Replace calls to `ptext . sLit` with `text` · b8abd852
      Jan Stolarek authored
      Summary:
      In the past the canonical way for constructing an SDoc string literal was the
      composition `ptext . sLit`.  But for some time now we have function `text` that
      does the same.  Plus it has some rules that optimize its runtime behaviour.
      This patch takes all uses of `ptext . sLit` in the compiler and replaces them
      with calls to `text`.  The main benefits of this patch are clener (shorter) code
      and less dependencies between module, because many modules now do not need to
      import `FastString`.  I don't expect any performance benefits - we mostly use
      SDocs to report errors and it seems there is little to be gained here.
      
      Test Plan: ./validate
      
      Reviewers: bgamari, austin, goldfire, hvr, alanz
      
      Subscribers: goldfire, thomie, mpickering
      
      Differential Revision: https://phabricator.haskell.org/D1784
      b8abd852
  34. 08 Jan, 2016 1 commit
  35. 03 Dec, 2015 1 commit
  36. 02 Dec, 2015 2 commits
    • Ben Gamari's avatar
      ErrUtils: Spruce up Haddocks · 0d1a2d23
      Ben Gamari authored
      This is a pretty commonly needed module; Haddocks are worth the effort.
      0d1a2d23
    • tvv's avatar
      Create empty dump files when there was nothing to dump · 8cba907a
      tvv authored
      This patch creates empty dump file when GHC was run with
      `-ddump-rule-firings` (or `-ddump-rule-rewrites`) and `-ddump-to-file`
      specified, and there were no rules applied. If dump already exists it
      will be overwritten by empty one.
      
      Test Plan: ./validate
      
      Reviewers: austin, thomie, bgamari
      
      Reviewed By: thomie, bgamari
      
      Subscribers: thomie
      
      Projects: #ghc
      
      Differential Revision: https://phabricator.haskell.org/D1514
      
      GHC Trac Issues: #10320
      8cba907a
  37. 24 Nov, 2015 1 commit
    • elaforge's avatar
      Rearrange error msgs and add section markers (Trac #11014). · c05fddde
      elaforge authored
      This puts the "Relevant bindings" section at the end.
      
      It uses a TcErrors.Report Monoid to divide messages by importance and
      then mappends them together.  This is not the most efficient way since
      there are various intermediate Reports and list appends, but it probably
      doesn't matter since error messages shouldn't get that large, and are
      usually prepended.  In practice, everything is `important` except
      `relevantBindings`, which is `supplementary`.
      
      ErrMsg's errMsgShortDoc and errMsgExtraInfo were extracted into ErrDoc,
      which has important, context, and suppelementary fields.  Each of those
      three sections is marked with a bullet character, '•' on unicode
      terminals and '*' on ascii terminals.  Since this breaks tons of tests,
      I also modified testlib.normalise_errmsg to strip out '•'s.
      
      --- Additional notes:
      
      To avoid prepending * to an empty doc, I needed to filter empty docs.
      This seemed less error-prone than trying to modify everyone who produces
      SDoc to instead produce Maybe SDoc.  So I added `Outputable.isEmpty`.
      Unfortunately it needs a DynFlags, which is kind of bogus, but otherwise
      I think I'd need another Empty case for SDoc, and then it couldn't be a
      newtype any more.
      
      ErrMsg's errMsgShortString is only used by the Show instance, which is
      in turn only used by Show HscTypes.SourceError, which is in turn only
      needed for the Exception instance.  So it's probably possible to get rid
      of errMsgShortString, but that would a be an unrelated cleanup.
      
      Fixes #11014.
      
      Test Plan: see above
      
      Reviewers: austin, simonpj, thomie, bgamari
      
      Reviewed By: thomie, bgamari
      
      Subscribers: simonpj, nomeata, thomie
      
      Differential Revision: https://phabricator.haskell.org/D1427
      
      GHC Trac Issues: #11014
      c05fddde