Skip to content

Commit 85b6f16

Browse files
committed
Revert "Enable MAP_32BIT for macOS (bytecodealliance#2992)"
This reverts commit 6fa6d6d. discussion: bytecodealliance#3009
1 parent 41d5bbc commit 85b6f16

File tree

2 files changed

+2
-19
lines changed

2 files changed

+2
-19
lines changed

build-scripts/config_common.cmake

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -473,8 +473,3 @@ else ()
473473
# Disable quick aot/jit entries for interp and fast-jit
474474
add_definitions (-DWASM_ENABLE_QUICK_AOT_ENTRY=0)
475475
endif ()
476-
if (APPLE)
477-
# On recent macOS versions, by default, the size of page zero is 4GB.
478-
# Shrink it to make MAP_32BIT mmap can work.
479-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-pagezero_size,0x4000")
480-
endif ()

core/shared/platform/common/posix/posix_memmap.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,15 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file)
7878
map_prot |= PROT_EXEC;
7979

8080
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64)
81+
#ifndef __APPLE__
8182
if (flags & MMAP_MAP_32BIT)
8283
map_flags |= MAP_32BIT;
84+
#endif
8385
#endif
8486

8587
if (flags & MMAP_MAP_FIXED)
8688
map_flags |= MAP_FIXED;
8789

88-
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64)
89-
#if defined(__APPLE__)
90-
retry_without_map_32bit:
91-
#endif
92-
#endif
93-
9490
#if defined(BUILD_TARGET_RISCV64_LP64D) || defined(BUILD_TARGET_RISCV64_LP64)
9591
/* As AOT relocation in RISCV64 may require that the code/data mapped
9692
* is in range 0 to 2GB, we try to map the memory with hint address
@@ -148,14 +144,6 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file)
148144
}
149145

150146
if (addr == MAP_FAILED) {
151-
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64)
152-
#if defined(__APPLE__)
153-
if ((map_flags & MAP_32BIT) != 0) {
154-
map_flags &= ~MAP_32BIT;
155-
goto retry_without_map_32bit;
156-
}
157-
#endif
158-
#endif
159147
#if BH_ENABLE_TRACE_MMAP != 0
160148
os_printf("mmap failed\n");
161149
#endif

0 commit comments

Comments
 (0)