Add special stdout for hClose002 on x64 Solaris

Summary:
This is identical to the x86 output from bug #4290,
and fixes the hClose002 test when running under
x86_64-unknown-solaris2.

Test Plan: Re-run 'make TEST=hClose002' under x64 Solaris.

Reviewers: ezyang, austin

Reviewed By: ezyang, austin

Subscribers: simonmar, ezyang, carter

Differential Revision: https://phabricator.haskell.org/D205
Find the target gcc when cross-compiling

Summary:
"./configure --target=TARGET" was broken; it would use the host gcc.
(So you had to explicitly specify "--with-gcc=TARGET-gcc" also,
as a workaround.)

This was broken by commit fc4856f9e811d9a23ae9212f43a09ddf5ef12b26
for #8148. A comment claimed that FP_ARG_WITH_PATH_GNU_PROG_OPTIONAL
was the same as FP_ARG_WITH_PATH_GNU_PROG except for not raising
an error when the program isn't found; but that wasn't true --
the former didn't prepend the target name when cross-compiling.

We actually need three versions of FP_ARG_WITH_PATH_GNU_PROG since
the LLVM tools are usually not prefixed with the target name even
when cross-compiling. So I generalized the logic in a single macro.

Test Plan:
Built with "./configure --target=i386-unknown-linux"
and BuildFlavour=quick, successfully

Reviewers: ezyang, austin

Reviewed By: ezyang, austin

Subscribers: simonmar, ezyang, carter

Differential Revision: https://phabricator.haskell.org/D204
Fix cppcheck warnings

Summary:
Cppcheck found a few defects in win32 IOManager and a typo in rts
testsuite. This commit fixes them.

Cppcheck 1.54 founds three possible null pointer dereferences of ioMan
pointer. It is dereferenced and checked for NULL after that.

testheapalloced.c contains typo in printf statement, which should print
percent sign but treated as parameter placement by compiler. To properly
print percent sign one need to use "%%" string.

FYI: Cppcheck 1.66 cannot find possible null pointer dereferences in
mentioned places, mistakenly thinking that some memory leaking instead.
I probably fill a regression bug to Cppcheck.

Test Plan:
Build project, run 'make fulltest'. It finished with 28 unexpected
failures. I don't know if they are related to my fix.

    Unexpected results from:
    TEST="T3500b T7891 tc124 T7653 T5321FD T5030 T4801 T6048 T5631 T5837 T5642 T9020 T3064 parsing001 T1969 T5321Fun T783 T3294"

    OVERALL SUMMARY for test run started at Tue Sep  9 16:46:27 2014 NOVT
     4:23:24 spent to go through
        4101 total tests, which gave rise to
       16075 test cases, of which
        3430 were skipped

         315 had missing libraries
       12154 expected passes
         145 expected failures

           3 caused framework failures
           0 unexpected passes
          28 unexpected failures

    Unexpected failures:
       ../../libraries/base/tests  T7653 [bad exit code] (ghci,threaded1,threaded2)
       perf/compiler               T1969 [stat not good enough] (normal)
       perf/compiler               T3064 [stat not good enough] (normal)
       perf/compiler               T3294 [stat not good enough] (normal)
       perf/compiler               T4801 [stat not good enough] (normal)
       perf/compiler               T5030 [stat not good enough] (normal)
       perf/compiler               T5321FD [stat not good enough] (normal)
       perf/compiler               T5321Fun [stat not good enough] (normal)
       perf/compiler               T5631 [stat not good enough] (normal)
       perf/compiler               T5642 [stat not good enough] (normal)
       perf/compiler               T5837 [stat not good enough] (normal)
       perf/compiler               T6048 [stat not good enough] (optasm)
       perf/compiler               T783 [stat not good enough] (normal)
       perf/compiler               T9020 [stat not good enough] (optasm)
       perf/compiler               parsing001 [stat not good enough] (normal)
       typecheck/should_compile    T7891 [exit code non-0] (hpc,optasm,optllvm)
       typecheck/should_compile    tc124 [exit code non-0] (hpc,optasm,optllvm)
       typecheck/should_run        T3500b [exit code non-0] (hpc,optasm,threaded2,dyn,optllvm)

Reviewers: austin

Reviewed By: austin

Subscribers: simonmar, ezyang, carter

Differential Revision: https://phabricator.haskell.org/D203
Remove special casing of singleton strings, split all strings.

Summary:
exprIsConApp_maybe now detects string literals and correctly
splits them. This means case-statemnts on string literals can
now push the literal into the cases.

fix trac issue #9400

Test Plan: validate

Reviewers: austin, simonpj

Reviewed By: austin, simonpj

Subscribers: simonmar, ezyang, carter

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

GHC Trac Issues: #9400
Add the ability to :set -l{foo} in ghci, fix #1407.

Summary:
The dynamic linking code was already there but it was not called
on flag changes in ghci.

Test Plan: validate

Reviewers: hvr, simonmar, austin

Reviewed By: austin

Subscribers: simonmar, ezyang, carter

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

GHC Trac Issues: #1407
Return nBytes instead of nextAddr from utf8DecodeChar

Summary:
While researching D176, I came across the following simplification
opportunity:

Not all functions that call utf8DecodeChar actually need the address
of the next char. And some need the 'number of bytes' read. So returning
nBytes instead of nextAddr should save a few addition and subtraction
operations, and makes the code a bit simpler.

Test Plan: it validates

Reviewers: simonmar, ezyang, austin

Reviewed By: austin

Subscribers: simonmar, ezyang, carter

Differential Revision: https://phabricator.haskell.org/D179
Revert "Revert "rts/base: Fix #9423"" and resolve issue that caused the revert.

Summary:
This reverts commit 4748f5936fe72d96edfa17b153dbfd84f2c4c053. The fix for #9423
was reverted because this commit introduced a C function setIOManagerControlFd()
(defined in Schedule.c) defined for all OS types, while the prototype
(in includes/rts/IOManager.h) was only included when mingw32_HOST_OS is
not defined. This broke Windows builds.

This commit reverts the original commit and resolves the problem by only defining
setIOManagerControlFd() when mingw32_HOST_OS is defined. Hence the missing prototype
error should not occur on Windows.

In addition, since the io_manager_control_wr_fd field of the Capability struct is only
usd by the setIOManagerControlFd, this commit includes the io_manager_control_wr_fd
field in the Capability struct only when mingw32_HOST_OS is not defined.

Test Plan: Try to compile successfully on all platforms.

Reviewers: austin

Reviewed By: austin

Subscribers: simonmar, ezyang, carter

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