From 41d5bbc3c74d084c603802b955b6884ab74b012e Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 16 Jan 2024 14:37:03 +0900 Subject: [PATCH 1/2] Revert "Do not use pagezero size option if osx version >= 13 (#3025)" This reverts commit bb053e3a2de24daaabdbbea7dfa7a3dd1ab8cf87. --- build-scripts/config_common.cmake | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index 5d710b2e1c..e39a186b04 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -474,13 +474,7 @@ else () add_definitions (-DWASM_ENABLE_QUICK_AOT_ENTRY=0) endif () if (APPLE) - EXEC_PROGRAM(sw_vers ARGS -productVersion OUTPUT_VARIABLE OS_X_VERSION) - STRING(REGEX MATCH "([0-9]+)" OS_X_VERSION ${OS_X_VERSION}) - if (OS_X_VERSION LESS 13) - set(PAGE_ZERO_SIZE_OPTION "-Wl,-pagezero_size,0x4000") - endif () - # 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} ${PAGE_ZERO_SIZE_OPTION}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-pagezero_size,0x4000") endif () From 85b6f167c982a643d4c75f096b509f46377be456 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 16 Jan 2024 14:37:20 +0900 Subject: [PATCH 2/2] Revert "Enable MAP_32BIT for macOS (#2992)" This reverts commit 6fa6d6d9a585696d171905edbb2605e0debcb5cf. discussion: https://github.com/bytecodealliance/wasm-micro-runtime/issues/3009 --- build-scripts/config_common.cmake | 5 ----- core/shared/platform/common/posix/posix_memmap.c | 16 ++-------------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/build-scripts/config_common.cmake b/build-scripts/config_common.cmake index e39a186b04..76ebcb0b7c 100644 --- a/build-scripts/config_common.cmake +++ b/build-scripts/config_common.cmake @@ -473,8 +473,3 @@ else () # Disable quick aot/jit entries for interp and fast-jit add_definitions (-DWASM_ENABLE_QUICK_AOT_ENTRY=0) 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 () diff --git a/core/shared/platform/common/posix/posix_memmap.c b/core/shared/platform/common/posix/posix_memmap.c index de13c065fe..1ab99fd918 100644 --- a/core/shared/platform/common/posix/posix_memmap.c +++ b/core/shared/platform/common/posix/posix_memmap.c @@ -78,19 +78,15 @@ os_mmap(void *hint, size_t size, int prot, int flags, os_file_handle file) map_prot |= PROT_EXEC; #if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) +#ifndef __APPLE__ if (flags & MMAP_MAP_32BIT) map_flags |= MAP_32BIT; +#endif #endif if (flags & MMAP_MAP_FIXED) map_flags |= MAP_FIXED; -#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) -#if defined(__APPLE__) -retry_without_map_32bit: -#endif -#endif - #if defined(BUILD_TARGET_RISCV64_LP64D) || defined(BUILD_TARGET_RISCV64_LP64) /* As AOT relocation in RISCV64 may require that the code/data mapped * 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) } if (addr == MAP_FAILED) { -#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) -#if defined(__APPLE__) - if ((map_flags & MAP_32BIT) != 0) { - map_flags &= ~MAP_32BIT; - goto retry_without_map_32bit; - } -#endif -#endif #if BH_ENABLE_TRACE_MMAP != 0 os_printf("mmap failed\n"); #endif