Make start address of `osReserveHeapMemory` tunable via command line -xb
authorFrancesco Mazzoli <f@mazzo.li>
Fri, 9 Sep 2016 17:15:49 +0000 (18:15 +0100)
committerBen Gamari <ben@smart-cactus.org>
Mon, 12 Sep 2016 14:45:56 +0000 (10:45 -0400)
commit658f0354326ddfdafec3772cdb86d89f0e424663
tree75780c8d026eaec724d7c472718122d48be7d226
parent43149ea634a99e125bf7e1750953945d04df823b
Make start address of `osReserveHeapMemory` tunable via command line -xb

Summary:
We stumbled upon a case where an external library (OpenCL) does not work
if a specific address (0x200000000) is taken.

It so happens that `osReserveHeapMemory` starts trying to mmap at 0x200000000:

```
        void *hint = (void*)((W_)8 * (1 << 30) + attempt * BLOCK_SIZE);
        at = osTryReserveHeapMemory(*len, hint);
```

This makes it impossible to use Haskell programs compiled with GHC 8
with C functions that use OpenCL.

See this example â€‹https://github.com/chpatrick/oclwtf for a repro.

This patch allows the user to work around this kind of behavior outside
our control by letting the user override the starting address through an
RTS command line flag.

Reviewers: bgamari, Phyx, simonmar, erikd, austin

Reviewed By: Phyx, simonmar

Subscribers: rwbarton, thomie

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

(cherry picked from commit 1b5f9207a649a64a1bba20b0283253425f9208d7)
docs/users_guide/8.0.2-notes.rst
includes/stg/Types.h
rts/RtsFlags.c
rts/posix/OSMem.c
rts/sm/MBlock.c
rts/sm/OSMem.h
rts/win32/OSMem.c