Opened 2 years ago

Closed 6 months ago

#12695 closed bug (fixed)

Build failure due to MAP_NORESERVE being removed in FreeBSD 11.x and later

Reported by: abbe Owned by:
Priority: normal Milestone: 8.6.1
Component: Compiler Version: 8.0.1
Keywords: Cc:
Operating System: FreeBSD Architecture: Unknown/Multiple
Type of failure: Building GHC failed Test Case:
Blocked By: Blocking:
Related Tickets: #15348 Differential Rev(s):
Wiki Page:

Description

While trying to build GHC 8.0.1 on FreeBSD 11.x, I come across following compiler error:

/usr/local/bin/clang-cpp38  -DPROFILING -DTHREADED_RTS -DDEBUG  -fno-stack-protector -O2 -pipe  -Qunused-arguments -I/usr/local/include -fstack-protector -fno-strict-aliasing -Wall  -Wall -Wextra -Wstrict-prototypes  -Wmissing-prototypes  -Wmissing-declarations -Winline -Waggregate-return -Wpointer-arith -Wmissing-noreturn -Wnested-externs -Wredundant-decls  -Iincludes -Iincludes/dist -Iincludes/dist-derivedconstants/header -Iincludes/dist-ghcconstants/header -Irts -Irts/dist/build -DCOMPILING_RTS -fno-strict-aliasing -fno-common -Irts/dist/build/autogen        -Wno-unknown-pragmas -O2 -fomit-frame-pointer -g -DRtsWay=\"rts_v\"     -MM -x c rts/posix/OSMem.c -MF rts/dist/build/.depend-v-p-dyn-l-debug-thr-thr_debug-thr_l-thr_p-debug_dyn-thr_dyn-thr_debug_dyn-l_dyn-thr_l_dyn.c_asm.bit
rts/posix/OSMem.c:158:5: error: USE_LARGE_ADDRESS_SPACE needs MAP_NORESERVE
#   error USE_LARGE_ADDRESS_SPACE needs MAP_NORESERVE
    ^
1 error generated.

From some investigation, it turns out when it was there, it was not even implemented. The value of __FreeBSD_version (in case you plan to add conditional based on it), where it is changed is 1100039.

Let me know if you need more information.

Thanks for looking

Change History (6)

comment:1 Changed 2 years ago by erikd

You can get around this by configuring GHC with --disable-large-address-space and rebuilding it. This turns off the large address space features to give the same behavior as versions of GHC before 8.0.

It would also be interesting to test whether #defined MAP_NO_RESERVE 0 at the top of rts/posix/OSMem.c and configuring with --enable-large-address-space results in a working compiler.

comment:2 Changed 2 years ago by dmm

I had no issue building stack and purescript with ghc 8.0.1 on FreeBSD 11 after adding #define MAP_NORESERVE 0 to rts/posix/OSMem.c

Building 8.0.2 now with same define.

comment:3 Changed 2 years ago by dmm

While 8.0.2 did build fine, I see lots of these on console:

    swap_pager_getswapspace(8): failed
    swap_pager_getswapspace(14): failed
    swap_pager_getswapspace(9): failed
    ...

That may have existed for 8.0.1 too and I missed it. Given the nature of use for MAP_NORESERVE change, it may be responsible for this.

comment:4 Changed 19 months ago by nh2

I think info about this should at least be added to https://ghc.haskell.org/trac/ghc/wiki/Building/Preparation/FreeBSD

comment:5 Changed 19 months ago by bgamari

I've noted this on Building/Preparation/FreeBSD.

comment:6 Changed 6 months ago by bgamari

Milestone: 8.6.1
Resolution: fixed
Status: newclosed

Note that the two-step allocator is now supported on FreeBSD. See #15348.

Note: See TracTickets for help on using tickets.