Enable MAP_32BIT for macOS (#2992)

On macOS, by default, the first 4GB is occupied by the pagezero.
While it can be controlled with link time options, as we are
an library, we usually don't have a control on how to link an
executable.
This commit is contained in:
YAMAMOTO Takashi
2024-01-10 17:19:06 +09:00
committed by GitHub
parent 49ac1e0636
commit 6fa6d6d9a5
2 changed files with 20 additions and 2 deletions

View File

@ -451,3 +451,9 @@ if (WAMR_BUILD_LINUX_PERF EQUAL 1)
add_definitions (-DWASM_ENABLE_LINUX_PERF=1)
message (" Enable linux perf support")
endif ()
if (APPLE)
# On recent macOS versions, by default, the size of page zero is 4GB.
# Shrink it to make MAP_32BIT mmap can work.
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-pagezero_size,0x4000")
endif ()