Make the LocalRdrEnv keep track of all the Names that are in scope

This allows us to give a sensible error message when a Template Haskell
splice generates an occurrence without a binding site.

Fixes Trac #5959 and #5971

MERGED from commit cb5a3f2d66e4dac2f6f44f56e365d18df884c943
Prevent nested TH exceptions from bubbling up to the top level (#5976)

MERGED from commit e7e5e277eb58a5ef6207200174e7982fdb9780bb
Fix tracking of reason safe inference failed. (#5988)
Update safe haskell error/warn formatting
Fix GHC API with respect to safe haskell. (#5989)

This fixes haddock so it correctly reports
the safe haskell mode of a module.
Improve the handling of threadDelay in the non-threaded RTS

Firstly, we were rounding up too much, such that the smallest delay
was 20ms.  Secondly, there is no need to use millisecond resolution on
a 64-bit machine where we have room in the TSO to use the normal
nanosecond resolution that we use elsewhere in the RTS.

MERGED from commit 9d26519c20194abc3832578a55fbe31327519eeb
Disable the timer signal while blocked in select() (#5991)

The threaded RTS had a fix for this a long time ago (#1623) but this
patch applies a similar fix to the non-threaded RTS.

MERGED from commit dd24d6bc37879c6b32a3d5ac4ee765e59e13501c
Fix a #define

I don't think it was causing any problems, but
    TimeToUS(x+y)
would have evaluated to
    x + (y / 1000)

MERGED from commit 54121fffb5ee069d9b7a5628104ff1114ea87182

On the 7.4 branch, this was causing a wrong conversion in
getDelayTarget.

Signed-off-by: Paolo Capriotti <p.capriotti@gmail.com>
Fix crash with tiny initial stack size (#5993)

MERGED from commit 5eabdc1675b8b5bc9fcdfb96ab63d14d42ca2d5b
Update 7.4.2 release notes.
Fix worker/wrapper for CPR functions

A long-standing and egregious bug in the worker/wrapper code meant
that some functions with the CPR property weren't getting a CPR
w/w. And that had the effect of making a tail-recursive function not
tail recursive.  As well as increasing allocation.

Fixes Trac #5920, and #5997.

Nofib results (highlights):

        Program           Size    Allocs   Runtime   Elapsed  TotalMem
--------------------------------------------------------------------------------
         boyer2          -0.1%    -15.3%      0.01      0.01     +0.0%
        mandel2          -0.0%     -8.1%      0.01      0.01     +0.0%
           para          -0.1%    -11.8%     -7.9%     -7.8%     +0.0%
--------------------------------------------------------------------------------
            Min          -0.1%    -15.3%     -7.9%     -7.8%    -33.3%
            Max          +0.0%     +0.2%     +6.3%     +6.3%     +3.7%
 Geometric Mean          -0.0%     -0.4%     +0.1%     +0.1%     -0.5%

Looks like a clear win.  And I have not even recompiled the libraries, so
it'll probably be a bit better in the ed.

MERGED from commit b8ff4448d899f783fc112f3774aab626979a4f22
Flags documentation: -fwarn-unrecognized-pragmas is enabled by -Wall (#6050)

MERGED from commit 44098b3dab032a83cc869855de67377f41d82384
Doc: updated list of warnings not enabled by -Wall (#4817)

MERGED from commit 18c2a2f71e38fad5e677b8f448f6135e5a691868
Compile link .note section separately from main.c

Fixes gas errors when -g is enabled:

Error: can't resolve `.debug-ghc-link-info' {.debug-ghc-link-info section} - `.Ltext0' {.text section}
Omit -osuf/-odir -hisuf/-hidir and -stubdir from the flag checker

The reasoning is that GHC will only skip recompilation if it has found
a valid up-to-date object file and .hi file, so there is no need to
also check that these flags have not changed, and indeed there are
valid reasons to want to change them.
Cast memory primops in the C backend (#5976)

To prevent conflicts with GCC builtins, generate identical code for
calls to mem primos and FFI calls.

Based on a patch by Joachim Breitner.
MERGED from commit 40c1106c338e209f07023d165f32bff0f75e2e54
hs_init(): cope with argc and/or argv being NULL (#6006)

MERGED from commit 4ca281829c70331571291ed3dcf813a6028cc904
Catch illegal imports earlier (#6007)

MERGED from commit b6e28266cf29bfdf07fe08e894df77b400da8a04
Build fix.
Update 7.4.2 release notes.