Fix --link-object <archive> with --restricted-command-line.

When --restricted-command-line is enabled, we try to shorten the link
command by creating a temporary archive of object files, including files
specified with --link-object.  --link-object can also be used to specify
archives (.a) to link with, which results in nested archives in the
temporary archive.  The linker does not look for object files in nested
archives so it does not work as intended.

compiler/compile_target_code.m:
	Create the temporary archive for --restricted-command-line
	consisting of only the file names in ObjectsList with known
	object file extensions.  Pass any other names in ObjectsList
	to the link command directly.
Document that --link-object and MLOBJS may specify archives.

It was not explicitly stated that --link-object and MLOBJS may specify
archives to link with.  The Mercury build system uses that fact, the
documentation contains some examples doing so, and it has been a
consideration since at least commit eadcd7ab00ca5599f4bc371803afd5b106c581f6,
so document it as a supported feature.

compiler/options.m:
doc/reference_manual.texi:
doc/user_guide.texi:
	Mention archives in --link-object and MLOBJS documentation.
Fix implicit declaration of GC_setup_mark_lock.

boehm_gc/misc.c:
	Include pthread_support.h for GC_setup_mark_lock,
	a Mercury-specific addition.
Enable thread-local allocation and parallel marking on more platforms.

The changes to the platforms that I am unable to test are based on the
boehm_gc/configure script.  If that script allows the features to be
enabled then I assume that the features are usable.

configure.ac:
	Enable parallel marking on Solaris (untested by me).

	Enable on Cygwin (untested by me).

	Enable on MinGW32 (tested).

	Enable on MinGW-w64 (tested with winpthreads, which requires some
	other changes).

	Enable on Darwin (tested by Julien).
Support building Boehm GC with Winpthreads.

Winpthreads is a pthreads implementation from the MinGW-w64 project,
different from pthreads-win32.  A similar patch to this should make its
way into Boehm GC upstream.  As we will not be upgrading Boehm GC on the
14.01 branch, apply this small change to our copy of the library for now.

boehm_gc/include/private/gc_locks.h:
	Winpthreads uses scalar thread IDs.

boehm_gc/win32_threads.c:
	Winpthread thread IDs should be practically unique but make the
	conservative assumption anyway.
Account for Winpthreads in configure.

configure.ac:
	Always build the par_gc library with GC_WIN32_PTHREADS when
	pthread.h is detected on MinGW* systems.  Previously, if the
	pthread implementation is not pthread-win32 we would fallback to
	building Boehm GC with GC_WIN32_THREADS (no "P"), so it would
	NOT provide pthread wrapper functions.  But since pthread.h was
	found, the Mercury implementation would make pthread calls, calls
	which are not intercepted by Boehm GC and thus unsafe.

	Change `--with-gc-pthreads-win32' to `--with-gc-win32-pthreads',
	to mean either of pthreads-win32 or winpthreads.
Fix configuration of thread support for MinGW-w64 32-bit target.

configure.ac:
	Relax a host pattern to cover MinGW-w64 x86 targets (i*86)
	in addition to x86_64.
Workaround bug #354 in the cairo binding.

extras/graphics/mercury_cairo/Mercury.options:
	Add a workaround for bug #354.

	Don't attempt to install his library in the csharp grade.
Backport Boehm GC changes for Winpthreads support.

Make our changes to support Winpthreads match those of upstream
bdwgc commit 94b85eea2e2713c7a6071f1965b1e98e645e65a7

boehm_gc/include/private/gc_locks.h:
boehm_gc/win32_threads.c:
	As above.
Fix a problem with library installation with mmc --make.

Library installation with mmc --make sometimes attempt to install libraries in
non-existent grades, for example java.par or java.trseg.  The cause of this
problem is some left over code from the GCC backend, in particular the
high-level C base grade components imply multiple possible target languages, C
and asm.  This is a problem because of the XXX in the predicate
convert_grade_option/3, where we only update the current target language if the
base grade component has a single target language associated with it.

For example, when a library is being installed in the grades java and hlc.par.gc and
we are at the step where we install it in the hlc.par.gc grade (second, since the
libgrade list is sorted), we build up the following command line for the mmc subprocess
that will do the installation in that grade:

   mmc --invoked-by-mmc-make ... --make        \
	--grade java --use-grade-subdirs       \
	--grade hlc.par.gc --use-grade-subdirs \
	--java-only --use-subdirs <target>

(XXX I don't know why we need to keep repeating --use-grade-subdirs like this,
or why we have to pass --use-subdirs at all given that it is implied by
--use-grade-subdirs.  Or what the rationale for passing all the --grade options
to the subprocess is.)

When the option "--grade java" is processed the target language will be set to
Java, but because of the XXX in convert_grade_option/3, the target language
will not be set to C when the option "--grade hlc.par.gc" is subsequently
processed, hence the compiler will attempt to install the library in the
non-existent grade java.par.  (Since --target java implies automatic GC,
the .gc component will vanish.)

The fix is to remove the asm target language for the high-level C base grade
components.

Additionally, remove other left over code for supporting --target asm.

compiler/handle_options.m:
	Delete the "asm" target language for the high-level C base grade
	components.

compiler/make.m:
compiler/globals.m:
compiler/add_pragma.m:
compiler/write_deps_file.m:
	Delete references to "--target asm" and update some other comments
	where necessary.

compiler/modules.m:
	Delete two unused predicate that were only required by the GCC backend.

compiler/compile_target_code.m:
	Delete the unused predicate assemble/7 that was only required by the
	GCC backend.

compiler/mlds_to_c.m:
	Add an XXX comment about some code that was required to support
	"--target asm".

NEWS:
	Announce the fix.
Use mmap for Boehm GC in threaded grades on Linux.

The glibc implementation of malloc (commonly used on Linux) can use sbrk
to acquire more memory, and so does Boehm GC in its default configuration
on Linux.  When both allocators are invoked simultaneously from different
threads then memory corruption may result.

configure.ac:
	Add --enable-gc-mmap option.

	Make --enable-gc-munmap imply --enable-gc-mmap.

	Detect mmap and set MR_HAVE_MMAP.

	Detect sbrk and set MR_HAVE_SBRK.

	On Linux (and potentially other platforms), build Boehm GC for
	threaded grades with -DUSE_MMAP if mmap was found.

Mmake.common.in:
	Add ENABLE_BOEHM_USE_MMAP.

runtime/mercury_conf.h.in:
	Add MR_HAVE_MMAP, although it is not used anywhere yet.

	Add MR_HAVE_SBRK.  It is only for used by the test program.

tests/hard_coded/Mmakefile:
tests/hard_coded/thread_sbrk.exp:
tests/hard_coded/thread_sbrk.exp2:
tests/hard_coded/thread_sbrk.m:
	Add test program.

NEWS:
	Announce changes.

(cherry picked from commit d63a294e1fa4b1a91b6c7acd9fe8ba45d9cffb6d)
Fix some comments in array.m.
Avoid strerror_s on MinGW-w64 for compatibility with Windows XP.

runtime/mercury_runtime_util.c:
	As above.