ghc.git
2 years agocompiler/cmm/PprC.hs: constify labels in .rodata
Sergei Trofimovich [Mon, 24 Apr 2017 13:41:35 +0000 (09:41 -0400)] 
compiler/cmm/PprC.hs: constify labels in .rodata

Consider one-line module
    module B (v) where v = "hello"
in -fvia-C mode it generates code like
    static char gibberish_str[] = "hello";

It resides in data section (precious resource on ia64!).
The patch switches genrator to emit:
    static const char gibberish_str[] = "hello";

Other types if symbols that gained 'const' qualifier are:

- info tables (from haskell and CMM)
- static reference tables (from haskell and CMM)

Cleanups along the way:

- fixed info tables defined in .cmm to reside in .rodata
- split out closure declaration into 'IC_' / 'EC_'
- added label declaration (based on label type) right before
  each label definition (based on section type) so that C
  compiler could check if declaration and definition matches
  at definition site.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Test Plan: ran testsuite on unregisterised x86_64 compiler

Reviewers: simonmar, ezyang, austin, bgamari, erikd

Reviewed By: bgamari, erikd

Subscribers: rwbarton, thomie

GHC Trac Issues: #8996

Differential Revision: https://phabricator.haskell.org/D3481

2 years agoDisable terminfo, if we don’t build it.
Moritz Angermann [Mon, 24 Apr 2017 13:38:14 +0000 (09:38 -0400)] 
Disable terminfo, if we don’t build it.

This is a derivation of a patch from @jophish.

This is necessary due to `haskeline`'s `terminfo` flag being marked as
`Manual` as of 43d7fa106027fcd4ec7f443923a8dd5b8c169f9c.

Reviewers: jophish, bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie, jophish

Differential Revision: https://phabricator.haskell.org/D3493

2 years agoAdd regression test for #13603
Ryan Scott [Mon, 24 Apr 2017 14:47:51 +0000 (10:47 -0400)] 
Add regression test for #13603

Summary:
Commit b207b536ded40156f9adb168565ca78e1eef2c74 (#11714) happened to
fix #13603 as well. Let's add a regression test so that it stays fixed.

Test Plan: make test TEST=T13603

Reviewers: bgamari, austin, simonpj

Reviewed By: bgamari, simonpj

Subscribers: simonpj, rwbarton, thomie

GHC Trac Issues: #13603

Differential Revision: https://phabricator.haskell.org/D3489

2 years agotestsuite: Mark T13075 as broken due to #13075
Ben Gamari [Sun, 23 Apr 2017 22:52:46 +0000 (18:52 -0400)] 
testsuite: Mark T13075 as broken due to #13075

2 years agoExport function for use in GHC API
Alan Zimmerman [Sun, 23 Apr 2017 16:53:33 +0000 (18:53 +0200)] 
Export function for use in GHC API

2 years agotestsuite: Add testcase for #13075
Ben Gamari [Sun, 23 Apr 2017 14:59:02 +0000 (10:59 -0400)] 
testsuite: Add testcase for #13075

2 years agotestsuite: Increase T13056 window size to +/-10%
Ben Gamari [Sat, 22 Apr 2017 14:18:23 +0000 (10:18 -0400)] 
testsuite: Increase T13056 window size to +/-10%

2 years agotestsuite: Add testcase for #13587
Ben Gamari [Sun, 23 Apr 2017 14:04:03 +0000 (10:04 -0400)] 
testsuite: Add testcase for #13587

Test Plan: Validate

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13587

Differential Revision: https://phabricator.haskell.org/D3474

2 years agotestsuite: Add test for #13591
Ben Gamari [Sun, 23 Apr 2017 14:03:46 +0000 (10:03 -0400)] 
testsuite: Add test for #13591

Reviewers: austin

Subscribers: rwbarton, thomie

GHC Trac Issues: #13591

Differential Revision: https://phabricator.haskell.org/D3470

2 years agoOnly build iserv with -threaded if GhcThreaded is set
Reid Barton [Sun, 23 Apr 2017 14:03:22 +0000 (10:03 -0400)] 
Only build iserv with -threaded if GhcThreaded is set

By default GhcThreaded is set by
```
GhcThreaded = $(if $(findstring thr,$(GhcRTSWays)),YES,NO)
```
so it seems incorrect to try to build iserv with -threaded when
GhcThreaded is not set. This came up when I was building GHC with
some strange combination of flavours (debugged and profiled but not
threaded).

Test Plan: harbormaster

Reviewers: simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie, snowleopard

Differential Revision: https://phabricator.haskell.org/D3429

2 years agoDocument the kind generalization behavior observed in #13555
Ryan Scott [Sun, 23 Apr 2017 14:02:45 +0000 (10:02 -0400)] 
Document the kind generalization behavior observed in #13555

The conclusion of #13555 was that a program which began to fail to
typecheck (starting in GHC 8.2) was never correct to begin with. Let's
document why this is the case with respect to `MonoLocalBinds`'
interaction with kind generalization. Also adds the reported program as
a `compile_fail` testcase.

Test Plan: make test TEST=T13555 # Also, read the docs

Reviewers: goldfire, simonpj, austin, bgamari

Reviewed By: goldfire, simonpj, bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13555

Differential Revision: https://phabricator.haskell.org/D3472

2 years ago[linker] Adds elf_compat.h, util.h, elf_util.h
Moritz Angermann [Sun, 23 Apr 2017 14:02:21 +0000 (10:02 -0400)] 
[linker] Adds elf_compat.h, util.h, elf_util.h

Further cleanup of the linker, we'll add elf_compat.h for a more
complete set of relocations.

Also Util.h has been added as suggested in the code already.

Depends on D3444, D3445

Reviewers: bgamari, austin, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3446

2 years ago[linker] Adds ElfTypes
Moritz Angermann [Sun, 23 Apr 2017 14:02:02 +0000 (10:02 -0400)] 
[linker] Adds ElfTypes

This diff introduces ElfTypes similar to provide the linker
code with a richer data structure, similar to the approach
taken for mach-o already.

Reviewers: bgamari, austin, erikd, simonmar

Reviewed By: simonmar

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3445

2 years agorts: Fix "ASSERT ("s
Ben Gamari [Sun, 23 Apr 2017 14:00:19 +0000 (10:00 -0400)] 
rts: Fix "ASSERT ("s

Reviewers: austin, erikd, simonmar

Reviewed By: erikd

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3486

2 years agocpp: Use #pragma once instead of #ifndef guards
Ben Gamari [Sat, 22 Apr 2017 13:34:18 +0000 (09:34 -0400)] 
cpp: Use #pragma once instead of #ifndef guards

This both says what we mean and silences a bunch of spurious CPP linting
warnings. This pragma is supported by all CPP implementations which we
support.

Reviewers: austin, erikd, simonmar, hvr

Reviewed By: simonmar

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3482

2 years agowin32/Ticker: Stop ticker on exit
Ben Gamari [Sat, 22 Apr 2017 13:33:31 +0000 (09:33 -0400)] 
win32/Ticker: Stop ticker on exit

While debugging an unrelated issue I noticed that we leak a
TimerQueueTimer on exit since we don't necessarily call stopTicker
before exitTicker. Fix this.

Test Plan: Validate on Windows

Reviewers: simonmar, austin, erikd

Reviewed By: simonmar

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3477

2 years agoghc.mk: fix 'make install' for cross-mingw32
Sergei Trofimovich [Sun, 23 Apr 2017 14:31:13 +0000 (15:31 +0100)] 
ghc.mk: fix 'make install' for cross-mingw32

Attempt to install cross-compiled mingw32 GHC built on linux failed as:

    $ make install DESTDIR=$(pwd)/__i__

    "mv" "$(pwd)/__i__/usr/local/lib/ghc-8.3.20170422/bin/ghc-stage2" \
         "$(pwd)/__i__/usr/local/lib/ghc-8.3.20170422/bin/ghc"
    mv: failed to stat
         '$(pwd)/__i__/usr/local/lib/ghc-8.3.20170422/bin/ghc-stage2': \
         No such file or directory

The rename should not be performed for windows targets.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoghc: tweak cross-compilation to mingw32
Sergei Trofimovich [Sun, 23 Apr 2017 14:10:26 +0000 (15:10 +0100)] 
ghc: tweak cross-compilation to mingw32

The build failure when cross-compiling from
linux to windows looks like:

    HC [stage 1] ghc/stage2/build/tmp/ghc-stage2.exe
      Call hs_init_ghc() from your main() function to set these options.
  /usr/libexec/gcc/i686-w64-mingw32/ld: cannot find -lHSghc-8.3-0

Similar to commit 745032dd02da511067c2939259ed212852187e0f
("rts: tweak cross-compilation to mingw32") decision to split
stage2 should be done based based on TargetOS, not HostOS.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoFix compilation for !HAVE_FLOCK
Herbert Valerio Riedel [Sun, 23 Apr 2017 13:41:50 +0000 (15:41 +0200)] 
Fix compilation for !HAVE_FLOCK

2 years agoMinor reordering of `#include`s fixing compilation on AIX
Herbert Valerio Riedel [Sun, 23 Apr 2017 13:28:52 +0000 (15:28 +0200)] 
Minor reordering of `#include`s fixing compilation on AIX

This helps ensure that system includes on some more fragile
platforms (like e.g. AIX) see a more consistent set of CPP defines,
and consequently reduce the risk of conflicting typdefs/prototypes
being exposed.

2 years agorts: tweak cross-compilation to mingw32
Sergei Trofimovich [Sun, 23 Apr 2017 10:44:45 +0000 (11:44 +0100)] 
rts: tweak cross-compilation to mingw32

Found the problem on x86_64-linux host where
I tried to cross-compile GHC to windows as:

    $ ./configure --target=i686-w64-mingw32 \
                  Windres=i686-w64-mingw32-windres \
                  DllWrap=i686-w64-mingw32-dllwrap

As a result build failed as POSIX bits of RTS.
For example 'rts/posix/OSMem.c' contains unix-specific
mmap() syscalls and constants and thus can't be compiled
by i686-w64-mingw32 toolchain.

It's caused by the following part of 'rts/ghc.mk':

  ifeq "$(HostOS_CPP)" "mingw32"
  ALL_DIRS += win32
  else
  ALL_DIRS += posix
  endif

In our case _CPP variables are defined this way (project.mk):
  BuildOS_CPP                = linux
  HostOS_CPP                 = linux
  TargetOS_CPP               = mingw32

RTS should never be built for 'BuildOS' or 'HostOS' as it's
always built by ghc-stage1 (targeted at TargetOS).

The change is to flip 'HostOS_CPP' to 'TargetOS_CPP' in 'rts/ghc.mk'.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoaclocal.m4: treat '*-w64-mingw32' targets as windows
Sergei Trofimovich [Sun, 23 Apr 2017 10:25:29 +0000 (11:25 +0100)] 
aclocal.m4: treat '*-w64-mingw32' targets as windows

Noticed when tried to cross-compile GHC from x86_64-linux
to --target=i686-w64-mingw32. Final ghc executables did
not have '.exe' extensions.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoconfigure.ac: print paths to dllwrap and windres
Sergei Trofimovich [Sun, 23 Apr 2017 10:22:44 +0000 (11:22 +0100)] 
configure.ac: print paths to dllwrap and windres

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoFirst update mingw-w64 packages for 8.4
Tamar Christina [Sun, 23 Apr 2017 10:21:18 +0000 (11:21 +0100)] 
First update mingw-w64 packages for 8.4

Summary: Updating to get latest binutils etc.

Test Plan: ./validate

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie, snowleopard

GHC Trac Issues: #12913

Differential Revision: https://phabricator.haskell.org/D3382

2 years agoskip T13525 when running on Windows.
Tamar Christina [Sun, 23 Apr 2017 09:44:54 +0000 (10:44 +0100)] 
skip T13525 when running on Windows.

2 years agoHaddock submodule update.
Edward Z. Yang [Sun, 23 Apr 2017 03:39:18 +0000 (20:39 -0700)] 
Haddock submodule update.

Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
2 years agoBump time submodule
Ben Gamari [Fri, 21 Apr 2017 16:42:50 +0000 (12:42 -0400)] 
Bump time submodule

2 years agoBump filepath submodule
Ben Gamari [Fri, 21 Apr 2017 16:39:35 +0000 (12:39 -0400)] 
Bump filepath submodule

2 years agoBump deepseeq submodule
Ben Gamari [Fri, 21 Apr 2017 16:36:33 +0000 (12:36 -0400)] 
Bump deepseeq submodule

2 years agobase: update comment to match the change from e134af01
Andrzej Rybczak [Sat, 22 Apr 2017 00:11:35 +0000 (20:11 -0400)] 
base: update comment to match the change from e134af01

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3484

2 years agotestsuite: Update performance metrics
Ben Gamari [Sat, 22 Apr 2017 00:06:27 +0000 (20:06 -0400)] 
testsuite: Update performance metrics

2 years agoEdit eventlog-formats.rst to match implementation
Mitsutoshi Aoe [Sun, 16 Apr 2017 21:08:25 +0000 (06:08 +0900)] 
Edit eventlog-formats.rst to match implementation

* Add missing filters in EVENT_HEAP_PROF_BEGIN and reorder them
* EVENT_HEAP_PROF_SAMPLE_COST_CENTRE isn't used in retainer profiling
* Modify EVENT_HEAP_PROF_SAMPLE_STRING's format
* Biography break-down isn't implemented

2 years agoSync up terminfo submodule to 0.4.1.0 release tag
Herbert Valerio Riedel [Fri, 21 Apr 2017 22:50:26 +0000 (00:50 +0200)] 
Sync up terminfo submodule to 0.4.1.0 release tag

2 years agoBuild system: fix bindist for cross-build GHC
Fangrui Song [Fri, 21 Apr 2017 00:03:30 +0000 (17:03 -0700)] 
Build system: fix bindist for cross-build GHC

The change fixes case of installing cross-built GHC
from bindist (BINDIST=YES) on TARGET.

In this case we need to use TARGET tools in `INSTALLED_GHC{,_PKG}_REAL`.

The original change is provided by Fangrui Song
as pull request https://github.com/ghc/ghc/pull/34

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoBump haskeline and terminfo submodules
Ben Gamari [Fri, 21 Apr 2017 15:33:47 +0000 (11:33 -0400)] 
Bump haskeline and terminfo submodules

2 years agolinters/check-cpp: Demote #if lints to warnings
Ben Gamari [Fri, 21 Apr 2017 16:27:51 +0000 (12:27 -0400)] 
linters/check-cpp: Demote #if lints to warnings

Errors trigger even for lines which the author didn't touch, which is undesired.

2 years agocatch the case where there is no symCmd
Moritz Angermann [Fri, 21 Apr 2017 16:12:01 +0000 (12:12 -0400)] 
catch the case where there is no symCmd

We do check for symCmd, to set the info->nlist value, but forgot to do
the same check for info->names.  Thus when trying to extract stroff from
symCmd, we hit a segfault.

Test Plan: The validation failure on windows is rather suspicious...
let's try this one

Reviewers: bgamari, adinapoli, austin, erikd, simonmar

Reviewed By: adinapoli

Subscribers: thomie, rwbarton

Differential Revision: https://phabricator.haskell.org/D3468

2 years agoFix build on DragonflyBSD
Ben Gamari [Fri, 21 Apr 2017 16:11:41 +0000 (12:11 -0400)] 
Fix build on DragonflyBSD

Test Plan: Validate on DragonflyBSD

Reviewers: austin, erikd, simonmar

Reviewed By: erikd

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3480

2 years agobase: Fix hWaitForInput with timeout on POSIX
Ben Gamari [Fri, 21 Apr 2017 16:11:28 +0000 (12:11 -0400)] 
base: Fix hWaitForInput with timeout on POSIX

This was previously broken (#13252) by
f46369b8a1bf90a3bdc30f2b566c3a7e03672518, which ported the fdReady
function from `select` to `poll` and in so doing dropping support for
timeouts. Unfortunately, while `select` tells us the amount of time not
slept (on Linux anyways; it turns out this is implementation dependent),
`poll` does not give us this luxury. Consequently, we manually need to
track time slept in this case.

Unfortunately, portably measuring time is hard. Ideally we would use
`clock_gettime` with the monotonic clock here, but sadly this isn't
supported on most versions of Darwin. Consequently, we instead use
`gettimeofday`, running the risk of system time changes messing us up.

Test Plan: Validate

Reviewers: simonmar, austin, hvr

Reviewed By: simonmar

Subscribers: rwbarton, thomie

GHC Trac Issues: #13252

Differential Revision: https://phabricator.haskell.org/D3473

2 years agotestsuite: Bump timeout multiplier for T11195
Ben Gamari [Fri, 21 Apr 2017 02:34:21 +0000 (22:34 -0400)] 
testsuite: Bump timeout multiplier for T11195

This test has been occassionally failing on the Darwin build bot for some time
now.

(cherry picked from commit b3a4dd1152884ff1240824137eca0a49cb6e5a2c)

2 years agobase: Fix offset initialization of Windows hLock implementation
Ben Gamari [Fri, 21 Apr 2017 16:10:33 +0000 (12:10 -0400)] 
base: Fix offset initialization of Windows hLock implementation

The previous implementation swapped the buffer size with the byte to be
set, essentially resulting in an uninitialized buffer.

Test Plan: Validate on Windows

Reviewers: austin, hvr

Subscribers: rwbarton, thomie

GHC Trac Issues: #13599

Differential Revision: https://phabricator.haskell.org/D3478

2 years agoSync up haskeline submodule to 0.7.4.0 release tag
Herbert Valerio Riedel [Thu, 20 Apr 2017 23:44:03 +0000 (01:44 +0200)] 
Sync up haskeline submodule to 0.7.4.0 release tag

2 years agoutils/debugNCG: remove old tool
Sergei Trofimovich [Fri, 21 Apr 2017 07:27:58 +0000 (08:27 +0100)] 
utils/debugNCG: remove old tool

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Reviewers: simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3476

2 years agopprDebugCLabel: drop duplicate trailing ')'
Sergei Trofimovich [Thu, 20 Apr 2017 19:49:26 +0000 (20:49 +0100)] 
pprDebugCLabel: drop duplicate trailing ')'

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agotestsuite: disable 'optllvm' for unregisterised compiler
Sergei Trofimovich [Thu, 20 Apr 2017 19:13:25 +0000 (20:13 +0100)] 
testsuite: disable 'optllvm' for unregisterised compiler

commit 74615f412ad3de2910a156ff494bfe5497fada7e
("UNREG: ignore -fllvm (Trac #13495)") enabled
'optllvm' tests to be ran in 'make fulltest' mode.

As a result many (~1000) tests fail due to stderr misamatch:
  +when making flags consistent: warning:
  +    Compiler unregisterised, so compiling via C

The change removes 'optllvm' tests for unregisterised compiler.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoSimplify StgCases when all alts refer to the case binder
Joachim Breitner [Tue, 18 Apr 2017 21:20:59 +0000 (17:20 -0400)] 
Simplify StgCases when all alts refer to the case binder

as proposed in #13588.

Differential Revision: https://phabricator.haskell.org/D3467

2 years agoRevert "linker/mach-o: Catch the case where there is no symCmd"
Ben Gamari [Tue, 18 Apr 2017 01:02:07 +0000 (21:02 -0400)] 
Revert "linker/mach-o: Catch the case where there is no symCmd"

This causes validation failures on Windows.

This reverts commit 6c05b27e5bafe9f232e7014f4760335f5e3ba591.

2 years agoAdd failing test case for #13588
Joachim Breitner [Tue, 18 Apr 2017 21:05:10 +0000 (17:05 -0400)] 
Add failing test case for #13588

2 years agoFix LaTeX in core-spec
Joachim Breitner [Tue, 18 Apr 2017 20:18:33 +0000 (16:18 -0400)] 
Fix LaTeX in core-spec

where d49b2bb21691892ca6ac8f2403e31f2a5e53feb3 introduced some TeX
breakage, and re-generate core-spec.pdf.

2 years agoUpdate xhtml submodule to potential 3000.2.2 release commit
Herbert Valerio Riedel [Tue, 18 Apr 2017 15:22:50 +0000 (17:22 +0200)] 
Update xhtml submodule to potential 3000.2.2 release commit

2 years agoCaret diag.: Avoid decoding whole module if only specific line is needed
alexbiehl [Mon, 17 Apr 2017 16:51:10 +0000 (12:51 -0400)] 
Caret diag.: Avoid decoding whole module if only specific line is needed

Before we were decoding the whole file to get to the desired line. This
patch introduces a fast function which searches a StringBuffer for the
desired line so we only need to utf8 decode a little portion.

This is especially interesting if we have big modules with lots of
warnings.

Reviewers: austin, bgamari, Rufflewind, trofi

Reviewed By: Rufflewind, trofi

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3440

2 years agoUse intersect and minus instead of filter
Bartosz Nitka [Mon, 17 Apr 2017 16:50:10 +0000 (12:50 -0400)] 
Use intersect and minus instead of filter

These are asymptotically better and convey the intent
a bit better.

Test Plan: ./validate

Reviewers: simonpj, bgamari, austin, goldfire

Reviewed By: bgamari

Subscribers: rwbarton, thomie, simonmar

Differential Revision: https://phabricator.haskell.org/D3455

2 years agoFix "Glasgow Haskell Compiler <release> Users Guide"
Bartosz Nitka [Mon, 17 Apr 2017 16:49:34 +0000 (12:49 -0400)] 
Fix "Glasgow Haskell Compiler <release> Users Guide"

If you go to
https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/index.html
the window title has `<release>` in it.  I don't understand how it all
works, but inspired by the line below which produces a correct string in
the docs I just blindly changed it in the same way.  Cabal appears to
have the same problem.

Test Plan:
it'd be nice if I could check the result
on harbormaster, can I?

Reviewers: thomie, bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, simonmar

Differential Revision: https://phabricator.haskell.org/D3458

2 years agoRemove redundant flag (-O) registration (fixes #13392)
Santiago Munin [Mon, 17 Apr 2017 16:44:52 +0000 (12:44 -0400)] 
Remove redundant flag (-O) registration (fixes #13392)

Reviewers: austin, bgamari, dfeuer

Reviewed By: bgamari, dfeuer

Subscribers: rwbarton, thomie

GHC Trac Issues: #13392

Differential Revision: https://phabricator.haskell.org/D3461

2 years ago[iserv] drop cryptonite dependency.
Moritz Angermann [Mon, 17 Apr 2017 16:28:22 +0000 (12:28 -0400)] 
[iserv] drop cryptonite dependency.

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3462

2 years agoutils: Lazily decode UTF8 strings
Ben Gamari [Mon, 17 Apr 2017 16:26:56 +0000 (12:26 -0400)] 
utils: Lazily decode UTF8 strings

Reviewers: austin, hvr

Subscribers: rwbarton, thomie

GHC Trac Issues: #13527

Differential Revision: https://phabricator.haskell.org/D3442

2 years agoFix space leak in sortBy
Gregory [Mon, 17 Apr 2017 15:24:31 +0000 (11:24 -0400)] 
Fix space leak in sortBy

This makes yields a small improvement in sort performance: around 3.5% in
runtime on random Ints.

Reviewers: austin, hvr, mpickering

Subscribers: siddhanathan, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3454

2 years agobase: Track timer PSQ timeouts as Word64 instead of Double
Ben Gamari [Mon, 17 Apr 2017 15:17:00 +0000 (11:17 -0400)] 
base: Track timer PSQ timeouts as Word64 instead of Double

Test Plan: Validate on all the platforms

Reviewers: nh2, hvr, austin

Subscribers: Phyx, nh2, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3417

2 years agoaclocal.m4: respect user's --with-ar= choice
Sergei Trofimovich [Mon, 17 Apr 2017 08:41:49 +0000 (09:41 +0100)] 
aclocal.m4: respect user's --with-ar= choice

'FP_PROG_AR' macro has a minor bug: it ignores
already existing value stored in '$fp_prog_ar'.

I've noticed it when tried to built UNREG ghc using thin LTO:

  $ ./configure --enable-unregisterised \
                --with-nm=gcc-nm \
                --with-ar=gcc-ar \
                --with-ranlib=gcc-ranlib \

./configure refused to use 'gcc-ar' (LTO-aware variant of 'ar')
and kept using 'ar'.

'$fp_prog_ar' is initialized (in a complex manner) in 'configure.ac' as:

    FP_ARG_WITH_PATH_GNU_PROG([AR], [ar], [ar])
    ArCmd="$AR"
    fp_prog_ar="$AR"
    AC_SUBST([ArCmd])

The change keeps that value.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoconfigure.ac: print resolved 'ar' and 'ranlib' tools
Sergei Trofimovich [Mon, 17 Apr 2017 08:40:17 +0000 (09:40 +0100)] 
configure.ac: print resolved 'ar' and 'ranlib' tools

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agohs_add_root() RTS API removal
Sergei Trofimovich [Mon, 17 Apr 2017 11:56:20 +0000 (12:56 +0100)] 
hs_add_root() RTS API removal

Before ghc-7.2 hs_add_root() had to be used to initialize haskell
modules when haskell was called from FFI.

commit a52ff7619e8b7d74a9d933d922eeea49f580bca8
("Change the way module initialisation is done (#3252, #4417)")
removed needs for hs_add_root() and made function a no-op.
For backward compatibility '__stginit_<module>' symbol was
not removed.

This change removes no-op hs_add_root() function and unused
'__stginit_<module>' symbol from each haskell module.

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Test Plan: ./validate

Reviewers: simonmar, austin, bgamari, erikd

Reviewed By: simonmar

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3460

2 years agoUNREG: fix spelling of '-split-objs' in warning
Sergei Trofimovich [Sun, 16 Apr 2017 16:56:35 +0000 (17:56 +0100)] 
UNREG: fix spelling of '-split-objs' in warning

Spelling if warning message slightly mismathed passed commandline:

  $ ghc-stage2 -split-objs -C N.hs
  on the commandline: warning: ignoring -fsplit-objs

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agoUNREG: remove dead code around -split-objs
Sergei Trofimovich [Sun, 16 Apr 2017 16:20:54 +0000 (17:20 +0100)] 
UNREG: remove dead code around -split-objs

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agorts/RtsUtils.c: drop stale comments
Sergei Trofimovich [Sun, 16 Apr 2017 09:45:00 +0000 (10:45 +0100)] 
rts/RtsUtils.c: drop stale comments

Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
2 years agolinker/mach-o: Catch the case where there is no symCmd
Moritz Angermann [Sun, 16 Apr 2017 01:30:10 +0000 (21:30 -0400)] 
linker/mach-o: Catch the case where there is no symCmd

We do check for symCmd, to set the info->nlist value, but
forgot to do the same check for info->names.  Thus when trying to
extract stroff from symCmd, we hit a segfault.

Reviewers: bgamari, adinapoli, austin, erikd, simonmar

Reviewed By: bgamari, adinapoli

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3459

2 years agolinters/cpp: Catch #ifndef
Ben Gamari [Fri, 14 Apr 2017 02:04:48 +0000 (22:04 -0400)] 
linters/cpp: Catch #ifndef

2 years agoFix typo in TcErrors.hs
Matthías Páll Gissurarson [Fri, 17 Mar 2017 00:46:58 +0000 (01:46 +0100)] 
Fix typo in TcErrors.hs

This fixes a very simple typo in TcErrors.hs. I hope this is small
enough in scope to be accepted through GitHub.

2 years agoDoc typo
Alex Biehl [Wed, 22 Mar 2017 09:25:24 +0000 (10:25 +0100)] 
Doc typo

2 years agoComments only in Type.isPredTy
Simon Peyton Jones [Thu, 13 Apr 2017 08:23:39 +0000 (09:23 +0100)] 
Comments only in Type.isPredTy

2 years agoRemove dead quantifyTyVars
Simon Peyton Jones [Wed, 12 Apr 2017 15:20:13 +0000 (16:20 +0100)] 
Remove dead quantifyTyVars

This patch

* removes a function TcMType.quantifyTyVars
  that was never called

* renames quantifyZonkedTyVars to quantifyTyVars

Plus a few comments.  No functional change at all

2 years agoYet more work on TcSimplify.simplifyInfer
Simon Peyton Jones [Wed, 12 Apr 2017 14:09:37 +0000 (15:09 +0100)] 
Yet more work on TcSimplify.simplifyInfer

The proximate cause for this patch is Trac #13482, which pointed out
further subtle interactions between
   - Inferring the most general type of a function
   - A partial type signature for that function

That led me into /further/ changes to the shiny new stuff in
TcSimplify.simplifyInfer, decideQuantification, decideMonoTyVars,
and related functions.

Happily, I was able to make some of it quite a bit simpler,
notably the bit about promoting free tyvars.  I'm happy with
the result.

Moreover I fixed Trac #13524 at the same time.  Happy days.

2 years agoFix a couple of user-manual typos
Simon Peyton Jones [Tue, 11 Apr 2017 14:24:42 +0000 (15:24 +0100)] 
Fix a couple of user-manual typos

2 years agoSplit up RnEnv into 4 modules, RnUnbound, RnUtils and RnFixity
Matthew Pickering [Sat, 8 Apr 2017 15:42:32 +0000 (16:42 +0100)] 
Split up RnEnv into 4 modules, RnUnbound, RnUtils and RnFixity

Summary:
RnEnv contains functions which convertn RdrNames into Names.

RnUnbound contains helper functions for reporting and creating
unbound variables.

RnFixity contains code which maintains the fixity environent
whilst renaming.

RnUtils contains the other stuff in RnEnv.

Reviewers: austin, goldfire, bgamari

Subscribers: goldfire, rwbarton, thomie, snowleopard

Differential Revision: https://phabricator.haskell.org/D3436

2 years agoDrop special handling of iOS
Moritz Angermann [Wed, 12 Apr 2017 18:12:33 +0000 (14:12 -0400)] 
Drop special handling of iOS

iOS at least since iOS8 (we are currently at iOS10.3), allows for
dynamic libaries, hence any artificail restriction on dyanmic
libraries should be lifted.

Please ping me with any iOS related issues that should potentially
resurface.  The iOS toolchain has considerably changed over the
years, and I'm willing to drop work arounds in good faith.

Reviewers: bgamari, austin

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13559, #7722

Differential Revision: https://phabricator.haskell.org/D3451

2 years agoFix typo in ReadP (succeds -> succeeds)
Chris Martin [Wed, 12 Apr 2017 18:12:05 +0000 (14:12 -0400)] 
Fix typo in ReadP (succeds -> succeeds)

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3452

2 years ago[linker] Remove dead code (ELF_FUNCTION_DESC)
Moritz Angermann [Wed, 12 Apr 2017 18:11:41 +0000 (14:11 -0400)] 
[linker] Remove dead code (ELF_FUNCTION_DESC)

Reviewers: bgamari, austin, erikd, simonmar, rwbarton

Reviewed By: bgamari, rwbarton

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3444

2 years agoAllow qualified names to be children in export lists
Matthew Pickering [Wed, 12 Apr 2017 18:10:54 +0000 (14:10 -0400)] 
Allow qualified names to be children in export lists

When doing this I noticed a horrible amount of duplication between
lookupSubBndrOcc and lookupExportChild (which I am responsible for).
I opened #13545 to keep track of this.

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #13528

Differential Revision: https://phabricator.haskell.org/D3434

2 years agoSuggest correct replacement flag name for -dppr-ticks
Reid Barton [Wed, 12 Apr 2017 18:10:39 +0000 (14:10 -0400)] 
Suggest correct replacement flag name for -dppr-ticks

It told me to use -fno-suppress-ticks, but it should have been
-dno-suppress-ticks.

Test Plan: tested -dppr-ticks and -frewrite-rules manually

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D3430

2 years agoRemove GhcDynamic (in favor of DYNAMIC_GHC_PROGRAMS)
Reid Barton [Wed, 12 Apr 2017 18:10:12 +0000 (14:10 -0400)] 
Remove GhcDynamic (in favor of DYNAMIC_GHC_PROGRAMS)

DYNAMIC_GHC_PROGRAMS and GhcDynamic both tried to control whether
the ghc binary was built as a dynamic executable, with confusing
results. In particular, setting GhcDynamic=NO has no effect on
systems where DYNAMIC_GHC_PROGRAMS defaults to YES.

DYNAMIC_GHC_PROGRAMS is more fully-featured (it ensures that the
correct flavor of the libraries is built, for example) so let's
keep it and remove GhcDynamic to reduce confusion.

This effectively reverts commit 3c6190b0.

Test Plan: tested locally; harbormaster

Reviewers: simonmar, austin, bgamari

Reviewed By: bgamari

Subscribers: thomie, snowleopard

Differential Revision: https://phabricator.haskell.org/D3428

2 years agoarc-linters: Add linting of #ifdef x and #if defined x
Ben Gamari [Wed, 12 Apr 2017 18:10:01 +0000 (14:10 -0400)] 
arc-linters: Add linting of #ifdef x and #if defined x

Reviewers: austin, erikd

Reviewed By: erikd

Subscribers: rwbarton, thomie, erikd

Differential Revision: https://phabricator.haskell.org/D3423

2 years agobase: Implement bit casts between word and float types
Erik de Castro Lopo [Wed, 12 Apr 2017 18:09:49 +0000 (14:09 -0400)] 
base: Implement bit casts between word and float types

Test Plan: Test on x86 and x86_64

Reviewers: duncan, trofi, simonmar, tibbe, hvr, austin, rwbarton,
bgamari

Reviewed By: duncan

Subscribers: Phyx, DemiMarie, rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3358

2 years agoRnEnv cleanup
Matthew Pickering [Wed, 12 Apr 2017 18:06:15 +0000 (14:06 -0400)] 
RnEnv cleanup

unless (not ..) -> when

Remove unused getLookupOccRn

Remove lookupGreRn2

It was only called in one place in a very strange way. It is easier
to just use lookupGreRn which has nearly the same implementation and
then directly call `unboundName`.

Remove unused function mapFvRnCPS

Remove unused functions bindLocatedLocalsRn and bindLocatedLocalsFV

Reviewers: austin, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3435

2 years agoUse -G1 for reliable peak mem usage
Simon Peyton Jones [Tue, 11 Apr 2017 15:09:42 +0000 (16:09 +0100)] 
Use -G1 for reliable peak mem usage

2 years agoMake let and app consistent in exprIsCheapX
Simon Peyton Jones [Tue, 11 Apr 2017 14:39:09 +0000 (15:39 +0100)] 
Make let and app consistent in exprIsCheapX

This fixes Trac #13558, by making App and Let behave
consistently; see Note [Arguments and let-bindings exprIsCheapX]

I renamed the mysterious exprIsOk to exprIsCheapX.  (The "X"
is because it is parameterised over a CheapAppFun.)

2 years agoAdd Outputable instance for ArityType
Simon Peyton Jones [Tue, 11 Apr 2017 14:36:30 +0000 (15:36 +0100)] 
Add Outputable instance for ArityType

2 years agoFix another literal-string buglet
Simon Peyton Jones [Tue, 11 Apr 2017 14:34:12 +0000 (15:34 +0100)] 
Fix another literal-string buglet

We were failing to float a nested binding
   x :: Addr# = "foo"#
to top level, even though we /were/ floating string
literals themselves.  A small oversight, easily fixed.

2 years agoImprove demand analysis for join points
Simon Peyton Jones [Mon, 10 Apr 2017 07:51:49 +0000 (08:51 +0100)] 
Improve demand analysis for join points

I realised (Trac #13543) that we can improve demand analysis for
join point quite straightforwardly.

The idea is explained in
    Note [Demand analysis for join points]
in DmdAnal

2 years agoKill off complications in CoreFVs
Simon Peyton Jones [Fri, 7 Apr 2017 16:10:07 +0000 (17:10 +0100)] 
Kill off complications in CoreFVs

When doing type-in-type, Richard introduce some substantial
complications in CoreFVs, gathering types and free variables
of type.  In Trac #13160 we decided that this complication was
unnecessary, so this patch removes it.

Unfortnately I then fell down a twisty rabbit hole.  Roughly:

* An apparently-innocuous change in the AnnApp case of
  fiExpr made the fuction a little bit stricter, so we ended
  up peering into the arguments when we didn't before (namely
  when there are no bindings being floated inwards).  I've
  rejigged it so that it's not fragile any more.

* Peering into the arguments was sometimes expensive, becuase
  exprIsExpandable can be expensive because it looks deeply into
  the expression.

* The combination of the two led to a non-linear explosion
  of work when the argument of a function is a deeep nest
  of constructors.  This bug has been lurking for ages.

  I solved it by replacing exprIsExpandable with exprIsHNF
  + exprIsTrivial; see Note [noFloatInto considerations]

* The code around floating case-expressions turned out to be
  very delicate, because can_fail primops (which we want to
  float inwards) can't be floated outwards; so we have to be
  careful never to float them too far. Note [Floating primops]
  has the details

* I ended up refactoring some rather opaque code in
  sepBindsByDropPoint.

Working all this out meant that I rewrote quite a bit of
code, so it's now a reasonably substantial patch.  But it's
a net improvement.

2 years agoTypos in comments [ci skip]
Gabor Greif [Thu, 6 Apr 2017 13:13:55 +0000 (15:13 +0200)] 
Typos in comments [ci skip]

2 years ago[Elf/arm] Thumb indicator bit only for STT_FUNC
Moritz Angermann [Tue, 11 Apr 2017 01:39:19 +0000 (21:39 -0400)] 
[Elf/arm] Thumb indicator bit only for STT_FUNC

Reviewers: rwbarton, bgamari, austin, erikd, simonmar, trofi

Reviewed By: trofi

Subscribers: trofi, thomie

Differential Revision: https://phabricator.haskell.org/D3438

2 years ago[MachO] Use OBJFORMAT_MACHO.
Moritz Angermann [Tue, 11 Apr 2017 01:39:02 +0000 (21:39 -0400)] 
[MachO] Use OBJFORMAT_MACHO.

Reviewers: bgamari, austin, erikd, simonmar, rwbarton

Reviewed By: rwbarton

Subscribers: rwbarton, thomie

Differential Revision: https://phabricator.haskell.org/D3433

2 years agoEnter iserv-proxy
Moritz Angermann [Tue, 11 Apr 2017 01:38:45 +0000 (21:38 -0400)] 
Enter iserv-proxy

With the introduction of -fexternal-interpreter we are
now able to compile template haskell via an extern iserv process.

This however is restricted to the same host, and can therefore
not be used with crosscompilers where the iserv slave process
needs to run on a different machine than the cross compiling
haskell compiler.

This diff breaks up iserv into a library and the iserv-bin binary.
It also introduces the iserv-proxy, a proxy instance that the
haskell compiler can talk to, and which forwards the calls
to the iserv slave on a different machine, as well as providing
some extra functionarily (sending files that are not available
on the machine the slave runs on), as well as forwarding from
the slave to the haskell compiler, when the slave needs to
interrogate the haskell compiler.

The iserv library now also exports the startSlave function to be
called by the application that implements the slave on the target.

The simplest such app would probably look something like:

```
extern void startServ(bool, const char *);

int main(int argc, char * argv[]) {
  hs_init(NULL, NULL);
  startServ(false,"/tmp");
  while(1);
}
```

Special thanks to Shea Levy for the first draft of the iserv-remote,
from which I took some inspiration.

The `Buildable` flags are due to ghc-cabal not being able to build
more than a single target.  Please note that only the stock iserv-bin
is supposed to be built *with* ghc.  The library and proxy are supposed
to be built outside of ghc.  Yet I believe that this code should live
together with iserv.

Reviewers: simonmar, ezyang, goldfire, austin, rwbarton, bgamari

Reviewed By: simonmar

Subscribers: luite, ryantrinkle, shlevy, thomie

Differential Revision: https://phabricator.haskell.org/D3233

2 years agoFix form of note
Ben Gamari [Tue, 11 Apr 2017 01:35:06 +0000 (21:35 -0400)] 
Fix form of note

2 years agobase: Fix erroneous reference to Data.Reflection in documentation
Ben Gamari [Mon, 10 Apr 2017 18:07:42 +0000 (14:07 -0400)] 
base: Fix erroneous reference to Data.Reflection in documentation

2 years agoImprove `readChan` documentation:
Ömer Sinan Ağacan [Mon, 10 Apr 2017 17:36:45 +0000 (20:36 +0300)] 
Improve `readChan` documentation:

- Mention that the read end is an `MVar`, so fairness guarantees are
  inherited.

- Mention that it can throw `BlockedIndefinitelyOnMVar` exception.

Reviewers: austin, hvr, bgamari

Reviewed By: bgamari

Subscribers: rwbarton, thomie

GHC Trac Issues: #5466

Differential Revision: https://phabricator.haskell.org/D3439

2 years agoTypos in bang patterns user manual [skip ci]
Ömer Sinan Ağacan [Mon, 10 Apr 2017 15:38:31 +0000 (18:38 +0300)] 
Typos in bang patterns user manual [skip ci]

2 years agoAdd a second regression test for #13536
Joachim Breitner [Mon, 10 Apr 2017 15:21:52 +0000 (11:21 -0400)] 
Add a second regression test for #13536

which counts allocations instead of observing recomputation directly.

2 years agoStgCse: Do not re-use trivial case scrutinees
Joachim Breitner [Sun, 9 Apr 2017 23:40:02 +0000 (19:40 -0400)] 
StgCse: Do not re-use trivial case scrutinees

as they might be marked as one-shot, and suddenly we’d evaluate them
multiple times. This came up in #13536 (test cases included).

The solution was layed out by SPJ in ticket:13536#comment:12.

Differential Revision: https://phabricator.haskell.org/D3437

2 years agoAdd a Note [Call Arity and Join Points]
Joachim Breitner [Sun, 9 Apr 2017 17:41:40 +0000 (13:41 -0400)] 
Add a Note [Call Arity and Join Points]

as discussed in #13479.

2 years agoParenthesize type/data families correctly for -ddump-splices
Alan Zimmerman [Sun, 9 Apr 2017 19:06:06 +0000 (21:06 +0200)] 
Parenthesize type/data families correctly for -ddump-splices

Fix a regression in the pretty-printed code for -ddump-splices, which regressed
since 8.0.

Closes trac issue #13550