summaryrefslogtreecommitdiff
path: root/rts/RtsFlags.c
diff options
context:
space:
mode:
authorFrancesco Mazzoli <f@mazzo.li>2016-09-09 18:15:49 +0100
committerTamar Christina <tamar@zhox.com>2016-09-09 18:24:30 +0100
commit1b5f9207a649a64a1bba20b0283253425f9208d7 (patch)
tree06b3373e9111c5061a578d1fe214a8d5810c852e /rts/RtsFlags.c
parent65d9597d98ead78198bb747aed4e1163ee0d60d3 (diff)
downloadhaskell-1b5f9207a649a64a1bba20b0283253425f9208d7.tar.gz
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
Diffstat (limited to 'rts/RtsFlags.c')
-rw-r--r--rts/RtsFlags.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/rts/RtsFlags.c b/rts/RtsFlags.c
index 92b7e871df..c994a0ce88 100644
--- a/rts/RtsFlags.c
+++ b/rts/RtsFlags.c
@@ -271,6 +271,9 @@ usage_text[] = {
" -O<size> Sets the minimum size of the old generation (default 1M)",
" -M<size> Sets the maximum heap size (default unlimited) Egs: -M256k -M1G",
" -H<size> Sets the minimum heap size (default 0M) Egs: -H24m -H1G",
+" -xb<addr> Sets the address from which a suitable start for the heap memory",
+" will be searched from. This is useful if the default address",
+" clashes with some third-party library.",
" -m<n> Minimum % of heap which must be available (default 3%)",
" -G<n> Number of generations (default: 2)",
" -c<n> Use in-place compaction instead of copying in the oldest generation",
@@ -1293,7 +1296,7 @@ error = rtsTrue;
OPTION_UNSAFE;
if (rts_argv[arg][3] != '\0') {
RtsFlags.GcFlags.heapBase
- = strtol(rts_argv[arg]+3, (char **) NULL, 16);
+ = strToStgWord(rts_argv[arg]+3, (char **) NULL, 0);
} else {
errorBelch("-xb: requires argument");
error = rtsTrue;