4 years agoUse a response file for linker command line arguments #10777
Michael Snoyman [Wed, 2 Sep 2015 11:31:25 +0000 (13:31 +0200)] 
Use a response file for linker command line arguments #10777

On Windows, we're constrained to 32k bytes total for command line
arguments.  When building large projects, this limit can be exceeded.
This patch changes GHC to always use response files for linker
arguments, a feature first used by Microsoft compilers and added to GCC
(over a decade ago).

Alternatives here include:

* Only use this method on Windows systems
* Check the length of the command line arguments and use that to decide
  whether to use this method

I did not pursue either of these, as I believe it would make the patch
more likely to break in less tested situations.

Test Plan:
Confirm that linking still works in general. Ideally: compile a very
large project on Windows with this patch. (I am attempting to do that
myself now, but having trouble getting the Windows build tool chain up
and running.)

Reviewers: goldfire, hvr, rwbarton, austin, thomie, bgamari, Phyx

Reviewed By: thomie, bgamari, Phyx

Subscribers: erikd, awson, #ghc_windows_task_force, thomie

Differential Revision:

GHC Trac Issues: #8596, #10777

4 years agoAdd test for updating a record with existentially quantified fields.
Matthew Pickering [Wed, 2 Sep 2015 11:28:34 +0000 (13:28 +0200)] 
Add test for updating a record with existentially quantified fields.

Test Plan: ./validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

4 years agoFix trac #10413
Ben Gamari [Wed, 2 Sep 2015 11:26:22 +0000 (13:26 +0200)] 
Fix trac #10413

Test Plan: Validate.

Reviewers: austin, tibbe, bgamari

Reviewed By: tibbe, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10413

4 years agoUse IP based CallStack in error and undefined
Eric Seidel [Wed, 2 Sep 2015 08:22:01 +0000 (10:22 +0200)] 
Use IP based CallStack in error and undefined

This patch modifies `error`, `undefined`, and `assertError` to use
implicit call-stacks to provide better error messages to users.

There are a few knock-on effects:

- `GHC.Classes.IP` is now wired-in so it can be used in the wired-in
  types for `error` and `undefined`.

- `TysPrim.tyVarList` has been replaced with a new function
  `TysPrim.mkTemplateTyVars`. `tyVarList` made it easy to introduce
  subtle bugs when you need tyvars of different kinds. The naive

  tv1 = head $ tyVarList kind1
  tv2 = head $ tyVarList kind2

  would result in `tv1` and `tv2` sharing a `Unique`, thus substitutions
  would be applied incorrectly, treating `tv1` and `tv2` as the same
  tyvar. `mkTemplateTyVars` avoids this pitfall by taking a list of kinds
  and producing a single tyvar of each kind.

- The types `GHC.SrcLoc.SrcLoc` and `GHC.Stack.CallStack` now live in

- The type `GHC.Exception.ErrorCall` has a new constructor
  `ErrorCallWithLocation` that takes two `String`s instead of one, the
  2nd one being arbitrary metadata about the error (but usually the
  call-stack). A bi-directional pattern synonym `ErrorCall` continues to
  provide the old API.

Updates Cabal, array, and haddock submodules.

Reviewers: nh2, goldfire, simonpj, hvr, rwbarton, austin, bgamari

Reviewed By: simonpj

Subscribers: rwbarton, rodlogic, goldfire, maoe, simonmar, carter,
liyang, bgamari, thomie

Differential Revision:

GHC Trac Issues: #5273

4 years agoTestsuite: refactoring only
Thomas Miedema [Fri, 28 Aug 2015 10:03:30 +0000 (12:03 +0200)] 
Testsuite: refactoring only

* Rename `platform_wordsize_qualify` to `find_expected_file`, and make
  it return a filename instead of an (absolute) filepath.

* Replace most usages of `qualify` by `in_testdir`. Others usage sites
  will be deleted in a later commit.

These changes will be useful in a later commit, when we'll distinguish
between files in the source directory and those in a (newly created)
test directory.

Reviewed by: austin, bgamari

Differential Revision:

4 years agoAnchor type family instances deterministically
Bartosz Nitka [Mon, 31 Aug 2015 15:10:34 +0000 (16:10 +0100)] 
Anchor type family instances deterministically

This is very similar to D1073. It makes type family instances to be
attached to a binding with a least `OccName`, therefore not depending on `Unique` ordering.

Test Plan:
* this makes `Language.Haskell.Exts.SrcLoc` deterministic
* ./validate

Reviewers: simonmar, austin, bgamari, simonpj

Reviewed By: simonpj

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #4012

4 years agoFix typo in pattern synonym documentation.
Matthew Pickering [Sun, 30 Aug 2015 16:31:01 +0000 (18:31 +0200)] 
Fix typo in pattern synonym documentation.

`MkT` is the name of the constructor whilst `T` is the name of
the type.

Reviewers: bgamari, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10787

4 years agoFix 7.10 validate
Matthew Pickering [Sun, 30 Aug 2015 16:30:51 +0000 (18:30 +0200)] 
Fix 7.10 validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

4 years agoStgCmmHeap: Re-add check for large static allocations
Ben Gamari [Thu, 27 Aug 2015 12:08:01 +0000 (14:08 +0200)] 
StgCmmHeap: Re-add check for large static allocations

This should at least help alleviate the annoyance of #4505. This
reintroduces a compile-time check originally added in
a278f3f02d09bc32b0a75d4a04d710090cde250f but dropped with the new code

4 years agointeger-gmp: optimise bitBigNat
Herbert Valerio Riedel [Sat, 29 Aug 2015 10:25:45 +0000 (12:25 +0200)] 
integer-gmp: optimise bitBigNat

This is a somewhat minor optimisation exploiting the static knowledge
of the operands involved allowing to save a few allocations.

Reviewers: austin, rwbarton, goldfire, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

4 years agoghc-pkg --enable-multi-instance should not complain about case sensitivity.
Edward Z. Yang [Sat, 29 Aug 2015 10:25:28 +0000 (12:25 +0200)] 
ghc-pkg --enable-multi-instance should not complain about case sensitivity.

Test Plan: validate

Reviewers: simonmar, bgamari, austin

Reviewed By: bgamari, austin

Subscribers: thomie

Differential Revision:

4 years agoFix identifier parsing in hp2ps
Yuras Shumovich [Sat, 29 Aug 2015 10:25:14 +0000 (12:25 +0200)] 
Fix identifier parsing in hp2ps

Now identifiers can start with a package key, which is a hash, so they
may also start with a digit. Identifiers always appear at the beginning
of a line, and numbers never appear here, soit's safe to allow
identifiers to start with a digit.

Test Plan: `concprog002` passes under `threaded2_hT` way

Reviewers: austin, bgamari, thomie

Reviewed By: austin, bgamari, thomie

Differential Revision:

GHC Trac Issues: #10661

4 years agoDwarf: Produce .dwarf_aranges section
Ben Gamari [Sat, 29 Aug 2015 10:25:04 +0000 (12:25 +0200)] 
Dwarf: Produce .dwarf_aranges section

Test Plan: Check with `readelf --debug-dump=ranges`

Reviewers: scpmw, austin

Subscribers: thomie

Differential Revision:

4 years agoDwarf: Produce {low,high}_pc attributes for compilation units
Ben Gamari [Sat, 29 Aug 2015 10:24:54 +0000 (12:24 +0200)] 
Dwarf: Produce {low,high}_pc attributes for compilation units

Some libraries (e.g. elfutils) need these otherwise they ignore our
DWARF annotations.

Test Plan: Test with elfutils' `readelf --debug-dump=cu_index`

Reviewers: scpmw, austin

Subscribers: thomie

Differential Revision:

4 years agoDwarf: Fix DW_AT_use_UTF8 attribute
Ben Gamari [Sat, 29 Aug 2015 10:24:14 +0000 (12:24 +0200)] 
Dwarf: Fix DW_AT_use_UTF8 attribute

Previously this was given in the body but not in the abbreviation table.
Who knows what sort of havoc this was wrecking.

Test Plan: Verify against DWARF4 specification

Reviewers: scpmw, austin

Subscribers: Tarrasch, thomie

Differential Revision:

4 years agoRespect GHC_CHARENC environment variable #10762
Michael Snoyman [Sat, 29 Aug 2015 10:23:48 +0000 (12:23 +0200)] 
Respect GHC_CHARENC environment variable #10762

Only supports UTF-8 as a value right now. I expect some discussion to go
on around the naming of this variable and whether it's valid to backport
it to GHC 7.10 (which would be my preference). The motivation here is
that, when capturing the output of GHC to a file, we often want to
ensure that the output is UTF-8, regardless of the actual character
encoding of the terminal/console.

On the other hand, we don't want to necessary change the
terminal/console encoding. The reason being:

* On Windows, this requires a global-esque change to the console
  codepage, which adversely affects other processes in the same console

* On all OSes, this can break features like smart quote auto-detection.

Test Plan:
Set LANG to C, GHC_CHARENC to UTF-8, and compile a Haskell source
file with a non-ASCII warning produced. The output who include the UTF-8
sequence instead of replacing it with ?.

Reviewers: austin, rwbarton, bgamari

Reviewed By: bgamari

Subscribers: hsyl20, thomie

Differential Revision:

GHC Trac Issues: #10762

4 years agoMake Generic (Proxy t) instance poly-kinded (fixes #10775)
RyanGlScott [Sat, 29 Aug 2015 10:23:31 +0000 (12:23 +0200)] 
Make Generic (Proxy t) instance poly-kinded (fixes #10775)

This amounts to enabling PolyKinds in GHC.Generics. However, explicit
kind signatures must be applied to the datatypes and typeclasses in
GHC.Generics to ensure that the Core which TcGenGenerics generates
is properly kinded.

Several of the typeclasses in GHC.Generics could be poly-kinded, but
this differential does not attempt to address this, since D493 already
addresses this.

Test Plan: ./validate

Reviewers: hvr, austin, dreixel, bgamari

Reviewed By: austin, dreixel, bgamari

Subscribers: goldfire, thomie

Differential Revision:

GHC Trac Issues: #10775

4 years agoAdd testcase for #7411
Ben Gamari [Thu, 27 Aug 2015 13:04:29 +0000 (15:04 +0200)] 
Add testcase for #7411

4 years agoRTS: Reduce MBLOCK_SPACE_SIZE on AArch64
Erik de Castro Lopo [Tue, 25 Aug 2015 02:07:45 +0000 (02:07 +0000)] 

Commit 0d1a8d09f4 added a two step allocator for 64 bit systems. This
allocator mmaps a huge (1 TB) chunk of memory out of which it does
smaller allocations. On AArch64/Arm64 linux, this mmap was failing
due to the Arm64 Linux kernel parameter CONFIG_ARM64_VA_BITS
defaulting to 39 bits.

Therefore reducing the AArch64 value for MBLOCK_SPACE_SIZE to make
this allocation 1/4 TB while remaining 1 TB for other archs.

Reviewers: ezyang, austin, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10682

4 years agobase: Remove a redundant 'return'
Simon Peyton Jones [Thu, 26 Mar 2015 11:06:12 +0000 (11:06 +0000)] 
base: Remove a redundant 'return'

4 years agoTysWiredIn: Shuffle code around
Ben Gamari [Wed, 26 Aug 2015 16:19:31 +0000 (18:19 +0200)] 
TysWiredIn: Shuffle code around

4 years agoMkIface: Introduce PatSynId, ReflectionId, DefMethId
Ben Gamari [Wed, 26 Aug 2015 16:14:31 +0000 (18:14 +0200)] 
MkIface: Introduce PatSynId, ReflectionId, DefMethId

Currently we don't persist these three "advisory" IdInfos through
interface files.  We easily could if needed.

4 years agoIfaceEnv: Clean up updNameCache a bit
Ben Gamari [Wed, 26 Aug 2015 16:10:21 +0000 (18:10 +0200)] 
IfaceEnv: Clean up updNameCache a bit

4 years agoMove newImplicitBinder to from IfaceEnv to BuildTyCl
Ben Gamari [Thu, 27 Aug 2015 06:01:21 +0000 (08:01 +0200)] 
Move newImplicitBinder to from IfaceEnv to BuildTyCl

4 years agoPrelNames: introduce dcQual in place of conName
Ben Gamari [Wed, 26 Aug 2015 16:03:00 +0000 (18:03 +0200)] 
PrelNames: introduce dcQual in place of conName

4 years agoRevert "Clean up handling of knownKeyNames"
Ben Gamari [Wed, 26 Aug 2015 23:00:52 +0000 (01:00 +0200)] 
Revert "Clean up handling of knownKeyNames"

This reverts commit 792446906c718a08f0870b58acbdf2cfdeb77770.

This commit was a failed part of an effort to split up D757. I'll need
to try again and make sure I build-test next time.

4 years agoClean up handling of knownKeyNames
Ben Gamari [Wed, 26 Aug 2015 15:58:25 +0000 (17:58 +0200)] 
Clean up handling of knownKeyNames

4 years agoBinIface: Clean up whitespace
Ben Gamari [Wed, 26 Aug 2015 15:56:06 +0000 (17:56 +0200)] 
BinIface: Clean up whitespace

4 years agoPrelNames: Clean up list a bit
Ben Gamari [Wed, 26 Aug 2015 15:50:33 +0000 (17:50 +0200)] 
PrelNames: Clean up list a bit

4 years agoTcDeriv: Kill dead code
Ben Gamari [Wed, 26 Aug 2015 15:46:22 +0000 (17:46 +0200)] 
TcDeriv: Kill dead code

4 years agotcRnDeclsi can use tcRnSrcDecls
Simon Peyton Jones [Mon, 23 Mar 2015 14:32:31 +0000 (14:32 +0000)] 
tcRnDeclsi can use tcRnSrcDecls

I'm not sure why tcRnDeclsi didn't call tcRnSrcDecls before, but now it
does.  About 20 lines of code vanish. Hooray.

4 years agoImplement lookupGlobal in TcEnv, and use it
Simon Peyton Jones [Fri, 20 Mar 2015 12:38:42 +0000 (12:38 +0000)] 
Implement lookupGlobal in TcEnv, and use it

This localises the (revolting) initTcForLookup function, exposing
instead the more civilised interface for lookupGlobal

4 years agoComments and white space
Simon Peyton Jones [Fri, 20 Mar 2015 12:36:22 +0000 (12:36 +0000)] 
Comments and white space

4 years agoFix algorithm.tex build and update with some new info.
Edward Z. Yang [Wed, 26 Aug 2015 17:16:05 +0000 (10:16 -0700)] 
Fix algorithm.tex build and update with some new info.

Signed-off-by: Edward Z. Yang <>
4 years Allow disabling of large-address-space
Erik de Castro Lopo [Tue, 25 Aug 2015 01:33:32 +0000 (11:33 +1000)] Allow disabling of large-address-space

Recent changes (commit 0d1a8d09f4) for 64 bit platforms allowed GHC
to mmap one huge (currently 1 terrabyte) memory region from which to
do its own allocations. This is enabled by default, but it would be
nice (even just from the point of view of testing) to be able to
disable this at configure time.

Test Plan: configure and grep mk/config.h for USE_LARGE_ADDRESS_SPACE

Reviewers: austin, ezyang, bgamari, rwbarton

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10791

4 years agofix 64bit two-stage allocator on Solaris/AMD64 platform (#10790)
Karel Gardas [Tue, 25 Aug 2015 12:06:29 +0000 (14:06 +0200)] 
fix 64bit two-stage allocator on Solaris/AMD64 platform (#10790)

Test Plan: tested on Solaris 11/AMD64 when previous build failed

Reviewers: bgamari, austin, simonmar, gcampax, ezyang

Subscribers: thomie

Differential Revision:

4 years agoDelete ExtsCompat46 (#8330)
Thomas Miedema [Tue, 21 Jul 2015 12:59:55 +0000 (14:59 +0200)] 
Delete ExtsCompat46 (#8330)

We require ghc-7.8 to build HEAD (ghc-7.11).

Differential Revision:

4 years agoCheck options before warning about source imports.
Alex Rozenshteyn [Fri, 21 Aug 2015 19:42:16 +0000 (21:42 +0200)] 
Check options before warning about source imports.

Summary: Fixes T10637

Reviewers: austin, bgamari, thomie

Subscribers: dfordivam, simonpj, thomie

Differential Revision:

GHC Trac Issues: #10637

4 years agoBuild system: delete unused distrib/Makefile
Thomas Miedema [Sat, 15 Aug 2015 17:07:52 +0000 (19:07 +0200)] 
Build system: delete unused distrib/Makefile

4 years agoBuild system: simplify
Thomas Miedema [Sat, 15 Aug 2015 12:18:07 +0000 (14:18 +0200)] 
Build system: simplify

This will allow fixing #1851 more easily
("make install-strip" should work).

This reverts 57e2a81c589103b50da80a9e378b1a11285bd521:
  "On Cygwin, use a Cygwin-style path for /bin/install's destination"

Update submodule haddock and hsc2hs.

4 years agoRefactor: delete most of the module FastTypes
Thomas Miedema [Fri, 21 Aug 2015 08:44:54 +0000 (10:44 +0200)] 
Refactor: delete most of the module FastTypes

This reverses some of the work done in #1405, and goes back to the
assumption that the bootstrap compiler understands GHC-haskell.

In particular:
  * use MagicHash instead of _ILIT and _CLIT
  * pattern matching on I# if possible, instead of using iUnbox
  * use Int#/Char#/Addr# instead of the following type synonyms:
    - type FastInt   = Int#
    - type FastChar  = Char#
    - type FastPtr a = Addr#
  * inline the following functions:
    - iBox           = I#
    - cBox           = C#
    - fastChr        = chr#
    - fastOrd        = ord#
    - eqFastChar     = eqChar#
    - shiftLFastInt  = uncheckedIShiftL#
    - shiftR_FastInt = uncheckedIShiftRL#
    - shiftRLFastInt = uncheckedIShiftRL#
  * delete the following unused functions:
    - minFastInt
    - maxFastInt
    - uncheckedIShiftRA#
    - castFastPtr
    - panicDocFastInt and pprPanicFastInt
  * rename panicFastInt back to panic#

These functions remain, since they actually do something:
  * iUnbox
  * bitAndFastInt
  * bitOrFastInt

Test Plan: validate

Reviewers: austin, bgamari

Subscribers: rwbarton

Differential Revision:

GHC Trac Issues: #1405

4 years agoDelete FastBool
Thomas Miedema [Fri, 21 Aug 2015 08:38:06 +0000 (10:38 +0200)] 
Delete FastBool

This reverses some of the work done in Trac #1405, and assumes GHC is
smart enough to do its own unboxing of booleans now.

I would like to do some more performance measurements, but the code
changes can be reviewed already.

Test Plan:
With a perf build:
./inplace/bin/ghc-stage2 nofib/spectral/simple/Main.hs -fforce-recomp
+RTS -t --machine-readable

  [("bytes allocated", "1300744864")
  ,("num_GCs", "302")
  ,("average_bytes_used", "8811118")
  ,("max_bytes_used", "24477464")
  ,("num_byte_usage_samples", "9")
  ,("peak_megabytes_allocated", "64")
  ,("init_cpu_seconds", "0.001")
  ,("init_wall_seconds", "0.001")
  ,("mutator_cpu_seconds", "2.833")
  ,("mutator_wall_seconds", "4.283")
  ,("GC_cpu_seconds", "0.960")
  ,("GC_wall_seconds", "0.961")

  [("bytes allocated", "1301088064")
  ,("num_GCs", "310")
  ,("average_bytes_used", "8820253")
  ,("max_bytes_used", "24539904")
  ,("num_byte_usage_samples", "9")
  ,("peak_megabytes_allocated", "64")
  ,("init_cpu_seconds", "0.001")
  ,("init_wall_seconds", "0.001")
  ,("mutator_cpu_seconds", "2.876")
  ,("mutator_wall_seconds", "4.474")
  ,("GC_cpu_seconds", "0.965")
  ,("GC_wall_seconds", "0.979")

CPU time seems to be up a bit, but I'm not sure. Unfortunately CPU time
measurements are rather noisy.

Reviewers: austin, bgamari, rwbarton

Subscribers: nomeata

Differential Revision:

GHC Trac Issues: #1405

4 years agoImplement getSizeofMutableByteArrayOp primop
Ben Gamari [Fri, 21 Aug 2015 08:37:39 +0000 (10:37 +0200)] 
Implement getSizeofMutableByteArrayOp primop

Now since ByteArrays are mutable we need to be more explicit about when
the size is queried.

Test Plan: Add testcase and validate

Reviewers: goldfire, hvr, austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #9447

4 years agoBag: Add Foldable instance
Ben Gamari [Tue, 18 Aug 2015 17:17:50 +0000 (19:17 +0200)] 
Bag: Add Foldable instance

4 years agoGhcMake: Fix spelling in comment
Ben Gamari [Tue, 18 Aug 2015 17:17:22 +0000 (19:17 +0200)] 
GhcMake: Fix spelling in comment

4 years agoDelete sync-all
Thomas Miedema [Thu, 20 Aug 2015 22:47:16 +0000 (00:47 +0200)] 
Delete sync-all

4 years agoBuild system: delete half-baked Cygwin support
Thomas Miedema [Sat, 15 Aug 2015 09:36:44 +0000 (11:36 +0200)] 
Build system: delete half-baked Cygwin support

We only support building GHC on mys2 nowadays, see

This (partially) reverts various commits from a few years ago, among which:
  * 5775d5142da227d65fb86994d363eb16841ee642
    "Add OSTYPE build-system variable, and use it"
  * 3fb8c431824aa2f3bd979e35d1a283546fcfbe74
    "Fix building libgmp on cygwin"
  * cdbb4720c424500adb57cbbef69721d0b039fa46
    "Fix cmd invocation by libffi cuild system on Windows 7 cygwin"
  * e8121501ee3549a35e954726ccfd871ac9d51f83
    "Fix dblatex and xml* tool detection on Windows"

Reviewed by: austin, Phyx

Differential Revision:

4 years agoComments reformating/corrections
Divam [Tue, 18 Aug 2015 16:08:26 +0000 (18:08 +0200)] 
Comments reformating/corrections

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

4 years agoAdd selectors for common fields (DataCon/PatSyn) to ConLike
Matthew Pickering [Tue, 18 Aug 2015 16:07:18 +0000 (18:07 +0200)] 
Add selectors for common fields (DataCon/PatSyn) to ConLike

When pattern synonyms were introduced a new sum type was used
in places where DataCon used to be used. PatSyn and DataCon share many
of the same fields, this patch adds selectors to ConLike for these

Reviewers: austin, goldfire, bgamari

Subscribers: thomie

Differential Revision:

4 years agorts/Printer.c: speed up '-Da' printer for 'LIBBFD' build
Sergei Trofimovich [Tue, 18 Aug 2015 16:06:41 +0000 (18:06 +0200)] 
rts/Printer.c: speed up '-Da' printer for 'LIBBFD' build

Patch switches from linear lookup in unordered array
to a hash table lookup.

When debugging GHC array contains 658_445 elements.

Found performance gap when tried to debug blackholes.

Signed-off-by: Sergei Trofimovich <>
Reviewers: simonmar, austin, bgamari

Subscribers: thomie

Differential Revision:

4 years agoFix rdynamic flag and test on Windows
Tamar Christina [Tue, 18 Aug 2015 15:59:04 +0000 (17:59 +0200)] 
Fix rdynamic flag and test on Windows

The rdynamic tests and feature are marked broken on windows.
This is because the flag used doesn't exist and the symbol lookup
in the test did not account for platform differences in name mangling.

This commit fixes the flag and tests for rdynamic on windows.

Test Plan:
make TEST="rdynamic"

on both x86 and x86_64

Reviewers: austin, thomie, bgamari

Reviewed By: thomie, bgamari

Subscribers: #ghc_windows_task_force

Differential Revision:

GHC Trac Issues: #9381

4 years agoDump files always use UTF8 encoding #10762
Michael Snoyman [Tue, 18 Aug 2015 15:58:36 +0000 (17:58 +0200)] 
Dump files always use UTF8 encoding #10762

When the Windows codepage or *nix LANG variable is something besides
UTF-8, dumping to file can cause GHC to exit currently. This changes the
output encoding for files to match the defined input encoding for
Haskell source code (UTF-8), making it easier for users and build tools
to capture this output.

Test Plan:
Create a Haskell source file with non-Latin characters for identifier
names and
compile with:

LANG=C ghc -ddump-to-file -ddump-hi filename.hs -fforce-recomp

Without this patch, it will fail. With this patch, it succeeds

Reviewers: austin, rwbarton, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10762

4 years agoTransliterate unknown characters at output
Michael Snoyman [Tue, 18 Aug 2015 15:58:02 +0000 (17:58 +0200)] 
Transliterate unknown characters at output

This avoids the compiler from crashing when, for example, a warning
contains a non-Latin identifier and the LANG variable is set to C.
Fixes #6037.

Test Plan:
Create a Haskell source file containing an identifier with non-Latin
characters and no type signature. Compile with `LANG=C ghc -Wall
foo.hs`, and it should fail. With this patch, it will succeed.

Reviewers: austin, rwbarton, bgamari

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #6037, #10762

4 years agoMake rts/ThreadLabels.c threadsafe for debug runtime.
Sergei Trofimovich [Mon, 17 Aug 2015 22:14:42 +0000 (23:14 +0100)] 
Make rts/ThreadLabels.c threadsafe for debug runtime.

rts/ThreadLabels.c has a global hashtable for each
running haskell thread. It's not synchronized across
OS threads.

Was discovered when ran -debug build of ghc itself as:

    $ ghc-stage2 -j8 +RTS -A256M -l

and glibc detected double-free corruption:

    #2  in __libc_message (do_abort=do_abort@entry=2,
        fmt=fmt@entry=0x7fe0bcebf368 "*** Error in `%s': %s: 0x%s ***\n")
    #3  in malloc_printerr (action=3, str=0x7fe0bcebf4c0 "double free or corruption (fasttop)",
        ptr=<optimized out>)
    #4  in _int_free (av=<optimized out>, p=<optimized out>, have_lock=0)
    #5  in stgFree (p=0x7fe060001820) at rts/RtsUtils.c:108
    #6  in freeHashTable (table=0x5929320, freeDataFun=0x36374df <stgFree>) at rts/Hash.c:360
    #7  in freeThreadLabelTable () at rts/ThreadLabels.c:37
    #8  in hs_exit_ (wait_foreign=rtsFalse) at rts/RtsStartup.c:403
    #9  in shutdownHaskellAndExit (n=0, fastExit=0) at rts/RtsStartup.c:481
    #10 in hs_main (...) at rts/RtsMain.c:91
    #11 in main (...) at ghc/hschooks.c:63

Exposed itself after commit:

> commit f6866824ce5cdf5359f0cad78c49d65f6d43af12
> Author: Sergei Trofimovich <>
> Date:   Mon Aug 4 08:10:33 2014 -0500
>     ghc --make: add nicer names to RTS threads (threaded IO manager, make workers)

Signed-off-by: Sergei Trofimovich <>
Reviewers: austin, simonmar, ezyang, bgamari

Reviewed By: ezyang, bgamari

Subscribers: thomie

Differential Revision:

4 years agoTravis: prevent 10' no output, by setting VERBOSE=2
Thomas Miedema [Mon, 17 Aug 2015 12:31:07 +0000 (14:31 +0200)] 
Travis: prevent 10' no output, by setting VERBOSE=2

4 years agoTestsuite: speedup running a single test
Thomas Miedema [Sat, 15 Aug 2015 19:10:32 +0000 (21:10 +0200)] 
Testsuite: speedup running a single test

Benchmark: in rootdirectory, run `time make test TEST=dummy VERBOSE=0`
Before this commit: 2.6s
After this commit: 0.7s

4 years agoTestsuite: recenter 2 performance tests on Windows
Thomas Miedema [Fri, 14 Aug 2015 10:05:20 +0000 (12:05 +0200)] 
Testsuite: recenter 2 performance tests on Windows

No major deviations. Also fixup T7861.

4 years agoTestsuite: mark encoding005 expect_broken(#10623) on Windows
Thomas Miedema [Sat, 15 Aug 2015 14:55:26 +0000 (16:55 +0200)] 
Testsuite: mark encoding005 expect_broken(#10623) on Windows

4 years agoTestsuite: mark T8089 expect_broken(#7325) on Windows
Thomas Miedema [Sat, 15 Aug 2015 14:33:33 +0000 (16:33 +0200)] 
Testsuite: mark T8089 expect_broken(#7325) on Windows

4 years agoName: Show NameSort in warning
Ben Gamari [Thu, 13 Aug 2015 18:18:56 +0000 (20:18 +0200)] 
Name: Show NameSort in warning

This is quite useful information to know. Spotted when looking at #10769.

4 years agoDynFlags: Prohibit hpc and byte-code interpreter
Ben Gamari [Thu, 13 Aug 2015 18:17:06 +0000 (20:17 +0200)] 
DynFlags: Prohibit hpc and byte-code interpreter

The user's guide says hpc is incompatible with GHCi and #9903 would
agree. Fixes #9903.

4 years agoSysTools: Fix whitespace in error message
Ben Gamari [Wed, 12 Aug 2015 14:31:46 +0000 (16:31 +0200)] 
SysTools: Fix whitespace in error message

4 years agoUpdate mingw tarball location
Ben Gamari [Wed, 12 Aug 2015 12:06:37 +0000 (14:06 +0200)] 
Update mingw tarball location

4 years agoUpgrade GCC to 5.2.0 for Windows x86 and x86_64
Tamar Christina [Wed, 12 Aug 2015 11:33:13 +0000 (13:33 +0200)] 
Upgrade GCC to 5.2.0 for Windows x86 and x86_64

This patch does a few things

- Moved GHC x86 to MinGW-w64 (Using Awson's patch)
- Moves Both GHCs to MSYS2 toolchains
- Completely removes the dependencies on the git tarball repo
  - Downloads only the required tarball for the architecture for
    which we are building
  - Downloads the perl tarball is missing as well
  - Fixed a few bugs in the linker to fix tests on Windows

The links currently point to and GitHub, it might be
more desirable to mirror them on as with the previous patch

For more details on what the MSYS2 packages I include see #10726
(Awson's comment). but it should contain all we need
and no python or fortran, which makes the uncompressed tar a 1-2
hundreds mb smaller.

The `GCC 5.2.0` in the package supports `libgcc` as a shared library,
this is a problem since
when compiling with -shared the produced dll now has a dependency on
To solve this the flag `-static-libgcc` is now being used for all GCC
calls on windows.

Test Plan:
./validate was ran both on x86 and x86_64 windows and compared against
the baseline.

A few test were failing due to Ld no longer being noisy. These were

The changes to the configure script *should* be validated by the build
bots for the other platforms before landing

Reviewers: simonmar, awson, bgamari, austin, thomie

Reviewed By: thomie

Subscribers: #ghc_windows_task_force, thomie, awson

Differential Revision:

GHC Trac Issues: #10726, #9014, #9218, #10435

4 years agotemplate-haskell: Add changelog entry to infix type operators
Ben Gamari [Wed, 12 Aug 2015 11:32:08 +0000 (13:32 +0200)] 
template-haskell: Add changelog entry to infix type operators

4 years agoPretty: improving the space/time performance of vcat, hsep, hcat (#10735)
Thomas Miedema [Wed, 5 Aug 2015 08:31:46 +0000 (10:31 +0200)] 
Pretty: improving the space/time performance of vcat, hsep, hcat (#10735)

After 5d57087e314bd484dbe14958f9b422be3ac6641a ("Pretty: fix a broken
invariant"), T3294 showed 50% more max_bytes_used (#3294). After this
commit, max_bytes_used is back to what it was before, and the test
passes again.

This is a backport of a bug fix by Benedikt Huber (#2393), from commit
1e50748beaa4bd2281d323b18ea51c786bba04a1 in the pretty library.


    vcat (hsep,cat) is implemented in an unneccessarily strict way.
    We only get some output after all of vcat's arguments are evaluated
    and checked against being Empty.
    This can be improved by only checking the right argument of foldr
    against being Empty, and
    then applying an Empty-filter on the resulting Doc. Space improvement
    is obvious.
    The microbenchmark (
    HughesPJPerfCheck.hs) suggests that
    the improvements in time are remarkable too.

4 years agoPretty: show rational as is (#10735)
Thomas Miedema [Wed, 5 Aug 2015 11:17:56 +0000 (13:17 +0200)] 
Pretty: show rational as is (#10735)

Following libraries/pretty. I'm not sure why it converted to Double

This function isn't used by GHC itself. It is exported from these two
  * compiler/utils/Outputable
  * libraries/template-haskell/Language/Haskell/TH/PprLib.hs

4 years agoPretty: fix a broken invariant (#10735)
Thomas Miedema [Wed, 5 Aug 2015 09:31:21 +0000 (11:31 +0200)] 
Pretty: fix a broken invariant (#10735)

This is a backport of a bug fix from
6cfbd0444981c074bae10a3cf72733bcb8597bef in libraries/pretty:

    Fix a broken invariant
    Patch from #694,  for the problem "empty is an identity for <> and $$" is
    currently broken by eg. isEmpty (empty<>empty)"

4 years agoPretty: fix potential bad formatting of error message (#10735)
Thomas Miedema [Wed, 5 Aug 2015 08:58:54 +0000 (10:58 +0200)] 
Pretty: fix potential bad formatting of error message (#10735)

This is a backport of a bug fix by Benedikt Huber for the same problem
in the pretty library (#1337), from commit
8d8866a8379c2fe8108ef034893c59e06d5e752f. The original explanation for
the fix is attached below.

Ticket #1776 originally reported an infinite loop when printing error
message. This promptly got fixed in:

  commit 2d52ee06786e5caf0c2d65a4b4bb7c45c6493190
  Author: <unknown>
  Date:   Thu Mar 1 11:45:13 2007 +0000

      Do not go into an infinite loop when pretty-printer finds a
      negative indent (Trac #1176)

SPJ reports in the ticket: "So infinite loop is fixed, but the bad
formatting remains. I've added a test, tcfail177."

tcfail177 however hasn't triggered the formatting problem for years (as
Ian reported in c9e0e6067a47c574d9ff3721afe58e30ca1be3e4).

This patch updates the test to a version that at least still failed with
ghc-7.0 (from #1776#comment:7).


by Benedikt Huber:

    Concerning ticket #1337, we have to change the formal specification of
    fill (it doesn't match the implementation):

    -- Current Specification:
    --   fill []  = empty
    --   fill [p] = p
    --   fill (p1:p2:ps) = oneLiner p1 <#> nest (length p1)
    --                                          (fill (oneLiner p2 : ps))
    --                     `union`
    --                      p1 $$ fill ps

    Problem 1: We want to `unnest' the second argument of (p1 $$ fill ps),
    but not the first one

    In the definition above we have e.g.

    > getSecondLayout $
    >   fillDef False [text "a", text "b", text "a"]

    >> text "ab"; nilabove; nest -1; text "a"; empty
    >> |ab|
    >> |.a|

    Problem 2: The overlapping $$ should only be used for those layouts of
    p1 which aren't one liners (otherwise violating the invariant "Left
    union arg has shorter first line").

    I suggest the following specification (i believe it almost matches the
    current implementation, modulo [fillNB: fix bug #1337] (see below):

    -- Revised Specification:
    --   fill g docs = fill' 0 docs
    --   gap g       = if g then 1 else 0
    --   fill' n []  = []
    --   fill' n [p] = [p]
    --   fill' n (p1:p2:ps) =
    --      oneLiner p1 <g> (fill' (n+length p1+gap g) (oneLiner p2 : ps))
    --        `union`
    --     (p1 $*$ nest (-n) (fill' g ps))
    -- $*$ is defined for layouts (One-Layout Documents) as
    -- layout1 $*$ layout2 | isOneLiner layout1 = layout1 $+$ layout2
    --                     | otherwise          = layout1 $$ layout2

    I've also implemented the specification in HughesPJQuickCheck.hs,
    and checked them against the patched pretty printer.

    Concerning Bug #1337:

    If the above formal specification is fine, it is easy to fix:
    elide the nests of (oneLiner p2) [see attached patch, record bug #1337].

    > PrettyPrint(0) $ ./Bug1337
    > ....ab
    > ...c

    The (long) explanation follows below.


    Explanation of Bug #1337:


    > fcat [ nest 1 $ text "a", nest 2 $ text "b", text "c"]

    --> expected: (nest 1; text "a"; text "b"; nest -3; "c")
    --> actual  : (nest 1; text "a"; text "b"; nest -5; "c")

    === (nest 1; text a) <> (fill (-2) (p2:ps))
    ==>                     (nest 2 (text "b") $+$ text "c")
    ==>                     (nest 2 (text "b")) `nilabove`
                            (nest (-3) (text "c"))
    ==> (nest 1; text a; text b; nest -5 c)

    The problem is that if we decide to layout (p1:p2:ps) as

    | p1 p2
    | ps

    (call it layout A), then we want to have

    > (p1 <> p2) $+$ ps.

    But following law <n6> this means that

    > fcat_A [p1:nest k p2:ps]

    is equivalent to

    > fcat_A [p1,p2,ps]

    so the nest of p2 has to be removed.

    This is somewhat similar to bug #667, but easier to fix
    from a semantic point of view:
    p1,p2 and ps are distinct layouts - we only have to preserve the
    individual layouts, and no combinations of them.

4 years agoPretty: bugfix fillNB (#10735)
Thomas Miedema [Tue, 4 Aug 2015 20:32:06 +0000 (22:32 +0200)] 
Pretty: bugfix fillNB (#10735)

This is a backport of a bug fix by Benedikt Huber (#2393), from commit
1e50748beaa4bd2281d323b18ea51c786bba04a1 in the pretty library.


    Law <l1> states that

    > sep (ps++[empty]++qs)   = sep (ps ++ qs)
    >         ...ditto hsep, hcat, vcat, fill...

    In the current implementation, this fails for the paragraph fill

    > render' $ fsep [ text "c", text "c",empty, text "c", text "b"]
    >   where render' = renderStyle (Style PageMode 7 1.4)
    >> c c c
    >>     b

4 years agoBump template-haskell to new major version 2.11
Herbert Valerio Riedel [Wed, 12 Aug 2015 07:48:53 +0000 (09:48 +0200)] 
Bump template-haskell to new major version 2.11

...since we already have introduced backward compat breakage
that breaks packages such as QuickCheck-2.8.1

Differential Revision:

4 years agoAdd missing </para> to User's guide to fix the build
Thomas Miedema [Tue, 11 Aug 2015 22:34:04 +0000 (00:34 +0200)] 
Add missing </para> to User's guide to fix the build

4 years agoUser manual update, as prodded by #10760.
Richard Eisenberg [Tue, 11 Aug 2015 13:05:30 +0000 (09:05 -0400)] 
User manual update, as prodded by #10760.

This clarifies that kind variables are inputs to type families
and can be used to distinguish instances.

4 years agoReplace HsBang type with HsSrcBang and HsImplBang
Adam Sandberg Eriksson [Mon, 10 Aug 2015 10:55:50 +0000 (12:55 +0200)] 
Replace HsBang type with HsSrcBang and HsImplBang

Updates haddock submodule.

Reviewers: tibbe, goldfire, simonpj, austin, bgamari

Reviewed By: simonpj, bgamari

Subscribers: goldfire, thomie, mpickering

Differential Revision:

4 years agoUpdate testsuite/.gitignore [skip ci]
Thomas Miedema [Sat, 18 Jul 2015 20:14:26 +0000 (22:14 +0200)] 
Update testsuite/.gitignore [skip ci]

4 years agoFix unused-matches warnings in CmmLex.x
Thomas Miedema [Sat, 4 Jul 2015 13:13:19 +0000 (15:13 +0200)] 
Fix unused-matches warnings in CmmLex.x

4 years agoUpdate transformers submodule to release
Herbert Valerio Riedel [Sat, 8 Aug 2015 09:13:52 +0000 (11:13 +0200)] 
Update transformers submodule to release

Differential Revision:

4 years agocmmCreateSwitchPlan: Handle singletons up-front
Joachim Breitner [Fri, 7 Aug 2015 08:56:09 +0000 (10:56 +0200)] 
cmmCreateSwitchPlan: Handle singletons up-front

and make sure these are implemented with an equality check, which is a
shorter instruction. This was suggested by rwbarton in #10677.

Differential Revision:

4 years agoMake oneShot open-kinded
Joachim Breitner [Fri, 7 Aug 2015 08:36:32 +0000 (10:36 +0200)] 
Make oneShot open-kinded

akio wants to use oneShot with unlifted types as well, and there is no
good reason not to let him. This changes the type of the built-in
oneShot definition to open kinds, and also expand the documentation a
little bit.

Differential Revision:

4 years agoSync base/ with GHC 7.10.2 release
Herbert Valerio Riedel [Fri, 7 Aug 2015 15:59:25 +0000 (17:59 +0200)] 
Sync base/ with GHC 7.10.2 release

[skip ci]

4 years agoComments only
Simon Peyton Jones [Fri, 7 Aug 2015 11:32:48 +0000 (12:32 +0100)] 
Comments only

4 years agoTest Trac #10753
Simon Peyton Jones [Fri, 7 Aug 2015 11:32:09 +0000 (12:32 +0100)] 
Test Trac #10753

4 years agoBig batch of Backpack documentation edits.
Edward Z. Yang [Fri, 7 Aug 2015 05:31:17 +0000 (22:31 -0700)] 
Big batch of Backpack documentation edits.

Signed-off-by: Edward Z. Yang <>
4 years agobase: Add missing Traversable instance for ZipList
Ben Gamari [Fri, 7 Aug 2015 03:50:22 +0000 (05:50 +0200)] 
base: Add missing Traversable instance for ZipList

4 years agoRejigger OSMem.my_mmap to allow building on Mac
Richard Eisenberg [Thu, 6 Aug 2015 18:37:53 +0000 (14:37 -0400)] 
Rejigger OSMem.my_mmap to allow building on Mac

Previously, the prot and flags variables were set but never used
on Mac (darwin). This caused a warning, and the build setup stopped
compilation. This commit is intended simply to omit these variables
when building with darwin_HOST_OS set. No change in behavior on any
platform is intended.

4 years agoAdd test for #10600 (exhaustiveness check with --make and -fno-code)
Reid Barton [Thu, 6 Aug 2015 18:12:38 +0000 (14:12 -0400)] 
Add test for #10600 (exhaustiveness check with --make and -fno-code)

4 years agollvmGen: Rework LLVM mangler
Ben Gamari [Thu, 6 Aug 2015 15:30:19 +0000 (17:30 +0200)] 
llvmGen: Rework LLVM mangler

The LLVM mangler does not currently transform AVX instructions on x86-64
platforms, due to a missing #include. Also, it is significantly more
complicated than necessary, due to the file into sections (not needed
anymore), and is sensitive to the details of the whitespace in the

Author: dobenour

Test Plan: Validation on x86-64, x86-32, and ARM

Reviewers: austin

Subscribers: thomie, bgamari, rwbarton

Differential Revision:

GHC Trac Issues: #10394

4 years agobase: Add instances
fumieval [Thu, 6 Aug 2015 15:28:04 +0000 (17:28 +0200)] 
base: Add instances

This patch adds following instances:

* Foldable ZipList
* Traversable ZipList
* Functor Complex
* Applicative Complex
* Monad Complex
* Foldable Complex
* Traversable Complex
* Generic1 Complex
* Monoid a => Monoid (Identity a)
* Storable ()

Reviewers: ekmett, fumieval, hvr, austin

Subscribers: thomie, #core_libraries_committee

Projects: #core_libraries_committee

Differential Revision:

GHC Trac Issues: #10609

4 years agoEnsure DynFlags are consistent
Ben Gamari [Thu, 6 Aug 2015 15:25:46 +0000 (17:25 +0200)] 
Ensure DynFlags are consistent

While we have always had makeDynFlagsConsistent to enforce a variety of
consistency invariants on DynFlags, it hasn't been widely used.
GHC.Main, for instance, ignored it entirely. This leads to issues like
Trac #10549, where an OPTIONS_GHC pragma introduced an inconsistency,
leading to a perplexing crash later in compilation.

Here I add consistency checks in GHC.Main.set{Session,Program}DynFlags,
closing this hole.

Fixes #10549.

Test Plan: Validate with T10549

Reviewers: austin

Subscribers: thomie

Differential Revision:

GHC Trac Issues: #10549

4 years agoTest Trac #10742
Simon Peyton Jones [Thu, 6 Aug 2015 13:50:35 +0000 (14:50 +0100)] 
Test Trac #10742

4 years agoT8968-1 and -3 should pass
Simon Peyton Jones [Thu, 6 Aug 2015 13:50:12 +0000 (14:50 +0100)] 
T8968-1 and -3 should pass

See Trac #9953, comment:22.

4 years agoComments only
Simon Peyton Jones [Thu, 6 Aug 2015 13:46:48 +0000 (14:46 +0100)] 
Comments only

4 years agoComents only
Simon Peyton Jones [Thu, 6 Aug 2015 12:40:07 +0000 (13:40 +0100)] 
Coments only

4 years agoFix quantification for inference with sigs
Simon Peyton Jones [Wed, 5 Aug 2015 15:46:16 +0000 (16:46 +0100)] 
Fix quantification for inference with sigs

When we are *inferring* the type of a let-bound function,
we might still have a type signature.  And we must be sure
to quantify over its type variables, else you get the crash
in Trac #10615.

See Note [Which type variables to quantify] in TcSimplify

4 years agoTidy up and refactor wildcard handling
Simon Peyton Jones [Wed, 5 Aug 2015 13:24:54 +0000 (14:24 +0100)] 
Tidy up and refactor wildcard handling

When examining #10615, I found the wildcard handling hard
to understand.  This patch refactors quite a bit, but with
no real change in behaviour.

 * Split out TcIdSigInfo from TcSigInfo, as a separate type,
   like TcPatSynInfo.

 * Make TcIdSigInfo express more invariants by pushing the
   wildard info into TcIdSigBndr

 * Remove all special treatment of unification variables that arise
   from wildcards; so the TauTv of TcType.MetaInfo loses its Bool

A ton of konck on changes.  The result is significantly simpler, I think.

4 years agoMinor refactor to use filterInScope
Simon Peyton Jones [Wed, 5 Aug 2015 13:03:34 +0000 (14:03 +0100)] 
Minor refactor to use filterInScope

4 years agoComments only
Simon Peyton Jones [Wed, 5 Aug 2015 12:56:48 +0000 (13:56 +0100)] 
Comments only

4 years agoWarn about missed specialisations for imports
Simon Peyton Jones [Wed, 5 Aug 2015 12:37:18 +0000 (13:37 +0100)] 
Warn about missed specialisations for imports

This change was provoked by Trac #10720, where a missing
INLINEABLE pragma gave very poor performance.

The change is to warn when an imported function is not specialised
in a situation where the user expects it to be.

New flags

Documented in user manual.
See Note [Warning about missed specialisations]

4 years agoDo not complain about SPECIALISE for INLINE
Simon Peyton Jones [Wed, 5 Aug 2015 12:38:20 +0000 (13:38 +0100)] 
Do not complain about SPECIALISE for INLINE

Fixes Trac #10721.
See Note [SPECIALISE on INLINE functions]

4 years agoAllow proper errors/warnings in core2core passes
Simon Peyton Jones [Wed, 5 Aug 2015 12:31:48 +0000 (13:31 +0100)] 
Allow proper errors/warnings in core2core passes

This patch makes it possible for core-to-core passes to emit
proper error messages and warnings.

  * New function CoreMonad.warnMsg

  * CoreMonad.warnMsg and errorMsg now print a proper warning/error
    message heading.

  * CoreMonad carries a SrcSpan, which is used in warning/error
    messages.  It is initialised to be the source file name, but
    a core-to-core pass could set it more specifically if it had
    better location information.

There was a bit of plumbing needed to get the filename to the
right place.