From 7b1835c4380dfc0e96d343f416cc22dc7641028a Mon Sep 17 00:00:00 2001 From: jingkaimori Date: Thu, 1 Feb 2024 15:34:21 +0800 Subject: [PATCH 1/4] enable mimalloc on wasm --- packages/m/mimalloc/xmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/m/mimalloc/xmake.lua b/packages/m/mimalloc/xmake.lua index 993e4c1a995..3f933466c61 100644 --- a/packages/m/mimalloc/xmake.lua +++ b/packages/m/mimalloc/xmake.lua @@ -34,7 +34,7 @@ package("mimalloc") add_syslinks("atomic") end - on_install("macosx", "windows", "linux", "android", "mingw", function (package) + on_install("macosx", "windows", "linux", "android", "mingw", "wasm", function (package) local configs = {"-DMI_OVERRIDE=OFF"} table.insert(configs, "-DMI_BUILD_STATIC=" .. (package:config("shared") and "OFF" or "ON")) table.insert(configs, "-DMI_BUILD_SHARED=" .. (package:config("shared") and "ON" or "OFF")) From 788f2df89ff5167bdfbdcb0d925c013074066822 Mon Sep 17 00:00:00 2001 From: jingkaimori Date: Sat, 3 Feb 2024 22:04:02 +0800 Subject: [PATCH 2/4] add missing flag --- packages/m/mimalloc/xmake.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/packages/m/mimalloc/xmake.lua b/packages/m/mimalloc/xmake.lua index 3f933466c61..924afdbe9a2 100644 --- a/packages/m/mimalloc/xmake.lua +++ b/packages/m/mimalloc/xmake.lua @@ -41,6 +41,9 @@ package("mimalloc") table.insert(configs, "-DMI_SECURE=" .. (package:config("secure") and "ON" or "OFF")) table.insert(configs, "-DMI_BUILD_TESTS=OFF") table.insert(configs, "-DMI_BUILD_OBJECT=OFF") + if package:is_plat("wasm") then + table.insert(configs, "-D__wasm__") + end --x64:mimalloc-redirect.lib/dll x86:mimalloc-redirect32.lib/dll if package:version():le("2.0.1") and package:config("shared") and package:is_plat("windows") and package:is_arch("x86") then io.replace("CMakeLists.txt", "-redirect.", "-redirect32.", {plain = true}) From b5f4342f60ec403dfc6bbea975670371146ba99a Mon Sep 17 00:00:00 2001 From: star9029 Date: Sun, 4 Feb 2024 18:58:29 +0800 Subject: [PATCH 3/4] replace `__wasi__` --- packages/m/mimalloc/xmake.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/m/mimalloc/xmake.lua b/packages/m/mimalloc/xmake.lua index 924afdbe9a2..b5934f563e7 100644 --- a/packages/m/mimalloc/xmake.lua +++ b/packages/m/mimalloc/xmake.lua @@ -42,7 +42,7 @@ package("mimalloc") table.insert(configs, "-DMI_BUILD_TESTS=OFF") table.insert(configs, "-DMI_BUILD_OBJECT=OFF") if package:is_plat("wasm") then - table.insert(configs, "-D__wasm__") + io.replace("src/prim/prim.c", "__wasi__", "__EMSCRIPTEN__", {plain = true}) end --x64:mimalloc-redirect.lib/dll x86:mimalloc-redirect32.lib/dll if package:version():le("2.0.1") and package:config("shared") and package:is_plat("windows") and package:is_arch("x86") then From 4eb4394a0297aa0d6873016ede005852ccf0900f Mon Sep 17 00:00:00 2001 From: jingkaimori Date: Fri, 26 Apr 2024 15:15:57 +0800 Subject: [PATCH 4/4] update mimalloc to 2.1.4 to build wasm version --- packages/m/mimalloc/xmake.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/m/mimalloc/xmake.lua b/packages/m/mimalloc/xmake.lua index b5934f563e7..c1aa1118a7e 100644 --- a/packages/m/mimalloc/xmake.lua +++ b/packages/m/mimalloc/xmake.lua @@ -5,6 +5,7 @@ package("mimalloc") set_license("MIT") set_urls("https://github.com/microsoft/mimalloc/archive/v$(version).zip") + add_versions("2.1.4", "41aa2f6ca7d60b41d0ed1644a4ab437a2233ca40115e36b41a1ebe07b7d58854") add_versions("2.1.2", "86281c918921c1007945a8a31e5ad6ae9af77e510abfec20d000dd05d15123c7") add_versions("2.0.7", "ddb32937aabddedd0d3a57bf68158d4e53ecf9e051618df3331a67182b8b0508") add_versions("2.0.6", "23e7443d0b4d7aa945779ea8a806e4e109c0ed62d740953d3656cddea7e04cf8") @@ -41,9 +42,6 @@ package("mimalloc") table.insert(configs, "-DMI_SECURE=" .. (package:config("secure") and "ON" or "OFF")) table.insert(configs, "-DMI_BUILD_TESTS=OFF") table.insert(configs, "-DMI_BUILD_OBJECT=OFF") - if package:is_plat("wasm") then - io.replace("src/prim/prim.c", "__wasi__", "__EMSCRIPTEN__", {plain = true}) - end --x64:mimalloc-redirect.lib/dll x86:mimalloc-redirect32.lib/dll if package:version():le("2.0.1") and package:config("shared") and package:is_plat("windows") and package:is_arch("x86") then io.replace("CMakeLists.txt", "-redirect.", "-redirect32.", {plain = true})